v0.16.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;
33 // Keep JSON-assigned block attributes alive when MOAB cannot hand back
34 // a direct pointer for this meshset/tag combination.
35 std::vector<double> blockAttributesStorage;
37
39 CubitMeshSets(Interface &moab, const CubitBCType cubit_bc_type,
40 const int msId);
41
42 /**
43 * \brief get meshset id as it set in preprocessing software
44 * @return id of meshset
45 */
46 inline int getMeshsetId() const { return msId ? *msId : -1; }
47
48 // /** \deprecated use getMeshsetId() instead
49 // */
50 // DEPRECATED inline int get_msId() const { return getMeshsetId(); }
51
52 /**
53 * \brief get type of meshset
54 *
55 * See CubitBC for set of types of meshsets.
56 *
57 * @return meshset type
58 */
59 inline CubitBCType getBcType() const { return cubitBcType; }
60
61 /**
62 * \brief get bc meshset
63 * @return meshset entity handle
64 */
65 inline EntityHandle getMeshset() const { return meshset; }
66
67 /**
68 * \brief get bc meshset type
69 * @return return type as unsigned int
70 */
71 inline unsigned long int getBcTypeULong() const {
72 return cubitBcType.to_ulong();
73 }
74
75 /**
76 * \brief get meshset type and mask
77 * @return type is returned as unsigned integer
78 */
79 inline unsigned long int getMaskedBcTypeULong() const {
80 return (cubitBcType & meshsetsMask).to_ulong();
81 }
82
83 /** @deprecated use getMaskedBcTypeULong */
84 DEPRECATED unsigned long int getMaksedBcTypeULong() const {
85 return (cubitBcType & meshsetsMask).to_ulong();
86 }
87
88 /**
89 * @brief Get the meshset entities dimension
90 *
91 * \note If dimension is -1, then dimension for meshset ins undetermined.
92 *
93 * @return unsigned int
94 */
95 unsigned int getMeshsetEntitiesDimension() const {
97 return tagBlockHeaderData[2];
98 else
99 return -1;
100 }
101
102 /**
103 * \brief get entities form meshset
104 * @param moab moab instance
105 * @param dimension dimension of entities
106 * @param entities range of returned entities
107 * @param recursive true if meshset should be searched recursively
108 * @return error code
109 */
111 getMeshsetIdEntitiesByDimension(Interface &moab, const int dimension,
112 Range &entities,
113 const bool recursive = false) const;
114
115 /**
116 * \brief get entities form meshset
117 *
118 * Use if meshset have predefined dimension
119 *
120 * @param moab moab instance
121 * @param entities range of returned entities
122 * @param recursive true if meshset should be searched recursively
123 * @return error code
124 *
125 */
128 const bool recursive = false) const;
129
130 /**
131 * \brief get entities by type
132 * @param moab moab instance
133 * @param type type of entity
134 * @param entities returned entities
135 * @param recursive true if meshset should be searched recursively
136 * @return error code
137 */
139 const EntityType type,
140 Range &entities,
141 const bool recursive = false) const;
142
143 /**
144 * \brief Function that returns the CubitBCType type of the contents of
145 * bc_data
146 */
147 MoFEMErrorCode getTypeFromBcData(const std::vector<char> &bc_data,
148 CubitBCType &type) const;
149
150 /**
151 * \brief Function that returns the CubitBCType type of the contents of
152 * bc_data
153 */
155
156 /**
157 * \brief get bc_data vector from MoFEM database
158 *
159 * \param bc_data is the in/out vector were bc_data will be stored
160 */
161 MoFEMErrorCode getBcData(std::vector<char> &bc_data) const;
162
163 /**
164 * \brief get block_headers vector from MoFEM database
165 *
166 * \param material_data is the in/out vector were the material data will be
167 * stored
168 */
170 getBlockHeaderData(std::vector<unsigned int> &material_data) const;
171
172 /**
173 * \brief print material_data int stream given by os
174 *
175 * f.e. it->print_Cubit_material_data(cout), i.e. printing to standard output
176 * f.e. it->print_Cubit_material_data(std::cerr), i.e. printing to standard
177 * error output
178 */
179 MoFEMErrorCode printBlockHeaderData(std::ostream &os) const;
180
181 /**
182 * \brief print bc_data int stream given by os
183 *
184 * f.e. it->printBcData(cout), i.e. printing to standard output
185 * f.e. it->printBcData(std::cerr), i.e. printing to standard error output
186 */
187 MoFEMErrorCode printBcData(std::ostream &os) const;
188
189 /**
190 * \brief Function that returns the CubitBCType type of the block name,
191 * sideset name etc.
192 */
193 MoFEMErrorCode getTypeFromName(const std::string &name,
194 CubitBCType &type) const;
195
196 /**
197 * \brief Function that returns the CubitBCType type of the block name,
198 * sideset name etc.
199 */
201
202 /**
203 * \brief get Cubit block attributes
204 *
205 * \param attributes is the vector where the block attribute data will be
206 * stored
207 */
208 MoFEMErrorCode getAttributes(std::vector<double> &attributes) const;
209
210 /**
211 * \brief cet Cubit block attributes
212 *
213 * \param attributes is the vector where the block attribute data will be
214 * stored
215 */
216 MoFEMErrorCode setAttributes(moab::Interface &moab,
217 const std::vector<double> &attributes);
218
219 /**
220 * \brief print the attributes vector
221 *
222 * f.e. it->printAttributes(cout), i.e. printing to standard output
223 * f.e. it->printAttributes(std::cerr), i.e. printing to standard error output
224 */
225 MoFEMErrorCode printAttributes(std::ostream &os) const;
226
227 /**
228 * \brief get name of block, sideset etc. (this is set in Cubit block
229 properties)
230 *
231 * Block Name Conventions:
232
233 * Materials are defined with block names starting with MAT_
234 * e.g. MAT_ELASTIC_abcd.
235 *
236 * List of materials/solution procedures
237
238 * Block name / Number of attributes / (1) Attribute 1, (2) Attribute 2 etc.
239 *
240 * MAT_ELASTIC / 10 / (1) Young's modulus
241 * (2) Poisson's ratio
242 * (3) User attribute 8
243 * ...
244 * (10) User attribute 8
245 *
246 * MAT_ELASTIC_TRANSISO / 5 / (1) Young's modulus in xy plane (Ep)
247 * (2) Young's modulus in z-direction (Ez)
248 * (3) Poisson's ratio in xy plane (vp)
249 * (4) Poisson's ratio in z-direction (vpz)
250 * (5) Shear modulus in z-direction (Gzp)
251 *
252 * MAT_INTERF / 1 / (1) Elastic modulus multiplier
253 *
254 * To be extended as appropriate
255 */
256 std::string getName() const;
257
258 /**
259 * \brief print name of block, sideset etc. (this is set in Cubit setting
260 * properties)
261 *
262 * e.g. it->printName(cout), i.e. printing to standard output
263 * e.g it->printName(std::cerr), i.e. printing to standard error output
264 */
265 MoFEMErrorCode printName(std::ostream &os) const;
266
267 /**
268 * \brief fill data structure with data saved on meshset
269 */
270 template <class ATTRIBUTE_TYPE>
271 MoFEMErrorCode getAttributeDataStructure(ATTRIBUTE_TYPE &data) const {
273 if ((cubitBcType & data.getType()).none()) {
274 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
275 "attributes are not for ATTRIBUTE_TYPE structure");
276 }
277 std::vector<double> attributes;
278 CHKERR getAttributes(attributes);
279 CHKERR data.fill_data(attributes);
281 }
282
283 /**
284 * \brief fill meshset data with data on structure
285 */
286 template <class ATTRIBUTE_TYPE>
287 MoFEMErrorCode setAttributeDataStructure(const ATTRIBUTE_TYPE &data) {
289 if ((cubitBcType & data.getType()).none()) {
290 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
291 "attributes are not for ATTRIBUTE_TYPE structure");
292 }
293 double *ptr = const_cast<double *>(tagBlockAttributes);
294 CHKERR data.set_data(ptr, 8 * tagBlockAttributesSize);
296 }
297
298 template <class CUBIT_BC_DATA_TYPE>
299 MoFEMErrorCode getBcDataStructure(CUBIT_BC_DATA_TYPE &data) const {
301
302 if ((cubitBcType & data.tYpe).none()) {
303 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
304 "bc_data are not for CUBIT_BC_DATA_TYPE structure");
305 }
306 std::vector<char> bc_data;
307 getBcData(bc_data);
308 ierr = data.fill_data(bc_data);
309 CHKERRG(ierr);
311 }
312
313 template <class CUBIT_BC_DATA_TYPE>
314 MoFEMErrorCode setBcDataStructure(CUBIT_BC_DATA_TYPE &data) {
316
317 char *ptr = const_cast<char *>(tagBcData);
318 ierr = data.set_data(ptr, tagBcSize);
319 CHKERRG(ierr);
321 }
322
323 friend std::ostream &operator<<(std::ostream &os, const CubitMeshSets &e);
324
327
329};
330
331/**
332 * \typedef CubitMeshSet_multiIndex
333 * \brief Stores data about meshsets (see CubitMeshSets) storing data about
334 * boundary conditions, interfaces, sidesets, nodests, blocksets
335 *
336 * \param Meshset_mi_tag index by meshset handle
337 * \param CubitMeshsetType_mi_tag index by bc type, see CubitBC
338 * \param CubitMeshsetMaskedType_mi_tag index by NODESET, SIDESET, BLOCKSET
339 * only
340 *
341 * \param CubitMeshsets_name index by meshset name
342 *
343 * \param Composite_Cubit_msId_And_MeshsetType_mi_tag index by meshset id and
344 * type NODESET, SIDESET or BLOCKSET
345 *
346 * Example:
347 * \code
348 * MeshsetsManager *m_mng;
349 * CHKERR m_field.getInterface(m_mng);
350 * auto &index = m_mng->getMeshsetsMultindex();
351 *
352 *
353 * auto mit =
354 * index.get<CubitMeshsetMaskedType_mi_tag>().lower_bound(BLOCKSET); auto
355 * hi_mit =
356 * index.get<CubitMeshsetMaskedType_mi_tag>().upper_bound(BLOCKSET);
357 *
358 * // Make a loop over all BLOCKSET
359 * for(;mit!=hi_mit;mit++) {
360 * int id = mit->getMeshsetId(); // get blockset id
361 * EntityHandle handle = mit->getMeshset(); // get block meshset
362 * std::vector< double > attributes;
363 * // get block attributes
364 * auto mit->getAttributes(attributes);
365 * // do something
366 * }
367 * \endcode
368 *
369 */
370typedef multi_index_container<
372 indexed_by<
373 hashed_unique<tag<Meshset_mi_tag>, member<CubitMeshSets, EntityHandle,
375 ordered_non_unique<tag<CubitMeshsetType_mi_tag>,
376 const_mem_fun<CubitMeshSets, unsigned long int,
378 ordered_non_unique<tag<CubitMeshsetMaskedType_mi_tag>,
379 const_mem_fun<CubitMeshSets, unsigned long int,
381 ordered_non_unique<
382 tag<CubitMeshsets_name>,
383 const_mem_fun<CubitMeshSets, std::string, &CubitMeshSets::getName>>,
384 hashed_unique<
385 tag<Composite_Cubit_msId_And_MeshsetType_mi_tag>,
386 composite_key<
388 const_mem_fun<CubitMeshSets, int, &CubitMeshSets::getMeshsetId>,
389 const_mem_fun<CubitMeshSets, unsigned long int,
392
393/** \brief change meshset type
394 */
401
402/**
403 * \brief change meshset name
404 */
407 std::string nAme;
408 CubitMeshSets_change_name(Interface &moab, const std::string &name)
409 : mOab(moab), nAme(name){};
410 void operator()(CubitMeshSets &e);
411};
412
413/**
414 * change meshset attributes
415 */
418 const std::vector<double> &aTtr;
420 const std::vector<double> &attr)
421 : mOab(moab), aTtr(attr) {}
422 void operator()(CubitMeshSets &e);
423};
424
425/**
426 * change meshset attributes for material data structure
427 */
436
437/**
438 * change meshset attributes for material data structure
439 */
448
449} // namespace MoFEM
450
451#endif // __BCMULTIINDICES_HPP__
452
453/**
454 * \defgroup mofem_bc Boundary conditions
455 * \ingroup mofem
456 */
std::string type
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ 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()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
auto bit
set bit
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
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_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
std::vector< double > blockAttributesStorage
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:16