v0.14.0
Loading...
Searching...
No Matches
BCMultiIndices.hpp
Go to the documentation of this file.
1/** \file BCMultiIndices.hpp
2 * \brief Multi-index containers, data boundary data structures and other
3 * low-level functions
4 *
5 */
6
7
8
9#ifndef __BCMULTIINDICES_HPP__
10#define __BCMULTIINDICES_HPP__
11
12namespace MoFEM {
13
14/**
15 * \brief this struct keeps basic methods for moab meshset about material and
16 * boundary conditions \ingroup mofem_bc
17 *
18 */
20
22 CubitBCType cubitBcType; ///< type of meshset from cubit NodeSet, BlockSet,
23 ///< SideSet and more
24 std::vector<Tag>
25 tag_handles; ///< vector of tag handles to types of data passed from cubit
26 int *msId = nullptr; ///< cubit meshset ID
27 char *tagBcData = nullptr;
29 unsigned int *tagBlockHeaderData = nullptr;
30 double *tagBlockAttributes = nullptr;
32 char *tagName = nullptr;
34
36 CubitMeshSets(Interface &moab, const CubitBCType cubit_bc_type,
37 const int msId);
38
39 /**
40 * \brief get meshset id as it set in preprocessing software
41 * @return id of meshset
42 */
43 inline int getMeshsetId() const { return msId ? *msId : -1; }
44
45 // /** \deprecated use getMeshsetId() instead
46 // */
47 // DEPRECATED inline int get_msId() const { return getMeshsetId(); }
48
49 /**
50 * \brief get type of meshset
51 *
52 * See CubitBC for set of types of meshsets.
53 *
54 * @return meshset type
55 */
56 inline CubitBCType getBcType() const { return cubitBcType; }
57
58 /**
59 * \brief get bc meshset
60 * @return meshset entity handle
61 */
62 inline EntityHandle getMeshset() const { return meshset; }
63
64 /**
65 * \brief get bc meshset type
66 * @return return type as unsigned int
67 */
68 inline unsigned long int getBcTypeULong() const {
69 return cubitBcType.to_ulong();
70 }
71
72 /**
73 * \brief get meshset type and mask
74 * @return type is returned as unsigned integer
75 */
76 inline unsigned long int getMaskedBcTypeULong() const {
77 return (cubitBcType & meshsetsMask).to_ulong();
78 }
79
80 /** @deprecated use getMaskedBcTypeULong */
81 DEPRECATED unsigned long int getMaksedBcTypeULong() const {
82 return (cubitBcType & meshsetsMask).to_ulong();
83 }
84
85 /**
86 * @brief Get the meshset entities dimension
87 *
88 * \note If dimension is -1, then dimension for meshset ins undetermined.
89 *
90 * @return unsigned int
91 */
92 unsigned int getMeshsetEntitiesDimension() const {
94 return tagBlockHeaderData[2];
95 else
96 return -1;
97 }
98
99 /**
100 * \brief get entities form meshset
101 * @param moab moab instance
102 * @param dimension dimension of entities
103 * @param entities range of returned entities
104 * @param recursive true if meshset should be searched recursively
105 * @return error code
106 */
108 getMeshsetIdEntitiesByDimension(Interface &moab, const int dimension,
109 Range &entities,
110 const bool recursive = false) const;
111
112 /**
113 * \brief get entities form meshset
114 *
115 * Use if meshset have predefined dimension
116 *
117 * @param moab moab instance
118 * @param entities range of returned entities
119 * @param recursive true if meshset should be searched recursively
120 * @return error code
121 *
122 */
125 const bool recursive = false) const;
126
127 /**
128 * \brief get entities by type
129 * @param moab moab instance
130 * @param type type of entity
131 * @param entities returned entities
132 * @param recursive true if meshset should be searched recursively
133 * @return error code
134 */
136 const EntityType type,
137 Range &entities,
138 const bool recursive = false) const;
139
140 /**
141 * \brief Function that returns the CubitBCType type of the contents of
142 * bc_data
143 */
144 MoFEMErrorCode getTypeFromBcData(const std::vector<char> &bc_data,
145 CubitBCType &type) const;
146
147 /**
148 * \brief Function that returns the CubitBCType type of the contents of
149 * bc_data
150 */
152
153 /**
154 * \brief get bc_data vector from MoFEM database
155 *
156 * \param bc_data is the in/out vector were bc_data will be stored
157 */
158 MoFEMErrorCode getBcData(std::vector<char> &bc_data) const;
159
160 /**
161 * \brief get block_headers vector from MoFEM database
162 *
163 * \param material_data is the in/out vector were the material data will be
164 * stored
165 */
167 getBlockHeaderData(std::vector<unsigned int> &material_data) const;
168
169 /**
170 * \brief print material_data int stream given by os
171 *
172 * f.e. it->print_Cubit_material_data(cout), i.e. printing to standard output
173 * f.e. it->print_Cubit_material_data(std::cerr), i.e. printing to standard
174 * error output
175 */
176 MoFEMErrorCode printBlockHeaderData(std::ostream &os) const;
177
178 /**
179 * \brief print bc_data int stream given by os
180 *
181 * f.e. it->printBcData(cout), i.e. printing to standard output
182 * f.e. it->printBcData(std::cerr), i.e. printing to standard error output
183 */
184 MoFEMErrorCode printBcData(std::ostream &os) const;
185
186 /**
187 * \brief Function that returns the CubitBCType type of the block name,
188 * sideset name etc.
189 */
190 MoFEMErrorCode getTypeFromName(const std::string &name,
191 CubitBCType &type) const;
192
193 /**
194 * \brief Function that returns the CubitBCType type of the block name,
195 * sideset name etc.
196 */
198
199 /**
200 * \brief get Cubit block attributes
201 *
202 * \param attributes is the vector where the block attribute data will be
203 * stored
204 */
205 MoFEMErrorCode getAttributes(std::vector<double> &attributes) const;
206
207 /**
208 * \brief cet Cubit block attributes
209 *
210 * \param attributes is the vector where the block attribute data will be
211 * stored
212 */
213 MoFEMErrorCode setAttributes(moab::Interface &moab,
214 const std::vector<double> &attributes);
215
216 /**
217 * \brief print the attributes vector
218 *
219 * f.e. it->printAttributes(cout), i.e. printing to standard output
220 * f.e. it->printAttributes(std::cerr), i.e. printing to standard error output
221 */
222 MoFEMErrorCode printAttributes(std::ostream &os) const;
223
224 /**
225 * \brief get name of block, sideset etc. (this is set in Cubit block
226 properties)
227 *
228 * Block Name Conventions:
229
230 * Materials are defined with block names starting with MAT_
231 * e.g. MAT_ELASTIC_abcd.
232 *
233 * List of materials/solution procedures
234
235 * Block name / Number of attributes / (1) Attribute 1, (2) Attribute 2 etc.
236 *
237 * MAT_ELASTIC / 10 / (1) Young's modulus
238 * (2) Poisson's ratio
239 * (3) User attribute 8
240 * ...
241 * (10) User attribute 8
242 *
243 * MAT_ELASTIC_TRANSISO / 5 / (1) Young's modulus in xy plane (Ep)
244 * (2) Young's modulus in z-direction (Ez)
245 * (3) Poisson's ratio in xy plane (vp)
246 * (4) Poisson's ratio in z-direction (vpz)
247 * (5) Shear modulus in z-direction (Gzp)
248 *
249 * MAT_INTERF / 1 / (1) Elastic modulus multiplier
250 *
251 * To be extended as appropriate
252 */
253 std::string getName() const;
254
255 /**
256 * \brief print name of block, sideset etc. (this is set in Cubit setting
257 * properties)
258 *
259 * e.g. it->printName(cout), i.e. printing to standard output
260 * e.g it->printName(std::cerr), i.e. printing to standard error output
261 */
262 MoFEMErrorCode printName(std::ostream &os) const;
263
264 /**
265 * \brief fill data structure with data saved on meshset
266 */
267 template <class ATTRIBUTE_TYPE>
268 MoFEMErrorCode getAttributeDataStructure(ATTRIBUTE_TYPE &data) const {
270 if ((cubitBcType & data.getType()).none()) {
271 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
272 "attributes are not for ATTRIBUTE_TYPE structure");
273 }
274 std::vector<double> attributes;
275 CHKERR getAttributes(attributes);
276 CHKERR data.fill_data(attributes);
278 }
279
280 /**
281 * \brief fill meshset data with data on structure
282 */
283 template <class ATTRIBUTE_TYPE>
284 MoFEMErrorCode setAttributeDataStructure(const ATTRIBUTE_TYPE &data) {
286 if ((cubitBcType & data.getType()).none()) {
287 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
288 "attributes are not for ATTRIBUTE_TYPE structure");
289 }
290 double *ptr = const_cast<double *>(tagBlockAttributes);
291 CHKERR data.set_data(ptr, 8 * tagBlockAttributesSize);
293 }
294
295 template <class CUBIT_BC_DATA_TYPE>
296 MoFEMErrorCode getBcDataStructure(CUBIT_BC_DATA_TYPE &data) const {
298
299 if ((cubitBcType & data.tYpe).none()) {
300 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
301 "bc_data are not for CUBIT_BC_DATA_TYPE structure");
302 }
303 std::vector<char> bc_data;
304 getBcData(bc_data);
305 ierr = data.fill_data(bc_data);
306 CHKERRG(ierr);
308 }
309
310 template <class CUBIT_BC_DATA_TYPE>
311 MoFEMErrorCode setBcDataStructure(CUBIT_BC_DATA_TYPE &data) {
313
314 char *ptr = const_cast<char *>(tagBcData);
315 ierr = data.set_data(ptr, tagBcSize);
316 CHKERRG(ierr);
318 }
319
320 friend std::ostream &operator<<(std::ostream &os, const CubitMeshSets &e);
321
324
326};
327
328/**
329 * \typedef CubitMeshSet_multiIndex
330 * \brief Stores data about meshsets (see CubitMeshSets) storing data about
331 * boundary conditions, interfaces, sidesets, nodests, blocksets
332 *
333 * \param Meshset_mi_tag index by meshset handle
334 * \param CubitMeshsetType_mi_tag index by bc type, see CubitBC
335 * \param CubitMeshsetMaskedType_mi_tag index by NODESET, SIDESET, BLOCKSET
336 * only
337 *
338 * \param CubitMeshsets_name index by meshset name
339 *
340 * \param Composite_Cubit_msId_And_MeshsetType_mi_tag index by meshset id and
341 * type NODESET, SIDESET or BLOCKSET
342 *
343 * Example:
344 * \code
345 * MeshsetsManager *m_mng;
346 * CHKERR m_field.getInterface(m_mng);
347 * auto &index = m_mng->getMeshsetsMultindex();
348 *
349 *
350 * auto mit =
351 * index.get<CubitMeshsetMaskedType_mi_tag>().lower_bound(BLOCKSET); auto
352 * hi_mit =
353 * index.get<CubitMeshsetMaskedType_mi_tag>().upper_bound(BLOCKSET);
354 *
355 * // Make a loop over all BLOCKSET
356 * for(;mit!=hi_mit;mit++) {
357 * int id = mit->getMeshsetId(); // get blockset id
358 * EntityHandle handle = mit->getMeshset(); // get block meshset
359 * std::vector< double > attributes;
360 * // get block attributes
361 * auto mit->getAttributes(attributes);
362 * // do something
363 * }
364 * \endcode
365 *
366 */
367typedef multi_index_container<
369 indexed_by<
370 hashed_unique<tag<Meshset_mi_tag>, member<CubitMeshSets, EntityHandle,
372 ordered_non_unique<tag<CubitMeshsetType_mi_tag>,
373 const_mem_fun<CubitMeshSets, unsigned long int,
375 ordered_non_unique<tag<CubitMeshsetMaskedType_mi_tag>,
376 const_mem_fun<CubitMeshSets, unsigned long int,
378 ordered_non_unique<
379 tag<CubitMeshsets_name>,
380 const_mem_fun<CubitMeshSets, std::string, &CubitMeshSets::getName>>,
381 hashed_unique<
382 tag<Composite_Cubit_msId_And_MeshsetType_mi_tag>,
383 composite_key<
385 const_mem_fun<CubitMeshSets, int, &CubitMeshSets::getMeshsetId>,
386 const_mem_fun<CubitMeshSets, unsigned long int,
389
390/** \brief change meshset type
391 */
395 : bIt(bit){};
396 void operator()(CubitMeshSets &e);
397};
398
399/**
400 * \brief change meshset name
401 */
404 std::string nAme;
405 CubitMeshSets_change_name(Interface &moab, const std::string &name)
406 : mOab(moab), nAme(name){};
407 void operator()(CubitMeshSets &e);
408};
409
410/**
411 * change meshset attributes
412 */
415 const std::vector<double> &aTtr;
417 const std::vector<double> &attr)
418 : mOab(moab), aTtr(attr) {}
419 void operator()(CubitMeshSets &e);
420};
421
422/**
423 * change meshset attributes for material data structure
424 */
429 Interface &moab, const GenericAttributeData &attr)
430 : mOab(moab), aTtr(attr) {}
431 void operator()(CubitMeshSets &e);
432};
433
434/**
435 * change meshset attributes for material data structure
436 */
441 const GenericCubitBcData &bc_data)
442 : mOab(moab), bcData(bc_data) {}
443 void operator()(CubitMeshSets &e);
444};
445
446} // namespace MoFEM
447
448#endif // __BCMULTIINDICES_HPP__
449
450/**
451 * \defgroup mofem_bc Boundary conditions
452 * \ingroup mofem
453 */
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define DEPRECATED
Definition: definitions.h:17
#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 MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
auto bit
set bit
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
std::bitset< 32 > CubitBCType
Definition: Types.hpp:52
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
multi_index_container< CubitMeshSets, indexed_by< hashed_unique< tag< Meshset_mi_tag >, member< CubitMeshSets, EntityHandle, &CubitMeshSets::meshset > >, ordered_non_unique< tag< CubitMeshsetType_mi_tag >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getBcTypeULong > >, ordered_non_unique< tag< CubitMeshsetMaskedType_mi_tag >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getMaskedBcTypeULong > >, ordered_non_unique< tag< CubitMeshsets_name >, const_mem_fun< CubitMeshSets, std::string, &CubitMeshSets::getName > >, hashed_unique< tag< Composite_Cubit_msId_And_MeshsetType_mi_tag >, composite_key< CubitMeshSets, const_mem_fun< CubitMeshSets, int, &CubitMeshSets::getMeshsetId >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getMaskedBcTypeULong > > > > > CubitMeshSet_multiIndex
Stores data about meshsets (see CubitMeshSets) storing data about boundary conditions,...
CubitMeshSets_change_add_bit_to_cubit_bc_type(const CubitBCType &bit)
CubitMeshSets_change_attributes_data_structure(Interface &moab, const GenericAttributeData &attr)
const std::vector< double > & aTtr
CubitMeshSets_change_attributes(Interface &moab, const std::vector< double > &attr)
CubitMeshSets_change_bc_data_structure(Interface &moab, const GenericCubitBcData &bc_data)
void operator()(CubitMeshSets &e)
CubitMeshSets_change_name(Interface &moab, const std::string &name)
this struct keeps basic methods for moab meshset about material and boundary conditions
MoFEMErrorCode getAttributes(std::vector< double > &attributes) const
get Cubit block attributes
unsigned long int getBcTypeULong() const
get bc meshset type
unsigned long int getMaskedBcTypeULong() const
get meshset type and mask
MoFEMErrorCode getBcData(std::vector< char > &bc_data) const
get bc_data vector from MoFEM database
MoFEMErrorCode printName(std::ostream &os) const
print name of block, sideset etc. (this is set in Cubit setting properties)
MoFEMErrorCode printAttributes(std::ostream &os) const
print the attributes vector
unsigned int * tagBlockHeaderData
MoFEMErrorCode getAttributeDataStructure(ATTRIBUTE_TYPE &data) const
fill data structure with data saved on meshset
MoFEMErrorCode getTypeFromName(const std::string &name, CubitBCType &type) const
Function that returns the CubitBCType type of the block name, sideset name etc.
MoFEMErrorCode setBcDataStructure(CUBIT_BC_DATA_TYPE &data)
CubitMeshSets(Interface &moab, const EntityHandle meshset)
MoFEMErrorCode getMeshsetIdEntitiesByDimension(Interface &moab, Range &entities, const bool recursive=false) const
get entities form meshset
MoFEMErrorCode setAttributes(moab::Interface &moab, const std::vector< double > &attributes)
cet Cubit block attributes
MoFEMErrorCode getBlockHeaderData(std::vector< unsigned int > &material_data) const
get block_headers vector from MoFEM database
friend std::ostream & operator<<(std::ostream &os, const CubitMeshSets &e)
MoFEMErrorCode getBcDataStructure(CUBIT_BC_DATA_TYPE &data) const
unsigned int getMeshsetEntitiesDimension() const
Get the meshset entities dimension.
CubitMeshSets(Interface &moab, const CubitBCType cubit_bc_type, const int msId)
MoFEMErrorCode printBcData(std::ostream &os) const
print bc_data int stream given by os
CubitBCType getBcType() const
get type of meshset
MoFEMErrorCode getMeshsetIdEntitiesByDimension(Interface &moab, const int dimension, Range &entities, const bool recursive=false) const
get entities form meshset
std::string getName() const
get name of block, sideset etc. (this is set in Cubit block properties)
std::vector< Tag > tag_handles
vector of tag handles to types of data passed from cubit
EntityHandle getMeshset() const
get bc meshset
MoFEMErrorCode setAttributeDataStructure(const ATTRIBUTE_TYPE &data)
fill meshset data with data on structure
MoFEMErrorCode getTagsHandlers(Interface &moab)
int * msId
cubit meshset ID
const CubitBCType meshsetsMask
MoFEMErrorCode getMeshsetIdEntitiesByType(Interface &moab, const EntityType type, Range &entities, const bool recursive=false) const
get entities by type
MoFEMErrorCode getTypeFromBcData(const std::vector< char > &bc_data, CubitBCType &type) const
Function that returns the CubitBCType type of the contents of bc_data.
int getMeshsetId() const
get meshset id as it set in preprocessing software
DEPRECATED unsigned long int getMaksedBcTypeULong() const
MoFEMErrorCode printBlockHeaderData(std::ostream &os) const
print material_data int stream given by os
Deprecated interface functions.
Generic attribute data structure.
Generic bc data structure.
Definition: BCData.hpp:20