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; ///< cubit meshset ID
27 char *tagBcData;
29 unsigned int *tagBlockHeaderData;
32 char *tagName;
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; }
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 getMaksedBcTypeULong() const {
77 return (cubitBcType & meshsetsMask).to_ulong();
78 }
79
80 /**
81 * @brief Get the meshset entities dimension
82 *
83 * \note If dimension is -1, then dimension for meshset ins undetermined.
84 *
85 * @return unsigned int
86 */
87 unsigned int getMeshsetEntitiesDimension() const {
89 return tagBlockHeaderData[2];
90 else
91 return -1;
92 }
93
94 /**
95 * \brief get entities form meshset
96 * @param moab moab instance
97 * @param dimension dimension of entities
98 * @param entities range of returned entities
99 * @param recursive true if meshset should be searched recursively
100 * @return error code
101 */
103 getMeshsetIdEntitiesByDimension(Interface &moab, const int dimension,
104 Range &entities,
105 const bool recursive = false) const;
106
107 /**
108 * \brief get entities form meshset
109 *
110 * Use if meshset have predefined dimension
111 *
112 * @param moab moab instance
113 * @param entities range of returned entities
114 * @param recursive true if meshset should be searched recursively
115 * @return error code
116 *
117 */
120 const bool recursive = false) const;
121
122 /**
123 * \brief get entities by type
124 * @param moab moab instance
125 * @param type type of entity
126 * @param entities returned entities
127 * @param recursive true if meshset should be searched recursively
128 * @return error code
129 */
131 const EntityType type,
132 Range &entities,
133 const bool recursive = false) const;
134
135 /**
136 * \brief Function that returns the CubitBCType type of the contents of
137 * bc_data
138 */
139 MoFEMErrorCode getTypeFromBcData(const std::vector<char> &bc_data,
140 CubitBCType &type) const;
141
142 /**
143 * \brief Function that returns the CubitBCType type of the contents of
144 * bc_data
145 */
147
148 /**
149 * \brief get bc_data vector from MoFEM database
150 *
151 * \param bc_data is the in/out vector were bc_data will be stored
152 */
153 MoFEMErrorCode getBcData(std::vector<char> &bc_data) const;
154
155 /**
156 * \brief get block_headers vector from MoFEM database
157 *
158 * \param material_data is the in/out vector were the material data will be
159 * stored
160 */
162 getBlockHeaderData(std::vector<unsigned int> &material_data) const;
163
164 /**
165 * \brief print material_data int stream given by os
166 *
167 * f.e. it->print_Cubit_material_data(cout), i.e. printing to standard output
168 * f.e. it->print_Cubit_material_data(std::cerr), i.e. printing to standard
169 * error output
170 */
171 MoFEMErrorCode printBlockHeaderData(std::ostream &os) const;
172
173 /**
174 * \brief print bc_data int stream given by os
175 *
176 * f.e. it->printBcData(cout), i.e. printing to standard output
177 * f.e. it->printBcData(std::cerr), i.e. printing to standard error output
178 */
179 MoFEMErrorCode printBcData(std::ostream &os) const;
180
181 /**
182 * \brief Function that returns the CubitBCType type of the block name,
183 * sideset name etc.
184 */
185 MoFEMErrorCode getTypeFromName(const std::string &name,
186 CubitBCType &type) const;
187
188 /**
189 * \brief Function that returns the CubitBCType type of the block name,
190 * sideset name etc.
191 */
193
194 /**
195 * \brief get Cubit block attributes
196 *
197 * \param attributes is the vector where the block attribute data will be
198 * stored
199 */
200 MoFEMErrorCode getAttributes(std::vector<double> &attributes) const;
201
202 /**
203 * \brief cet Cubit block attributes
204 *
205 * \param attributes is the vector where the block attribute data will be
206 * stored
207 */
208 MoFEMErrorCode setAttributes(moab::Interface &moab,
209 const std::vector<double> &attributes);
210
211 /**
212 * \brief print the attributes vector
213 *
214 * f.e. it->printAttributes(cout), i.e. printing to standard output
215 * f.e. it->printAttributes(std::cerr), i.e. printing to standard error output
216 */
217 MoFEMErrorCode printAttributes(std::ostream &os) const;
218
219 /**
220 * \brief get name of block, sideset etc. (this is set in Cubit block
221 properties)
222 *
223 * Block Name Conventions:
224
225 * Materials are defined with block names starting with MAT_
226 * e.g. MAT_ELASTIC_abcd.
227 *
228 * List of materials/solution procedures
229
230 * Block name / Number of attributes / (1) Attribute 1, (2) Attribute 2 etc.
231 *
232 * MAT_ELASTIC / 10 / (1) Young's modulus
233 * (2) Poisson's ratio
234 * (3) User attribute 8
235 * ...
236 * (10) User attribute 8
237 *
238 * MAT_ELASTIC_TRANSISO / 5 / (1) Young's modulus in xy plane (Ep)
239 * (2) Young's modulus in z-direction (Ez)
240 * (3) Poisson's ratio in xy plane (vp)
241 * (4) Poisson's ratio in z-direction (vpz)
242 * (5) Shear modulus in z-direction (Gzp)
243 *
244 * MAT_INTERF / 1 / (1) Elastic modulus multiplier
245 *
246 * To be extended as appropriate
247 */
248 std::string getName() const;
249
250 /**
251 * \brief print name of block, sideset etc. (this is set in Cubit setting
252 * properties)
253 *
254 * e.g. it->printName(cout), i.e. printing to standard output
255 * e.g it->printName(std::cerr), i.e. printing to standard error output
256 */
257 MoFEMErrorCode printName(std::ostream &os) const;
258
259 /**
260 * \brief fill data structure with data saved on meshset
261 */
262 template <class ATTRIBUTE_TYPE>
263 MoFEMErrorCode getAttributeDataStructure(ATTRIBUTE_TYPE &data) const {
265 if ((cubitBcType & data.getType()).none()) {
266 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
267 "attributes are not for ATTRIBUTE_TYPE structure");
268 }
269 std::vector<double> attributes;
270 CHKERR getAttributes(attributes);
271 CHKERR data.fill_data(attributes);
273 }
274
275 /**
276 * \brief fill meshset data with data on structure
277 */
278 template <class ATTRIBUTE_TYPE>
279 MoFEMErrorCode setAttributeDataStructure(const ATTRIBUTE_TYPE &data) {
281 if ((cubitBcType & data.getType()).none()) {
282 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
283 "attributes are not for ATTRIBUTE_TYPE structure");
284 }
285 double *ptr = const_cast<double *>(tagBlockAttributes);
286 CHKERR data.set_data(ptr, 8 * tagBlockAttributesSize);
288 }
289
290 template <class CUBIT_BC_DATA_TYPE>
291 MoFEMErrorCode getBcDataStructure(CUBIT_BC_DATA_TYPE &data) const {
293
294 if ((cubitBcType & data.tYpe).none()) {
295 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
296 "bc_data are not for CUBIT_BC_DATA_TYPE structure");
297 }
298 std::vector<char> bc_data;
299 getBcData(bc_data);
300 ierr = data.fill_data(bc_data);
301 CHKERRG(ierr);
303 }
304
305 template <class CUBIT_BC_DATA_TYPE>
306 MoFEMErrorCode setBcDataStructure(CUBIT_BC_DATA_TYPE &data) {
308
309 char *ptr = const_cast<char *>(tagBcData);
310 ierr = data.set_data(ptr, tagBcSize);
311 CHKERRG(ierr);
313 }
314
315 friend std::ostream &operator<<(std::ostream &os, const CubitMeshSets &e);
316
319
321};
322
323/**
324 * \typedef CubitMeshSet_multiIndex
325 * \brief Stores data about meshsets (see CubitMeshSets) storing data about
326 * boundary conditions, interfaces, sidesets, nodests, blocksets
327 *
328 * \param Meshset_mi_tag index by meshset handle
329 * \param CubitMeshsetType_mi_tag index by bc type, see CubitBC
330 * \param CubitMeshsetMaskedType_mi_tag index by NODESET, SIDESET, BLOCKSET
331 * only
332 *
333 * \param CubitMeshsets_name index by meshset name
334 *
335 * \param Composite_Cubit_msId_And_MeshsetType_mi_tag index by meshset id and
336 * type NODESET, SIDESET or BLOCKSET
337 *
338 * Example:
339 * \code
340 * MeshsetsManager *m_mng;
341 * CHKERR m_field.getInterface(m_mng);
342 * auto &index = m_mng->getMeshsetsMultindex();
343 *
344 *
345 * auto mit =
346 * index.get<CubitMeshsetMaskedType_mi_tag>().lower_bound(BLOCKSET); auto
347 * hi_mit =
348 * index.get<CubitMeshsetMaskedType_mi_tag>().upper_bound(BLOCKSET);
349 *
350 * // Make a loop over all BLOCKSET
351 * for(;mit!=hi_mit;mit++) {
352 * int id = mit->getMeshsetId(); // get blockset id
353 * EntityHandle handle = mit->getMeshset(); // get block meshset
354 * std::vector< double > attributes;
355 * // get block attributes
356 * auto mit->getAttributes(attributes);
357 * // do something
358 * }
359 * \endcode
360 *
361 */
362typedef multi_index_container<
364 indexed_by<
365 hashed_unique<tag<Meshset_mi_tag>, member<CubitMeshSets, EntityHandle,
367 ordered_non_unique<tag<CubitMeshsetType_mi_tag>,
368 const_mem_fun<CubitMeshSets, unsigned long int,
370 ordered_non_unique<tag<CubitMeshsetMaskedType_mi_tag>,
371 const_mem_fun<CubitMeshSets, unsigned long int,
373 ordered_non_unique<
374 tag<CubitMeshsets_name>,
375 const_mem_fun<CubitMeshSets, std::string, &CubitMeshSets::getName>>,
376 hashed_unique<
377 tag<Composite_Cubit_msId_And_MeshsetType_mi_tag>,
378 composite_key<
380 const_mem_fun<CubitMeshSets, int, &CubitMeshSets::getMeshsetId>,
381 const_mem_fun<CubitMeshSets, unsigned long int,
384
385/** \brief change meshset type
386 */
390 : bIt(bit){};
391 void operator()(CubitMeshSets &e);
392};
393
394/**
395 * \brief change meshset name
396 */
399 std::string nAme;
400 CubitMeshSets_change_name(Interface &moab, const std::string &name)
401 : mOab(moab), nAme(name){};
402 void operator()(CubitMeshSets &e);
403};
404
405/**
406 * change meshset attributes
407 */
410 const std::vector<double> &aTtr;
412 const std::vector<double> &attr)
413 : mOab(moab), aTtr(attr) {}
414 void operator()(CubitMeshSets &e);
415};
416
417/**
418 * change meshset attributes for material data structure
419 */
424 Interface &moab, const GenericAttributeData &attr)
425 : mOab(moab), aTtr(attr) {}
426 void operator()(CubitMeshSets &e);
427};
428
429/**
430 * change meshset attributes for material data structure
431 */
436 const GenericCubitBcData &bc_data)
437 : mOab(moab), bcData(bc_data) {}
438 void operator()(CubitMeshSets &e);
439};
440
441} // namespace MoFEM
442
443#endif // __BCMULTIINDICES_HPP__
444
445/**
446 * \defgroup mofem_bc Boundary conditions
447 * \ingroup mofem
448 */
#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 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::getMaksedBcTypeULong > >, 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::getMaksedBcTypeULong > > > > > 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
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.
unsigned long int getMaksedBcTypeULong() const
get meshset type and mask
int getMeshsetId() const
get meshset id as it set in preprocessing software
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:16