b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2branch_property.H
1//------------------------------------------------------------------------
2// b2branch_property.H --
3//
4//
5// written by Mathias Doreille
6// Neda Ebrahimi Pour <neda.ebrahimipour@dlr.de>
7// Thomas Blome <thomas.blome@dlr.de>
8//
9// (c) 2004-2015,2017 SMR Engineering & Development SA
10// 2502 Bienne, Switzerland
11//
12// (c) 2023 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
13// Linder Höhe, 51147 Köln
14//
15// All Rights Reserved. Proprietary source code. The contents of
16// this file may not be disclosed to third parties, copied or
17// duplicated in any form, in whole or in part, without the prior
18// written permission of SMR.
19//------------------------------------------------------------------------
20
21#ifndef B2_BRANCH_PROPERTY_H_
22#define B2_BRANCH_PROPERTY_H_
23
24#include <vector>
25
26#include "b2domain_property.H"
27#include "b2ppconfig.h"
28#include "model/b2case.H"
29#include "model/b2node.H"
30#include "model_imp/b2case_component.H"
31#include "utils/b2linear_algebra.H"
32#include "utils/b2rtable.H"
33
34namespace b2000::b2dbv3 {
35
41public:
42 BranchProperty(DomainProperty& parent_) : parent(parent_) {}
43
44 void init(int branch_id_, size_t branch_internal_id_, size_t first_node_id_of_branch_) {
45 branch_id = branch_id_;
46 branch_internal_id = branch_internal_id_;
47 first_node_id_of_branch = first_node_id_of_branch_;
48 }
49
50 void set_case(b2000::Case& case_);
51
52 void set_subcase_id(const int subcase_id_) { subcase_id = subcase_id_; }
53
54 int get_subcase_id() const { return subcase_id; }
55
56 Domain& get_domain() { return parent.get_domain(); }
57
58 DomainProperty& get_domain_property() { return parent; }
59
60 size_t get_branch_internal_id() const { return branch_internal_id; }
61
62 bool have_temperature() const {
63 auto it = node_temp_map.find(subcase_id);
64 return (it != node_temp_map.end() && !it->second.empty());
65 }
66
67 bool get_material_temperature(
68 const Element* element,
69 b2linalg::Vector<double, b2linalg::Vdense_constref> nodes_interpolation,
70 const size_t nb_thickness_interpolation, const double thickness_interpolation[],
71 const double time, double& temperature, double& d_temperature_d_time) const {
72 temperature = 0;
73 d_temperature_d_time = 0;
74 auto it = node_temp_map.find(subcase_id);
75 if (it == node_temp_map.end() || it->second.empty()) { return false; }
76 const NodeTempVector& node_temp_vector = it->second;
77 int current_stage = current_case->get_stage_number();
78 std::pair<size_t, Node* const*> nodes = element->get_nodes();
79 for (size_t k = 0; k != node_temp_vector.size(); ++k) {
80 const NodeTemp& nt = node_temp_vector[k];
81 if (nt.stage_number < current_stage) { continue; }
82 double scale;
83 double scale_d;
84 if (nt.stage_number > current_stage) {
85 scale = current_case->get_stage_size(nt.stage_number);
86 scale_d = 0;
87 } else {
88 scale = nt.scalef->value(time);
89 scale_d = nt.scalef->d_value(time);
90 }
91
92 // Interpolate and scale.
93 if (nt.values.size1() < nb_thickness_interpolation) {
94 Exception() << "Number of temperature values per node "
95 "mismatch."
96 << THROW;
97 }
98 for (size_t j = 0; j != nodes.first; ++j) {
99 const size_t jj = nodes.second[j]->get_id() - first_node_id_of_branch;
100 for (size_t i = 0; i != nb_thickness_interpolation; ++i) {
101 const double f =
102 thickness_interpolation[i] * nodes_interpolation[j] * nt.values(i, jj);
103 temperature += f * scale;
104 d_temperature_d_time += f * scale_d;
105 }
106 }
107 }
108 return true;
109 }
110
111private:
112 void load();
113
114 struct NodeTemp {
115 int stage_number;
116 b2linalg::Matrix<double, b2linalg::Mrectangle> values;
117 TimeFunction* scalef;
118 };
119
120 typedef std::vector<NodeTemp> NodeTempVector;
121 typedef std::map<int, NodeTempVector> NodeTempVectorMap;
122
123 int branch_id{};
124 size_t branch_internal_id{};
125 size_t first_node_id_of_branch{};
126 DomainProperty& parent;
127 b2000::Case* current_case{};
128 int subcase_id{};
129 NodeTempVectorMap node_temp_map;
130 bool loaded{};
131};
132
133} // namespace b2000::b2dbv3
134
135#endif // B2_BRANCH_PROPERTY_H_
#define THROW
Definition b2exception.H:198
Definition b2case.H:110
virtual double get_stage_size(int stage=-1) const =0
virtual int get_stage_number() const =0
Defines the complete interface for Element instances (C++ representations of Finite Elements).
Definition b2element.H:156
virtual std::pair< int, Node *const * > get_nodes() const
Definition b2element.H:327
Definition b2exception.H:131
Definition b2branch_property.H:40
Definition b2domain_property.H:28
A in-core implementation of the b2dbv3::Domain. All the Element, Node and ElementProperty objects are...
Definition b2domain_database.H:62