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