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
7
8
9using namespace std;
10namespace po = boost::program_options;
11
12namespace MoFEM {
13
15
17MeshsetsManager::query_interface(boost::typeindex::type_index type_index,
18 UnknownInterface **iface) const {
19 *iface = const_cast<MeshsetsManager *>(this);
20 return 0;
21}
22
24 : cOre(const_cast<Core &>(core)) {
25
26 if (!LogManager::checkIfChannelExist("MeshsetMngWorld")) {
27 auto core_log = logging::core::get();
28
29 core_log->add_sink(
31 core_log->add_sink(
33 core_log->add_sink(
35
36 LogManager::setLog("MeshsetMngWorld");
37 LogManager::setLog("MeshsetMngSync");
38 LogManager::setLog("MeshsetMngSelf");
39
40 MOFEM_LOG_TAG("MeshsetMngWorld", "MeshsetMng");
41 MOFEM_LOG_TAG("MeshsetMngSync", "MeshsetMng");
42 MOFEM_LOG_TAG("MeshsetMngSelf", "MeshsetMng");
43 }
44
45 MOFEM_LOG("MeshsetMngWorld", Sev::noisy) << "Mashset manager created";
46}
47
50 cubitMeshsets.clear();
52}
53
55 Interface &m_field = cOre;
57 CHKERR readMeshsets(verb);
60
61 std::vector<const CubitMeshSets *> vec_ptr;
62
63 for (auto &m : cubitMeshsets) {
64 vec_ptr.push_back(&m);
65 }
66 std::sort(vec_ptr.begin(), vec_ptr.end(),
67 [](const CubitMeshSets *a, const CubitMeshSets *b) {
68 return a->getMeshsetId() < b->getMeshsetId();
69 });
70
71 for (auto m_ptr : vec_ptr) {
72 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *m_ptr;
73 }
74 // Verbose synchronised print
75 for (auto m_ptr : vec_ptr) {
76 MOFEM_LOG("MeshsetMngSync", Sev::verbose) << *m_ptr;
77 }
78 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
79
81}
82
84 Interface &m_field = cOre;
85 moab::Interface &moab = m_field.get_moab();
87
88 Range meshsets;
89 CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
90 for (auto m : meshsets) {
91 // check if meshset is cubit meshset
92 CubitMeshSets block(moab, m);
93 if ((block.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET)).any()) {
94 auto p = cubitMeshsets.insert(block);
95 if (!p.second)
96 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
97 "meshset not inserted");
98 MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << "read " << block;
99 }
100 }
101
103}
104
106 Interface &m_field = cOre;
107 moab::Interface &moab = m_field.get_moab();
109
110 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
111 if (pcomm == NULL)
112 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
113 "MOAB communicator not set");
114
115 const double coords[] = {0, 0, 0};
116
117 auto set_tags_dummy_node = [&](const EntityHandle dummy_node,
118 const EntityHandle meshset) {
120 std::vector<Tag> tag_handles;
121 CHKERR moab.tag_get_tags_on_entity(meshset, tag_handles);
122 for (auto th : tag_handles) {
123 void *data[1];
124 int tag_size;
125 CHKERR moab.tag_get_by_ptr(th, &meshset, 1, (const void **)data,
126 &tag_size);
127 CHKERR moab.tag_set_by_ptr(th, &dummy_node, 1, data, &tag_size);
128 }
130 };
131
132 for (int from_proc = 0; from_proc < pcomm->size(); ++from_proc) {
133
134 Range r_dummy_nodes;
135
136 if (from_proc == pcomm->rank()) {
137 std::vector<EntityHandle> dummy_nodes(cubitMeshsets.size(), 0);
138 int i = 0;
139 for (auto &m : cubitMeshsets) {
140 CHKERR moab.create_vertex(coords, dummy_nodes[i]);
141 CHKERR set_tags_dummy_node(dummy_nodes[i], m.getMeshset());
142 ++i;
143 }
144 r_dummy_nodes.insert_list(dummy_nodes.begin(), dummy_nodes.end());
145 }
146
147 CHKERR pcomm->broadcast_entities(from_proc, r_dummy_nodes, false, true);
148
149 for (auto dummy_node : r_dummy_nodes) {
151 CHKERR moab.create_meshset(MESHSET_SET, m);
152 CHKERR set_tags_dummy_node(m, dummy_node);
153
154 CubitMeshSets broadcast_block(moab, m);
155 if ((broadcast_block.cubitBcType &
157 .any()) {
158 auto p = cubitMeshsets.insert(broadcast_block);
159 if (!p.second) {
160 CHKERR moab.delete_entities(&m, 1);
161 } else {
162 MOFEM_LOG("MeshsetMngSelf", Sev::noisy)
163 << "broadcast " << broadcast_block;
164 }
165 }
166 }
167
168 CHKERR moab.delete_entities(r_dummy_nodes);
169 }
170
172}
173
176 Interface &m_field = cOre;
177 moab::Interface &moab = m_field.get_moab();
178 int default_val = -1;
179 CHKERR moab.tag_get_handle(DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag,
180 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
181
182 CHKERR moab.tag_get_handle(NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag,
183 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
184
185 const int def_bc_data_len = 0;
186 std::string tag_name = std::string(DIRICHLET_SET_TAG_NAME) + "__BC_DATA";
187 CHKERR moab.tag_get_handle(
188 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nsTag_data,
189 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
190
191 tag_name = std::string(NEUMANN_SET_TAG_NAME) + "__BC_DATA";
192 CHKERR moab.tag_get_handle(
193 tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, ssTag_data,
194 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
195
196 CHKERR moab.tag_get_handle(MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, bhTag,
197 MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
198
199 std::vector<unsigned int> def_uint_zero(3, 0);
200 CHKERR moab.tag_get_handle(
201 BLOCK_HEADER, 3 * sizeof(unsigned int), MB_TYPE_INTEGER, bhTag_header,
202 MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES, &def_uint_zero[0]);
203
204 Tag block_attribs;
205 int def_Block_Attributes_length = 0;
206 CHKERR moab.tag_get_handle(
207 BLOCK_ATTRIBUTES, def_Block_Attributes_length, MB_TYPE_DOUBLE,
208 block_attribs, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
209
210 Tag entity_name_tag;
211 CHKERR moab.tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
212 entity_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT);
213
215}
216
220 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
222}
223
225 PressureCubitBcData mydata;
227 CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
229}
230
232 ForceCubitBcData mydata;
234 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
236}
237
241 CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
243}
244
246 HeatFluxCubitBcData mydata;
248 CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
250}
251
254 const Interface &m_field = cOre;
255 const moab::Interface &moab = m_field.get_moab();
257 (*this), BLOCKSET | MAT_ELASTICSET, it)) {
258 Mat_Elastic data;
259 CHKERR it->getAttributeDataStructure(data);
260 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
261 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
262 Range tets;
263 CHKERR moab.get_entities_by_dimension(it->meshset, 3, tets, true);
264 MOFEM_LOG("MeshsetMngWorld", Sev::inform)
265 << "MAT_ELATIC msId " << it->getMeshsetId() << " nb. volumes "
266 << tets.size();
267 }
268
270 m_field, BLOCKSET | MAT_THERMALSET, it)) {
271 Mat_Thermal data;
272 CHKERR it->getAttributeDataStructure(data);
273 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
274 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
275 }
276
278 m_field, BLOCKSET | MAT_MOISTURESET, it)) {
279 Mat_Moisture data;
280 CHKERR it->getAttributeDataStructure(data);
281 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
282 MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
283 }
285}
286
287bool MeshsetsManager::checkMeshset(const int ms_id,
288 const CubitBCType cubit_bc_type) const {
289 auto miit =
291 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
292 if (miit !=
294 return true;
295 }
296 return false;
297}
298
299bool MeshsetsManager::checkMeshset(const string name,
300 int *const number_of_meshsets_ptr) const {
301 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
302 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
303 if (std::distance(miit, hi_miit) == 0) {
304 return false;
305 }
306 if (number_of_meshsets_ptr) {
307 *number_of_meshsets_ptr = std::distance(miit, hi_miit);
308 }
309 return true;
310}
311
313 const int ms_id,
314 const std::string name) {
315 Interface &m_field = cOre;
316 moab::Interface &moab = m_field.get_moab();
318 if (checkMeshset(ms_id, cubit_bc_type)) {
319 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
320 "such cubit meshset is already there", ms_id);
321 }
322
323 CubitMeshSets cmeshset(moab, cubit_bc_type, ms_id);
324 if ((cmeshset.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET))
325 .any()) {
326 auto p = cubitMeshsets.insert(cmeshset);
327 if (!p.second) {
328 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
329 "meshset not inserted");
330 }
331 if (name.size() > 0) {
332 bool success =
333 cubitMeshsets.modify(p.first, CubitMeshSets_change_name(moab, name));
334 if (!success) {
335 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
336 "name to cubit meshset can not be set");
337 }
338 }
339 }
340
342}
343
346 const int ms_id, const Range &ents) {
347 Interface &m_field = cOre;
348 moab::Interface &moab = m_field.get_moab();
350 auto cit =
352 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
353 if (cit ==
355 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
356 "Cannot find Cubit meshset with id: %d", ms_id);
357 }
358 EntityHandle meshset = cit->getMeshset();
359 CHKERR moab.add_entities(meshset, ents);
360
362}
363
366 const int ms_id, const EntityHandle *ents,
367 const int nb_ents) {
368 Interface &m_field = cOre;
369 moab::Interface &moab = m_field.get_moab();
371 auto cit =
373 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
374 if (cit ==
376 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
377 "Cannot find Cubit meshset with id: %d", ms_id);
378 }
379 EntityHandle meshset = cit->getMeshset();
380 CHKERR moab.add_entities(meshset, ents, nb_ents);
381
383}
384
386MeshsetsManager::setAtributes(const CubitBCType cubit_bc_type, const int ms_id,
387 const std::vector<double> &attributes,
388 const std::string name) {
389 Interface &m_field = cOre;
390 moab::Interface &moab = m_field.get_moab();
392 auto cit =
394 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
395 if (cit ==
397 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
398 "Cannot find Cubit meshset with id: %d", ms_id);
399 }
400 if (name.size() > 0) {
401 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
402 CubitMeshSets_change_name(moab, name));
403 if (!success) {
404 SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
405 "name to cubit meshset can not be set");
406 }
407 }
408 bool success =
409 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
410 CubitMeshSets_change_attributes(moab, attributes));
411 if (!success)
412 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
413 "modification unsuccessful");
414
415 std::ostringstream ss;
416 ss << "Block " << cit->getName();
417 ss << " Add attr: ";
418 for (unsigned int ii = 0; ii != attributes.size(); ii++) {
419 ss << attributes[ii] << " ";
420 }
421 MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << ss.str();
422
424}
425
427 const CubitBCType cubit_bc_type, const int ms_id,
428 const GenericAttributeData &data, const std::string name) {
429 Interface &m_field = cOre;
430 moab::Interface &moab = m_field.get_moab();
432 auto cit =
434 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
435 if (cit ==
437 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
438 "Cannot find Cubit meshset with id: %d", ms_id);
439 }
440 if (name.size() > 0) {
441 bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
442 CubitMeshSets_change_name(moab, name));
443 if (!success) {
444 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
445 "name to cubit meshset can not be set");
446 }
447 }
448 bool success = cubitMeshsets.modify(
449 cubitMeshsets.project<0>(cit),
451 if (!success)
452 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
453 "modification unsuccessful");
455}
456
458 const int ms_id,
459 const GenericCubitBcData &data) {
460 Interface &m_field = cOre;
461 moab::Interface &moab = m_field.get_moab();
463 auto cit =
465 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
466 if (cit ==
468 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
469 "Cubit meshset with id is already there", ms_id);
470 }
471 bool success =
472 cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
474 if (!success)
475 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
476 "modification unsuccessful");
478}
479
481 const int ms_id,
482 const MoFEMTypes bh) {
483 Interface &m_field = cOre;
484 moab::Interface &moab = m_field.get_moab();
486 auto miit =
488 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
489 if (miit ==
491 if (bh & MF_EXIST) {
492 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
493 "meshset not found", ms_id);
494 } else {
496 }
497 }
498 EntityHandle meshset = miit->getMeshset();
500 CHKERR moab.delete_entities(&meshset, 1);
501
503}
504
506 const int ms_id, const CubitBCType cubit_bc_type,
507 const CubitMeshSets **cubit_meshset_ptr) const {
508 Interface &m_field = cOre;
510 auto miit =
512 boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
513 if (miit !=
515 *cubit_meshset_ptr = &*miit;
516 } else {
517 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
518 "msId = %d is not there", ms_id);
519 }
521}
522
523const CubitMeshSets *
525 const CubitBCType cubit_bc_type) const {
526 const CubitMeshSets *cubit_meshset_ptr;
528 getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr),
529 "Get not get meshset");
530 return cubit_meshset_ptr;
531}
532
534 const string name, const CubitMeshSets **cubit_meshset_ptr) const {
535 Interface &m_field = cOre;
537 auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
538 auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
539 if (std::distance(miit, hi_miit) == 0) {
540 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
541 "meshset name <%s> is not there", name.c_str());
542 }
543 if (std::distance(miit, hi_miit) > 1) {
544 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
545 "more that one meshser of that name <%s>", name.c_str());
546 }
547 *cubit_meshset_ptr = &*miit;
549}
550
552 const CubitBCType cubit_bc_type,
553 std::vector<const CubitMeshSets *> &vec_ptr) const {
555 for (auto &c : cubitMeshsets) {
556 if ((c.getBcType() & cubit_bc_type) == cubit_bc_type) {
557 vec_ptr.push_back(&c);
558 }
559 }
560 std::sort(vec_ptr.begin(), vec_ptr.end(),
561 [](const CubitMeshSets *a, const CubitMeshSets *b) {
562 return a->getMeshsetId() < b->getMeshsetId();
563 });
564
566}
567
568std::vector<const CubitMeshSets *>
570 std::vector<const CubitMeshSets *> vec_ptr;
571 CHK_MOAB_THROW(getCubitMeshsetPtr(cubit_bc_type, vec_ptr),
572 "Error in getting meshsets by name");
573 return vec_ptr;
574}
575
577 const std::regex reg_exp_name,
578 std::vector<const CubitMeshSets *> &vec_ptr) const {
580 auto r =
582 for (; r.first != r.second; ++r.first) {
583 const auto name = r.first->getName();
584 if (std::regex_match(name, reg_exp_name)) {
585 vec_ptr.push_back(&*r.first);
586 }
587 }
588 std::sort(vec_ptr.begin(), vec_ptr.end(),
589 [](const CubitMeshSets *a, const CubitMeshSets *b) {
590 return a->getMeshsetId() < b->getMeshsetId();
591 });
593}
594
595std::vector<const CubitMeshSets *>
596MeshsetsManager::getCubitMeshsetPtr(const std::regex reg_exp_name) const {
597 std::vector<const CubitMeshSets *> vec_ptr;
598 CHK_MOAB_THROW(getCubitMeshsetPtr(reg_exp_name, vec_ptr),
599 "Error in getting meshsets by name");
600 return vec_ptr;
601}
602
604 const int msId, const unsigned int cubit_bc_type, const int dimension,
605 Range &entities, const bool recursive) const {
606 Interface &m_field = cOre;
607 moab::Interface &moab = m_field.get_moab();
609 auto miit =
611 boost::make_tuple(msId, cubit_bc_type));
612 if (miit !=
614 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, dimension, entities,
615 recursive);
616 } else {
617 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
618 "msId = %d is not there", msId);
619 }
621}
622
624 const int ms_id, const unsigned int cubit_bc_type, Range &entities,
625 const bool recursive) const {
626 Interface &m_field = cOre;
627 moab::Interface &moab = m_field.get_moab();
629 auto miit =
631 boost::make_tuple(ms_id, cubit_bc_type));
632 if (miit !=
634 CHKERR miit->getMeshsetIdEntitiesByDimension(moab, entities, recursive);
635 } else {
636 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
637 "ms_id = %d is not there", ms_id);
638 }
640}
641
643 const unsigned int cubit_bc_type,
644 EntityHandle &meshset) const {
645 Interface &m_field = cOre;
647 auto miit =
649 boost::make_tuple(ms_id, cubit_bc_type));
650 if (miit !=
652 meshset = miit->meshset;
653 } else {
654 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
655 "ms_id = %d is not there", ms_id);
656 }
658}
659
661 const int ms_id, const unsigned int cubit_bc_type,
662 const EntityHandle *entities, int num_entities, const int operation_type) {
663 auto miit =
665 boost::make_tuple(ms_id, cubit_bc_type));
666 if (miit !=
668 Interface &m_field = cOre;
669 return m_field.get_moab().contains_entities(miit->meshset, entities,
670 num_entities, operation_type);
671 } else
672 return false;
673}
674
676MeshsetsManager::getMeshsetsByType(const unsigned int cubit_bc_type,
677 Range &meshsets) const {
679 auto miit =
680 cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(cubit_bc_type);
681 auto hi_miit =
682 cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(cubit_bc_type);
683 for (; miit != hi_miit; miit++) {
684 meshsets.insert(miit->meshset);
685 }
687}
688
689struct BlockData {
690
692
693 int iD;
694 string addType;
695 string nAme;
697
698 // Materials
703
704 // BCs
711
713 std::vector<double> aTtr;
714
716 std::memcpy(dispBc.data.name, "Displacement", 12);
717 std::memcpy(forceBc.data.name, "Force", 5);
718 std::memcpy(pressureBc.data.name, "Pressure", 8);
719 std::memcpy(temperatureBc.data.name, "Temperature", 11);
720 std::memcpy(heatFluxBc.data.name, "HeatFlux", 8);
721 std::memcpy(cfgBc.data.name, "cfd_bc", 6);
722 }
723};
724
726 bool clean_file_options) {
727 Interface &m_field = cOre;
729 std::ifstream ini_file(file_name.c_str(), std::ifstream::in);
730 po::variables_map vm;
731 if (clean_file_options) {
733 boost::shared_ptr<boost::program_options::options_description>(
734 new po::options_description());
735 }
736
737 auto add_block_attributes = [&](auto prefix, auto &block_lists, auto &it) {
738 // remove spacec from blockset name
739 configFileOptionsPtr->add_options()(
740 (prefix + ".number_of_attributes").c_str(),
741 po::value<int>(&block_lists[it->getMeshsetId()].numberOfAttributes)
742 ->default_value(-1),
743 "Number of blockset attribute");
744 for (int ii = 1; ii <= 10; ii++) {
745 std::string surfix = ".user" + boost::lexical_cast<std::string>(ii);
746 configFileOptionsPtr->add_options()(
747 (prefix + surfix).c_str(),
748 po::value<double>(&block_lists[it->getMeshsetId()].aTtr[ii - 1])
749 ->default_value(0.0),
750 "Add block attribute");
751 }
752 };
753
754 // Add blocks
755 map<int, BlockData> block_lists;
757 block_lists[it->getMeshsetId()].cubitMeshset = it->getMeshset();
758 std::string prefix =
759 "block_" + boost::lexical_cast<std::string>(it->getMeshsetId());
760 configFileOptionsPtr->add_options()(
761 (prefix + ".add").c_str(),
762 po::value<string>(&block_lists[it->getMeshsetId()].addType)
763 ->default_value("UNKNOWNSET"),
764 "Add block set")(
765 (prefix + ".id").c_str(),
766 po::value<int>(&block_lists[it->getMeshsetId()].iD)->default_value(-1),
767 "Id of meshset")(
768 (prefix + ".name").c_str(),
769 po::value<string>(&block_lists[it->getMeshsetId()].nAme)
770 ->default_value(""),
771 "Name of the meshset");
772
773 // Block attributes
774 add_block_attributes(prefix, block_lists, it);
775
776 // Mat elastic
777 {
778 // double Young; ///< Young's modulus
779 // double Poisson; ///< Poisson's ratio
780 // double ThermalExpansion; ///< Thermal expansion
781 configFileOptionsPtr->add_options()(
782 (prefix + ".young").c_str(),
783 po::value<double>(
784 &block_lists[it->getMeshsetId()].matElastic.data.Young)
785 ->default_value(-1),
786 "Young modulus")(
787 (prefix + ".poisson").c_str(),
788 po::value<double>(
789 &block_lists[it->getMeshsetId()].matElastic.data.Poisson)
790 ->default_value(-2),
791 "Poisson ratio")(
792 (prefix + ".thermalexpansion").c_str(),
793 po::value<double>(
794 &block_lists[it->getMeshsetId()].matElastic.data.ThermalExpansion)
795 ->default_value(-1),
796 "Thermal expansion");
797 // TODO Add users parameters
798 }
799 // Mat Trans Iso
800 {
801 // Young's modulus in xy plane (Ep)
802 // Young's modulus in z-direction (Ez)
803 // Poisson's ratio in xy plane (vp)
804 // Poisson's ratio in z-direction (vpz)
805 // Shear modulus in z-direction (Gzp)
806 configFileOptionsPtr->add_options()(
807 (prefix + ".Youngp").c_str(),
808 po::value<double>(
809 &block_lists[it->getMeshsetId()].matTransIso.data.Youngp)
810 ->default_value(-1),
811 "Youngp")(
812 (prefix + ".Youngz").c_str(),
813 po::value<double>(
814 &block_lists[it->getMeshsetId()].matTransIso.data.Youngz)
815 ->default_value(-1),
816 "Youngz")(
817 (prefix + ".Poissonp").c_str(),
818 po::value<double>(
819 &block_lists[it->getMeshsetId()].matTransIso.data.Poissonp)
820 ->default_value(0),
821 "Poissonp")(
822 (prefix + ".Poissonpz").c_str(),
823 po::value<double>(
824 &block_lists[it->getMeshsetId()].matTransIso.data.Poissonpz)
825 ->default_value(0),
826 "Poissonpz")(
827 (prefix + ".Shearzp").c_str(),
828 po::value<double>(
829 &block_lists[it->getMeshsetId()].matTransIso.data.Shearzp)
830 ->default_value(-1),
831 "Shearzp");
832 // TODO Add users parameters
833 }
834 // Mat thermal
835 {
836 // double Conductivity; ///< Thermal conductivity
837 // double HeatCapacity; ///< Heat Capacity
838 configFileOptionsPtr->add_options()(
839 (prefix + ".conductivity").c_str(),
840 po::value<double>(
841 &block_lists[it->getMeshsetId()].matThermal.data.Conductivity)
842 ->default_value(-1),
843 "Conductivity")(
844 (prefix + ".capacity").c_str(),
845 po::value<double>(
846 &block_lists[it->getMeshsetId()].matThermal.data.HeatCapacity)
847 ->default_value(-1),
848 "Capacity");
849 // TODO Add users parameters
850 }
851 // Mat interface
852 {
853 // double alpha; ///< Elastic modulus multiplier
854 // double beta; ///< Damage Coupling multiplier between normal and
855 // shear (g=sqrt(gn^2 + beta(gt1^2 + gt2^2))) double ft; ///< Maximum
856 // stress of crack double Gf; ///< Fracture Energy
857 configFileOptionsPtr->add_options()(
858 (prefix + ".interface_alpha").c_str(),
859 po::value<double>(
860 &block_lists[it->getMeshsetId()].matInterf.data.alpha)
861 ->default_value(-1),
862 "alpha")((prefix + ".interface_beta").c_str(),
863 po::value<double>(
864 &block_lists[it->getMeshsetId()].matInterf.data.beta)
865 ->default_value(-1),
866 "beta")(
867 (prefix + ".interface_ft").c_str(),
868 po::value<double>(&block_lists[it->getMeshsetId()].matInterf.data.ft)
869 ->default_value(-1),
870 "ft")(
871 (prefix + ".interface_Gf").c_str(),
872 po::value<double>(&block_lists[it->getMeshsetId()].matInterf.data.Gf)
873 ->default_value(-1),
874 "Gf");
875 // TODO Add users parameters
876 }
877
878 // Displacement bc
879 {
880 // char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
881 // char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
882 // char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
883 // char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
884 // char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
885 // char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
886 // double value1; //< Value for X-Translation
887 // double value2; //< Value for Y-Translation
888 // double value3; //< Value for Z-Translation
889 // double value4; //< Value for X-Rotation
890 // double value5; //< Value for Y-Rotation
891 // double value6; //< Value for Z-Rotation
892 configFileOptionsPtr->add_options()(
893 (prefix + ".disp_flag1").c_str(),
894 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag1)
895 ->default_value(0),
896 "flag1")(
897 (prefix + ".disp_flag2").c_str(),
898 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag2)
899 ->default_value(0),
900 "flag2")(
901 (prefix + ".disp_flag3").c_str(),
902 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag3)
903 ->default_value(0),
904 "flag3")(
905 (prefix + ".disp_flag4").c_str(),
906 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag4)
907 ->default_value(0),
908 "flag4")(
909 (prefix + ".disp_flag5").c_str(),
910 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag5)
911 ->default_value(0),
912 "flag5")(
913 (prefix + ".disp_flag6").c_str(),
914 po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag6)
915 ->default_value(0),
916 "flag6")(
917 (prefix + ".disp_ux").c_str(),
918 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value1)
919 ->default_value(0),
920 "value1")(
921 (prefix + ".disp_uy").c_str(),
922 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value2)
923 ->default_value(0),
924 "value2")(
925 (prefix + ".disp_uz").c_str(),
926 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value3)
927 ->default_value(0),
928 "value3")(
929 (prefix + ".disp_rx").c_str(),
930 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value4)
931 ->default_value(0),
932 "value4")(
933 (prefix + ".disp_ry").c_str(),
934 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value5)
935 ->default_value(0),
936 "value5")(
937 (prefix + ".disp_rz").c_str(),
938 po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value6)
939 ->default_value(0),
940 "value6");
941 }
942 // Force BC data
943 {
944 // char zero[3]; //< 3 zeros
945 // double value1; //< Force magnitude
946 // double value2; //< Moment magnitude
947 // double value3; //< X-component of force direction vector
948 // double value4; //< Y-component of force direction vector
949 // double value5; //< Z-component of force direction vector
950 // double value6; //< X-component of moment direction vector
951 // double value7; //< Y-component of moment direction vector
952 // double value8; //< Z-component of moment direction vector
953 // char zero2; // 0
954 configFileOptionsPtr->add_options()(
955 (prefix + ".force_magnitude").c_str(),
956 po::value<double>(
957 &block_lists[it->getMeshsetId()].forceBc.data.value1)
958 ->default_value(0),
959 "value1")((prefix + ".moment_magnitude").c_str(),
960 po::value<double>(
961 &block_lists[it->getMeshsetId()].forceBc.data.value2)
962 ->default_value(0),
963 "value2")(
964 (prefix + ".force_fx").c_str(),
965 po::value<double>(
966 &block_lists[it->getMeshsetId()].forceBc.data.value3)
967 ->default_value(0),
968 "value3")((prefix + ".force_fy").c_str(),
969 po::value<double>(
970 &block_lists[it->getMeshsetId()].forceBc.data.value4)
971 ->default_value(0),
972 "value4")(
973 (prefix + ".force_fz").c_str(),
974 po::value<double>(
975 &block_lists[it->getMeshsetId()].forceBc.data.value5)
976 ->default_value(0),
977 "value5")((prefix + ".moment_mx").c_str(),
978 po::value<double>(
979 &block_lists[it->getMeshsetId()].forceBc.data.value6)
980 ->default_value(0),
981 "value6")(
982 (prefix + ".moment_my").c_str(),
983 po::value<double>(
984 &block_lists[it->getMeshsetId()].forceBc.data.value7)
985 ->default_value(0),
986 "value7")((prefix + ".moment_mz").c_str(),
987 po::value<double>(
988 &block_lists[it->getMeshsetId()].forceBc.data.value8)
989 ->default_value(0),
990 "value8");
991 }
992 {
993 // char name[11]; //< 11 characters for "Temperature"
994 // char pre1; //< This is always zero
995 // char pre2; //< 0: temperature is not applied on thin shells
996 // (default); 1: temperature is applied on thin shells char flag1; //<
997 // 0: N/A, 1: temperature value applied (not on thin shells) char flag2;
998 // //< 0: N/A, 1: temperature applied on thin shell middle char flag3;
999 // //< 0: N/A, 1: thin shell temperature gradient specified char flag4;
1000 // //< 0: N/A, 1: top thin shell temperature char flag5; //< 0: N/A, 1:
1001 // bottom thin shell temperature char flag6; //< This is always zero
1002 // double value1; //< Temperature (default case - no thin shells)
1003 // double value2; //< Temperature for middle of thin shells
1004 // double value3; //< Temperature gradient for thin shells
1005 // double value4; //< Temperature for top of thin shells
1006 // double value5; //< Temperature for bottom of thin shells
1007 // double value6; //< This is always zero, i.e. ignore
1008 configFileOptionsPtr->add_options()(
1009 (prefix + ".temperature_flag1").c_str(),
1010 po::value<char>(
1011 &block_lists[it->getMeshsetId()].temperatureBc.data.flag1)
1012 ->default_value(0),
1013 "flag1")(
1014 (prefix + ".temperature_t").c_str(),
1015 po::value<double>(
1016 &block_lists[it->getMeshsetId()].temperatureBc.data.value1)
1017 ->default_value(0),
1018 "value1");
1019 // TODO: Add more cases, see above
1020 }
1021 // Sideset
1022 {
1023 // char name[8]; //< 8 characters for "Pressure"
1024 // char zero; //< This is always zero
1025 // char flag2; //< 0: Pressure is interpreted as pure pressure 1:
1026 // pressure is interpreted as total force double value1; //< Pressure
1027 // value
1028 configFileOptionsPtr->add_options()(
1029 (prefix + ".pressure_flag2").c_str(),
1030 po::value<char>(
1031 &block_lists[it->getMeshsetId()].pressureBc.data.flag2)
1032 ->default_value(0),
1033 "flag2")((prefix + ".pressure_magnitude").c_str(),
1034 po::value<double>(
1035 &block_lists[it->getMeshsetId()].pressureBc.data.value1)
1036 ->default_value(0),
1037 "value1");
1038 }
1039 {
1040 // char name[8]; //< 8 characters for "HeatFlux" (no space)
1041 // char pre1; //< This is always zero
1042 // char pre2; //< 0: heat flux is not applied on thin shells (default);
1043 // 1: heat flux is applied on thin shells char flag1; //< 0: N/A, 1:
1044 // normal heat flux case (i.e. single value, case without thin shells)
1045 // char flag2; //< 0: N/A, 1: Thin shell top heat flux specified
1046 // char flag3; //< 0: N/A, 1: Thin shell bottom heat flux specidied
1047 // double value1; //< Heat flux value for default case (no thin shells)
1048 // double value2; //< Heat flux (thin shell top)
1049 // double value3; //< Heat flux (thin shell bottom)
1050 configFileOptionsPtr->add_options()(
1051 (prefix + ".heatflux_flag1").c_str(),
1052 po::value<char>(
1053 &block_lists[it->getMeshsetId()].heatFluxBc.data.flag1)
1054 ->default_value(0),
1055 "flag1")((prefix + ".heatflux_magnitude").c_str(),
1056 po::value<double>(
1057 &block_lists[it->getMeshsetId()].heatFluxBc.data.value1)
1058 ->default_value(0),
1059 "value1");
1060 }
1061 // Interface set
1062 {
1063 configFileOptionsPtr->add_options()(
1064 (prefix + ".interface_type").c_str(),
1065 po::value<char>(&block_lists[it->getMeshsetId()].cfgBc.data.type)
1066 ->default_value(0),
1067 "type");
1068 }
1069 }
1070
1071 map<int, BlockData> block_set_attributes;
1073 block_set_attributes[it->getMeshsetId()].cubitMeshset = it->getMeshset();
1074 block_set_attributes[it->getMeshsetId()].iD = it->getMeshsetId();
1075 block_set_attributes[it->getMeshsetId()].bcType = BLOCKSET;
1076 std::string block_name = it->getName();
1077 block_name.erase(
1078 std::remove_if(block_name.begin(), block_name.end(), ::isspace),
1079 block_name.end());
1080 block_set_attributes[it->getMeshsetId()].nAme = block_name;
1081 // Only blocks which have name
1082 if (block_name.compare("NoNameSet") != 0) {
1083 std::string prefix = "SET_ATTR_" + block_name;
1084 // Block attributes
1085 add_block_attributes(prefix, block_set_attributes, it);
1086 }
1087 }
1088
1089 po::parsed_options parsed =
1090 parse_config_file(ini_file, *configFileOptionsPtr, true);
1091 store(parsed, vm);
1092 po::notify(vm);
1093
1094 // Set type from name
1096
1097 CubitBCType bc_type;
1098 unsigned jj = 0;
1099 while (1 << jj != LASTSET_BC) {
1100 if (string(CubitBCNames[jj + 1]) ==
1101 block_lists[it->getMeshsetId()].addType) {
1102 bc_type = 1 << jj;
1103 }
1104 ++jj;
1105 }
1106 if (bc_type.none()) {
1107 block_lists[it->getMeshsetId()].bcType = UNKNOWNSET;
1108 // Skip the bockset nothing is defined for it
1109 continue;
1110 }
1111
1112 if (bc_type.to_ulong() == BLOCKSET)
1113 block_lists[it->getMeshsetId()].bcType = BLOCKSET;
1114 else if (bc_type.to_ulong() == NODESET)
1115 block_lists[it->getMeshsetId()].bcType = NODESET;
1116 else if (bc_type.to_ulong() == SIDESET)
1117 block_lists[it->getMeshsetId()].bcType = SIDESET;
1118 else {
1119 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1120 "Not yet implemented type %s\n",
1121 block_lists[it->getMeshsetId()].addType.c_str());
1122 }
1123 if (block_lists[it->getMeshsetId()].iD == -1) {
1124 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1125 "Unset iD number %d\n", block_lists[it->getMeshsetId()].iD);
1126 }
1127 }
1128
1129 std::vector<std::string> additional_parameters;
1130 additional_parameters =
1131 collect_unrecognized(parsed.options, po::include_positional);
1132 for (std::vector<std::string>::iterator vit = additional_parameters.begin();
1133 vit != additional_parameters.end(); vit++) {
1134 MOFEM_LOG_C("MeshsetMngSelf", Sev::warning, "Unrecognized option %s",
1135 vit->c_str());
1136 }
1137 for (map<int, BlockData>::iterator mit = block_lists.begin();
1138 mit != block_lists.end(); mit++) {
1139 CubitMeshSet_multiIndex::iterator cubit_meshset_it =
1140 cubitMeshsets.find(mit->second.cubitMeshset);
1141 if (cubit_meshset_it == cubitMeshsets.end()) {
1142 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1143 "Data inconsistency\n");
1144 }
1145 switch (mit->second.bcType) {
1146 case UNKNOWNSET:
1147 break;
1148 case BLOCKSET: {
1149 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1150 .any() &&
1151 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1152 // Meshset is the same, only modification
1153 } else {
1154 CHKERR addMeshset(mit->second.bcType, mit->second.iD, mit->second.nAme);
1155 EntityHandle meshset = cubit_meshset_it->getMeshset();
1156 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1157 &meshset, 1);
1158 }
1159 // Add attributes
1160 CHKERR setAtributes(mit->second.bcType, mit->second.iD, mit->second.aTtr);
1161 // Add material elastic data if value are physical (i.e. Young > 0,
1162 // Poisson in (-1.0.5) and ThermalExpansion>0)
1163 if (mit->second.matElastic.data.Young != -1) {
1164 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1165 mit->second.matElastic);
1166 }
1167 if (mit->second.matTransIso.data.Youngp != -1) {
1168 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1169 mit->second.matTransIso);
1170 }
1171 if (mit->second.matThermal.data.Conductivity != -1) {
1172 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1173 mit->second.matThermal);
1174 }
1175 if (mit->second.matInterf.data.ft != -1) {
1176 CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1177 mit->second.matInterf);
1178 }
1179 } break;
1180 case NODESET: {
1181 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1182 .any() &&
1183 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1184 // Meshset is the same, only modification
1185 } else {
1186 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1187 EntityHandle meshset = cubit_meshset_it->getMeshset();
1188 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1189 &meshset, 1);
1190 }
1191 // Add displacement bc
1192 if (mit->second.dispBc.data.flag1 || mit->second.dispBc.data.flag2 ||
1193 mit->second.dispBc.data.flag3 || mit->second.dispBc.data.flag4 ||
1194 mit->second.dispBc.data.flag5 || mit->second.dispBc.data.flag6) {
1195 if (mit->second.dispBc.data.flag1 == '0')
1196 mit->second.dispBc.data.flag1 = 0;
1197 if (mit->second.dispBc.data.flag1 == 'N')
1198 mit->second.dispBc.data.flag1 = 0;
1199 if (mit->second.dispBc.data.flag1)
1200 mit->second.dispBc.data.flag1 = 1;
1201 if (mit->second.dispBc.data.flag2 == '0')
1202 mit->second.dispBc.data.flag2 = 0;
1203 if (mit->second.dispBc.data.flag2 == 'N')
1204 mit->second.dispBc.data.flag2 = 0;
1205 if (mit->second.dispBc.data.flag2)
1206 mit->second.dispBc.data.flag2 = 1;
1207 if (mit->second.dispBc.data.flag3 == '0')
1208 mit->second.dispBc.data.flag3 = 0;
1209 if (mit->second.dispBc.data.flag3 == 'N')
1210 mit->second.dispBc.data.flag3 = 0;
1211 if (mit->second.dispBc.data.flag3)
1212 mit->second.dispBc.data.flag3 = 1;
1213 if (mit->second.dispBc.data.flag4 == '0')
1214 mit->second.dispBc.data.flag4 = 0;
1215 if (mit->second.dispBc.data.flag4 == 'N')
1216 mit->second.dispBc.data.flag4 = 0;
1217 if (mit->second.dispBc.data.flag4)
1218 mit->second.dispBc.data.flag4 = 1;
1219 if (mit->second.dispBc.data.flag5 == '0')
1220 mit->second.dispBc.data.flag5 = 0;
1221 if (mit->second.dispBc.data.flag5 == 'N')
1222 mit->second.dispBc.data.flag5 = 0;
1223 if (mit->second.dispBc.data.flag5)
1224 mit->second.dispBc.data.flag5 = 1;
1225 if (mit->second.dispBc.data.flag6 == '0')
1226 mit->second.dispBc.data.flag6 = 0;
1227 if (mit->second.dispBc.data.flag6 == 'N')
1228 mit->second.dispBc.data.flag6 = 0;
1229 if (mit->second.dispBc.data.flag6)
1230 mit->second.dispBc.data.flag6 = 1;
1231 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1232 mit->second.dispBc);
1233 }
1234 if (mit->second.forceBc.data.value1 != 0 ||
1235 mit->second.forceBc.data.value2 != 0) {
1236 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1237 mit->second.forceBc);
1238 }
1239 // Add temperature boundary condition
1240 if (mit->second.temperatureBc.data.flag1) {
1241 if (mit->second.temperatureBc.data.flag1 == '0')
1242 mit->second.temperatureBc.data.flag1 = 0;
1243 if (mit->second.temperatureBc.data.flag1 == 'N')
1244 mit->second.temperatureBc.data.flag1 = 0;
1245 if (mit->second.temperatureBc.data.flag1)
1246 mit->second.temperatureBc.data.flag1 = 1;
1247 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1248 mit->second.temperatureBc);
1249 }
1250 } break;
1251 case SIDESET: {
1252 if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1253 .any() &&
1254 mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1255 // Meshset is the same, only modification
1256 } else {
1257 CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1258 EntityHandle meshset = cubit_meshset_it->getMeshset();
1259 CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1260 &meshset, 1);
1261 }
1262 // Add pressure
1263 if (mit->second.pressureBc.data.value1 != 0) {
1264 if (mit->second.pressureBc.data.flag2 == '0')
1265 mit->second.pressureBc.data.flag2 = 0;
1266 if (mit->second.pressureBc.data.flag2 == 'N')
1267 mit->second.pressureBc.data.flag2 = 0;
1268 if (mit->second.pressureBc.data.flag2)
1269 mit->second.pressureBc.data.flag2 = 1;
1270 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1271 mit->second.pressureBc);
1272 }
1273 // Add heat flux
1274 if (mit->second.heatFluxBc.data.value1 != 0) {
1275 if (mit->second.heatFluxBc.data.flag1 == '0')
1276 mit->second.heatFluxBc.data.flag1 = 0;
1277 if (mit->second.heatFluxBc.data.flag1 == 'N')
1278 mit->second.heatFluxBc.data.flag1 = 0;
1279 if (mit->second.heatFluxBc.data.flag1)
1280 mit->second.heatFluxBc.data.flag1 = 1;
1281 CHKERR setBcData(mit->second.bcType, mit->second.iD,
1282 mit->second.heatFluxBc);
1283 }
1284 // Add Interface
1285 if (mit->second.cfgBc.data.type != 0) {
1286 CHKERR setBcData(mit->second.bcType, mit->second.iD, mit->second.cfgBc);
1287 }
1288 } break;
1289 default:
1290 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1291 "Not yet implemented type\n");
1292 }
1293 }
1294
1295 for (auto set_attr : block_set_attributes) {
1296 // Add attributes
1297 if (set_attr.second.numberOfAttributes > 0) {
1298 MOFEM_LOG("MeshsetMngSelf", Sev::verbose)
1299 << "Set attributes to blockset " << set_attr.second.nAme;
1300 set_attr.second.aTtr.resize(set_attr.second.numberOfAttributes);
1301 CHKERR setAtributes(set_attr.second.bcType, set_attr.second.iD,
1302 set_attr.second.aTtr);
1303 }
1304 }
1305
1307}
1308
1310 Interface &m_field = cOre;
1311 PetscBool flg_file;
1312 char meshset_file_name[255] = "config_file.cfg";
1314 CHKERR PetscOptionsBegin(m_field.get_comm(), "", "Set meshsets form file",
1315 "none");
1316 CHKERR PetscOptionsString("-meshsets_config", "meshsets config file name",
1317 "", "add_cubit_meshsets.in", meshset_file_name, 255,
1318 &flg_file);
1319 if (flg_file == PETSC_TRUE) {
1320 ifstream f(meshset_file_name);
1321 if (!f.good()) {
1322 SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1323 "File configuring meshsets ( %s ) can not be open\n",
1324 meshset_file_name);
1325 }
1326 CHKERR setMeshsetFromFile(string(meshset_file_name));
1327 }
1328 ierr = PetscOptionsEnd();
1329 CHKERRG(ierr);
1331}
1332
1334 const int ms_id, const unsigned int cubit_bc_type,
1335 const std::string file_name, const std::string file_type,
1336 const std::string options) const {
1337
1339 MoFEM::Interface &m_field = cOre;
1340 const CubitMeshSets *cubit_meshset_ptr;
1341 CHKERR getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr);
1342 EntityHandle meshset = cubit_meshset_ptr->getMeshset();
1343 CHKERR m_field.get_moab().write_file(file_name.c_str(), file_type.c_str(),
1344 options.c_str(), &meshset, 1);
1346}
1347
1349 const int ms_id, const unsigned int cubit_bc_type, const int dim,
1350 const std::string file_name, const bool recursive,
1351 const std::string file_type, const std::string options) const {
1352
1354 MoFEM::Interface &m_field = cOre;
1355 moab::Interface &moab = m_field.get_moab();
1356 Range entities;
1357 CHKERR getEntitiesByDimension(ms_id, cubit_bc_type, dim, entities, recursive);
1358 EntityHandle meshset;
1359 CHKERR moab.create_meshset(MESHSET_SET, meshset);
1360 CHKERR moab.add_entities(meshset, entities);
1361 CHKERR moab.write_file(file_name.c_str(), file_type.c_str(), options.c_str(),
1362 &meshset, 1);
1363 CHKERR moab.delete_entities(&meshset, 1);
1365}
1366
1371 for (_IT_CUBITMESHSETS_FOR_LOOP_((*this), iit)) {
1372 EntityHandle meshset = iit->getMeshset();
1373 for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t)
1374 CHKERR bit_mng->updateMeshsetByEntitiesChildren(meshset, bit, meshset, t,
1375 true);
1376 }
1378}
1379
1380} // 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
const double c
speed of light (cm/ns)
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:475
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
EntityHandle getMeshset() const
get bc meshset
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:134
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:422
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:399
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.
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:374
Definition of the temperature bc data structure.
Definition: BCData.hpp:301
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.