b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2super_element.H
1//------------------------------------------------------------------------
2// b2super_element.H --
3//
4// written by doreille
5// Thomas Blome <thomas.blome@dlr.de>
6//
7// Copyright (c) 2010 SMR Engineering & Development SA
8// 2502 Bienne, Switzerland
9//
10// (c) 2023 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
11// Linder Höhe, 51147 Köln
12//
13//
14// All Rights Reserved. Proprietary source code. The contents of
15// this file may not be disclosed to third parties, copied or
16// duplicated in any form, in whole or in part, without the prior
17// written permission of SMR.
18//------------------------------------------------------------------------
19
20#ifndef B2SUPER_ELEMENT_H_
21#define B2SUPER_ELEMENT_H_
22
23#include <vector>
24
25#include "elements/properties/b2super_element_properties.H"
26#include "model/b2element.H"
27#include "model/b2node.H"
28#include "utils/b2linear_algebra.H"
29
30namespace b2000 {
31
34template <typename T, typename MATRIX_TYPE>
35class SuperElement : public TypedElement<T> {
36public:
38
40
41 int get_number_of_dof() const { return property->get_number_of_internal_dof(); }
42
43 size_t set_global_dof_numbering(size_t index) {
44 internal_dof_index = index;
45 return index + property->get_number_of_internal_dof();
46 }
47
48 std::pair<size_t, size_t> get_global_dof_numbering() const {
49 return std::pair<size_t, size_t>(
50 internal_dof_index, internal_dof_index + property->get_number_of_internal_dof());
51 }
52
53 std::pair<size_t, size_t> get_interface_reduction_internal_dof() {
54 std::pair<size_t, size_t> r = property->get_interface_reduction_internal_dof();
55 r.first += internal_dof_index;
56 r.second += internal_dof_index;
57 return r;
58 }
59
60 void set_nodes(std::pair<int, Node* const*> nodes_) {
61 nodes.assign(nodes_.second, nodes_.second + nodes_.first);
62 }
63
64 std::pair<int, Node* const*> get_nodes() const {
65 return std::pair<int, Node* const*>(nodes.size(), &nodes[0]);
66 }
67
68 void set_property(ElementProperty* property_) {
69 property = dynamic_cast<property_type*>(property_);
70 if (property == nullptr) {
71 TypeError() << "Super element has wrong property type " << typeid(*property_) << THROW;
72 }
73 // maybe print property->get_object_name() << std::endl;
74 }
75
76 const ElementProperty* get_property() const { return property; }
77
78 const std::vector<Element::VariableInfo> get_value_info() const {
79 assert(property != nullptr);
80 return std::vector<Element::VariableInfo>(property->get_order(), Element::linear);
81 }
82
83 void get_value(
84 Model& model, const bool linear, const EquilibriumSolution equilibrium_solution,
85 const double time, const double delta_time,
86 const b2linalg::Matrix<T, b2linalg::Mrectangle_constref>& dof,
87 GradientContainer* gradient_container, SolverHints* solver_hints,
88 b2linalg::Index& dof_numbering, b2linalg::Vector<T, b2linalg::Vdense>& value,
89 const std::vector<bool>& d_value_d_dof_flags,
90 std::vector<b2linalg::Matrix<T, MATRIX_TYPE> >& d_value_d_dof,
91 b2linalg::Vector<T, b2linalg::Vdense>& d_value_d_time) {
92 if (!dof_numbering.is_null()) {
93 const size_t id = property->get_number_of_internal_dof();
94 const size_t ed = property->get_number_of_external_dof();
95 dof_numbering.resize(id + ed);
96 size_t* ptr = &dof_numbering[0];
97 for (size_t k = 0; k != nodes.size(); ++k) {
98 std::pair<size_t, size_t> dn = nodes[k]->get_global_dof_numbering();
99 while (dn.first != dn.second) {
100 if (ptr == &dof_numbering[0] + ed) {
101 Exception() << "Number of degree of freedom mismatch in super element "
103 }
104 *ptr++ = dn.first++;
105 }
106 }
107 if (ptr != &dof_numbering[0] + ed) {
108 Exception() << "Number of degree of freedom mismatch in super element "
110 }
111 size_t is = internal_dof_index;
112 size_t ie = is + id;
113 for (; is != ie; ++is, ++ptr) { *ptr = is; }
114 }
115 if (dof.is_null() || value.is_null()) {
116 property->get_value(value, d_value_d_dof_flags, d_value_d_dof);
117 } else {
118 // computation of the linear contribution of the dof to the value
119 std::vector<b2linalg::Matrix<T, MATRIX_TYPE> > d_value_d_dof_tmp;
120 std::vector<bool> d_value_d_dof_flags(dof.size2(), true);
121 property->get_value(
122 value, d_value_d_dof_flags,
123 d_value_d_dof.empty() ? d_value_d_dof_tmp : d_value_d_dof);
124 for (size_t k = 0; k != d_value_d_dof.size(); ++k) {
125 value += (d_value_d_dof.empty() ? d_value_d_dof_tmp : d_value_d_dof)[k]
126 * dof[k](dof_numbering);
127 }
128 }
129 }
130
131 int face_field_order(const int face_id, const std::string& field_name) {
132 return property->face_field_order(face_id, field_name);
133 }
134
135 bool face_field_linear_on_dof(const int face_id, const std::string& field_name) {
136 return property->face_field_linear_on_dof(face_id, field_name);
137 }
138
140 const int face_id, const std::string& field_name,
141 b2linalg::Matrix<double, b2linalg::Mrectangle>& sub_nodes,
142 std::vector<Element::Triangle>& sub_faces) {
143 return property->face_field_polynomial_sub_face(face_id, field_name, sub_nodes, sub_faces);
144 }
145
147 const int face_id,
148 const b2linalg::Vector<double, b2linalg::Vdense_constref>& internal_coor,
149 b2linalg::Vector<double>& geom,
150 b2linalg::Matrix<double, b2linalg::Mrectangle>& d_geom_d_icoor) {
151 property->face_geom(face_id, internal_coor, geom, d_geom_d_icoor);
152 }
153
154 void face_field_value(
155 const int face_id, const std::string& field_name,
156 const b2linalg::Vector<double, b2linalg::Vdense_constref>& internal_coor,
157 const b2linalg::Matrix<double, b2linalg::Mrectangle_constref>& dof, const double time,
158 b2linalg::Vector<double, b2linalg::Vdense>& value,
159 b2linalg::Matrix<double, b2linalg::Mrectangle>& d_value_d_icoor,
160 b2linalg::Index& dof_numbering,
161 b2linalg::Matrix<double, b2linalg::Mrectangle>& d_value_d_dof,
162 b2linalg::Index& d_value_d_dof_dep_col) {
163 property->face_field_value(
164 face_id, field_name, internal_coor, dof, time, value, d_value_d_icoor, dof_numbering,
165 d_value_d_dof, d_value_d_dof_dep_col);
166 if (!dof_numbering.is_null()) {
167 for (size_t i = 0; i != dof_numbering.size(); ++i) {
168 dof_numbering[i] += internal_dof_index;
169 }
170 }
171 }
172
173 static type_t type;
174
175private:
176 size_t internal_dof_index;
177 std::vector<Node*> nodes;
178 property_type* property;
179};
180
181} // namespace b2000
182
183#endif /* B2SUPER_ELEMENT_H_ */
#define THROW
Definition b2exception.H:198
Definition b2element.H:71
@ linear
Definition b2element.H:615
Definition b2exception.H:131
Definition b2solution.H:54
Definition b2model.H:69
Definition b2object.H:415
virtual const std::string & get_object_name() const
Definition b2object.H:460
Definition b2solver.H:168
Definition b2super_element_properties.H:25
Definition b2super_element.H:35
size_t set_global_dof_numbering(size_t index)
Definition b2super_element.H:43
void face_geom(const int face_id, const b2linalg::Vector< double, b2linalg::Vdense_constref > &internal_coor, b2linalg::Vector< double > &geom, b2linalg::Matrix< double, b2linalg::Mrectangle > &d_geom_d_icoor)
Definition b2super_element.H:146
int get_number_of_dof() const
Definition b2super_element.H:41
int face_field_polynomial_sub_face(const int face_id, const std::string &field_name, b2linalg::Matrix< double, b2linalg::Mrectangle > &sub_nodes, std::vector< Element::Triangle > &sub_faces)
Definition b2super_element.H:139
std::pair< int, Node *const * > get_nodes() const
Definition b2super_element.H:64
int face_field_order(const int face_id, const std::string &field_name)
Definition b2super_element.H:131
std::pair< size_t, size_t > get_global_dof_numbering() const
Definition b2super_element.H:48
const std::vector< Element::VariableInfo > get_value_info() const
Definition b2super_element.H:78
const ElementProperty * get_property() const
Definition b2super_element.H:76
void set_nodes(std::pair< int, Node *const * > nodes_)
Definition b2super_element.H:60
void set_property(ElementProperty *property_)
Definition b2super_element.H:68
bool face_field_linear_on_dof(const int face_id, const std::string &field_name)
Definition b2super_element.H:135
Definition b2element.H:1054
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32
GenericException< TypeError_name > TypeError
Definition b2exception.H:325
Definition b2type.H:72