v0.14.0
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
61 cubitMeshsets.clear();
63}
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 // blocsket/nodeset/sideste 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 CHKERR moab.tag_set_by_ptr(th, &dummy_node, 1, data, &tag_size);
152 }
154 };
155
156 for (auto t : {NODESET, SIDESET, BLOCKSET}) {
157 std::vector<const CubitMeshSets *> vec_ptr;
158 for (auto &m : cubitMeshsets) {
159 if ((m.getBcType() & CubitBCType(t)).any()) {
160 vec_ptr.push_back(&m);
161 }
162 }
163 sortMeshsets(vec_ptr);
164
165 std::vector<EntityHandle> vec_meshsets;
166 vec_meshsets.reserve(vec_ptr.size());
167 for (auto m_ptr : vec_ptr) {
168 vec_meshsets.push_back(m_ptr->getMeshset());
169 }
170
171 switch (t) {
172 case NODESET:
173 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
174 << "broadcast NODESET " << vec_meshsets.size();
175 break;
176 case SIDESET:
177 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
178 << "broadcast SIDESET " << vec_meshsets.size();
179 break;
180 case BLOCKSET:
181 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
182 << "broadcast BLOCKSET " << vec_meshsets.size();
183 break;
184 }
185
186 for (int from_proc = 0; from_proc < pcomm->size(); ++from_proc) {
187
188 Range r_dummy_nodes;
189
190 if (from_proc == pcomm->rank()) {
191 std::vector<EntityHandle> dummy_nodes(vec_meshsets.size(), 0);
192 int i = 0;
193 for (auto m : vec_meshsets) {
194 CHKERR moab.create_vertex(coords, dummy_nodes[i]);
195 CHKERR set_tags_dummy_node(dummy_nodes[i], m);
196 ++i;
197 }
198 r_dummy_nodes.insert_list(dummy_nodes.begin(), dummy_nodes.end());
199 }
200
201 CHKERR pcomm->broadcast_entities(from_proc, r_dummy_nodes, false, true);
202
203 if (from_proc != pcomm->rank()) {
204
205 for (auto dummy_node : r_dummy_nodes) {
206 CubitMeshSets broadcast_block(moab, dummy_node);
207 auto id = broadcast_block.getMeshsetId();
208 if (id != -1) {
209 auto mit =
211 .find(boost::make_tuple(
212 id, broadcast_block.getMaskedBcTypeULong()));
213 if (mit ==
215 .end()) {
217 CHKERR moab.create_meshset(MESHSET_SET, m);
218 CHKERR set_tags_dummy_node(m, dummy_node);
219 auto p = cubitMeshsets.insert(CubitMeshSets(moab, m));
220 }
221 } else {
222 MOFEM_LOG("MeshsetMngSync", Sev::warning)
223 << "broadcasted vertex " << dummy_node << " has negative id";
224 }
225
226 }
227
228 } else {
229 MOFEM_LOG("MeshsetMngSync", Sev::verbose)
230 << "broadcast send from " << from_proc;
231 }
232
233 CHKERR moab.delete_entities(r_dummy_nodes);
234 }
235
236 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
237 }
238
240}
241
244 Interface &m_field = cOre;
245 moab::Interface &moab = m_field.get_moab();
246 int default_val = -1;
247 CHKERR moab.tag_get_handle(DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag,
248 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
249
250 CHKERR moab.tag_get_handle(NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag,
251 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
252
253 const int def_bc_data_len = 0;
254 std::string tag_name = std::string(DIRICHLET_SET_TAG_NAME) + "__BC_DATA";
255 CHKERR moab.tag_get_handle(
256 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nsTag_data,
257 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
258
259 tag_name = std::string(NEUMANN_SET_TAG_NAME) + "__BC_DATA";
260 CHKERR moab.tag_get_handle(
261 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, ssTag_data,
262 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
263
264 CHKERR moab.tag_get_handle(MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, bhTag,
265 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
266
267 std::vector<unsigned int> def_uint_zero(3, 0);
268 CHKERR moab.tag_get_handle(
269 BLOCK_HEADER, 3 * sizeof(unsigned int), MB_TYPE_INTEGER, bhTag_header,
270 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES, &def_uint_zero[0]);
271
272 Tag block_attribs;
273 int def_Block_Attributes_length = 0;
274 CHKERR moab.tag_get_handle(
275 BLOCK_ATTRIBUTES, def_Block_Attributes_length, MB_TYPE_DOUBLE,
276 block_attribs, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
277
278 Tag entity_name_tag;
279 CHKERR moab.tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
280 entity_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT);
281
283}
284
288 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
290}
291
293 PressureCubitBcData mydata;
295 CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
297}
298
300 ForceCubitBcData mydata;
302 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
304}
305
309 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
311}
312
314 HeatFluxCubitBcData mydata;
316 CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
318}
319
322 const Interface &m_field = cOre;
323 const moab::Interface &moab = m_field.get_moab();
325 (*this), BLOCKSET | MAT_ELASTICSET, it)) {
326 Mat_Elastic data;
327 CHKERR it->getAttributeDataStructure(data);
328 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
329 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
330 Range tets;
331 CHKERR moab.get_entities_by_dimension(it->meshset, 3, tets, true);
332 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
333 << "MAT_ELATIC msId " << it->getMeshsetId() << " nb. volumes "
334 << tets.size();
335 }
336
338 m_field, BLOCKSET | MAT_THERMALSET, it)) {
339 Mat_Thermal data;
340 CHKERR it->getAttributeDataStructure(data);
341 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
342 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
343 }
344
346 m_field, BLOCKSET | MAT_MOISTURESET, it)) {
347 Mat_Moisture data;
348 CHKERR it->getAttributeDataStructure(data);
349 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
350 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
351 }
353}
354
355bool MeshsetsManager::checkMeshset(const int ms_id,
356 const CubitBCType cubit_bc_type) const {
357 auto miit =
359 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
360 if (miit !=
362 return true;
363 }
364 return false;
365}
366
367bool MeshsetsManager::checkMeshset(const string name,
368 int *const number_of_meshsets_ptr) const {
369 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
370 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
371 if (std::distance(miit, hi_miit) == 0) {
372 return false;
373 }
374 if (number_of_meshsets_ptr) {
375 *number_of_meshsets_ptr = std::distance(miit, hi_miit);
376 }
377 return true;
378}
379
381 const int ms_id,
382 const std::string name) {
383 Interface &m_field = cOre;
384 moab::Interface &moab = m_field.get_moab();
386 if (checkMeshset(ms_id, cubit_bc_type)) {
387 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
388 "such cubit meshset is already there", ms_id);
389 }
390
391 CubitMeshSets cmeshset(moab, cubit_bc_type, ms_id);
392 if ((cmeshset.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET))
393 .any()) {
394 auto p = cubitMeshsets.insert(cmeshset);
395 if (!p.second) {
396 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
397 "meshset not inserted");
398 }
399 if (name.size() > 0) {
400 bool success =
401 cubitMeshsets.modify(p.first, CubitMeshSets_change_name(moab, name));
402 if (!success) {
403 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
404 "name to cubit meshset can not be set");
405 }
406 }
407 }
408
410}
411
414 const int ms_id, const Range &ents) {
415 Interface &m_field = cOre;
416 moab::Interface &moab = m_field.get_moab();
418 auto cit =
420 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
421 if (cit ==
423 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
424 "Cannot find Cubit meshset with id: %d", ms_id);
425 }
426 EntityHandle meshset = cit->getMeshset();
427 CHKERR moab.add_entities(meshset, ents);
428
430}
431
434 const int ms_id, const EntityHandle *ents,
435 const int nb_ents) {
436 Interface &m_field = cOre;
437 moab::Interface &moab = m_field.get_moab();
439 auto cit =
441 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
442 if (cit ==
444 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
445 "Cannot find Cubit meshset with id: %d", ms_id);
446 }
447 EntityHandle meshset = cit->getMeshset();
448 CHKERR moab.add_entities(meshset, ents, nb_ents);
449
451}
452
454MeshsetsManager::setAtributes(const CubitBCType cubit_bc_type, const int ms_id,
455 const std::vector<double> &attributes,
456 const std::string name) {
457 Interface &m_field = cOre;
458 moab::Interface &moab = m_field.get_moab();
460 auto cit =
462 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
463 if (cit ==
465 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
466 "Cannot find Cubit meshset with id: %d", ms_id);
467 }
468 if (name.size() > 0) {
469 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
470 CubitMeshSets_change_name(moab, name));
471 if (!success) {
472 SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
473 "name to cubit meshset can not be set");
474 }
475 }
476 bool success =
477 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
478 CubitMeshSets_change_attributes(moab, attributes));
479 if (!success)
480 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
481 "modification unsuccessful");
482
483 std::ostringstream ss;
484 ss << "Block " << cit->getName();
485 ss << " Add attr: ";
486 for (unsigned int ii = 0; ii != attributes.size(); ii++) {
487 ss << attributes[ii] << " ";
488 }
489 MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << ss.str();
490
492}
493
495 const CubitBCType cubit_bc_type, const int ms_id,
496 const GenericAttributeData &data, const std::string name) {
497 Interface &m_field = cOre;
498 moab::Interface &moab = m_field.get_moab();
500 auto cit =
502 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
503 if (cit ==
505 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
506 "Cannot find Cubit meshset with id: %d", ms_id);
507 }
508 if (name.size() > 0) {
509 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
510 CubitMeshSets_change_name(moab, name));
511 if (!success) {
512 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
513 "name to cubit meshset can not be set");
514 }
515 }
516 bool success = cubitMeshsets.modify(
517 cubitMeshsets.project<0>(cit),
519 if (!success)
520 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
521 "modification unsuccessful");
523}
524
526 const int ms_id,
527 const GenericCubitBcData &data) {
528 Interface &m_field = cOre;
529 moab::Interface &moab = m_field.get_moab();
531 auto cit =
533 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
534 if (cit ==
536 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
537 "Cubit meshset with id is already there", ms_id);
538 }
539 bool success =
540 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
542 if (!success)
543 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
544 "modification unsuccessful");
546}
547
549 const int ms_id,
550 const MoFEMTypes bh) {
551 Interface &m_field = cOre;
552 moab::Interface &moab = m_field.get_moab();
554 auto miit =
556 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
557 if (miit ==
559 if (bh & MF_EXIST) {
560 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
561 "meshset not found", ms_id);
562 } else {
564 }
565 }
566 EntityHandle meshset = miit->getMeshset();
568 CHKERR moab.delete_entities(&meshset, 1);
569
571}
572
574 const int ms_id, const CubitBCType cubit_bc_type,
575 const CubitMeshSets **cubit_meshset_ptr) const {
576 Interface &m_field = cOre;
578 auto miit =
580 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
581 if (miit !=
583 *cubit_meshset_ptr = &*miit;
584 } else {
585 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
586 "msId = %d is not there", ms_id);
587 }
589}
590
591const CubitMeshSets *
593 const CubitBCType cubit_bc_type) const {
594 const CubitMeshSets *cubit_meshset_ptr;
596 getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr),
597 "Get not get meshset");
598 return cubit_meshset_ptr;
599}
600
602 const string name, const CubitMeshSets **cubit_meshset_ptr) const {
603 Interface &m_field = cOre;
605 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
606 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
607 if (std::distance(miit, hi_miit) == 0) {
608 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
609 "meshset name <%s> is not there", name.c_str());
610 }
611 if (std::distance(miit, hi_miit) > 1) {
612 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
613 "more that one meshser of that name <%s>", name.c_str());
614 }
615 *cubit_meshset_ptr = &*miit;
617}
618
620 const CubitBCType cubit_bc_type,
621 std::vector<const CubitMeshSets *> &vec_ptr) const {
623 auto r = cubitMeshsets.get<CubitMeshsetType_mi_tag>().equal_range(
624 cubit_bc_type.to_ulong());
625 for (auto it = r.first; it != r.second; ++it) {
626 vec_ptr.push_back(&*it);
627 }
628 sortMeshsets(vec_ptr);
630}
631
632std::vector<const CubitMeshSets *>
634 std::vector<const CubitMeshSets *> vec_ptr;
635 CHK_MOAB_THROW(getCubitMeshsetPtr(cubit_bc_type, vec_ptr),
636 "Error in getting meshsets by name");
637 return vec_ptr;
638}
639
641 const std::regex reg_exp_name,
642 std::vector<const CubitMeshSets *> &vec_ptr) const {
644 auto r =
646 for (; r.first != r.second; ++r.first) {
647 const auto name = r.first->getName();
648 if (std::regex_match(name, reg_exp_name)) {
649 vec_ptr.push_back(&*r.first);
650 }
651 }
652 sortMeshsets(vec_ptr);
654}
655
656std::vector<const CubitMeshSets *>
657MeshsetsManager::getCubitMeshsetPtr(const std::regex reg_exp_name) const {
658 std::vector<const CubitMeshSets *> vec_ptr;
659 CHK_MOAB_THROW(getCubitMeshsetPtr(reg_exp_name, vec_ptr),
660 "Error in getting meshsets by name");
661 return vec_ptr;
662}
663
665 const int msId, const unsigned int cubit_bc_type, const int dimension,
666 Range &entities, const bool recursive) const {
667 Interface &m_field = cOre;
668 moab::Interface &moab = m_field.get_moab();
670 auto miit =
672 boost::make_tuple(msId, cubit_bc_type));
673 if (miit !=
675 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, dimension, entities,
676 recursive);
677 } else {
678 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
679 "msId = %d is not there", msId);
680 }
682}
683
685 const int ms_id, const unsigned int cubit_bc_type, Range &entities,
686 const bool recursive) const {
687 Interface &m_field = cOre;
688 moab::Interface &moab = m_field.get_moab();
690 auto miit =
692 boost::make_tuple(ms_id, cubit_bc_type));
693 if (miit !=
695 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, entities, recursive);
696 } else {
697 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
698 "ms_id = %d is not there", ms_id);
699 }
701}
702
704 const unsigned int cubit_bc_type,
705 EntityHandle &meshset) const {
706 Interface &m_field = cOre;
708 auto miit =
710 boost::make_tuple(ms_id, cubit_bc_type));
711 if (miit !=
713 meshset = miit->meshset;
714 } else {
715 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
716 "ms_id = %d is not there", ms_id);
717 }
719}
720
722 const int ms_id, const unsigned int cubit_bc_type,
723 const EntityHandle *entities, int num_entities, const int operation_type) {
724 auto miit =
726 boost::make_tuple(ms_id, cubit_bc_type));
727 if (miit !=
729 Interface &m_field = cOre;
730 return m_field.get_moab().contains_entities(miit->meshset, entities,
731 num_entities, operation_type);
732 } else
733 return false;
734}
735
737MeshsetsManager::getMeshsetsByType(const unsigned int cubit_bc_type,
738 Range &meshsets) const {
740 auto miit =
741 cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(cubit_bc_type);
742 auto hi_miit =
743 cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(cubit_bc_type);
744 for (; miit != hi_miit; miit++) {
745 meshsets.insert(miit->meshset);
746 }
748}
749
750struct BlockData {
751
753
754 int iD;
755 string addType;
756 string nAme;
758
759 // Materials
764
765 // BCs
772
774 std::vector<double> aTtr;
775
777 std::memcpy(dispBc.data.name, "Displacement", 12);
778 std::memcpy(forceBc.data.name, "Force", 5);
779 std::memcpy(pressureBc.data.name, "Pressure", 8);
780 std::memcpy(temperatureBc.data.name, "Temperature", 11);
781 std::memcpy(heatFluxBc.data.name, "HeatFlux", 8);
782 std::memcpy(cfgBc.data.name, "cfd_bc", 6);
783 }
784};
785
787 bool clean_file_options) {
788 Interface &m_field = cOre;
790 std::ifstream ini_file(file_name.c_str(), std::ifstream::in);
791 po::variables_map vm;
792 if (clean_file_options) {
794 boost::shared_ptr<boost::program_options::options_description>(
795 new po::options_description());
796 }
797
798 auto add_block_attributes = [&](auto prefix, auto &block_lists, auto &it) {
799 // remove spacec from blockset name
800 configFileOptionsPtr->add_options()(
801 (prefix + ".number_of_attributes").c_str(),
802 po::value<int>(&block_lists[it->getMeshsetId()].numberOfAttributes)
803 ->default_value(-1),
804 "Number of blockset attribute");
805 for (int ii = 1; ii <= 10; ii++) {
806 std::string surfix = ".user" + boost::lexical_cast<std::string>(ii);
807 configFileOptionsPtr->add_options()(
808 (prefix + surfix).c_str(),
809 po::value<double>(&block_lists[it->getMeshsetId()].aTtr[ii - 1])
810 ->default_value(0.0),
811 "Add block attribute");
812 }
813 };
814
815 // Add blocks
816 map<int, BlockData> block_lists;
818 block_lists[it->getMeshsetId()].cubitMeshset = it->getMeshset();
819 std::string prefix =
820 "block_" + boost::lexical_cast<std::string>(it->getMeshsetId());
821 configFileOptionsPtr->add_options()(
822 (prefix + ".add").c_str(),
823 po::value<string>(&block_lists[it->getMeshsetId()].addType)
824 ->default_value("UNKNOWNSET"),
825 "Add block set")(
826 (prefix + ".id").c_str(),
827 po::value<int>(&block_lists[it->getMeshsetId()].iD)->default_value(-1),
828 "Id of meshset")(
829 (prefix + ".name").c_str(),
830 po::value<string>(&block_lists[it->getMeshsetId()].nAme)
831 ->default_value(""),
832 "Name of the meshset");
833
834 // Block attributes
835 add_block_attributes(prefix, block_lists, it);
836
837 // Mat elastic
838 {
839 // double Young; ///< Young's modulus
840 // double Poisson; ///< Poisson's ratio
841 // double ThermalExpansion; ///< Thermal expansion
842 configFileOptionsPtr->add_options()(
843 (prefix + ".young").c_str(),
844 po::value<double>(
845 &block_lists[it->getMeshsetId()].matElastic.data.Young)
846 ->default_value(-1),
847 "Young modulus")(
848 (prefix + ".poisson").c_str(),
849 po::value<double>(
850 &block_lists[it->getMeshsetId()].matElastic.data.Poisson)
851 ->default_value(-2),
852 "Poisson ratio")(
853 (prefix + ".thermalexpansion").c_str(),
854 po::value<double>(
855 &block_lists[it->getMeshsetId()].matElastic.data.ThermalExpansion)
856 ->default_value(-1),
857 "Thermal expansion");
858 // TODO Add users parameters
859 }
860 // Mat Trans Iso
861 {
862 // Young's modulus in xy plane (Ep)
863 // Young's modulus in z-direction (Ez)
864 // Poisson's ratio in xy plane (vp)
865 // Poisson's ratio in z-direction (vpz)
866 // Shear modulus in z-direction (Gzp)
867 configFileOptionsPtr->add_options()(
868 (prefix + ".Youngp").c_str(),
869 po::value<double>(
870 &block_lists[it->getMeshsetId()].matTransIso.data.Youngp)
871 ->default_value(-1),
872 "Youngp")(
873 (prefix + ".Youngz").c_str(),
874 po::value<double>(
875 &block_lists[it->getMeshsetId()].matTransIso.data.Youngz)
876 ->default_value(-1),
877 "Youngz")(
878 (prefix + ".Poissonp").c_str(),
879 po::value<double>(
880 &block_lists[it->getMeshsetId()].matTransIso.data.Poissonp)
881 ->default_value(0),
882 "Poissonp")(
883 (prefix + ".Poissonpz").c_str(),
884 po::value<double>(
885 &block_lists[it->getMeshsetId()].matTransIso.data.Poissonpz)
886 ->default_value(0),
887 "Poissonpz")(
888 (prefix + ".Shearzp").c_str(),
889 po::value<double>(
890 &block_lists[it->getMeshsetId()].matTransIso.data.Shearzp)
891 ->default_value(-1),
892 "Shearzp");
893 // TODO Add users parameters
894 }
895 // Mat thermal
896 {
897 // double Conductivity; ///< Thermal conductivity
898 // double HeatCapacity; ///< Heat Capacity
899 configFileOptionsPtr->add_options()(
900 (prefix + ".conductivity").c_str(),
901 po::value<double>(
902 &block_lists[it->getMeshsetId()].matThermal.data.Conductivity)
903 ->default_value(-1),
904 "Conductivity")(
905 (prefix + ".capacity").c_str(),
906 po::value<double>(
907 &block_lists[it->getMeshsetId()].matThermal.data.HeatCapacity)
908 ->default_value(-1),
909 "Capacity");
910 // TODO Add users parameters
911 }
912 // Mat interface
913 {
914 // double alpha; ///< Elastic modulus multiplier
915 // double beta; ///< Damage Coupling multiplier between normal and
916 // shear (g=sqrt(gn^2 + beta(gt1^2 + gt2^2))) double ft; ///< Maximum
917 // stress of crack double Gf; ///< Fracture Energy
918 configFileOptionsPtr->add_options()(
919 (prefix + ".interface_alpha").c_str(),
920 po::value<double>(
921 &block_lists[it->getMeshsetId()].matInterf.data.alpha)
922 ->default_value(-1),
923 "alpha")((prefix + ".interface_beta").c_str(),
924 po::value<double>(
925 &block_lists[it->getMeshsetId()].matInterf.data.beta)
926 ->default_value(-1),
927 "beta")(
928 (prefix + ".interface_ft").c_str(),
929 po::value<double>(&block_lists[it->getMeshsetId()].matInterf.data.ft)
930 ->default_value(-1),
931 "ft")(
932 (prefix + ".interface_Gf").c_str(),
933 po::value<double>(&block_lists[it->getMeshsetId()].matInterf.data.Gf)
934 ->default_value(-1),
935 "Gf");
936 // TODO Add users parameters
937 }
938
939 // Displacement bc
940 {
941 // char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
942 // char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
943 // char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
944 // char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
945 // char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
946 // char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
947 // double value1; //< Value for X-Translation
948 // double value2; //< Value for Y-Translation
949 // double value3; //< Value for Z-Translation
950 // double value4; //< Value for X-Rotation
951 // double value5; //< Value for Y-Rotation
952 // double value6; //< Value for Z-Rotation
953 configFileOptionsPtr->add_options()(
954 (prefix + ".disp_flag1").c_str(),
955 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag1)
956 ->default_value(0),
957 "flag1")(
958 (prefix + ".disp_flag2").c_str(),
959 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag2)
960 ->default_value(0),
961 "flag2")(
962 (prefix + ".disp_flag3").c_str(),
963 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag3)
964 ->default_value(0),
965 "flag3")(
966 (prefix + ".disp_flag4").c_str(),
967 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag4)
968 ->default_value(0),
969 "flag4")(
970 (prefix + ".disp_flag5").c_str(),
971 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag5)
972 ->default_value(0),
973 "flag5")(
974 (prefix + ".disp_flag6").c_str(),
975 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag6)
976 ->default_value(0),
977 "flag6")(
978 (prefix + ".disp_ux").c_str(),
979 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value1)
980 ->default_value(0),
981 "value1")(
982 (prefix + ".disp_uy").c_str(),
983 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value2)
984 ->default_value(0),
985 "value2")(
986 (prefix + ".disp_uz").c_str(),
987 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value3)
988 ->default_value(0),
989 "value3")(
990 (prefix + ".disp_rx").c_str(),
991 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value4)
992 ->default_value(0),
993 "value4")(
994 (prefix + ".disp_ry").c_str(),
995 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value5)
996 ->default_value(0),
997 "value5")(
998 (prefix + ".disp_rz").c_str(),
999 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value6)
1000 ->default_value(0),
1001 "value6");
1002 }
1003 // Force BC data
1004 {
1005 // char zero[3]; //< 3 zeros
1006 // double value1; //< Force magnitude
1007 // double value2; //< Moment magnitude
1008 // double value3; //< X-component of force direction vector
1009 // double value4; //< Y-component of force direction vector
1010 // double value5; //< Z-component of force direction vector
1011 // double value6; //< X-component of moment direction vector
1012 // double value7; //< Y-component of moment direction vector
1013 // double value8; //< Z-component of moment direction vector
1014 // char zero2; // 0
1015 configFileOptionsPtr->add_options()(
1016 (prefix + ".force_magnitude").c_str(),
1017 po::value<double>(
1018 &block_lists[it->getMeshsetId()].forceBc.data.value1)
1019 ->default_value(0),
1020 "value1")((prefix + ".moment_magnitude").c_str(),
1021 po::value<double>(
1022 &block_lists[it->getMeshsetId()].forceBc.data.value2)
1023 ->default_value(0),
1024 "value2")(
1025 (prefix + ".force_fx").c_str(),
1026 po::value<double>(
1027 &block_lists[it->getMeshsetId()].forceBc.data.value3)
1028 ->default_value(0),
1029 "value3")((prefix + ".force_fy").c_str(),
1030 po::value<double>(
1031 &block_lists[it->getMeshsetId()].forceBc.data.value4)
1032 ->default_value(0),
1033 "value4")(
1034 (prefix + ".force_fz").c_str(),
1035 po::value<double>(
1036 &block_lists[it->getMeshsetId()].forceBc.data.value5)
1037 ->default_value(0),
1038 "value5")((prefix + ".moment_mx").c_str(),
1039 po::value<double>(
1040 &block_lists[it->getMeshsetId()].forceBc.data.value6)
1041 ->default_value(0),
1042 "value6")(
1043 (prefix + ".moment_my").c_str(),
1044 po::value<double>(
1045 &block_lists[it->getMeshsetId()].forceBc.data.value7)
1046 ->default_value(0),
1047 "value7")((prefix + ".moment_mz").c_str(),
1048 po::value<double>(
1049 &block_lists[it->getMeshsetId()].forceBc.data.value8)
1050 ->default_value(0),
1051 "value8");
1052 }
1053 {
1054 // char name[11]; //< 11 characters for "Temperature"
1055 // char pre1; //< This is always zero
1056 // char pre2; //< 0: temperature is not applied on thin shells
1057 // (default); 1: temperature is applied on thin shells char flag1; //<
1058 // 0: N/A, 1: temperature value applied (not on thin shells) char flag2;
1059 // //< 0: N/A, 1: temperature applied on thin shell middle char flag3;
1060 // //< 0: N/A, 1: thin shell temperature gradient specified char flag4;
1061 // //< 0: N/A, 1: top thin shell temperature char flag5; //< 0: N/A, 1:
1062 // bottom thin shell temperature char flag6; //< This is always zero
1063 // double value1; //< Temperature (default case - no thin shells)
1064 // double value2; //< Temperature for middle of thin shells
1065 // double value3; //< Temperature gradient for thin shells
1066 // double value4; //< Temperature for top of thin shells
1067 // double value5; //< Temperature for bottom of thin shells
1068 // double value6; //< This is always zero, i.e. ignore
1069 configFileOptionsPtr->add_options()(
1070 (prefix + ".temperature_flag1").c_str(),
1071 po::value<char>(
1072 &block_lists[it->getMeshsetId()].temperatureBc.data.flag1)
1073 ->default_value(0),
1074 "flag1")(
1075 (prefix + ".temperature_t").c_str(),
1076 po::value<double>(
1077 &block_lists[it->getMeshsetId()].temperatureBc.data.value1)
1078 ->default_value(0),
1079 "value1");
1080 // TODO: Add more cases, see above
1081 }
1082 // Sideset
1083 {
1084 // char name[8]; //< 8 characters for "Pressure"
1085 // char zero; //< This is always zero
1086 // char flag2; //< 0: Pressure is interpreted as pure pressure 1:
1087 // pressure is interpreted as total force double value1; //< Pressure
1088 // value
1089 configFileOptionsPtr->add_options()(
1090 (prefix + ".pressure_flag2").c_str(),
1091 po::value<char>(
1092 &block_lists[it->getMeshsetId()].pressureBc.data.flag2)
1093 ->default_value(0),
1094 "flag2")((prefix + ".pressure_magnitude").c_str(),
1095 po::value<double>(
1096 &block_lists[it->getMeshsetId()].pressureBc.data.value1)
1097 ->default_value(0),
1098 "value1");
1099 }
1100 {
1101 // char name[8]; //< 8 characters for "HeatFlux" (no space)
1102 // char pre1; //< This is always zero
1103 // char pre2; //< 0: heat flux is not applied on thin shells (default);
1104 // 1: heat flux is applied on thin shells char flag1; //< 0: N/A, 1:
1105 // normal heat flux case (i.e. single value, case without thin shells)
1106 // char flag2; //< 0: N/A, 1: Thin shell top heat flux specified
1107 // char flag3; //< 0: N/A, 1: Thin shell bottom heat flux specidied
1108 // double value1; //< Heat flux value for default case (no thin shells)
1109 // double value2; //< Heat flux (thin shell top)
1110 // double value3; //< Heat flux (thin shell bottom)
1111 configFileOptionsPtr->add_options()(
1112 (prefix + ".heatflux_flag1").c_str(),
1113 po::value<char>(
1114 &block_lists[it->getMeshsetId()].heatFluxBc.data.flag1)
1115 ->default_value(0),
1116 "flag1")((prefix + ".heatflux_magnitude").c_str(),
1117 po::value<double>(
1118 &block_lists[it->getMeshsetId()].heatFluxBc.data.value1)
1119 ->default_value(0),
1120 "value1");
1121 }
1122 // Interface set
1123 {
1124 configFileOptionsPtr->add_options()(
1125 (prefix + ".interface_type").c_str(),
1126 po::value<char>(&block_lists[it->getMeshsetId()].cfgBc.data.type)
1127 ->default_value(0),
1128 "type");
1129 }
1130 }
1131
1132 map<int, BlockData> block_set_attributes;
1134 block_set_attributes[it->getMeshsetId()].cubitMeshset = it->getMeshset();
1135 block_set_attributes[it->getMeshsetId()].iD = it->getMeshsetId();
1136 block_set_attributes[it->getMeshsetId()].bcType = BLOCKSET;
1137 std::string block_name = it->getName();
1138 block_name.erase(
1139 std::remove_if(block_name.begin(), block_name.end(), ::isspace),
1140 block_name.end());
1141 block_set_attributes[it->getMeshsetId()].nAme = block_name;
1142 // Only blocks which have name
1143 if (block_name.compare("NoNameSet") != 0) {
1144 std::string prefix = "SET_ATTR_" + block_name;
1145 // Block attributes
1146 add_block_attributes(prefix, block_set_attributes, it);
1147 }
1148 }
1149
1150 po::parsed_options parsed =
1151 parse_config_file(ini_file, *configFileOptionsPtr, true);
1152 store(parsed, vm);
1153 po::notify(vm);
1154
1155 // Set type from name
1157
1158 CubitBCType bc_type;
1159 unsigned jj = 0;
1160 while (1 << jj != LASTSET_BC) {
1161 if (string(CubitBCNames[jj + 1]) ==
1162 block_lists[it->getMeshsetId()].addType) {
1163 bc_type = 1 << jj;
1164 }
1165 ++jj;
1166 }
1167 if (bc_type.none()) {
1168 block_lists[it->getMeshsetId()].bcType = UNKNOWNSET;
1169 // Skip the bockset nothing is defined for it
1170 continue;
1171 }
1172
1173 if (bc_type.to_ulong() == BLOCKSET)
1174 block_lists[it->getMeshsetId()].bcType = BLOCKSET;
1175 else if (bc_type.to_ulong() == NODESET)
1176 block_lists[it->getMeshsetId()].bcType = NODESET;
1177 else if (bc_type.to_ulong() == SIDESET)
1178 block_lists[it->getMeshsetId()].bcType = SIDESET;
1179 else {
1180 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1181 "Not yet implemented type %s\n",
1182 block_lists[it->getMeshsetId()].addType.c_str());
1183 }
1184 if (block_lists[it->getMeshsetId()].iD == -1) {
1185 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1186 "Unset iD number %d\n", block_lists[it->getMeshsetId()].iD);
1187 }
1188 }
1189
1190 std::vector<std::string> additional_parameters;
1191 additional_parameters =
1192 collect_unrecognized(parsed.options, po::include_positional);
1193 for (std::vector<std::string>::iterator vit = additional_parameters.begin();
1194 vit != additional_parameters.end(); vit++) {
1195 MOFEM_LOG_C("MeshsetMngSelf", Sev::warning, "Unrecognized option %s",
1196 vit->c_str());
1197 }
1198 for (map<int, BlockData>::iterator mit = block_lists.begin();
1199 mit != block_lists.end(); mit++) {
1200 CubitMeshSet_multiIndex::iterator cubit_meshset_it =
1201 cubitMeshsets.find(mit->second.cubitMeshset);
1202 if (cubit_meshset_it == cubitMeshsets.end()) {
1203 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1204 "Data inconsistency\n");
1205 }
1206 switch (mit->second.bcType) {
1207 case UNKNOWNSET:
1208 break;
1209 case BLOCKSET: {
1210 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1211 .any() &&
1212 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1213 // Meshset is the same, only modification
1214 } else {
1215 CHKERR addMeshset(mit->second.bcType, mit->second.iD, mit->second.nAme);
1216 EntityHandle meshset = cubit_meshset_it->getMeshset();
1217 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1218 &meshset, 1);
1219 }
1220 // Add attributes
1221 CHKERR setAtributes(mit->second.bcType, mit->second.iD, mit->second.aTtr);
1222 // Add material elastic data if value are physical (i.e. Young > 0,
1223 // Poisson in (-1.0.5) and ThermalExpansion>0)
1224 if (mit->second.matElastic.data.Young != -1) {
1225 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1226 mit->second.matElastic);
1227 }
1228 if (mit->second.matTransIso.data.Youngp != -1) {
1229 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1230 mit->second.matTransIso);
1231 }
1232 if (mit->second.matThermal.data.Conductivity != -1) {
1233 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1234 mit->second.matThermal);
1235 }
1236 if (mit->second.matInterf.data.ft != -1) {
1237 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1238 mit->second.matInterf);
1239 }
1240 } break;
1241 case NODESET: {
1242 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1243 .any() &&
1244 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1245 // Meshset is the same, only modification
1246 } else {
1247 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1248 EntityHandle meshset = cubit_meshset_it->getMeshset();
1249 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1250 &meshset, 1);
1251 }
1252 // Add displacement bc
1253 if (mit->second.dispBc.data.flag1 || mit->second.dispBc.data.flag2 ||
1254 mit->second.dispBc.data.flag3 || mit->second.dispBc.data.flag4 ||
1255 mit->second.dispBc.data.flag5 || mit->second.dispBc.data.flag6) {
1256 if (mit->second.dispBc.data.flag1 == '0')
1257 mit->second.dispBc.data.flag1 = 0;
1258 if (mit->second.dispBc.data.flag1 == 'N')
1259 mit->second.dispBc.data.flag1 = 0;
1260 if (mit->second.dispBc.data.flag1)
1261 mit->second.dispBc.data.flag1 = 1;
1262 if (mit->second.dispBc.data.flag2 == '0')
1263 mit->second.dispBc.data.flag2 = 0;
1264 if (mit->second.dispBc.data.flag2 == 'N')
1265 mit->second.dispBc.data.flag2 = 0;
1266 if (mit->second.dispBc.data.flag2)
1267 mit->second.dispBc.data.flag2 = 1;
1268 if (mit->second.dispBc.data.flag3 == '0')
1269 mit->second.dispBc.data.flag3 = 0;
1270 if (mit->second.dispBc.data.flag3 == 'N')
1271 mit->second.dispBc.data.flag3 = 0;
1272 if (mit->second.dispBc.data.flag3)
1273 mit->second.dispBc.data.flag3 = 1;
1274 if (mit->second.dispBc.data.flag4 == '0')
1275 mit->second.dispBc.data.flag4 = 0;
1276 if (mit->second.dispBc.data.flag4 == 'N')
1277 mit->second.dispBc.data.flag4 = 0;
1278 if (mit->second.dispBc.data.flag4)
1279 mit->second.dispBc.data.flag4 = 1;
1280 if (mit->second.dispBc.data.flag5 == '0')
1281 mit->second.dispBc.data.flag5 = 0;
1282 if (mit->second.dispBc.data.flag5 == 'N')
1283 mit->second.dispBc.data.flag5 = 0;
1284 if (mit->second.dispBc.data.flag5)
1285 mit->second.dispBc.data.flag5 = 1;
1286 if (mit->second.dispBc.data.flag6 == '0')
1287 mit->second.dispBc.data.flag6 = 0;
1288 if (mit->second.dispBc.data.flag6 == 'N')
1289 mit->second.dispBc.data.flag6 = 0;
1290 if (mit->second.dispBc.data.flag6)
1291 mit->second.dispBc.data.flag6 = 1;
1292 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1293 mit->second.dispBc);
1294 }
1295 if (mit->second.forceBc.data.value1 != 0 ||
1296 mit->second.forceBc.data.value2 != 0) {
1297 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1298 mit->second.forceBc);
1299 }
1300 // Add temperature boundary condition
1301 if (mit->second.temperatureBc.data.flag1) {
1302 if (mit->second.temperatureBc.data.flag1 == '0')
1303 mit->second.temperatureBc.data.flag1 = 0;
1304 if (mit->second.temperatureBc.data.flag1 == 'N')
1305 mit->second.temperatureBc.data.flag1 = 0;
1306 if (mit->second.temperatureBc.data.flag1)
1307 mit->second.temperatureBc.data.flag1 = 1;
1308 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1309 mit->second.temperatureBc);
1310 }
1311 } break;
1312 case SIDESET: {
1313 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1314 .any() &&
1315 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1316 // Meshset is the same, only modification
1317 } else {
1318 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1319 EntityHandle meshset = cubit_meshset_it->getMeshset();
1320 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1321 &meshset, 1);
1322 }
1323 // Add pressure
1324 if (mit->second.pressureBc.data.value1 != 0) {
1325 if (mit->second.pressureBc.data.flag2 == '0')
1326 mit->second.pressureBc.data.flag2 = 0;
1327 if (mit->second.pressureBc.data.flag2 == 'N')
1328 mit->second.pressureBc.data.flag2 = 0;
1329 if (mit->second.pressureBc.data.flag2)
1330 mit->second.pressureBc.data.flag2 = 1;
1331 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1332 mit->second.pressureBc);
1333 }
1334 // Add heat flux
1335 if (mit->second.heatFluxBc.data.value1 != 0) {
1336 if (mit->second.heatFluxBc.data.flag1 == '0')
1337 mit->second.heatFluxBc.data.flag1 = 0;
1338 if (mit->second.heatFluxBc.data.flag1 == 'N')
1339 mit->second.heatFluxBc.data.flag1 = 0;
1340 if (mit->second.heatFluxBc.data.flag1)
1341 mit->second.heatFluxBc.data.flag1 = 1;
1342 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1343 mit->second.heatFluxBc);
1344 }
1345 // Add Interface
1346 if (mit->second.cfgBc.data.type != 0) {
1347 CHKERR setBcData(mit->second.bcType, mit->second.iD, mit->second.cfgBc);
1348 }
1349 } break;
1350 default:
1351 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1352 "Not yet implemented type\n");
1353 }
1354 }
1355
1356 for (auto set_attr : block_set_attributes) {
1357 // Add attributes
1358 if (set_attr.second.numberOfAttributes > 0) {
1359 MOFEM_LOG("MeshsetMngSelf", Sev::verbose)
1360 << "Set attributes to blockset " << set_attr.second.nAme;
1361 set_attr.second.aTtr.resize(set_attr.second.numberOfAttributes);
1362 CHKERR setAtributes(set_attr.second.bcType, set_attr.second.iD,
1363 set_attr.second.aTtr);
1364 }
1365 }
1366
1368}
1369
1371 Interface &m_field = cOre;
1372 PetscBool flg_file;
1373 char meshset_file_name[255] = "config_file.cfg";
1375 CHKERR PetscOptionsBegin(m_field.get_comm(), "", "Set meshsets form file",
1376 "none");
1377 CHKERR PetscOptionsString("-meshsets_config", "meshsets config file name",
1378 "", "add_cubit_meshsets.in", meshset_file_name, 255,
1379 &flg_file);
1380 if (flg_file == PETSC_TRUE) {
1381 ifstream f(meshset_file_name);
1382 if (!f.good()) {
1383 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1384 "File configuring meshsets ( %s ) can not be open\n",
1385 meshset_file_name);
1386 }
1387 CHKERR setMeshsetFromFile(string(meshset_file_name));
1388 }
1389 ierr = PetscOptionsEnd();
1390 CHKERRG(ierr);
1392}
1393
1395 const int ms_id, const unsigned int cubit_bc_type,
1396 const std::string file_name, const std::string file_type,
1397 const std::string options) const {
1398
1400 MoFEM::Interface &m_field = cOre;
1401 const CubitMeshSets *cubit_meshset_ptr;
1402 CHKERR getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr);
1403 EntityHandle meshset = cubit_meshset_ptr->getMeshset();
1404 CHKERR m_field.get_moab().write_file(file_name.c_str(), file_type.c_str(),
1405 options.c_str(), &meshset, 1);
1407}
1408
1410 const int ms_id, const unsigned int cubit_bc_type, const int dim,
1411 const std::string file_name, const bool recursive,
1412 const std::string file_type, const std::string options) const {
1413
1415 MoFEM::Interface &m_field = cOre;
1416 moab::Interface &moab = m_field.get_moab();
1417 Range entities;
1418 CHKERR getEntitiesByDimension(ms_id, cubit_bc_type, dim, entities, recursive);
1419 EntityHandle meshset;
1420 CHKERR moab.create_meshset(MESHSET_SET, meshset);
1421 CHKERR moab.add_entities(meshset, entities);
1422 CHKERR moab.write_file(file_name.c_str(), file_type.c_str(), options.c_str(),
1423 &meshset, 1);
1424 CHKERR moab.delete_entities(&meshset, 1);
1426}
1427
1432 for (_IT_CUBITMESHSETS_FOR_LOOP_((*this), iit)) {
1433 EntityHandle meshset = iit->getMeshset();
1434 for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t)
1435 CHKERR bit_mng->updateMeshsetByEntitiesChildren(meshset, bit, meshset, t,
1436 true);
1437 }
1439}
1440
1441} // namespace MoFEM
static Index< 'p', 3 > p
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
Definition: LogManager.hpp:352
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
constexpr double a
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:97
@ MF_EXIST
Definition: definitions.h:100
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:595
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
#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
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:576
CubitBC
Types of sets and boundary conditions.
Definition: definitions.h:144
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
Definition: definitions.h:159
@ NODESET
Definition: definitions.h:146
@ SIDESET
Definition: definitions.h:147
@ LASTSET_BC
Definition: definitions.h:166
@ MAT_THERMALSET
block name is "MAT_THERMAL"
Definition: definitions.h:161
@ MAT_MOISTURESET
block name is "MAT_MOISTURE"
Definition: definitions.h:163
@ UNKNOWNSET
Definition: definitions.h:145
@ BLOCKSET
Definition: definitions.h:148
@ 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.
Definition: definitions.h:175
#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
const int dim
FTensor::Index< 'm', SPACE_DIM > m
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.
Definition: LogManager.cpp:389
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEMErrorCode getMeshset(const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
get meshset from CUBIT Id and CUBIT type
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
check for CUBIT Id and CUBIT type
#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 addMeshset(const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
add cubit meshset
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
#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
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
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
Definition: enable_if.hpp:6
constexpr double t
plate stiffness
Definition: plate.cpp:59
Managing BitRefLevels.
PressureCubitBcData pressureBc
CfgCubitBcData cfgBc
Mat_Elastic_TransIso matTransIso
HeatFluxCubitBcData heatFluxBc
Mat_Thermal matThermal
DisplacementCubitBcData dispBc
ForceCubitBcData forceBc
Mat_Elastic matElastic
std::vector< double > aTtr
TemperatureCubitBcData temperatureBc
EntityHandle cubitMeshset
Definition of the cfd_bc data structure.
Definition: BCData.hpp:480
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:76
Definition of the force bc data structure.
Definition: BCData.hpp:139
Generic attribute data structure.
Generic bc data structure.
Definition: BCData.hpp:20
const CubitBCType tYpe
Type of boundary condition.
Definition: BCData.hpp:59
Definition of the heat flux bc data structure.
Definition: BCData.hpp:427
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Definition: LogManager.cpp:348
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
Definition: LogManager.cpp:404
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Definition: LogManager.cpp:340
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)
MoFEMErrorCode printForceSet() const
print meshsets with force boundary conditions data structure
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
MoFEMErrorCode setBcData(const CubitBCType cubit_bc_type, const int ms_id, const GenericCubitBcData &data)
set boundary data structure to meshset
MoFEMErrorCode broadcastMeshsets(int verb=DEFAULT_VERBOSITY)
Boradcats meshsets.
MoFEMErrorCode initialiseDatabaseFromMesh(int verb=DEFAULT_VERBOSITY)
MoFEMErrorCode setAtributes(const CubitBCType cubit_bc_type, const int ms_id, const std::vector< double > &attributes, const std::string name="")
set attributes to cubit meshset
MoFEMErrorCode deleteMeshset(const CubitBCType cubit_bc_type, const int ms_id, const MoFEMTypes bh=MF_EXIST)
delete cubit meshset
MoFEMErrorCode clearMap()
clear multi-index container
MoFEMErrorCode addEntitiesToMeshset(const CubitBCType cubit_bc_type, const int ms_id, const Range &ents)
add entities to cubit meshset
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
MoFEMErrorCode updateAllMeshsetsByEntitiesChildren(const BitRefLevel &bit)
Update all blolsets, sidesets and node sets.
MoFEMErrorCode printPressureSet() const
print meshsets with pressure boundary conditions data structure
MoFEMErrorCode printBcSet(CUBIT_BC_DATA_TYPE &data, unsigned long int type) const
MoFEMErrorCode printMaterialsSet() const
print meshsets with material data structure set on it
MoFEMErrorCode setMeshsetFromFile()
get name of config file from line command '-meshsets_config'
MoFEMErrorCode setAtributesByDataStructure(const CubitBCType cubit_bc_type, const int ms_id, const GenericAttributeData &data, const std::string name="")
set (material) data structure to cubit meshset
CubitMeshSet_multiIndex cubitMeshsets
cubit meshsets
MoFEMErrorCode readMeshsets(int verb=DEFAULT_VERBOSITY)
Boradcats meshsets.
MoFEMErrorCode printHeatFluxSet() const
print meshsets with heat flux boundary conditions data structure
MoFEMErrorCode printTemperatureSet() const
print meshsets with temperature boundary conditions data structure
MoFEMErrorCode getTags(int verb=-1)
get tags handlers used on meshsets
boost::shared_ptr< boost::program_options::options_description > configFileOptionsPtr
config file options
MoFEMErrorCode printDisplacementSet() const
print meshsets with displacement boundary conditions data structure
Definition of the pressure bc data structure.
Definition: BCData.hpp:379
Definition of the temperature bc data structure.
Definition: BCData.hpp:306
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.