v0.13.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
MoFEM::Field Struct Reference

Provide data structure for (tensor) field approximation. More...

#include <src/multi_indices/FieldMultiIndices.hpp>

Collaboration diagram for MoFEM::Field:
[legend]

Public Types

using SequenceDofContainer = multi_index_container< boost::weak_ptr< std::vector< DofEntity > >, indexed_by< sequenced<> > >
 
typedef std::array< std::array< int, MAX_DOFS_ON_ENTITY >, MBMAXTYPE > DofsOrderMap
 

Public Member Functions

 Field (moab::Interface &moab, const EntityHandle meshset)
 constructor for moab field More...
 
virtual ~Field ()=default
 
FieldOrderTablegetFieldOrderTable ()
 Get the Field Order Table. More...
 
UId generateGlobalUniqueIdForTypeLo (const EntityType type, const int owner_proc) const
 
UId generateGlobalUniqueIdForTypeHi (const EntityType type, const int owner_proc) const
 
EntityHandle getMeshset () const
 Get field meshset. More...
 
const BitFieldIdgetId () const
 Get unique field id. More...
 
boost::string_ref getNameRef () const
 Get string reference to field name. More...
 
std::string getName () const
 Get field name. More...
 
FieldSpace getSpace () const
 Get field approximation space. More...
 
auto getSpaceName () const
 Get field approximation space. More...
 
FieldApproximationBase getApproxBase () const
 Get approximation base. More...
 
auto getApproxBaseName () const
 Get approximation base. More...
 
FieldCoefficientsNumber getNbOfCoeffs () const
 Get number of field coefficients. More...
 
FieldBitNumber getBitNumber () const
 Get number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set for given field. Field ID has only one bit set for each field. More...
 
FieldBitNumber getBitNumberCalculate () const
 Calculate number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set for given field. Field ID has only one bit set for each field. More...
 
SequenceDofContainergetDofSequenceContainer () const
 Get reference to sequence data container. More...
 
const std::array< ApproximationOrder, MAX_DOFS_ON_ENTITY > & getDofOrderMap (const EntityType type) const
 get hash-map relating dof index on entity with its order More...
 
const DofsOrderMapgetDofOrderMap () const
 get hash-map relating dof index on entity with its order More...
 
MoFEMErrorCode rebuildDofsOrderMap ()
 
const FieldgetFieldRawPtr () const
 

Static Public Member Functions

static UId generateGlobalUniqueIdForTypeLo (const char bit_number, const EntityType type, const int owner_proc)
 
static UId generateGlobalUniqueIdForTypeHi (const char bit_number, const EntityType type, const int owner_proc)
 
static FieldBitNumber getBitNumberCalculate (const BitFieldId &id)
 Calculate number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set for given field. Field ID has only one bit set for each field. More...
 

Public Attributes

moab::Interface & moab
 
EntityHandle meshSet
 keeps entities for this meshset More...
 
TagType tagFieldDataVertsType
 
Tag th_FieldDataVerts
 Tag storing field values on vertices in the field. More...
 
Tag th_FieldData
 Tag storing field values on entity in the field. More...
 
Tag th_AppOrder
 Tag storing approximation order on entity. More...
 
Tag th_FieldRank
 
BitFieldIdtagId
 Tag field rank. More...
 
FieldSpacetagSpaceData
 tag keeps field space More...
 
FieldApproximationBasetagBaseData
 tag keeps field base More...
 
FieldCoefficientsNumbertagNbCoeffData
 
const void * tagName
 tag keeps name of the field More...
 
int tagNameSize
 number of bits necessary to keep field name More...
 
const void * tagNamePrefixData
 tag keeps name prefix of the field More...
 
int tagNamePrefixSize
 
FieldOrderTable forderTable
 nb. DOFs table for entities More...
 
unsigned int bitNumber
 

Private Attributes

SequenceDofContainer sequenceDofContainer
 
DofsOrderMap dofOrderMap
 

Friends

std::ostream & operator<< (std::ostream &os, const Field &e)
 

Detailed Description

Provide data structure for (tensor) field approximation.

The Field is intended to provide support for fields, with a strong bias towards supporting first and best the capabilities required for scientific computing applications. Since we work with discrete spaces, data structure has to carry information about type of approximation space, its regularity.

Field data structure storing information about space, approximation base, coordinate systems, etc. It stores additional data needed for book keeping, like tags to data on the mesh.

Each filed has unique ID and name. This data structure is shared between entities on which is spanning and DOFs on those entities.

Examples
EshelbianPlasticity.cpp, forces_and_sources_testing_users_base.cpp, and scalar_check_approximation.cpp.

Definition at line 51 of file FieldMultiIndices.hpp.

Member Typedef Documentation

◆ DofsOrderMap

typedef std::array<std::array<int, MAX_DOFS_ON_ENTITY>, MBMAXTYPE> MoFEM::Field::DofsOrderMap

Definition at line 69 of file FieldMultiIndices.hpp.

◆ SequenceDofContainer

using MoFEM::Field::SequenceDofContainer = multi_index_container< boost::weak_ptr<std::vector<DofEntity> >, indexed_by<sequenced<> >>

Definition at line 62 of file FieldMultiIndices.hpp.

Constructor & Destructor Documentation

◆ Field()

MoFEM::Field::Field ( moab::Interface &  moab,
const EntityHandle  meshset 
)

constructor for moab field

Parameters
meshsetwhich keeps entities for this field

Definition at line 16 of file FieldMultiIndices.cpp.

17 : moab(moab), meshSet(meshset), tagId(NULL), tagSpaceData(NULL),
18 tagNbCoeffData(NULL), tagName(NULL), tagNameSize(0) {
19
20 auto get_tag_data_ptr = [&](const auto name, auto &tag_data) {
22 Tag th;
23 CHKERR moab.tag_get_handle(name, th);
24 CHKERR moab.tag_get_by_ptr(th, &meshset, 1, (const void **)&tag_data);
26 };
27
28 // id
29 ierr = get_tag_data_ptr("_FieldId", tagId);
30 CHKERRABORT(PETSC_COMM_SELF, ierr);
31 // space
32 ierr = get_tag_data_ptr("_FieldSpace", tagSpaceData);
33 CHKERRABORT(PETSC_COMM_SELF, ierr);
34
35 // approx. base
36 ierr = get_tag_data_ptr("_FieldBase", tagBaseData);
37 CHKERRABORT(PETSC_COMM_SELF, ierr);
38
39 // name
40 Tag th_field_name;
41 CHKERR moab.tag_get_handle("_FieldName", th_field_name);
42 CHKERR moab.tag_get_by_ptr(th_field_name, &meshSet, 1,
43 (const void **)&tagName, &tagNameSize);
44 // name prefix
45 Tag th_field_name_data_name_prefix;
46 CHKERR moab.tag_get_handle("_FieldName_DataNamePrefix",
47 th_field_name_data_name_prefix);
48 CHKERR moab.tag_get_by_ptr(th_field_name_data_name_prefix, &meshSet, 1,
49 (const void **)&tagNamePrefixData,
51 std::string name_data_prefix((char *)tagNamePrefixData, tagNamePrefixSize);
52
53 // rank
54 std::string Tag_rank_name = "_Field_Rank_" + getName();
55 CHKERR moab.tag_get_handle(Tag_rank_name.c_str(), th_FieldRank);
56 CHKERR moab.tag_get_by_ptr(th_FieldRank, &meshSet, 1,
57 (const void **)&tagNbCoeffData);
58
59 auto get_all_tags = [&]() {
61 // order
62 ApproximationOrder def_approx_order = -1;
63 std::string tag_approximation_order_name = "_App_Order_" + getName();
64 rval = moab.tag_get_handle(tag_approximation_order_name.c_str(), 1,
65 MB_TYPE_INTEGER, th_AppOrder,
66 MB_TAG_CREAT | MB_TAG_SPARSE, &def_approx_order);
67 if (rval == MB_ALREADY_ALLOCATED)
68 rval = MB_SUCCESS;
70
71 // data
72 std::string tag_data_name = name_data_prefix + getName();
73 const int def_len = 0;
74 rval = moab.tag_get_handle(
75 tag_data_name.c_str(), def_len, MB_TYPE_DOUBLE, th_FieldData,
76 MB_TAG_CREAT | MB_TAG_VARLEN | MB_TAG_SPARSE, NULL);
77 if (rval == MB_ALREADY_ALLOCATED)
78 rval = MB_SUCCESS;
80
81 std::string tag_data_name_verts = name_data_prefix + getName() + "_V";
82 rval = moab.tag_get_handle(tag_data_name_verts.c_str(), th_FieldDataVerts);
83 if (rval == MB_SUCCESS)
85 else {
86 // Since vertex tag is not it mesh that tag is not dense, it is sparse,
87 // sinc it is set to all vertices on the mesh. Is unlikely that mesh has
88 // no vertices, then above assumption does not hold.
89 tagFieldDataVertsType = MB_TAG_SPARSE;
90 VectorDouble def_vert_data(*tagNbCoeffData);
91 def_vert_data.clear();
92 rval = moab.tag_get_handle(tag_data_name_verts.c_str(), *tagNbCoeffData,
93 MB_TYPE_DOUBLE, th_FieldDataVerts,
94 MB_TAG_CREAT | tagFieldDataVertsType,
95 &*def_vert_data.begin());
96 if (rval == MB_ALREADY_ALLOCATED)
97 rval = MB_SUCCESS;
99 }
100
102 };
103
104 auto get_all_tags_deprecated = [&]() {
106 // order
107 ApproximationOrder def_approx_order = -1;
108 std::string tag_approximation_order_name = "_App_Order_" + getName();
109 rval = moab.tag_get_handle(tag_approximation_order_name.c_str(), 1,
110 MB_TYPE_INTEGER, th_AppOrder,
111 MB_TAG_CREAT | MB_TAG_SPARSE, &def_approx_order);
112 if (rval == MB_ALREADY_ALLOCATED)
113 rval = MB_SUCCESS;
115
116 // data
117 std::string tag_data_name = name_data_prefix + getName();
118 const int def_len = 0;
119 rval = moab.tag_get_handle(
120 tag_data_name.c_str(), def_len, MB_TYPE_DOUBLE, th_FieldData,
121 MB_TAG_CREAT | MB_TAG_VARLEN | MB_TAG_SPARSE, NULL);
122 if (rval == MB_ALREADY_ALLOCATED)
123 rval = MB_SUCCESS;
125
126 std::string tag_data_name_verts = name_data_prefix + getName() + "V";
127 rval = moab.tag_get_handle(tag_data_name_verts.c_str(), th_FieldDataVerts);
128 if (rval == MB_SUCCESS)
130 else {
131 // Since vertex tag is not it mesh that tag is not dense, it is sparse,
132 // sinc it is set to all vertices on the mesh. Is unlikely that mesh has
133 // no vertices, then above assumption does not hold.
134 tagFieldDataVertsType = MB_TAG_SPARSE;
135 VectorDouble def_vert_data(*tagNbCoeffData);
136 def_vert_data.clear();
137 rval = moab.tag_get_handle(tag_data_name_verts.c_str(), *tagNbCoeffData,
138 MB_TYPE_DOUBLE, th_FieldDataVerts,
139 MB_TAG_CREAT | tagFieldDataVertsType,
140 &*def_vert_data.begin());
141 if (rval == MB_ALREADY_ALLOCATED)
142 rval = MB_SUCCESS;
144 }
145
147 };
148
149 Version file_ver;
151 CHK_THROW_MESSAGE(ierr, "Not known file version");
152 if (file_ver.majorVersion >= 0 && file_ver.minorVersion >= 12 &&
153 file_ver.buildVersion >= 1) {
154 ierr = get_all_tags();
155 CHKERRABORT(PETSC_COMM_SELF, ierr);
156 } else {
157 ierr = get_all_tags_deprecated();
158 CHKERRABORT(PETSC_COMM_SELF, ierr);
159 }
160
162
163 auto reset_entity_order_table = [&]() {
164 for (int tt = 0; tt != MBMAXTYPE; ++tt)
165 forderTable[tt] = NULL;
166 };
167
168 auto set_entity_order_table = [&]() {
169 switch (*tagBaseData) {
172 switch (*tagSpaceData) {
173 case H1:
174 forderTable[MBVERTEX] = [](int P) -> int { return (P > 0) ? 1 : 0; };
175 forderTable[MBEDGE] = [](int P) -> int { return NBEDGE_H1(P); };
176 forderTable[MBTRI] = [](int P) -> int { return NBFACETRI_H1(P); };
177 forderTable[MBQUAD] = [](int P) -> int { return NBFACEQUAD_H1(P); };
178 forderTable[MBTET] = [](int P) -> int { return NBVOLUMETET_H1(P); };
179 forderTable[MBHEX] = [](int P) -> int { return NBVOLUMEHEX_H1(P); };
180 forderTable[MBPRISM] = [](int P) -> int { return NBVOLUMEPRISM_H1(P); };
181 break;
182 case HCURL:
183 forderTable[MBVERTEX] = [](int P) -> int {
184 (void)P;
185 return 0;
186 };
187 forderTable[MBEDGE] = [](int P) -> int {
188 return NBEDGE_AINSWORTH_HCURL(P);
189 };
190 forderTable[MBTRI] = [](int P) -> int {
192 };
193 forderTable[MBTET] = [](int P) -> int {
195 };
196 break;
197 case HDIV:
198 forderTable[MBVERTEX] = [](int P) -> int {
199 (void)P;
200 return 0;
201 };
202 forderTable[MBEDGE] = [](int P) -> int {
203 (void)P;
204 return NBEDGE_HDIV(P);
205 };
206 forderTable[MBTRI] = [](int P) -> int {
207 return NBFACETRI_AINSWORTH_HDIV(P);
208 };
209 forderTable[MBTET] = [](int P) -> int {
211 };
212 break;
213 case L2:
214 forderTable[MBVERTEX] = [](int P) -> int {
215 (void)P;
216 return 1;
217 };
218 forderTable[MBEDGE] = [](int P) -> int { return NBEDGE_L2(P); };
219 forderTable[MBTRI] = [](int P) -> int { return NBFACETRI_L2(P); };
220 forderTable[MBQUAD] = [](int P) -> int { return NBFACEQUAD_L2(P); };
221 forderTable[MBTET] = [](int P) -> int { return NBVOLUMETET_L2(P); };
222 forderTable[MBHEX] = [](int P) -> int { return NBVOLUMEHEX_L2(P); };
223 break;
224 default:
225 THROW_MESSAGE("unknown approximation space");
226 }
227 break;
229 switch (*tagSpaceData) {
230 case H1:
231 forderTable[MBVERTEX] = [](int P) -> int { return (P > 0) ? 1 : 0; };
232 forderTable[MBEDGE] = [](int P) -> int { return NBEDGE_H1(P); };
233 forderTable[MBTRI] = [](int P) -> int { return NBFACETRI_H1(P); };
234 forderTable[MBQUAD] = [](int P) -> int { return NBFACEQUAD_H1(P); };
235 forderTable[MBTET] = [](int P) -> int { return NBVOLUMETET_H1(P); };
236 forderTable[MBPRISM] = [](int P) -> int { return NBVOLUMEPRISM_H1(P); };
237 break;
238 case L2:
239 forderTable[MBVERTEX] = [](int P) -> int {
240 (void)P;
241 return 1;
242 };
243 forderTable[MBEDGE] = [](int P) -> int { return NBEDGE_L2(P); };
244 forderTable[MBTRI] = [](int P) -> int { return NBFACETRI_L2(P); };
245 forderTable[MBQUAD] = [](int P) -> int { return NBFACEQUAD_L2(P); };
246 forderTable[MBTET] = [](int P) -> int { return NBVOLUMETET_L2(P); };
247 forderTable[MBHEX] = [](int P) -> int { return NBVOLUMEHEX_L2(P); };
248 break;
249 default:
250 THROW_MESSAGE("unknown approximation space or not yet implemented");
251 }
252 break;
254 switch (*tagSpaceData) {
255 case H1:
256 forderTable[MBVERTEX] = [](int P) -> int { return (P > 0) ? 1 : 0; };
257 forderTable[MBEDGE] = [](int P) -> int { return NBEDGE_H1(P); };
258 forderTable[MBTRI] = [](int P) -> int { return NBFACETRI_H1(P); };
259 forderTable[MBQUAD] = [](int P) -> int { return NBFACEQUAD_H1(P); };
260 forderTable[MBTET] = [](int P) -> int { return NBVOLUMETET_H1(P); };
261 forderTable[MBHEX] = [](int P) -> int { return NBVOLUMEHEX_H1(P); };
262 forderTable[MBPRISM] = [](int P) -> int { return NBVOLUMEPRISM_H1(P); };
263 break;
264 case HCURL:
265 forderTable[MBVERTEX] = [](int P) -> int {
266 (void)P;
267 return 0;
268 };
269 forderTable[MBEDGE] = [](int P) -> int {
270 return NBEDGE_DEMKOWICZ_HCURL(P);
271 };
272 forderTable[MBTRI] = [](int P) -> int {
274 };
275 forderTable[MBQUAD] = [](int P) -> int {
277 };
278 forderTable[MBTET] = [](int P) -> int {
280 };
281 forderTable[MBHEX] = [](int P) -> int {
283 };
284 break;
285 case HDIV:
286 forderTable[MBVERTEX] = [](int P) -> int {
287 (void)P;
288 return 0;
289 };
290 forderTable[MBEDGE] = [](int P) -> int {
291 (void)P;
292 return 0;
293 };
294 forderTable[MBTRI] = [](int P) -> int {
295 return NBFACETRI_DEMKOWICZ_HDIV(P);
296 };
297 forderTable[MBQUAD] = [](int P) -> int {
299 };
300 forderTable[MBTET] = [](int P) -> int {
302 };
303 forderTable[MBHEX] = [](int P) -> int {
305 };
306 break;
307 case L2:
308 forderTable[MBVERTEX] = [](int P) -> int {
309 (void)P;
310 return 1;
311 };
312 forderTable[MBEDGE] = [](int P) -> int { return NBEDGE_L2(P); };
313 forderTable[MBTRI] = [](int P) -> int { return NBFACETRI_L2(P); };
314 forderTable[MBQUAD] = [](int P) -> int { return NBFACEQUAD_L2(P); };
315 forderTable[MBTET] = [](int P) -> int { return NBVOLUMETET_L2(P); };
316 forderTable[MBHEX] = [](int P) -> int { return NBVOLUMEHEX_L2(P); };
317 break;
318 default:
319 THROW_MESSAGE("unknown approximation space or not yet implemented");
320 }
321 break;
322 case USER_BASE:
323 for (int ee = 0; ee < MBMAXTYPE; ee++) {
324 forderTable[ee] = [](int P) -> int {
325 (void)P;
326 return 0;
327 };
328 }
329 break;
330 default:
331 if (*tagSpaceData != NOFIELD) {
332 THROW_MESSAGE("unknown approximation base");
333 } else {
334 for (EntityType t = MBVERTEX; t < MBMAXTYPE; t++)
335 forderTable[t] = [](int P) -> int {
336 (void)P;
337 return 1;
338 };
339 }
340 }
341 };
342
343 reset_entity_order_table();
344 set_entity_order_table();
346 CHKERRABORT(PETSC_COMM_SELF, ierr);
347};
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ AINSWORTH_LOBATTO_BASE
Definition: definitions.h:62
@ USER_BASE
user implemented approximation base
Definition: definitions.h:68
@ DEMKOWICZ_JACOBI_BASE
Definition: definitions.h:66
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
Definition: definitions.h:64
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:541
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:595
@ L2
field with C-1 continuity
Definition: definitions.h:88
@ NOFIELD
scalar or vector of scalars describe (no true field)
Definition: definitions.h:84
@ H1
continuous field
Definition: definitions.h:85
@ HCURL
field with continuous tangents
Definition: definitions.h:86
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:561
#define NBFACEQUAD_DEMKOWICZ_HDIV(P)
#define NBEDGE_DEMKOWICZ_HCURL(P)
#define NBVOLUMETET_H1(P)
Number of base functions on tetrahedron for H1 space.
#define NBVOLUMETET_AINSWORTH_HDIV(P)
#define NBVOLUMEHEX_DEMKOWICZ_HCURL(P)
#define NBFACEQUAD_H1(P)
Number of base functions on quad for H1 space.
#define NBVOLUMETET_AINSWORTH_HCURL(P)
#define NBFACETRI_AINSWORTH_HCURL(P)
#define NBFACEQUAD_L2(P)
Number of base functions on quad for L2 space.
#define NBVOLUMEHEX_H1(P)
Number of base functions on hex for H1 space.
#define NBFACETRI_L2(P)
Number of base functions on triangle for L2 space.
#define NBVOLUMETET_DEMKOWICZ_HDIV(P)
#define NBEDGE_HDIV(P)
#define NBVOLUMEPRISM_H1(P)
Number of base functions on prism for H1 space.
#define NBVOLUMEHEX_DEMKOWICZ_HDIV(P)
#define NBFACEQUAD_DEMKOWICZ_HCURL(P)
#define NBEDGE_H1(P)
Numer of base function on edge for H1 space.
#define NBFACETRI_DEMKOWICZ_HDIV(P)
#define NBEDGE_L2(P)
Number of base functions on edge fro L2 space.
#define NBVOLUMEHEX_L2(P)
Number of base functions on hexahedron for L2 space.
#define NBVOLUMETET_DEMKOWICZ_HCURL(P)
#define NBFACETRI_DEMKOWICZ_HCURL(P)
#define NBEDGE_AINSWORTH_HCURL(P)
#define NBFACETRI_H1(P)
Number of base function on triangle for H1 space.
#define NBFACETRI_AINSWORTH_HDIV(P)
#define NBVOLUMETET_L2(P)
Number of base functions on tetrahedron for L2 space.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:26
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
constexpr double t
plate stiffness
Definition: plate.cpp:59
const void * tagNamePrefixData
tag keeps name prefix of the field
FieldOrderTable forderTable
nb. DOFs table for entities
const void * tagName
tag keeps name of the field
int tagNameSize
number of bits necessary to keep field name
std::string getName() const
Get field name.
unsigned int bitNumber
EntityHandle meshSet
keeps entities for this meshset
FieldSpace * tagSpaceData
tag keeps field space
FieldBitNumber getBitNumberCalculate() const
Calculate number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set f...
Tag th_FieldData
Tag storing field values on entity in the field.
MoFEMErrorCode rebuildDofsOrderMap()
FieldCoefficientsNumber * tagNbCoeffData
BitFieldId * tagId
Tag field rank.
Tag th_FieldDataVerts
Tag storing field values on vertices in the field.
FieldApproximationBase * tagBaseData
tag keeps field base
TagType tagFieldDataVertsType
Tag th_AppOrder
Tag storing approximation order on entity.
moab::Interface & moab
static MoFEMErrorCode getFileVersion(moab::Interface &moab, Version &version)
Get database major version.

◆ ~Field()

virtual MoFEM::Field::~Field ( )
virtualdefault

Member Function Documentation

◆ generateGlobalUniqueIdForTypeHi() [1/2]

static UId MoFEM::Field::generateGlobalUniqueIdForTypeHi ( const char  bit_number,
const EntityType  type,
const int  owner_proc 
)
inlinestatic

Definition at line 123 of file FieldMultiIndices.hpp.

125 {
126 constexpr int ent_shift = 8 * sizeof(EntityHandle);
127 return (static_cast<UId>(type) << MB_ID_WIDTH |
128 static_cast<UId>(bit_number) << ent_shift |
129 static_cast<UId>(owner_proc) << 5 + ent_shift)
130 << 9;
131 }
#define MB_ID_WIDTH
Definition: definitions.h:227
uint128_t UId
Unique Id.
Definition: Types.hpp:31

◆ generateGlobalUniqueIdForTypeHi() [2/2]

UId MoFEM::Field::generateGlobalUniqueIdForTypeHi ( const EntityType  type,
const int  owner_proc 
) const
inline

Definition at line 133 of file FieldMultiIndices.hpp.

134 {
135 return generateGlobalUniqueIdForTypeHi(bitNumber, type, owner_proc);
136 }
static UId generateGlobalUniqueIdForTypeHi(const char bit_number, const EntityType type, const int owner_proc)

◆ generateGlobalUniqueIdForTypeLo() [1/2]

static UId MoFEM::Field::generateGlobalUniqueIdForTypeLo ( const char  bit_number,
const EntityType  type,
const int  owner_proc 
)
inlinestatic

Definition at line 108 of file FieldMultiIndices.hpp.

110 {
111 constexpr int ent_shift = 8 * sizeof(EntityHandle);
112 return (static_cast<UId>(type) << MB_ID_WIDTH |
113 static_cast<UId>(bit_number) << 8 * sizeof(EntityHandle) |
114 static_cast<UId>(owner_proc) << 5 + ent_shift)
115 << 9;
116 }

◆ generateGlobalUniqueIdForTypeLo() [2/2]

UId MoFEM::Field::generateGlobalUniqueIdForTypeLo ( const EntityType  type,
const int  owner_proc 
) const
inline

Definition at line 118 of file FieldMultiIndices.hpp.

119 {
120 return generateGlobalUniqueIdForTypeLo(bitNumber, type, owner_proc);
121 }
static UId generateGlobalUniqueIdForTypeLo(const char bit_number, const EntityType type, const int owner_proc)

◆ getApproxBase()

FieldApproximationBase MoFEM::Field::getApproxBase ( ) const
inline

Get approximation base.

Returns
Approximation base

Definition at line 194 of file FieldMultiIndices.hpp.

194{ return *tagBaseData; }

◆ getApproxBaseName()

auto MoFEM::Field::getApproxBaseName ( ) const
inline

Get approximation base.

Returns
Approximation base name

Definition at line 200 of file FieldMultiIndices.hpp.

200 {
201 return std::string(ApproximationBaseNames[getApproxBase()]);
202 }
static const char *const ApproximationBaseNames[]
Definition: definitions.h:72
FieldApproximationBase getApproxBase() const
Get approximation base.

◆ getBitNumber()

FieldBitNumber MoFEM::Field::getBitNumber ( ) const
inline

Get number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set for given field. Field ID has only one bit set for each field.

Definition at line 227 of file FieldMultiIndices.hpp.

227{ return bitNumber; }

◆ getBitNumberCalculate() [1/2]

FieldBitNumber MoFEM::Field::getBitNumberCalculate ( ) const
inline

Calculate number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set for given field. Field ID has only one bit set for each field.

Definition at line 248 of file FieldMultiIndices.hpp.

248 {
249 return getBitNumberCalculate(static_cast<BitFieldId &>(*tagId));
250 }
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
Definition: Types.hpp:42

◆ getBitNumberCalculate() [2/2]

static FieldBitNumber MoFEM::Field::getBitNumberCalculate ( const BitFieldId id)
inlinestatic

Calculate number of set bit in Field ID. Each field has uid, get getBitNumber get number of bit set for given field. Field ID has only one bit set for each field.

Definition at line 234 of file FieldMultiIndices.hpp.

234 {
235 static_assert(BITFIELDID_SIZE >= 32,
236 "Too many fields allowed, can be more but ...");
237 FieldBitNumber b = ffsl(id.to_ulong());
238 if (b != 0)
239 return b;
240 return 0;
241 }
#define BITFIELDID_SIZE
max number of fields
Definition: definitions.h:220
char FieldBitNumber
Field bit number.
Definition: Types.hpp:28

◆ getDofOrderMap() [1/2]

const DofsOrderMap & MoFEM::Field::getDofOrderMap ( ) const
inline

get hash-map relating dof index on entity with its order

Dofs of given field are indexed on entity of the same type, same space, approximation base and number of coefficients, are sorted in the way.

Definition at line 296 of file FieldMultiIndices.hpp.

296{ return dofOrderMap; }
DofsOrderMap dofOrderMap

◆ getDofOrderMap() [2/2]

const std::array< ApproximationOrder, MAX_DOFS_ON_ENTITY > & MoFEM::Field::getDofOrderMap ( const EntityType  type) const
inline

get hash-map relating dof index on entity with its order

Dofs of given field are indexed on entity of the same type, same space, approximation base and number of coefficients, are sorted in the way.

Examples
forces_and_sources_testing_users_base.cpp.

Definition at line 284 of file FieldMultiIndices.hpp.

284 {
285 return dofOrderMap[type];
286 }

◆ getDofSequenceContainer()

SequenceDofContainer & MoFEM::Field::getDofSequenceContainer ( ) const
inline

Get reference to sequence data container.

In sequence data container data are physically stored. The purpose of this is to allocate DofEntity data in bulk, having only one allocation instead each time entity is inserted. That makes code efficient.

The vector in sequence is destroyed if last entity inside that vector is destroyed. All MoFEM::MoFEMEntities have aliased shared_ptr which points to the vector.

Not all DOFs are starred in this way, currently such cases are considered;

  • DOFs on vertices. That is exploited that for H1 space, there is some fixed number of DOFs on each vertex

For other cases, DOFs are stored locally in each MoFEM::MoFEMEntities.

Returns
MoFEM::Field::SequenceDofContainer

Definition at line 271 of file FieldMultiIndices.hpp.

271 {
273 }
SequenceDofContainer sequenceDofContainer

◆ getFieldOrderTable()

FieldOrderTable & MoFEM::Field::getFieldOrderTable ( )
inline

Get the Field Order Table.

Returns
FieldOrderTable&

Definition at line 100 of file FieldMultiIndices.hpp.

100{ return forderTable; }

◆ getFieldRawPtr()

const Field * MoFEM::Field::getFieldRawPtr ( ) const
inline

Definition at line 302 of file FieldMultiIndices.hpp.

302{ return this; };

◆ getId()

const BitFieldId & MoFEM::Field::getId ( ) const
inline

Get unique field id.

Returns
Filed ID

Definition at line 158 of file FieldMultiIndices.hpp.

158{ return *((BitFieldId *)tagId); }

◆ getMeshset()

EntityHandle MoFEM::Field::getMeshset ( ) const
inline

Get field meshset.

To meshsets entity are attached Tags which keeps basic information about field. Those information is field name, approximation base, approximation space, id, etc.

In meshset contains entities on which given filed is sparing. Type of entities depended on approximations space.

Returns
EntityHandle

Definition at line 152 of file FieldMultiIndices.hpp.

152{ return meshSet; }

◆ getName()

std::string MoFEM::Field::getName ( ) const
inline

Get field name.

Returns
Field name

Definition at line 172 of file FieldMultiIndices.hpp.

172 {
173 return std::string((char *)tagName, tagNameSize);
174 }

◆ getNameRef()

boost::string_ref MoFEM::Field::getNameRef ( ) const
inline

Get string reference to field name.

Returns
Field name

Definition at line 164 of file FieldMultiIndices.hpp.

164 {
165 return boost::string_ref((char *)tagName, tagNameSize);
166 }

◆ getNbOfCoeffs()

FieldCoefficientsNumber MoFEM::Field::getNbOfCoeffs ( ) const
inline

Get number of field coefficients.

Scalar field has only one coefficient, vector field in 3D has three. In general number determine space needed to keep data on entities. What coefficient means depend on interpretation and associated coordinate system. For example 3 coefficient means could be covariant or contravariant, or mean three temperatures for mixture of solid, air and water, etc.

Definition at line 218 of file FieldMultiIndices.hpp.

218 {
219 return *tagNbCoeffData;
220 };

◆ getSpace()

FieldSpace MoFEM::Field::getSpace ( ) const
inline

Get field approximation space.

Returns
approximation space

Definition at line 180 of file FieldMultiIndices.hpp.

180{ return *tagSpaceData; }

◆ getSpaceName()

auto MoFEM::Field::getSpaceName ( ) const
inline

Get field approximation space.

Returns
approximation space name

Definition at line 186 of file FieldMultiIndices.hpp.

186 {
187 return std::string(FieldSpaceNames[getSpace()]);
188 }
static const char *const FieldSpaceNames[]
Definition: definitions.h:92
FieldSpace getSpace() const
Get field approximation space.

◆ rebuildDofsOrderMap()

MoFEMErrorCode MoFEM::Field::rebuildDofsOrderMap ( )

Definition at line 349 of file FieldMultiIndices.cpp.

349 {
351
352 for (auto t = MBVERTEX; t != MBMAXTYPE; ++t) {
353
354 int DD = 0;
355 int nb_last_order_dofs = 0;
356 const int rank = (*tagNbCoeffData);
357 if (forderTable[t]) {
358
359 for (int oo = 0; oo < MAX_DOFS_ON_ENTITY; ++oo) {
360
361 const int nb_order_dofs = forderTable[t](oo);
362 const int diff_oo = nb_order_dofs - nb_last_order_dofs;
363 if (diff_oo >= 0) {
364
365 if ((DD + rank * diff_oo) < MAX_DOFS_ON_ENTITY)
366 for (int dd = 0; dd < diff_oo; ++dd)
367 for (int rr = 0; rr != rank; ++rr, ++DD)
368 dofOrderMap[t][DD] = oo;
369 else
370 break;
371
372 nb_last_order_dofs = nb_order_dofs;
373
374 } else {
375 break;
376 }
377 }
378 }
379
380 std::fill(&dofOrderMap[t][DD], dofOrderMap[t].end(), -1);
381 }
382
384}
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:236
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Field e 
)
friend

Definition at line 386 of file FieldMultiIndices.cpp.

386 {
387 os << e.getNameRef() << " field_id " << e.getId().to_ulong() << " space "
388 << FieldSpaceNames[e.getSpace()] << " approximation base "
389 << ApproximationBaseNames[e.getApproxBase()] << " nb coefficients "
390 << e.getNbOfCoeffs() << " meshset " << e.meshSet;
391 return os;
392}

Member Data Documentation

◆ bitNumber

unsigned int MoFEM::Field::bitNumber

Field Id is bit set. Each field has only one bit on, bitNumber stores number of set bit

Definition at line 106 of file FieldMultiIndices.hpp.

◆ dofOrderMap

DofsOrderMap MoFEM::Field::dofOrderMap
mutableprivate

Definition at line 306 of file FieldMultiIndices.hpp.

◆ forderTable

FieldOrderTable MoFEM::Field::forderTable

nb. DOFs table for entities

Definition at line 93 of file FieldMultiIndices.hpp.

◆ meshSet

EntityHandle MoFEM::Field::meshSet

keeps entities for this meshset

Definition at line 73 of file FieldMultiIndices.hpp.

◆ moab

moab::Interface& MoFEM::Field::moab

Definition at line 71 of file FieldMultiIndices.hpp.

◆ sequenceDofContainer

SequenceDofContainer MoFEM::Field::sequenceDofContainer
mutableprivate

Definition at line 305 of file FieldMultiIndices.hpp.

◆ tagBaseData

FieldApproximationBase* MoFEM::Field::tagBaseData

tag keeps field base

Definition at line 83 of file FieldMultiIndices.hpp.

◆ tagFieldDataVertsType

TagType MoFEM::Field::tagFieldDataVertsType

Definition at line 75 of file FieldMultiIndices.hpp.

◆ tagId

BitFieldId* MoFEM::Field::tagId

Tag field rank.

tag keeps field id

Definition at line 81 of file FieldMultiIndices.hpp.

◆ tagName

const void* MoFEM::Field::tagName

tag keeps name of the field

Definition at line 88 of file FieldMultiIndices.hpp.

◆ tagNamePrefixData

const void* MoFEM::Field::tagNamePrefixData

tag keeps name prefix of the field

Definition at line 90 of file FieldMultiIndices.hpp.

◆ tagNamePrefixSize

int MoFEM::Field::tagNamePrefixSize

number of bits necessary to keep field name prefix

Definition at line 91 of file FieldMultiIndices.hpp.

◆ tagNameSize

int MoFEM::Field::tagNameSize

number of bits necessary to keep field name

Definition at line 89 of file FieldMultiIndices.hpp.

◆ tagNbCoeffData

FieldCoefficientsNumber* MoFEM::Field::tagNbCoeffData

tag keeps field rank (dimension, f.e. Temperature field has rank 1, displacements field in 3d has rank 3)

Definition at line 87 of file FieldMultiIndices.hpp.

◆ tagSpaceData

FieldSpace* MoFEM::Field::tagSpaceData

tag keeps field space

Definition at line 82 of file FieldMultiIndices.hpp.

◆ th_AppOrder

Tag MoFEM::Field::th_AppOrder

Tag storing approximation order on entity.

Definition at line 78 of file FieldMultiIndices.hpp.

◆ th_FieldData

Tag MoFEM::Field::th_FieldData

Tag storing field values on entity in the field.

Definition at line 77 of file FieldMultiIndices.hpp.

◆ th_FieldDataVerts

Tag MoFEM::Field::th_FieldDataVerts

Tag storing field values on vertices in the field.

Definition at line 76 of file FieldMultiIndices.hpp.

◆ th_FieldRank

Tag MoFEM::Field::th_FieldRank

Definition at line 79 of file FieldMultiIndices.hpp.


The documentation for this struct was generated from the following files: