v0.15.5
Loading...
Searching...
No Matches
MeshsetsManager.cpp
Go to the documentation of this file.
1/** \file MeshsetsManager.cpp
2 * \brief Interface to manage meshsets which carrying information about boundary
3 * conditions and material blocks
4 *
5 */
6
7using namespace std;
8namespace po = boost::program_options;
9
10namespace MoFEM {
11
13 std::vector<const CubitMeshSets *> &vec_ptr) {
14 std::sort(vec_ptr.begin(), vec_ptr.end(),
15 [](const CubitMeshSets *a, const CubitMeshSets *b) {
16 if (a->getBcType().to_ullong() < b->getBcType().to_ullong())
17 return true;
18 if (a->getBcType().to_ullong() > b->getBcType().to_ullong())
19 return false;
20 else
21 return a->getMeshsetId() < b->getMeshsetId();
22 });
23}
24
26
28MeshsetsManager::query_interface(boost::typeindex::type_index type_index,
29 UnknownInterface **iface) const {
30 *iface = const_cast<MeshsetsManager *>(this);
31 return 0;
32}
33
35 : cOre(const_cast<Core &>(core)) {
36
37 if (!LogManager::checkIfChannelExist("MeshsetMngWorld")) {
38 auto core_log = logging::core::get();
39
40 core_log->add_sink(
42 core_log->add_sink(
44 core_log->add_sink(
46
47 LogManager::setLog("MeshsetMngWorld");
48 LogManager::setLog("MeshsetMngSync");
49 LogManager::setLog("MeshsetMngSelf");
50
51 MOFEM_LOG_TAG("MeshsetMngWorld", "MeshsetMng");
52 MOFEM_LOG_TAG("MeshsetMngSync", "MeshsetMng");
53 MOFEM_LOG_TAG("MeshsetMngSelf", "MeshsetMng");
54 }
55
56 MOFEM_LOG("MeshsetMngWorld", Sev::noisy) << "Mashset manager created";
57}
58
64
66 Interface &m_field = cOre;
68 CHKERR readMeshsets(verb);
71
72 std::vector<const CubitMeshSets *> vec_ptr;
73 for (auto &m : cubitMeshsets) {
74 vec_ptr.push_back(&m);
75 }
76 sortMeshsets(vec_ptr);
77
78 for (auto m_ptr : vec_ptr) {
79 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
80 << "meshset in database " << *m_ptr;
81 }
82 // Verbose synchronised print
83 for (auto m_ptr : vec_ptr) {
84 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
85 << "meshset in database " << *m_ptr;
86 }
87 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
88
90}
91
93 Interface &m_field = cOre;
94 moab::Interface &moab = m_field.get_moab();
96
97 Range meshsets;
98 CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
99 for (auto m : meshsets) {
100 // check if meshset is cubit meshset
101 CubitMeshSets block(moab, m);
102 if ((block.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET)).any()) {
103 auto p = cubitMeshsets.insert(block);
104 if (!p.second) {
105 // blockset/nodeset/sideset set exist, could be created on other
106 // processor.
107 Range ents;
108 CHKERR m_field.get_moab().get_entities_by_handle(m, ents, true);
109 CHKERR m_field.get_moab().add_entities(p.first->getMeshset(), ents);
110 CHKERR m_field.get_moab().delete_entities(&m, 1);
111 }
112 }
113 }
114
115 std::vector<const CubitMeshSets *> vec_ptr;
116 for (auto &m : cubitMeshsets) {
117 vec_ptr.push_back(&m);
118 }
119 sortMeshsets(vec_ptr);
120
121 for (auto m_ptr : vec_ptr) {
122 MOFEM_LOG("MeshsetMngSync", Sev::verbose) << "read " << *m_ptr;
123 }
124 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
125
127}
128
130 Interface &m_field = cOre;
131 moab::Interface &moab = m_field.get_moab();
133
134 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
135 if (pcomm == NULL)
136 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
137 "MOAB communicator not set");
138
139 const double coords[] = {0, 0, 0};
140
141 auto set_tags_dummy_node = [&](const EntityHandle dummy_node,
142 const EntityHandle meshset) {
144 std::vector<Tag> tag_handles;
145 CHKERR moab.tag_get_tags_on_entity(meshset, tag_handles);
146 for (auto th : tag_handles) {
147 void *data[1];
148 int tag_size;
149 CHKERR moab.tag_get_by_ptr(th, &meshset, 1, (const void **)data,
150 &tag_size);
151 if (tag_size > 0)
152 CHKERR moab.tag_set_by_ptr(th, &dummy_node, 1, data, &tag_size);
153 }
155 };
156
157 for (auto t : {NODESET, SIDESET, BLOCKSET}) {
158 std::vector<const CubitMeshSets *> vec_ptr;
159 for (auto &m : cubitMeshsets) {
160 if ((m.getBcType() & CubitBCType(t)).any()) {
161 vec_ptr.push_back(&m);
162 }
163 }
164 sortMeshsets(vec_ptr);
165
166 std::vector<EntityHandle> vec_meshsets;
167 vec_meshsets.reserve(vec_ptr.size());
168 for (auto m_ptr : vec_ptr) {
169 vec_meshsets.push_back(m_ptr->getMeshset());
170 }
171
172 switch (t) {
173 case NODESET:
174 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
175 << "broadcast NODESET " << vec_meshsets.size();
176 break;
177 case SIDESET:
178 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
179 << "broadcast SIDESET " << vec_meshsets.size();
180 break;
181 case BLOCKSET:
182 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
183 << "broadcast BLOCKSET " << vec_meshsets.size();
184 break;
185 default:
186 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
187 << "broadcast Unknown " << vec_meshsets.size();
188 }
189
190 for (int from_proc = 0; from_proc < pcomm->size(); ++from_proc) {
191
192 Range r_dummy_nodes;
193
194 if (from_proc == pcomm->rank()) {
195 std::vector<EntityHandle> dummy_nodes(vec_meshsets.size(), 0);
196 int i = 0;
197 for (auto m : vec_meshsets) {
198 CHKERR moab.create_vertex(coords, dummy_nodes[i]);
199 CHKERR set_tags_dummy_node(dummy_nodes[i], m);
200 ++i;
201 }
202 r_dummy_nodes.insert_list(dummy_nodes.begin(), dummy_nodes.end());
203 }
204
205 CHKERR pcomm->broadcast_entities(from_proc, r_dummy_nodes, false, true);
206
207 if (from_proc != pcomm->rank()) {
208
209 for (auto dummy_node : r_dummy_nodes) {
210 CubitMeshSets broadcast_block(moab, dummy_node);
211 auto id = broadcast_block.getMeshsetId();
212 if (id != -1) {
213 auto mit =
215 .find(boost::make_tuple(
216 id, broadcast_block.getMaskedBcTypeULong()));
217 if (mit ==
219 .end()) {
221 CHKERR moab.create_meshset(MESHSET_SET, m);
222 CHKERR set_tags_dummy_node(m, dummy_node);
223 auto hint = cubitMeshsets.end();
224 /*auto p = */ cubitMeshsets.emplace_hint(hint, moab, m);
225 }
226 } else {
227 MOFEM_LOG("MeshsetMngSync", Sev::warning)
228 << "broadcasted vertex " << dummy_node << " has negative id";
229 }
230
231 }
232
233 } else {
234 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
235 << "broadcast send from " << from_proc;
236 }
237
238 CHKERR moab.delete_entities(r_dummy_nodes);
239 }
240
241 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
242 }
243
245}
246
249 Interface &m_field = cOre;
250 moab::Interface &moab = m_field.get_moab();
252 bhTag_header, verb);
254}
255
256MoFEMErrorCode MeshsetsManager::getTags(moab::Interface &moab, Tag &nsTag,
257 Tag &ssTag, Tag &nsTag_data,
258 Tag &ssTag_data, Tag &bhTag,
259 Tag &bhTag_header, int verb) {
261
262 int default_val = -1;
263 CHKERR moab.tag_get_handle(DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag,
264 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
265
266 CHKERR moab.tag_get_handle(NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag,
267 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
268
269 const int def_bc_data_len = 0;
270 std::string tag_name = std::string(DIRICHLET_SET_TAG_NAME) + "__BC_DATA";
271 CHKERR moab.tag_get_handle(
272 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nsTag_data,
273 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
274
275 tag_name = std::string(NEUMANN_SET_TAG_NAME) + "__BC_DATA";
276 CHKERR moab.tag_get_handle(
277 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, ssTag_data,
278 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
279
280 CHKERR moab.tag_get_handle(MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, bhTag,
281 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
282
283 std::vector<unsigned int> def_uint_zero(3, 0);
284 CHKERR moab.tag_get_handle(
285 BLOCK_HEADER, 3 * sizeof(unsigned int), MB_TYPE_INTEGER, bhTag_header,
286 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES, &def_uint_zero[0]);
287
288 Tag block_attribs;
289 int def_Block_Attributes_length = 0;
290 CHKERR moab.tag_get_handle(
291 BLOCK_ATTRIBUTES, def_Block_Attributes_length, MB_TYPE_DOUBLE,
292 block_attribs, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
293
294 Tag entity_name_tag;
295 CHKERR moab.tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
296 entity_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT);
297
299}
300
307
314
321
328
335
338 const Interface &m_field = cOre;
339 const moab::Interface &moab = m_field.get_moab();
341 (*this), BLOCKSET | MAT_ELASTICSET, it)) {
342 Mat_Elastic data;
343 CHKERR it->getAttributeDataStructure(data);
344 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
345 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
346 Range tets;
347 CHKERR moab.get_entities_by_dimension(it->meshset, 3, tets, true);
348 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
349 << "MAT_ELATIC msId " << it->getMeshsetId() << " nb. volumes "
350 << tets.size();
351 }
352
354 m_field, BLOCKSET | MAT_THERMALSET, it)) {
355 Mat_Thermal data;
356 CHKERR it->getAttributeDataStructure(data);
357 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
358 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
359 }
360
362 m_field, BLOCKSET | MAT_MOISTURESET, it)) {
363 Mat_Moisture data;
364 CHKERR it->getAttributeDataStructure(data);
365 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
366 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
367 }
369}
370
371bool MeshsetsManager::checkMeshset(const int ms_id,
372 const CubitBCType cubit_bc_type) const {
373 auto miit =
375 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
376 if (miit !=
378 return true;
379 }
380 return false;
381}
382
383bool MeshsetsManager::checkMeshset(const string name,
384 int *const number_of_meshsets_ptr) const {
385 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
386 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
387 if (std::distance(miit, hi_miit) == 0) {
388 return false;
389 }
390 if (number_of_meshsets_ptr) {
391 *number_of_meshsets_ptr = std::distance(miit, hi_miit);
392 }
393 return true;
394}
395
397 const int ms_id,
398 const std::string name) {
399 Interface &m_field = cOre;
400 moab::Interface &moab = m_field.get_moab();
402 if (checkMeshset(ms_id, cubit_bc_type)) {
403 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
404 "such cubit meshset is already there id = %d", ms_id);
405 }
406
407 CubitMeshSets cmeshset(moab, cubit_bc_type, ms_id);
408 if ((cmeshset.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET))
409 .any()) {
410 auto p = cubitMeshsets.insert(cmeshset);
411 if (!p.second) {
412 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
413 "meshset not inserted");
414 }
415 if (name.size() > 0) {
416 bool success =
417 cubitMeshsets.modify(p.first, CubitMeshSets_change_name(moab, name));
418 if (!success) {
419 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
420 "name to cubit meshset can not be set");
421 }
422 }
423 }
424
426}
427
430 const int ms_id, const Range &ents) {
431 Interface &m_field = cOre;
432 moab::Interface &moab = m_field.get_moab();
434 auto cit =
436 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
437 if (cit ==
439 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
440 "Cannot find Cubit meshset with id: %d", ms_id);
441 }
442 EntityHandle meshset = cit->getMeshset();
443 CHKERR moab.add_entities(meshset, ents);
444
446}
447
450 const int ms_id, const EntityHandle *ents,
451 const int nb_ents) {
452 Interface &m_field = cOre;
453 moab::Interface &moab = m_field.get_moab();
455 auto cit =
457 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
458 if (cit ==
460 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
461 "Cannot find Cubit meshset with id: %d", ms_id);
462 }
463 EntityHandle meshset = cit->getMeshset();
464 CHKERR moab.add_entities(meshset, ents, nb_ents);
465
467}
468
470MeshsetsManager::setAttributes(const CubitBCType cubit_bc_type, const int ms_id,
471 const std::vector<double> &attributes,
472 const std::string name) {
473 Interface &m_field = cOre;
474 moab::Interface &moab = m_field.get_moab();
476 auto cit =
478 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
479 if (cit ==
481 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
482 "Cannot find Cubit meshset with id: %d", ms_id);
483 }
484 if (name.size() > 0) {
485 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
486 CubitMeshSets_change_name(moab, name));
487 if (!success) {
488 SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
489 "name to cubit meshset can not be set");
490 }
491 }
492 bool success =
493 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
494 CubitMeshSets_change_attributes(moab, attributes));
495 if (!success)
496 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
497 "modification unsuccessful");
498
499 std::ostringstream ss;
500 ss << "Block " << cit->getName();
501 ss << " Add attr: ";
502 for (unsigned int ii = 0; ii != attributes.size(); ii++) {
503 ss << attributes[ii] << " ";
504 }
505 MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << ss.str();
506
508}
509
511 const CubitBCType cubit_bc_type, const int ms_id,
512 const GenericAttributeData &data, const std::string name) {
513 Interface &m_field = cOre;
514 moab::Interface &moab = m_field.get_moab();
516 auto cit =
518 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
519 if (cit ==
521 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
522 "Cannot find Cubit meshset with id: %d", ms_id);
523 }
524 if (name.size() > 0) {
525 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
526 CubitMeshSets_change_name(moab, name));
527 if (!success) {
528 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
529 "name to cubit meshset can not be set");
530 }
531 }
532 bool success = cubitMeshsets.modify(
533 cubitMeshsets.project<0>(cit),
535 if (!success)
536 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
537 "modification unsuccessful");
539}
540
542 const int ms_id,
543 const GenericCubitBcData &data) {
544 Interface &m_field = cOre;
545 moab::Interface &moab = m_field.get_moab();
547 auto cit =
549 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
550 if (cit ==
552 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
553 "Cubit meshset with id is already there id = %d", ms_id);
554 }
555 bool success =
556 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
558 if (!success)
559 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
560 "modification unsuccessful");
562}
563
565 const int ms_id,
566 const MoFEMTypes bh) {
567 Interface &m_field = cOre;
568 moab::Interface &moab = m_field.get_moab();
570 auto miit =
572 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
573 if (miit ==
575 if (bh & MF_EXIST) {
576 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
577 "meshset not found id = %d", ms_id);
578 } else {
580 }
581 }
582 EntityHandle meshset = miit->getMeshset();
584 CHKERR moab.delete_entities(&meshset, 1);
585
587}
588
590 const int ms_id, const CubitBCType cubit_bc_type,
591 const CubitMeshSets **cubit_meshset_ptr) const {
592 Interface &m_field = cOre;
594 auto miit =
596 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
597 if (miit !=
599 *cubit_meshset_ptr = &*miit;
600 } else {
601 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
602 "msId = %d is not there", ms_id);
603 }
605}
606
607const CubitMeshSets *
609 const CubitBCType cubit_bc_type) const {
610 const CubitMeshSets *cubit_meshset_ptr;
612 getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr),
613 "Get not get meshset");
614 return cubit_meshset_ptr;
615}
616
618 const string name, const CubitMeshSets **cubit_meshset_ptr) const {
619 Interface &m_field = cOre;
621 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
622 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
623 if (std::distance(miit, hi_miit) == 0) {
624 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
625 "meshset name <%s> is not there", name.c_str());
626 }
627 if (std::distance(miit, hi_miit) > 1) {
628 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
629 "more that one meshser of that name <%s>", name.c_str());
630 }
631 *cubit_meshset_ptr = &*miit;
633}
634
636 const CubitBCType cubit_bc_type,
637 std::vector<const CubitMeshSets *> &vec_ptr) const {
639 auto r = cubitMeshsets.get<CubitMeshsetType_mi_tag>().equal_range(
640 cubit_bc_type.to_ulong());
641 for (auto it = r.first; it != r.second; ++it) {
642 vec_ptr.push_back(&*it);
643 }
644 sortMeshsets(vec_ptr);
646}
647
648std::vector<const CubitMeshSets *>
650 std::vector<const CubitMeshSets *> vec_ptr;
651 CHK_MOAB_THROW(getCubitMeshsetPtr(cubit_bc_type, vec_ptr),
652 "Error in getting meshsets by name");
653 return vec_ptr;
654}
655
657 const std::regex reg_exp_name,
658 std::vector<const CubitMeshSets *> &vec_ptr) const {
660 auto r =
662 for (; r.first != r.second; ++r.first) {
663 const auto name = r.first->getName();
664 if (std::regex_match(name, reg_exp_name)) {
665 vec_ptr.push_back(&*r.first);
666 }
667 }
668 sortMeshsets(vec_ptr);
670}
671
672std::vector<const CubitMeshSets *>
673MeshsetsManager::getCubitMeshsetPtr(const std::regex reg_exp_name) const {
674 std::vector<const CubitMeshSets *> vec_ptr;
675 CHK_MOAB_THROW(getCubitMeshsetPtr(reg_exp_name, vec_ptr),
676 "Error in getting meshsets by name");
677 return vec_ptr;
678}
679
681 const int msId, const unsigned int cubit_bc_type, const int dimension,
682 Range &entities, const bool recursive) const {
683 Interface &m_field = cOre;
684 moab::Interface &moab = m_field.get_moab();
686 auto miit =
688 boost::make_tuple(msId, cubit_bc_type));
689 if (miit !=
691 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, dimension, entities,
692 recursive);
693 } else {
694 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
695 "msId = %d is not there", msId);
696 }
698}
699
701 const int ms_id, const unsigned int cubit_bc_type, Range &entities,
702 const bool recursive) const {
703 Interface &m_field = cOre;
704 moab::Interface &moab = m_field.get_moab();
706 auto miit =
708 boost::make_tuple(ms_id, cubit_bc_type));
709 if (miit !=
711 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, entities, recursive);
712 } else {
713 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
714 "ms_id = %d is not there", ms_id);
715 }
717}
718
720 const unsigned int cubit_bc_type,
721 EntityHandle &meshset) const {
722 Interface &m_field = cOre;
724 auto miit =
726 boost::make_tuple(ms_id, cubit_bc_type));
727 if (miit !=
729 meshset = miit->meshset;
730 } else {
731 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
732 "ms_id = %d is not there", ms_id);
733 }
735}
736
738 const int ms_id, const unsigned int cubit_bc_type,
739 const EntityHandle *entities, int num_entities, const int operation_type) {
740 auto miit =
742 boost::make_tuple(ms_id, cubit_bc_type));
743 if (miit !=
745 Interface &m_field = cOre;
746 return m_field.get_moab().contains_entities(miit->meshset, entities,
747 num_entities, operation_type);
748 } else
749 return false;
750}
751
753MeshsetsManager::getMeshsetsByType(const unsigned int cubit_bc_type,
754 Range &meshsets) const {
756 auto miit =
757 cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(cubit_bc_type);
758 auto hi_miit =
759 cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(cubit_bc_type);
760 for (; miit != hi_miit; miit++) {
761 meshsets.insert(miit->meshset);
762 }
764}
765
766struct BlockData {
767
769
770 int iD;
771 string addType;
772 string nAme;
774
775 // Materials
780
781 // BCs
788
790 std::vector<double> aTtr;
791
793 std::memcpy(dispBc.data.name, "Displacement", 12);
794 std::memcpy(forceBc.data.name, "Force", 5);
795 std::memcpy(pressureBc.data.name, "Pressure", 8);
796 std::memcpy(temperatureBc.data.name, "Temperature", 11);
797 std::memcpy(heatFluxBc.data.name, "HeatFlux", 8);
798 std::memcpy(cfgBc.data.name, "cfd_bc", 6);
799 }
800};
801
803 bool clean_file_options) {
804 Interface &m_field = cOre;
806 std::ifstream ini_file(file_name.c_str(), std::ifstream::in);
807 po::variables_map vm;
808 if (clean_file_options) {
810 boost::shared_ptr<boost::program_options::options_description>(
811 new po::options_description());
812 }
813
814 auto add_block_attributes = [&](auto prefix, auto &block_lists, auto &it) {
815 // remove spacec from blockset name
816 configFileOptionsPtr->add_options()(
817 (prefix + ".number_of_attributes").c_str(),
818 po::value<int>(&block_lists[it->getMeshsetId()].numberOfAttributes)
819 ->default_value(-1),
820 "Number of blockset attribute");
821 for (int ii = 1; ii <= 10; ii++) {
822 std::string surfix = ".user" + boost::lexical_cast<std::string>(ii);
823 configFileOptionsPtr->add_options()(
824 (prefix + surfix).c_str(),
825 po::value<double>(&block_lists[it->getMeshsetId()].aTtr[ii - 1])
826 ->default_value(0.0),
827 "Add block attribute");
828 }
829 };
830
831 // Add blocks
832 map<int, BlockData> block_lists;
834 const auto id = it->getMeshsetId();
835 block_lists[id].cubitMeshset = it->getMeshset();
836 std::string prefix =
837 "block_" + boost::lexical_cast<std::string>(id);
838 configFileOptionsPtr->add_options()(
839 (prefix + ".add").c_str(),
840 po::value<string>(&block_lists[it->getMeshsetId()].addType)
841 ->default_value("UNKNOWNSET"),
842 "Add block set")(
843 (prefix + ".id").c_str(),
844 po::value<int>(&block_lists[it->getMeshsetId()].iD)->default_value(-1),
845 "Id of meshset")(
846 (prefix + ".name").c_str(),
847 po::value<string>(&block_lists[it->getMeshsetId()].nAme)
848 ->default_value(""),
849 "Name of the meshset");
850
851 // Block attributes
852 add_block_attributes(prefix, block_lists, it);
853
854 // Mat elastic
855 {
856 // double Young; ///< Young's modulus
857 // double Poisson; ///< Poisson's ratio
858 // double ThermalExpansion; ///< Thermal expansion
859 configFileOptionsPtr->add_options()(
860 (prefix + ".young").c_str(),
861 po::value<double>()->default_value(-1)->notifier(
862 [&block_lists, id](double v) {
863 block_lists[id].matElastic.data.Young = v;
864 }),
865 "Young modulus")(
866 (prefix + ".poisson").c_str(),
867 po::value<double>()->default_value(-2)->notifier(
868 [&block_lists, id](double v) {
869 block_lists[id].matElastic.data.Poisson = v;
870 }),
871 "Poisson ratio")(
872 (prefix + ".thermalexpansion").c_str(),
873 po::value<double>()->default_value(-1)->notifier(
874 [&block_lists, id](double v) {
875 block_lists[id].matElastic.data.ThermalExpansion = v;
876 }),
877 "Thermal expansion");
878 // TODO Add users parameters
879 }
880 // Mat Trans Iso
881 {
882 // Young's modulus in xy plane (Ep)
883 // Young's modulus in z-direction (Ez)
884 // Poisson's ratio in xy plane (vp)
885 // Poisson's ratio in z-direction (vpz)
886 // Shear modulus in z-direction (Gzp)
887 configFileOptionsPtr->add_options()(
888 (prefix + ".Youngp").c_str(),
889 po::value<double>()->default_value(-1)->notifier(
890 [&block_lists, id](double v) {
891 block_lists[id].matTransIso.data.Youngp = v;
892 }),
893 "Youngp")(
894 (prefix + ".Youngz").c_str(),
895 po::value<double>()->default_value(-1)->notifier(
896 [&block_lists, id](double v) {
897 block_lists[id].matTransIso.data.Youngz = v;
898 }),
899 "Youngz")(
900 (prefix + ".Poissonp").c_str(),
901 po::value<double>()->default_value(0)->notifier(
902 [&block_lists, id](double v) {
903 block_lists[id].matTransIso.data.Poissonp = v;
904 }),
905 "Poissonp")(
906 (prefix + ".Poissonpz").c_str(),
907 po::value<double>()->default_value(0)->notifier(
908 [&block_lists, id](double v) {
909 block_lists[id].matTransIso.data.Poissonpz = v;
910 }),
911 "Poissonpz")(
912 (prefix + ".Shearzp").c_str(),
913 po::value<double>()->default_value(-1)->notifier(
914 [&block_lists, id](double v) {
915 block_lists[id].matTransIso.data.Shearzp = v;
916 }),
917 "Shearzp");
918 // TODO Add users parameters
919 }
920 // Mat thermal
921 {
922 // double Conductivity; ///< Thermal conductivity
923 // double HeatCapacity; ///< Heat Capacity
924 configFileOptionsPtr->add_options()(
925 (prefix + ".conductivity").c_str(),
926 po::value<double>()->default_value(-1)->notifier(
927 [&block_lists, id](double v) {
928 block_lists[id].matThermal.data.Conductivity = v;
929 }),
930 "Conductivity")(
931 (prefix + ".capacity").c_str(),
932 po::value<double>()->default_value(-1)->notifier(
933 [&block_lists, id](double v) {
934 block_lists[id].matThermal.data.HeatCapacity = v;
935 }),
936 "Capacity");
937 // TODO Add users parameters
938 }
939 // Mat interface
940 {
941 // double alpha; ///< Elastic modulus multiplier
942 // double beta; ///< Damage Coupling multiplier between normal and
943 // shear (g=sqrt(gn^2 + beta(gt1^2 + gt2^2))) double ft; ///< Maximum
944 // stress of crack double Gf; ///< Fracture Energy
945 configFileOptionsPtr->add_options()(
946 (prefix + ".interface_alpha").c_str(),
947 po::value<double>()->default_value(-1)->notifier(
948 [&block_lists, id](double v) {
949 block_lists[id].matInterf.data.alpha = v;
950 }),
951 "alpha")((prefix + ".interface_beta").c_str(),
952 po::value<double>()->default_value(-1)->notifier(
953 [&block_lists, id](double v) {
954 block_lists[id].matInterf.data.beta = v;
955 }),
956 "beta")(
957 (prefix + ".interface_ft").c_str(),
958 po::value<double>()->default_value(-1)->notifier(
959 [&block_lists, id](double v) {
960 block_lists[id].matInterf.data.ft = v;
961 }),
962 "ft")(
963 (prefix + ".interface_Gf").c_str(),
964 po::value<double>()->default_value(-1)->notifier(
965 [&block_lists, id](double v) {
966 block_lists[id].matInterf.data.Gf = v;
967 }),
968 "Gf");
969 // TODO Add users parameters
970 }
971
972 // Displacement bc
973 {
974 // char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
975 // char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
976 // char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
977 // char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
978 // char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
979 // char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
980 // double value1; //< Value for X-Translation
981 // double value2; //< Value for Y-Translation
982 // double value3; //< Value for Z-Translation
983 // double value4; //< Value for X-Rotation
984 // double value5; //< Value for Y-Rotation
985 // double value6; //< Value for Z-Rotation
986 configFileOptionsPtr->add_options()(
987 (prefix + ".disp_flag1").c_str(),
988 po::value<char>()->default_value(0)->notifier(
989 [&block_lists, id](char v) {
990 block_lists[id].dispBc.data.flag1 = v;
991 }),
992 "flag1")(
993 (prefix + ".disp_flag2").c_str(),
994 po::value<char>()->default_value(0)->notifier(
995 [&block_lists, id](char v) {
996 block_lists[id].dispBc.data.flag2 = v;
997 }),
998 "flag2")(
999 (prefix + ".disp_flag3").c_str(),
1000 po::value<char>()->default_value(0)->notifier(
1001 [&block_lists, id](char v) {
1002 block_lists[id].dispBc.data.flag3 = v;
1003 }),
1004 "flag3")(
1005 (prefix + ".disp_flag4").c_str(),
1006 po::value<char>()->default_value(0)->notifier(
1007 [&block_lists, id](char v) {
1008 block_lists[id].dispBc.data.flag4 = v;
1009 }),
1010 "flag4")(
1011 (prefix + ".disp_flag5").c_str(),
1012 po::value<char>()->default_value(0)->notifier(
1013 [&block_lists, id](char v) {
1014 block_lists[id].dispBc.data.flag5 = v;
1015 }),
1016 "flag5")(
1017 (prefix + ".disp_flag6").c_str(),
1018 po::value<char>()->default_value(0)->notifier(
1019 [&block_lists, id](char v) {
1020 block_lists[id].dispBc.data.flag6 = v;
1021 }),
1022 "flag6")(
1023 (prefix + ".disp_ux").c_str(),
1024 po::value<double>()->default_value(0)->notifier(
1025 [&block_lists, id](double v) {
1026 block_lists[id].dispBc.data.value1 = v;
1027 }),
1028 "value1")(
1029 (prefix + ".disp_uy").c_str(),
1030 po::value<double>()->default_value(0)->notifier(
1031 [&block_lists, id](double v) {
1032 block_lists[id].dispBc.data.value2 = v;
1033 }),
1034 "value2")(
1035 (prefix + ".disp_uz").c_str(),
1036 po::value<double>()->default_value(0)->notifier(
1037 [&block_lists, id](double v) {
1038 block_lists[id].dispBc.data.value3 = v;
1039 }),
1040 "value3")(
1041 (prefix + ".disp_rx").c_str(),
1042 po::value<double>()->default_value(0)->notifier(
1043 [&block_lists, id](double v) {
1044 block_lists[id].dispBc.data.value4 = v;
1045 }),
1046 "value4")(
1047 (prefix + ".disp_ry").c_str(),
1048 po::value<double>()->default_value(0)->notifier(
1049 [&block_lists, id](double v) {
1050 block_lists[id].dispBc.data.value5 = v;
1051 }),
1052 "value5")(
1053 (prefix + ".disp_rz").c_str(),
1054 po::value<double>()->default_value(0)->notifier(
1055 [&block_lists, id](double v) {
1056 block_lists[id].dispBc.data.value6 = v;
1057 }),
1058 "value6");
1059 }
1060 // Force BC data
1061 {
1062 // char zero[3]; //< 3 zeros
1063 // double value1; //< Force magnitude
1064 // double value2; //< Moment magnitude
1065 // double value3; //< X-component of force direction vector
1066 // double value4; //< Y-component of force direction vector
1067 // double value5; //< Z-component of force direction vector
1068 // double value6; //< X-component of moment direction vector
1069 // double value7; //< Y-component of moment direction vector
1070 // double value8; //< Z-component of moment direction vector
1071 // char zero2; // 0
1072 configFileOptionsPtr->add_options()(
1073 (prefix + ".force_magnitude").c_str(),
1074 po::value<double>()->default_value(0)->notifier(
1075 [&block_lists, id](double v) {
1076 block_lists[id].forceBc.data.value1 = v;
1077 }),
1078 "value1")((prefix + ".moment_magnitude").c_str(),
1079 po::value<double>()->default_value(0)->notifier(
1080 [&block_lists, id](double v) {
1081 block_lists[id].forceBc.data.value2 = v;
1082 }),
1083 "value2")(
1084 (prefix + ".force_fx").c_str(),
1085 po::value<double>()->default_value(0)->notifier(
1086 [&block_lists, id](double v) {
1087 block_lists[id].forceBc.data.value3 = v;
1088 }),
1089 "value3")((prefix + ".force_fy").c_str(),
1090 po::value<double>()->default_value(0)->notifier(
1091 [&block_lists, id](double v) {
1092 block_lists[id].forceBc.data.value4 = v;
1093 }),
1094 "value4")(
1095 (prefix + ".force_fz").c_str(),
1096 po::value<double>()->default_value(0)->notifier(
1097 [&block_lists, id](double v) {
1098 block_lists[id].forceBc.data.value5 = v;
1099 }),
1100 "value5")((prefix + ".moment_mx").c_str(),
1101 po::value<double>()->default_value(0)->notifier(
1102 [&block_lists, id](double v) {
1103 block_lists[id].forceBc.data.value6 = v;
1104 }),
1105 "value6")(
1106 (prefix + ".moment_my").c_str(),
1107 po::value<double>()->default_value(0)->notifier(
1108 [&block_lists, id](double v) {
1109 block_lists[id].forceBc.data.value7 = v;
1110 }),
1111 "value7")((prefix + ".moment_mz").c_str(),
1112 po::value<double>()->default_value(0)->notifier(
1113 [&block_lists, id](double v) {
1114 block_lists[id].forceBc.data.value8 = v;
1115 }),
1116 "value8");
1117 }
1118 {
1119 // char name[11]; //< 11 characters for "Temperature"
1120 // char pre1; //< This is always zero
1121 // char pre2; //< 0: temperature is not applied on thin shells
1122 // (default); 1: temperature is applied on thin shells char flag1; //<
1123 // 0: N/A, 1: temperature value applied (not on thin shells) char flag2;
1124 // //< 0: N/A, 1: temperature applied on thin shell middle char flag3;
1125 // //< 0: N/A, 1: thin shell temperature gradient specified char flag4;
1126 // //< 0: N/A, 1: top thin shell temperature char flag5; //< 0: N/A, 1:
1127 // bottom thin shell temperature char flag6; //< This is always zero
1128 // double value1; //< Temperature (default case - no thin shells)
1129 // double value2; //< Temperature for middle of thin shells
1130 // double value3; //< Temperature gradient for thin shells
1131 // double value4; //< Temperature for top of thin shells
1132 // double value5; //< Temperature for bottom of thin shells
1133 // double value6; //< This is always zero, i.e. ignore
1134 configFileOptionsPtr->add_options()(
1135 (prefix + ".temperature_flag1").c_str(),
1136 po::value<char>()->default_value(0)->notifier(
1137 [&block_lists, id](char v) {
1138 block_lists[id].temperatureBc.data.flag1 = v;
1139 }),
1140 "flag1")(
1141 (prefix + ".temperature_t").c_str(),
1142 po::value<double>()->default_value(0)->notifier(
1143 [&block_lists, id](double v) {
1144 block_lists[id].temperatureBc.data.value1 = v;
1145 }),
1146 "value1");
1147 // TODO: Add more cases, see above
1148 }
1149 // Sideset
1150 {
1151 // char name[8]; //< 8 characters for "Pressure"
1152 // char zero; //< This is always zero
1153 // char flag2; //< 0: Pressure is interpreted as pure pressure 1:
1154 // pressure is interpreted as total force double value1; //< Pressure
1155 // value
1156 configFileOptionsPtr->add_options()(
1157 (prefix + ".pressure_flag2").c_str(),
1158 po::value<char>()->default_value(0)->notifier(
1159 [&block_lists, id](char v) {
1160 block_lists[id].pressureBc.data.flag2 = v;
1161 }),
1162 "flag2")((prefix + ".pressure_magnitude").c_str(),
1163 po::value<double>()->default_value(0)->notifier(
1164 [&block_lists, id](double v) {
1165 block_lists[id].pressureBc.data.value1 = v;
1166 }),
1167 "value1");
1168 }
1169 {
1170 // char name[8]; //< 8 characters for "HeatFlux" (no space)
1171 // char pre1; //< This is always zero
1172 // char pre2; //< 0: heat flux is not applied on thin shells (default);
1173 // 1: heat flux is applied on thin shells char flag1; //< 0: N/A, 1:
1174 // normal heat flux case (i.e. single value, case without thin shells)
1175 // char flag2; //< 0: N/A, 1: Thin shell top heat flux specified
1176 // char flag3; //< 0: N/A, 1: Thin shell bottom heat flux specidied
1177 // double value1; //< Heat flux value for default case (no thin shells)
1178 // double value2; //< Heat flux (thin shell top)
1179 // double value3; //< Heat flux (thin shell bottom)
1180 configFileOptionsPtr->add_options()(
1181 (prefix + ".heatflux_flag1").c_str(),
1182 po::value<char>()->default_value(0)->notifier(
1183 [&block_lists, id](char v) {
1184 block_lists[id].heatFluxBc.data.flag1 = v;
1185 }),
1186 "flag1")((prefix + ".heatflux_magnitude").c_str(),
1187 po::value<double>()->default_value(0)->notifier(
1188 [&block_lists, id](double v) {
1189 block_lists[id].heatFluxBc.data.value1 = v;
1190 }),
1191 "value1");
1192 }
1193 // Interface set
1194 {
1195 configFileOptionsPtr->add_options()(
1196 (prefix + ".interface_type").c_str(),
1197 po::value<char>()->default_value(0)->notifier(
1198 [&block_lists, id](char v) {
1199 block_lists[id].cfgBc.data.type = v;
1200 }),
1201 "type");
1202 }
1203 }
1204
1205 map<int, BlockData> block_set_attributes;
1207 block_set_attributes[it->getMeshsetId()].cubitMeshset = it->getMeshset();
1208 block_set_attributes[it->getMeshsetId()].iD = it->getMeshsetId();
1209 block_set_attributes[it->getMeshsetId()].bcType = BLOCKSET;
1210 std::string block_name = it->getName();
1211 block_name.erase(
1212 std::remove_if(block_name.begin(), block_name.end(), ::isspace),
1213 block_name.end());
1214 block_set_attributes[it->getMeshsetId()].nAme = block_name;
1215 // Only blocks which have name
1216 if (block_name.compare("NoNameSet") != 0) {
1217 std::string prefix = "SET_ATTR_" + block_name;
1218 // Block attributes
1219 add_block_attributes(prefix, block_set_attributes, it);
1220 }
1221 }
1222
1223 po::parsed_options parsed =
1224 parse_config_file(ini_file, *configFileOptionsPtr, true);
1225 store(parsed, vm);
1226 po::notify(vm);
1227
1228 // Set type from name
1230
1231 CubitBCType bc_type;
1232 unsigned jj = 0;
1233 while (1 << jj != LASTSET_BC) {
1234 if (string(CubitBCNames[jj + 1]) ==
1235 block_lists[it->getMeshsetId()].addType) {
1236 bc_type = 1 << jj;
1237 }
1238 ++jj;
1239 }
1240 if (bc_type.none()) {
1241 block_lists[it->getMeshsetId()].bcType = UNKNOWNSET;
1242 // Skip the bockset nothing is defined for it
1243 continue;
1244 }
1245
1246 if (bc_type.to_ulong() == BLOCKSET)
1247 block_lists[it->getMeshsetId()].bcType = BLOCKSET;
1248 else if (bc_type.to_ulong() == NODESET)
1249 block_lists[it->getMeshsetId()].bcType = NODESET;
1250 else if (bc_type.to_ulong() == SIDESET)
1251 block_lists[it->getMeshsetId()].bcType = SIDESET;
1252 else {
1253 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1254 "Not yet implemented type %s\n",
1255 block_lists[it->getMeshsetId()].addType.c_str());
1256 }
1257 if (block_lists[it->getMeshsetId()].iD == -1) {
1258 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1259 "Unset iD number %d\n", block_lists[it->getMeshsetId()].iD);
1260 }
1261 }
1262
1263 std::vector<std::string> additional_parameters;
1264 additional_parameters =
1265 collect_unrecognized(parsed.options, po::include_positional);
1266 for (std::vector<std::string>::iterator vit = additional_parameters.begin();
1267 vit != additional_parameters.end(); vit++) {
1268 MOFEM_LOG_C("MeshsetMngSelf", Sev::warning, "Unrecognized option %s",
1269 vit->c_str());
1270 }
1271 for (map<int, BlockData>::iterator mit = block_lists.begin();
1272 mit != block_lists.end(); mit++) {
1273 CubitMeshSet_multiIndex::iterator cubit_meshset_it =
1274 cubitMeshsets.find(mit->second.cubitMeshset);
1275 if (cubit_meshset_it == cubitMeshsets.end()) {
1276 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1277 "Data inconsistency\n");
1278 }
1279 switch (mit->second.bcType) {
1280 case UNKNOWNSET:
1281 break;
1282 case BLOCKSET: {
1283 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1284 .any() &&
1285 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1286 // Meshset is the same, only modification
1287 } else {
1288 CHKERR addMeshset(mit->second.bcType, mit->second.iD, mit->second.nAme);
1289 EntityHandle meshset = cubit_meshset_it->getMeshset();
1290 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1291 &meshset, 1);
1292 }
1293 // Add attributes
1294 CHKERR setAttributes(mit->second.bcType, mit->second.iD, mit->second.aTtr);
1295 // Add material elastic data if value are physical (i.e. Young > 0,
1296 // Poisson in (-1.0.5) and ThermalExpansion>0)
1297 if (mit->second.matElastic.data.Young != -1) {
1298 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1299 mit->second.matElastic);
1300 }
1301 if (mit->second.matTransIso.data.Youngp != -1) {
1302 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1303 mit->second.matTransIso);
1304 }
1305 if (mit->second.matThermal.data.Conductivity != -1) {
1306 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1307 mit->second.matThermal);
1308 }
1309 if (mit->second.matInterf.data.ft != -1) {
1310 CHKERR setAttributesByDataStructure(mit->second.bcType, mit->second.iD,
1311 mit->second.matInterf);
1312 }
1313 } break;
1314 case NODESET: {
1315 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1316 .any() &&
1317 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1318 // Meshset is the same, only modification
1319 } else {
1320 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1321 EntityHandle meshset = cubit_meshset_it->getMeshset();
1322 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1323 &meshset, 1);
1324 }
1325 // Add displacement bc
1326 if (mit->second.dispBc.data.flag1 || mit->second.dispBc.data.flag2 ||
1327 mit->second.dispBc.data.flag3 || mit->second.dispBc.data.flag4 ||
1328 mit->second.dispBc.data.flag5 || mit->second.dispBc.data.flag6) {
1329 if (mit->second.dispBc.data.flag1 == '0')
1330 mit->second.dispBc.data.flag1 = 0;
1331 if (mit->second.dispBc.data.flag1 == 'N')
1332 mit->second.dispBc.data.flag1 = 0;
1333 if (mit->second.dispBc.data.flag1)
1334 mit->second.dispBc.data.flag1 = 1;
1335 if (mit->second.dispBc.data.flag2 == '0')
1336 mit->second.dispBc.data.flag2 = 0;
1337 if (mit->second.dispBc.data.flag2 == 'N')
1338 mit->second.dispBc.data.flag2 = 0;
1339 if (mit->second.dispBc.data.flag2)
1340 mit->second.dispBc.data.flag2 = 1;
1341 if (mit->second.dispBc.data.flag3 == '0')
1342 mit->second.dispBc.data.flag3 = 0;
1343 if (mit->second.dispBc.data.flag3 == 'N')
1344 mit->second.dispBc.data.flag3 = 0;
1345 if (mit->second.dispBc.data.flag3)
1346 mit->second.dispBc.data.flag3 = 1;
1347 if (mit->second.dispBc.data.flag4 == '0')
1348 mit->second.dispBc.data.flag4 = 0;
1349 if (mit->second.dispBc.data.flag4 == 'N')
1350 mit->second.dispBc.data.flag4 = 0;
1351 if (mit->second.dispBc.data.flag4)
1352 mit->second.dispBc.data.flag4 = 1;
1353 if (mit->second.dispBc.data.flag5 == '0')
1354 mit->second.dispBc.data.flag5 = 0;
1355 if (mit->second.dispBc.data.flag5 == 'N')
1356 mit->second.dispBc.data.flag5 = 0;
1357 if (mit->second.dispBc.data.flag5)
1358 mit->second.dispBc.data.flag5 = 1;
1359 if (mit->second.dispBc.data.flag6 == '0')
1360 mit->second.dispBc.data.flag6 = 0;
1361 if (mit->second.dispBc.data.flag6 == 'N')
1362 mit->second.dispBc.data.flag6 = 0;
1363 if (mit->second.dispBc.data.flag6)
1364 mit->second.dispBc.data.flag6 = 1;
1365 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1366 mit->second.dispBc);
1367 }
1368 if (mit->second.forceBc.data.value1 != 0 ||
1369 mit->second.forceBc.data.value2 != 0) {
1370 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1371 mit->second.forceBc);
1372 }
1373 // Add temperature boundary condition
1374 if (mit->second.temperatureBc.data.flag1) {
1375 if (mit->second.temperatureBc.data.flag1 == '0')
1376 mit->second.temperatureBc.data.flag1 = 0;
1377 if (mit->second.temperatureBc.data.flag1 == 'N')
1378 mit->second.temperatureBc.data.flag1 = 0;
1379 if (mit->second.temperatureBc.data.flag1)
1380 mit->second.temperatureBc.data.flag1 = 1;
1381 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1382 mit->second.temperatureBc);
1383 }
1384 } break;
1385 case SIDESET: {
1386 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1387 .any() &&
1388 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1389 // Meshset is the same, only modification
1390 } else {
1391 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1392 EntityHandle meshset = cubit_meshset_it->getMeshset();
1393 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1394 &meshset, 1);
1395 }
1396 // Add pressure
1397 if (mit->second.pressureBc.data.value1 != 0) {
1398 if (mit->second.pressureBc.data.flag2 == '0')
1399 mit->second.pressureBc.data.flag2 = 0;
1400 if (mit->second.pressureBc.data.flag2 == 'N')
1401 mit->second.pressureBc.data.flag2 = 0;
1402 if (mit->second.pressureBc.data.flag2)
1403 mit->second.pressureBc.data.flag2 = 1;
1404 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1405 mit->second.pressureBc);
1406 }
1407 // Add heat flux
1408 if (mit->second.heatFluxBc.data.value1 != 0) {
1409 if (mit->second.heatFluxBc.data.flag1 == '0')
1410 mit->second.heatFluxBc.data.flag1 = 0;
1411 if (mit->second.heatFluxBc.data.flag1 == 'N')
1412 mit->second.heatFluxBc.data.flag1 = 0;
1413 if (mit->second.heatFluxBc.data.flag1)
1414 mit->second.heatFluxBc.data.flag1 = 1;
1415 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1416 mit->second.heatFluxBc);
1417 }
1418 // Add Interface
1419 if (mit->second.cfgBc.data.type != 0) {
1420 CHKERR setBcData(mit->second.bcType, mit->second.iD, mit->second.cfgBc);
1421 }
1422 } break;
1423 default:
1424 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1425 "Not yet implemented type\n");
1426 }
1427 }
1428
1429 for (auto set_attr : block_set_attributes) {
1430 // Add attributes
1431 if (set_attr.second.numberOfAttributes > 0) {
1432 MOFEM_LOG("MeshsetMngSelf", Sev::verbose)
1433 << "Set attributes to blockset " << set_attr.second.nAme;
1434 set_attr.second.aTtr.resize(set_attr.second.numberOfAttributes);
1435 CHKERR setAttributes(set_attr.second.bcType, set_attr.second.iD,
1436 set_attr.second.aTtr);
1437 }
1438 }
1439
1441}
1442
1444 Interface &m_field = cOre;
1445 PetscBool flg_file;
1446 char meshset_file_name[255] = "config_file.cfg";
1448 PetscOptionsBegin(m_field.get_comm(), "", "Set meshsets form file",
1449 "none");
1450 CHKERR PetscOptionsString("-meshsets_config", "meshsets config file name",
1451 "", "add_cubit_meshsets.in", meshset_file_name, 255,
1452 &flg_file);
1453 if (flg_file == PETSC_TRUE) {
1454 ifstream f(meshset_file_name);
1455 if (!f.good()) {
1456 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1457 "File configuring meshsets ( %s ) can not be open\n",
1458 meshset_file_name);
1459 }
1460 CHKERR setMeshsetFromFile(string(meshset_file_name));
1461 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
1462 << "Printing all meshsets (old and added from meshsets "
1463 "configurational file)";
1464 for (auto cit = getBegin(); cit != getEnd(); cit++) {
1465 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *cit;
1466 }
1467 }
1468 PetscOptionsEnd();
1470}
1471
1473 const int ms_id, const unsigned int cubit_bc_type,
1474 const std::string file_name, const std::string file_type,
1475 const std::string options) const {
1476
1478 MoFEM::Interface &m_field = cOre;
1479 const CubitMeshSets *cubit_meshset_ptr;
1480 CHKERR getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr);
1481 EntityHandle meshset = cubit_meshset_ptr->getMeshset();
1482 CHKERR m_field.get_moab().write_file(file_name.c_str(), file_type.c_str(),
1483 options.c_str(), &meshset, 1);
1485}
1486
1488 const int ms_id, const unsigned int cubit_bc_type, const int dim,
1489 const std::string file_name, const bool recursive,
1490 const std::string file_type, const std::string options) const {
1491
1493 MoFEM::Interface &m_field = cOre;
1494 moab::Interface &moab = m_field.get_moab();
1495 Range entities;
1496 CHKERR getEntitiesByDimension(ms_id, cubit_bc_type, dim, entities, recursive);
1497 EntityHandle meshset;
1498 CHKERR moab.create_meshset(MESHSET_SET, meshset);
1499 CHKERR moab.add_entities(meshset, entities);
1500 CHKERR moab.write_file(file_name.c_str(), file_type.c_str(), options.c_str(),
1501 &meshset, 1);
1502 CHKERR moab.delete_entities(&meshset, 1);
1504}
1505
1510 for (_IT_CUBITMESHSETS_FOR_LOOP_((*this), iit)) {
1511 EntityHandle meshset = iit->getMeshset();
1512 for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t)
1513 CHKERR bit_mng->updateMeshsetByEntitiesChildren(meshset, bit, meshset, t,
1514 true);
1515 }
1517}
1518
1519} // namespace MoFEM
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
#define MOFEM_LOG_C(channel, severity, format,...)
constexpr double a
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
@ MF_EXIST
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
CubitBC
Types of sets and boundary conditions.
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
@ NODESET
@ SIDESET
@ LASTSET_BC
@ MAT_THERMALSET
block name is "MAT_THERMAL"
@ MAT_MOISTURESET
block name is "MAT_MOISTURE"
@ UNKNOWNSET
@ BLOCKSET
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
static const char *const CubitBCNames[]
Names of types of sets and boundary conditions.
#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 ...
MoFEMErrorCode deleteMeshset(const CubitBCType cubit_bc_type, const int ms_id, const MoFEMTypes bh=MF_EXIST)
delete cubit meshset
MoFEMErrorCode updateMeshsetByEntitiesChildren(const EntityHandle parent, const BitRefLevel parent_bit, const BitRefLevel parent_mask, const BitRefLevel child_bit, const BitRefLevel child_mask, const EntityHandle child, EntityType child_type, const bool recursive=false, int verb=0)
Get child entities form meshset containing parent entities.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
MoFEMErrorCode printForceSet() const
Print meshsets with force boundary conditions.
MoFEMErrorCode getMeshset(const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
get meshset from CUBIT Id and CUBIT type
MoFEMErrorCode setBcData(const CubitBCType cubit_bc_type, const int ms_id, const GenericCubitBcData &data)
Set boundary condition data for meshset.
MoFEMErrorCode broadcastMeshsets(int verb=DEFAULT_VERBOSITY)
Broadcast meshsets across MPI processes.
MoFEMErrorCode initialiseDatabaseFromMesh(int verb=DEFAULT_VERBOSITY)
Initialize container from mesh data.
MoFEMErrorCode clearMap()
Clear the multi-index container.
MoFEMErrorCode setAttributes(const CubitBCType cubit_bc_type, const int ms_id, const std::vector< double > &attributes, const std::string name="")
Set attributes for CUBIT meshset.
MoFEMErrorCode addEntitiesToMeshset(const CubitBCType cubit_bc_type, const int ms_id, const Range &ents)
Add entities to CUBIT meshset.
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
Check for CUBIT meshset by ID and type.
CubitMeshSet_multiIndex::iterator getBegin() const
get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP...
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
MoFEMErrorCode printPressureSet() const
Print meshsets with pressure boundary conditions.
MoFEMErrorCode printMaterialsSet() const
Print meshsets with material properties.
MoFEMErrorCode setMeshsetFromFile()
Load meshset configuration from command line specified file.
MoFEMErrorCode addMeshset(const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
Add CUBIT meshset to manager.
MoFEMErrorCode getMeshsetsByType(const unsigned int cubit_bc_type, Range &meshsets) const
get all CUBIT meshsets by CUBIT type
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
MoFEMErrorCode getEntitiesByDimension(const int ms_id, const unsigned int cubit_bc_type, const int dimension, Range &entities, const bool recursive=true) const
get entities from CUBIT/meshset of a particular entity dimension
MoFEMErrorCode readMeshsets(int verb=DEFAULT_VERBOSITY)
Read meshsets from mesh database.
MoFEMErrorCode printHeatFluxSet() const
Print meshsets with heat flux boundary conditions.
MoFEMErrorCode printTemperatureSet() const
Print meshsets with temperature boundary conditions.
MoFEMErrorCode getTags(int verb=-1)
Get tag handles used on meshsets.
MoFEMErrorCode setAttributesByDataStructure(const CubitBCType cubit_bc_type, const int ms_id, const GenericAttributeData &data, const std::string name="")
Set attributes using data structure.
MoFEMErrorCode printDisplacementSet() const
Print meshsets with displacement boundary conditions.
CubitMeshSet_multiIndex::iterator getEnd() const
get begin iterator of cubit meshset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP...
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
auto bit
set bit
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< 32 > CubitBCType
Definition Types.hpp:52
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
constexpr double t
plate stiffness
Definition plate.cpp:58
FTensor::Index< 'm', 3 > m
Managing BitRefLevels.
PressureCubitBcData pressureBc
CfgCubitBcData cfgBc
Mat_Elastic_TransIso matTransIso
HeatFluxCubitBcData heatFluxBc
DisplacementCubitBcData dispBc
ForceCubitBcData forceBc
std::vector< double > aTtr
TemperatureCubitBcData temperatureBc
EntityHandle cubitMeshset
Definition of the cfd_bc data structure.
Definition BCData.hpp:476
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Core (interface) class.
Definition Core.hpp:82
this struct keeps basic methods for moab meshset about material and boundary conditions
unsigned long int getMaskedBcTypeULong() const
get meshset type and mask
EntityHandle getMeshset() const
get bc meshset
int getMeshsetId() const
get meshset id as it set in preprocessing software
MultiIndex Tag for field id.
Deprecated interface functions.
Definition of the displacement bc data structure.
Definition BCData.hpp:72
Definition of the force bc data structure.
Definition BCData.hpp:135
Generic attribute data structure.
Generic bc data structure.
Definition BCData.hpp:16
const CubitBCType tYpe
Type of boundary condition.
Definition BCData.hpp:55
Definition of the heat flux bc data structure.
Definition BCData.hpp:423
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Transverse Isotropic material data structure.
Elastic material data structure.
Linear interface data structure.
moisture transport material data structure
Thermal material data structure.
Interface for managing meshsets containing materials and boundary conditions.
MeshsetsManager(const MoFEM::Core &core)
Constructor for MeshsetsManager.
MoFEMErrorCode saveMeshsetToFile(const int ms_id, const unsigned int cubit_bc_type, const std::string file_name="out_meshset.vtk", const std::string file_type="VTK", const std::string options="") const
save cubit meshset entities on the moab mesh
bool checkIfMeshsetContainsEntities(const int ms_id, const unsigned int cubit_bc_type, const EntityHandle *entities, int num_entities, const int operation_type=moab::Interface::INTERSECT)
Check if meshset constains entities.
static void sortMeshsets(std::vector< const CubitMeshSets * > &vec_ptr)
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for MeshsetsManager.
MoFEMErrorCode updateAllMeshsetsByEntitiesChildren(const BitRefLevel &bit)
Update all blocksets, sidesets and node sets.
MoFEMErrorCode printBcSet(CUBIT_BC_DATA_TYPE &data, unsigned long int type) const
CubitMeshSet_multiIndex cubitMeshsets
cubit meshsets
MoFEM::Core & cOre
Reference to MoFEM Core interface.
boost::shared_ptr< boost::program_options::options_description > configFileOptionsPtr
config file options
Definition of the pressure bc data structure.
Definition BCData.hpp:375
Definition of the temperature bc data structure.
Definition BCData.hpp:302
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.