v0.13.0
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  * The MoFEM package is copyrighted by Lukasz Kaczmarczyk.
9  * It can be freely used for educational and research purposes
10  * by other institutions. If you use this software pleas cite my work.
11  *
12  * MoFEM is free software: you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation, either version 3 of the License, or (at your
15  * option) any later version.
16  *
17  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
24  */
25 
26 using namespace std;
27 namespace po = boost::program_options;
28 
29 namespace MoFEM {
30 
31 bool MeshsetsManager::brodcastMeshsets = true;
32 
34 MeshsetsManager::query_interface(boost::typeindex::type_index type_index,
35  UnknownInterface **iface) const {
36  *iface = const_cast<MeshsetsManager *>(this);
37  return 0;
38 }
39 
40 MeshsetsManager::MeshsetsManager(const Core &core)
41  : cOre(const_cast<Core &>(core)) {
42 
43  if (!LogManager::checkIfChannelExist("MeshsetMngWorld")) {
44  auto core_log = logging::core::get();
45 
46  core_log->add_sink(
47  LogManager::createSink(LogManager::getStrmWorld(), "MeshsetMngWorld"));
48  core_log->add_sink(
49  LogManager::createSink(LogManager::getStrmSync(), "MeshsetMngSync"));
50  core_log->add_sink(
51  LogManager::createSink(LogManager::getStrmSelf(), "MeshsetMngSelf"));
52 
53  LogManager::setLog("MeshsetMngWorld");
54  LogManager::setLog("MeshsetMngSync");
55  LogManager::setLog("MeshsetMngSelf");
56 
57  MOFEM_LOG_TAG("MeshsetMngWorld", "MeshsetMng");
58  MOFEM_LOG_TAG("MeshsetMngSync", "MeshsetMng");
59  MOFEM_LOG_TAG("MeshsetMngSelf", "MeshsetMng");
60  }
61 
62  MOFEM_LOG("MeshsetMngWorld", Sev::noisy) << "Mashset manager created";
63 }
64 
67  cubitMeshsets.clear();
69 }
70 
72  Interface &m_field = cOre;
74  CHKERR readMeshsets(verb);
75  if (brodcastMeshsets)
77 
78  for (auto &m : cubitMeshsets) {
79  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << m;
80  }
81 
83 }
84 
86  Interface &m_field = cOre;
87  moab::Interface &moab = m_field.get_moab();
89 
90  Range meshsets;
91  CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
92  for (auto m : meshsets) {
93  // check if meshset is cubit meshset
94  CubitMeshSets block(moab, m);
95  if ((block.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET)).any()) {
96  auto p = cubitMeshsets.insert(block);
97  if (!p.second)
98  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
99  "meshset not inserted");
100  MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << "read " << block;
101  }
102  }
103 
105 }
106 
108  Interface &m_field = cOre;
109  moab::Interface &moab = m_field.get_moab();
111 
112  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
113  if (pcomm == NULL)
114  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
115  "MOAB communicator not set");
116 
117  const double coords[] = {0, 0, 0};
118 
119  auto set_tags_dummy_node = [&](const EntityHandle dummy_node,
120  const EntityHandle meshset) {
122  std::vector<Tag> tag_handles;
123  CHKERR moab.tag_get_tags_on_entity(meshset, tag_handles);
124  for (auto th : tag_handles) {
125  void *data[1];
126  int tag_size;
127  CHKERR moab.tag_get_by_ptr(th, &meshset, 1, (const void **)data,
128  &tag_size);
129  CHKERR moab.tag_set_by_ptr(th, &dummy_node, 1, data, &tag_size);
130  }
132  };
133 
134  for (int from_proc = 0; from_proc < pcomm->size(); ++from_proc) {
135 
136  Range r_dummy_nodes;
137 
138  if (from_proc == pcomm->rank()) {
139  std::vector<EntityHandle> dummy_nodes(cubitMeshsets.size(), 0);
140  int i = 0;
141  for (auto &m : cubitMeshsets) {
142  CHKERR moab.create_vertex(coords, dummy_nodes[i]);
143  CHKERR set_tags_dummy_node(dummy_nodes[i], m.getMeshset());
144  ++i;
145  }
146  r_dummy_nodes.insert_list(dummy_nodes.begin(), dummy_nodes.end());
147  }
148 
149  CHKERR pcomm->broadcast_entities(from_proc, r_dummy_nodes, false, true);
150 
151  for (auto dummy_node : r_dummy_nodes) {
152  EntityHandle m;
153  CHKERR moab.create_meshset(MESHSET_SET, m);
154  CHKERR set_tags_dummy_node(m, dummy_node);
155 
156  CubitMeshSets broadcast_block(moab, m);
157  if ((broadcast_block.cubitBcType &
159  .any()) {
160  auto p = cubitMeshsets.insert(broadcast_block);
161  if (!p.second) {
162  CHKERR moab.delete_entities(&m, 1);
163  } else {
164  MOFEM_LOG("MeshsetMngSelf", Sev::noisy)
165  << "broadcast " << broadcast_block;
166  }
167  }
168  }
169 
170  CHKERR moab.delete_entities(r_dummy_nodes);
171  }
172 
174 }
175 
178  Interface &m_field = cOre;
179  moab::Interface &moab = m_field.get_moab();
180  int default_val = -1;
181  CHKERR moab.tag_get_handle(DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag,
182  MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
183 
184  CHKERR moab.tag_get_handle(NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag,
185  MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
186 
187  const int def_bc_data_len = 0;
188  std::string tag_name = std::string(DIRICHLET_SET_TAG_NAME) + "__BC_DATA";
189  CHKERR moab.tag_get_handle(
190  tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nsTag_data,
191  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
192 
193  tag_name = std::string(NEUMANN_SET_TAG_NAME) + "__BC_DATA";
194  CHKERR moab.tag_get_handle(
195  tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, ssTag_data,
196  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
197 
198  CHKERR moab.tag_get_handle(MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, bhTag,
199  MB_TAG_SPARSE | MB_TAG_CREAT, &default_val);
200 
201  std::vector<unsigned int> def_uint_zero(3, 0);
202  CHKERR moab.tag_get_handle(
203  BLOCK_HEADER, 3 * sizeof(unsigned int), MB_TYPE_INTEGER, bhTag_header,
204  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES, &def_uint_zero[0]);
205 
206  Tag block_attribs;
207  int def_Block_Attributes_length = 0;
208  CHKERR moab.tag_get_handle(
209  BLOCK_ATTRIBUTES, def_Block_Attributes_length, MB_TYPE_DOUBLE,
210  block_attribs, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
211 
212  Tag entity_name_tag;
213  CHKERR moab.tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
214  entity_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT);
215 
217 }
218 
222  CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
224 }
225 
227  PressureCubitBcData mydata;
229  CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
231 }
232 
234  ForceCubitBcData mydata;
236  CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
238 }
239 
241  TemperatureCubitBcData mydata;
243  CHKERR printBcSet(mydata, NODESET | mydata.tYpe.to_ulong());
245 }
246 
248  HeatFluxCubitBcData mydata;
250  CHKERR printBcSet(mydata, SIDESET | mydata.tYpe.to_ulong());
252 }
253 
256  const Interface &m_field = cOre;
257  const moab::Interface &moab = m_field.get_moab();
259  (*this), BLOCKSET | MAT_ELASTICSET, it)) {
260  Mat_Elastic data;
261  CHKERR it->getAttributeDataStructure(data);
262  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
263  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
264  Range tets;
265  CHKERR moab.get_entities_by_dimension(it->meshset, 3, tets, true);
266  MOFEM_LOG("MeshsetMngWorld", Sev::inform)
267  << "MAT_ELATIC msId " << it->getMeshsetId() << " nb. volumes "
268  << tets.size();
269  }
270 
272  m_field, BLOCKSET | MAT_THERMALSET, it)) {
273  Mat_Thermal data;
274  CHKERR it->getAttributeDataStructure(data);
275  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
276  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
277  }
278 
280  m_field, BLOCKSET | MAT_MOISTURESET, it)) {
281  Mat_Moisture data;
282  CHKERR it->getAttributeDataStructure(data);
283  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << *it;
284  MOFEM_LOG("MeshsetMngWorld", Sev::inform) << data;
285  }
287 }
288 
289 bool MeshsetsManager::checkMeshset(const int ms_id,
290  const CubitBCType cubit_bc_type) const {
291  auto miit =
293  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
294  if (miit !=
296  return true;
297  }
298  return false;
299 }
300 
301 bool MeshsetsManager::checkMeshset(const string name,
302  int *const number_of_meshsets_ptr) const {
303  auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
304  auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
305  if (std::distance(miit, hi_miit) == 0) {
306  return false;
307  }
308  if (number_of_meshsets_ptr) {
309  *number_of_meshsets_ptr = std::distance(miit, hi_miit);
310  }
311  return true;
312 }
313 
315  const int ms_id,
316  const std::string name) {
317  Interface &m_field = cOre;
318  moab::Interface &moab = m_field.get_moab();
320  if (checkMeshset(ms_id, cubit_bc_type)) {
321  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
322  "such cubit meshset is already there", ms_id);
323  }
324 
325  CubitMeshSets cmeshset(moab, cubit_bc_type, ms_id);
326  if ((cmeshset.cubitBcType & CubitBCType(NODESET | SIDESET | BLOCKSET))
327  .any()) {
328  auto p = cubitMeshsets.insert(cmeshset);
329  if (!p.second) {
330  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
331  "meshset not inserted");
332  }
333  if (name.size() > 0) {
334  bool success =
335  cubitMeshsets.modify(p.first, CubitMeshSets_change_name(moab, name));
336  if (!success) {
337  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
338  "name to cubit meshset can not be set");
339  }
340  }
341  }
342 
344 }
345 
348  const int ms_id, const Range &ents) {
349  Interface &m_field = cOre;
350  moab::Interface &moab = m_field.get_moab();
352  auto cit =
354  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
355  if (cit ==
357  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
358  "Cannot find Cubit meshset with id: %d", ms_id);
359  }
360  EntityHandle meshset = cit->getMeshset();
361  CHKERR moab.add_entities(meshset, ents);
362 
364 }
365 
368  const int ms_id, const EntityHandle *ents,
369  const int nb_ents) {
370  Interface &m_field = cOre;
371  moab::Interface &moab = m_field.get_moab();
373  auto cit =
375  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
376  if (cit ==
378  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
379  "Cannot find Cubit meshset with id: %d", ms_id);
380  }
381  EntityHandle meshset = cit->getMeshset();
382  CHKERR moab.add_entities(meshset, ents, nb_ents);
383 
385 }
386 
388 MeshsetsManager::setAtributes(const CubitBCType cubit_bc_type, const int ms_id,
389  const std::vector<double> &attributes,
390  const std::string name) {
391  Interface &m_field = cOre;
392  moab::Interface &moab = m_field.get_moab();
394  auto cit =
396  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
397  if (cit ==
399  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
400  "Cannot find Cubit meshset with id: %d", ms_id);
401  }
402  if (name.size() > 0) {
403  bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
404  CubitMeshSets_change_name(moab, name));
405  if (!success) {
406  SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
407  "name to cubit meshset can not be set");
408  }
409  }
410  bool success =
411  cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
412  CubitMeshSets_change_attributes(moab, attributes));
413  if (!success)
414  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
415  "modification unsuccessful");
416 
417  std::ostringstream ss;
418  ss << "Block " << cit->getName();
419  ss << " Add attr: ";
420  for (unsigned int ii = 0; ii != attributes.size(); ii++) {
421  ss << attributes[ii] << " ";
422  }
423  MOFEM_LOG("MeshsetMngSelf", Sev::noisy) << ss.str();
424 
426 }
427 
429  const CubitBCType cubit_bc_type, const int ms_id,
430  const GenericAttributeData &data, const std::string name) {
431  Interface &m_field = cOre;
432  moab::Interface &moab = m_field.get_moab();
434  auto cit =
436  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
437  if (cit ==
439  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
440  "Cannot find Cubit meshset with id: %d", ms_id);
441  }
442  if (name.size() > 0) {
443  bool success = cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
444  CubitMeshSets_change_name(moab, name));
445  if (!success) {
446  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
447  "name to cubit meshset can not be set");
448  }
449  }
450  bool success = cubitMeshsets.modify(
451  cubitMeshsets.project<0>(cit),
453  if (!success)
454  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
455  "modification unsuccessful");
457 }
458 
460  const int ms_id,
461  const GenericCubitBcData &data) {
462  Interface &m_field = cOre;
463  moab::Interface &moab = m_field.get_moab();
465  auto cit =
467  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
468  if (cit ==
470  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
471  "Cubit meshset with id is already there", ms_id);
472  }
473  bool success =
474  cubitMeshsets.modify(cubitMeshsets.project<0>(cit),
476  if (!success)
477  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
478  "modification unsuccessful");
480 }
481 
483  const int ms_id,
484  const MoFEMTypes bh) {
485  Interface &m_field = cOre;
486  moab::Interface &moab = m_field.get_moab();
488  auto miit =
490  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
491  if (miit ==
493  if (bh & MF_EXIST) {
494  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
495  "meshset not found", ms_id);
496  } else {
498  }
499  }
500  EntityHandle meshset = miit->getMeshset();
502  CHKERR moab.delete_entities(&meshset, 1);
503 
505 }
506 
508  const int ms_id, const CubitBCType cubit_bc_type,
509  const CubitMeshSets **cubit_meshset_ptr) const {
510  Interface &m_field = cOre;
512  auto miit =
514  boost::make_tuple(ms_id, cubit_bc_type.to_ulong()));
515  if (miit !=
517  *cubit_meshset_ptr = &*miit;
518  } else {
519  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
520  "msId = %d is not there", ms_id);
521  }
523 }
524 
526  const string name, const CubitMeshSets **cubit_meshset_ptr) const {
527  Interface &m_field = cOre;
529  auto miit = cubitMeshsets.get<CubitMeshsets_name>().lower_bound(name);
530  auto hi_miit = cubitMeshsets.get<CubitMeshsets_name>().upper_bound(name);
531  if (std::distance(miit, hi_miit) == 0) {
532  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
533  "meshset name <%s> is not there", name.c_str());
534  }
535  if (std::distance(miit, hi_miit) > 1) {
536  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
537  "more that one meshser of that name <%s>", name.c_str());
538  }
539  *cubit_meshset_ptr = &*miit;
541 }
542 
544  const std::regex reg_exp_name,
545  std::vector<const CubitMeshSets *> &vec_ptr) const {
546  Interface &m_field = cOre;
548  auto r =
550  for (; r.first != r.second; ++r.first) {
551  const auto name = r.first->getName();
552  if (std::regex_match(name, reg_exp_name)) {
553  vec_ptr.push_back(&*r.first);
554  }
555  }
557 }
558 
560  const int msId, const unsigned int cubit_bc_type, const int dimension,
561  Range &entities, const bool recursive) const {
562  Interface &m_field = cOre;
563  moab::Interface &moab = m_field.get_moab();
565  auto miit =
567  boost::make_tuple(msId, cubit_bc_type));
568  if (miit !=
570  CHKERR miit->getMeshsetIdEntitiesByDimension(moab, dimension, entities,
571  recursive);
572  } else {
573  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
574  "msId = %d is not there", msId);
575  }
577 }
578 
580  const int ms_id, const unsigned int cubit_bc_type, Range &entities,
581  const bool recursive) const {
582  Interface &m_field = cOre;
583  moab::Interface &moab = m_field.get_moab();
585  auto miit =
587  boost::make_tuple(ms_id, cubit_bc_type));
588  if (miit !=
590  CHKERR miit->getMeshsetIdEntitiesByDimension(moab, entities, recursive);
591  } else {
592  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
593  "ms_id = %d is not there", ms_id);
594  }
596 }
597 
599  const unsigned int cubit_bc_type,
600  EntityHandle &meshset) const {
601  Interface &m_field = cOre;
603  auto miit =
605  boost::make_tuple(ms_id, cubit_bc_type));
606  if (miit !=
608  meshset = miit->meshset;
609  } else {
610  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
611  "ms_id = %d is not there", ms_id);
612  }
614 }
615 
617  const int ms_id, const unsigned int cubit_bc_type,
618  const EntityHandle *entities, int num_entities, const int operation_type) {
619  auto miit =
621  boost::make_tuple(ms_id, cubit_bc_type));
622  if (miit !=
624  Interface &m_field = cOre;
625  return m_field.get_moab().contains_entities(miit->meshset, entities,
626  num_entities, operation_type);
627  } else
628  return false;
629 }
630 
632 MeshsetsManager::getMeshsetsByType(const unsigned int cubit_bc_type,
633  Range &meshsets) const {
635  auto miit =
636  cubitMeshsets.get<CubitMeshsetType_mi_tag>().lower_bound(cubit_bc_type);
637  auto hi_miit =
638  cubitMeshsets.get<CubitMeshsetType_mi_tag>().upper_bound(cubit_bc_type);
639  for (; miit != hi_miit; miit++) {
640  meshsets.insert(miit->meshset);
641  }
643 }
644 
645 struct BlockData {
646 
648 
649  int iD;
650  string addType;
651  string nAme;
653 
654  // Materials
659 
660  // BCs
667 
669  std::vector<double> aTtr;
670 
672  std::memcpy(dispBc.data.name, "Displacement", 12);
673  std::memcpy(forceBc.data.name, "Force", 5);
674  std::memcpy(pressureBc.data.name, "Pressure", 8);
675  std::memcpy(temperatureBc.data.name, "Temperature", 11);
676  std::memcpy(heatFluxBc.data.name, "HeatFlux", 8);
677  std::memcpy(cfgBc.data.name, "cfd_bc", 6);
678  }
679 };
680 
682  bool clean_file_options) {
683  Interface &m_field = cOre;
685  std::ifstream ini_file(file_name.c_str(), std::ifstream::in);
686  po::variables_map vm;
687  if (clean_file_options) {
689  boost::shared_ptr<boost::program_options::options_description>(
690  new po::options_description());
691  }
692 
693  auto add_block_attributes = [&](auto prefix, auto &block_lists, auto &it) {
694  // remove spacec from blockset name
695  configFileOptionsPtr->add_options()(
696  (prefix + ".number_of_attributes").c_str(),
697  po::value<int>(&block_lists[it->getMeshsetId()].numberOfAttributes)
698  ->default_value(-1),
699  "Number of blockset attribute");
700  for (int ii = 1; ii <= 10; ii++) {
701  std::string surfix = ".user" + boost::lexical_cast<std::string>(ii);
702  configFileOptionsPtr->add_options()(
703  (prefix + surfix).c_str(),
704  po::value<double>(&block_lists[it->getMeshsetId()].aTtr[ii - 1])
705  ->default_value(0.0),
706  "Add block attribute");
707  }
708  };
709 
710  // Add blocks
711  map<int, BlockData> block_lists;
713  block_lists[it->getMeshsetId()].cubitMeshset = it->getMeshset();
714  std::string prefix =
715  "block_" + boost::lexical_cast<std::string>(it->getMeshsetId());
716  configFileOptionsPtr->add_options()(
717  (prefix + ".add").c_str(),
718  po::value<string>(&block_lists[it->getMeshsetId()].addType)
719  ->default_value("UNKNOWNSET"),
720  "Add block set")(
721  (prefix + ".id").c_str(),
722  po::value<int>(&block_lists[it->getMeshsetId()].iD)->default_value(-1),
723  "Id of meshset")(
724  (prefix + ".name").c_str(),
725  po::value<string>(&block_lists[it->getMeshsetId()].nAme)
726  ->default_value(""),
727  "Name of the meshset");
728 
729  // Block attributes
730  add_block_attributes(prefix, block_lists, it);
731 
732  // Mat elastic
733  {
734  // double Young; ///< Young's modulus
735  // double Poisson; ///< Poisson's ratio
736  // double ThermalExpansion; ///< Thermal expansion
737  configFileOptionsPtr->add_options()(
738  (prefix + ".young").c_str(),
739  po::value<double>(
740  &block_lists[it->getMeshsetId()].matElastic.data.Young)
741  ->default_value(-1),
742  "Young modulus")(
743  (prefix + ".poisson").c_str(),
744  po::value<double>(
745  &block_lists[it->getMeshsetId()].matElastic.data.Poisson)
746  ->default_value(-2),
747  "Poisson ratio")(
748  (prefix + ".thermalexpansion").c_str(),
749  po::value<double>(
750  &block_lists[it->getMeshsetId()].matElastic.data.ThermalExpansion)
751  ->default_value(-1),
752  "Thermal expansion");
753  // TODO Add users parameters
754  }
755  // Mat Trans Iso
756  {
757  // Young's modulus in xy plane (Ep)
758  // Young's modulus in z-direction (Ez)
759  // Poisson's ratio in xy plane (vp)
760  // Poisson's ratio in z-direction (vpz)
761  // Shear modulus in z-direction (Gzp)
762  configFileOptionsPtr->add_options()(
763  (prefix + ".Youngp").c_str(),
764  po::value<double>(
765  &block_lists[it->getMeshsetId()].matTransIso.data.Youngp)
766  ->default_value(-1),
767  "Youngp")(
768  (prefix + ".Youngz").c_str(),
769  po::value<double>(
770  &block_lists[it->getMeshsetId()].matTransIso.data.Youngz)
771  ->default_value(-1),
772  "Youngz")(
773  (prefix + ".Poissonp").c_str(),
774  po::value<double>(
775  &block_lists[it->getMeshsetId()].matTransIso.data.Poissonp)
776  ->default_value(0),
777  "Poissonp")(
778  (prefix + ".Poissonpz").c_str(),
779  po::value<double>(
780  &block_lists[it->getMeshsetId()].matTransIso.data.Poissonpz)
781  ->default_value(0),
782  "Poissonpz")(
783  (prefix + ".Shearzp").c_str(),
784  po::value<double>(
785  &block_lists[it->getMeshsetId()].matTransIso.data.Shearzp)
786  ->default_value(-1),
787  "Shearzp");
788  // TODO Add users parameters
789  }
790  // Mat thermal
791  {
792  // double Conductivity; ///< Thermal conductivity
793  // double HeatCapacity; ///< Heat Capacity
794  configFileOptionsPtr->add_options()(
795  (prefix + ".conductivity").c_str(),
796  po::value<double>(
797  &block_lists[it->getMeshsetId()].matThermal.data.Conductivity)
798  ->default_value(-1),
799  "Conductivity")(
800  (prefix + ".capacity").c_str(),
801  po::value<double>(
802  &block_lists[it->getMeshsetId()].matThermal.data.HeatCapacity)
803  ->default_value(-1),
804  "Capacity");
805  // TODO Add users parameters
806  }
807  // Mat interface
808  {
809  // double alpha; ///< Elastic modulus multiplier
810  // double beta; ///< Damage Coupling multiplier between normal and
811  // shear (g=sqrt(gn^2 + beta(gt1^2 + gt2^2))) double ft; ///< Maximum
812  // stress of crack double Gf; ///< Fracture Energy
813  configFileOptionsPtr->add_options()(
814  (prefix + ".interface_alpha").c_str(),
815  po::value<double>(
816  &block_lists[it->getMeshsetId()].matInterf.data.alpha)
817  ->default_value(-1),
818  "alpha")((prefix + ".interface_beta").c_str(),
819  po::value<double>(
820  &block_lists[it->getMeshsetId()].matInterf.data.beta)
821  ->default_value(-1),
822  "beta")(
823  (prefix + ".interface_ft").c_str(),
824  po::value<double>(&block_lists[it->getMeshsetId()].matInterf.data.ft)
825  ->default_value(-1),
826  "ft")(
827  (prefix + ".interface_Gf").c_str(),
828  po::value<double>(&block_lists[it->getMeshsetId()].matInterf.data.Gf)
829  ->default_value(-1),
830  "Gf");
831  // TODO Add users parameters
832  }
833 
834  // Displacement bc
835  {
836  // char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
837  // char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
838  // char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
839  // char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
840  // char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
841  // char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
842  // double value1; //< Value for X-Translation
843  // double value2; //< Value for Y-Translation
844  // double value3; //< Value for Z-Translation
845  // double value4; //< Value for X-Rotation
846  // double value5; //< Value for Y-Rotation
847  // double value6; //< Value for Z-Rotation
848  configFileOptionsPtr->add_options()(
849  (prefix + ".disp_flag1").c_str(),
850  po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag1)
851  ->default_value(0),
852  "flag1")(
853  (prefix + ".disp_flag2").c_str(),
854  po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag2)
855  ->default_value(0),
856  "flag2")(
857  (prefix + ".disp_flag3").c_str(),
858  po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag3)
859  ->default_value(0),
860  "flag3")(
861  (prefix + ".disp_flag4").c_str(),
862  po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag4)
863  ->default_value(0),
864  "flag4")(
865  (prefix + ".disp_flag5").c_str(),
866  po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag5)
867  ->default_value(0),
868  "flag5")(
869  (prefix + ".disp_flag6").c_str(),
870  po::value<char>(&block_lists[it->getMeshsetId()].dispBc.data.flag6)
871  ->default_value(0),
872  "flag6")(
873  (prefix + ".disp_ux").c_str(),
874  po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value1)
875  ->default_value(0),
876  "value1")(
877  (prefix + ".disp_uy").c_str(),
878  po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value2)
879  ->default_value(0),
880  "value2")(
881  (prefix + ".disp_uz").c_str(),
882  po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value3)
883  ->default_value(0),
884  "value3")(
885  (prefix + ".disp_rx").c_str(),
886  po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value4)
887  ->default_value(0),
888  "value4")(
889  (prefix + ".disp_ry").c_str(),
890  po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value5)
891  ->default_value(0),
892  "value5")(
893  (prefix + ".disp_rz").c_str(),
894  po::value<double>(&block_lists[it->getMeshsetId()].dispBc.data.value6)
895  ->default_value(0),
896  "value6");
897  }
898  // Force BC data
899  {
900  // char zero[3]; //< 3 zeros
901  // double value1; //< Force magnitude
902  // double value2; //< Moment magnitude
903  // double value3; //< X-component of force direction vector
904  // double value4; //< Y-component of force direction vector
905  // double value5; //< Z-component of force direction vector
906  // double value6; //< X-component of moment direction vector
907  // double value7; //< Y-component of moment direction vector
908  // double value8; //< Z-component of moment direction vector
909  // char zero2; // 0
910  configFileOptionsPtr->add_options()(
911  (prefix + ".force_magnitude").c_str(),
912  po::value<double>(
913  &block_lists[it->getMeshsetId()].forceBc.data.value1)
914  ->default_value(0),
915  "value1")((prefix + ".moment_magnitude").c_str(),
916  po::value<double>(
917  &block_lists[it->getMeshsetId()].forceBc.data.value2)
918  ->default_value(0),
919  "value2")(
920  (prefix + ".force_fx").c_str(),
921  po::value<double>(
922  &block_lists[it->getMeshsetId()].forceBc.data.value3)
923  ->default_value(0),
924  "value3")((prefix + ".force_fy").c_str(),
925  po::value<double>(
926  &block_lists[it->getMeshsetId()].forceBc.data.value4)
927  ->default_value(0),
928  "value4")(
929  (prefix + ".force_fz").c_str(),
930  po::value<double>(
931  &block_lists[it->getMeshsetId()].forceBc.data.value5)
932  ->default_value(0),
933  "value5")((prefix + ".moment_mx").c_str(),
934  po::value<double>(
935  &block_lists[it->getMeshsetId()].forceBc.data.value6)
936  ->default_value(0),
937  "value6")(
938  (prefix + ".moment_my").c_str(),
939  po::value<double>(
940  &block_lists[it->getMeshsetId()].forceBc.data.value7)
941  ->default_value(0),
942  "value7")((prefix + ".moment_mz").c_str(),
943  po::value<double>(
944  &block_lists[it->getMeshsetId()].forceBc.data.value8)
945  ->default_value(0),
946  "value8");
947  }
948  {
949  // char name[11]; //< 11 characters for "Temperature"
950  // char pre1; //< This is always zero
951  // char pre2; //< 0: temperature is not applied on thin shells
952  // (default); 1: temperature is applied on thin shells char flag1; //<
953  // 0: N/A, 1: temperature value applied (not on thin shells) char flag2;
954  // //< 0: N/A, 1: temperature applied on thin shell middle char flag3;
955  // //< 0: N/A, 1: thin shell temperature gradient specified char flag4;
956  // //< 0: N/A, 1: top thin shell temperature char flag5; //< 0: N/A, 1:
957  // bottom thin shell temperature char flag6; //< This is always zero
958  // double value1; //< Temperature (default case - no thin shells)
959  // double value2; //< Temperature for middle of thin shells
960  // double value3; //< Temperature gradient for thin shells
961  // double value4; //< Temperature for top of thin shells
962  // double value5; //< Temperature for bottom of thin shells
963  // double value6; //< This is always zero, i.e. ignore
964  configFileOptionsPtr->add_options()(
965  (prefix + ".temperature_flag1").c_str(),
966  po::value<char>(
967  &block_lists[it->getMeshsetId()].temperatureBc.data.flag1)
968  ->default_value(0),
969  "flag1")(
970  (prefix + ".temperature_t").c_str(),
971  po::value<double>(
972  &block_lists[it->getMeshsetId()].temperatureBc.data.value1)
973  ->default_value(0),
974  "value1");
975  // TODO: Add more cases, see above
976  }
977  // Sideset
978  {
979  // char name[8]; //< 8 characters for "Pressure"
980  // char zero; //< This is always zero
981  // char flag2; //< 0: Pressure is interpreted as pure pressure 1:
982  // pressure is interpreted as total force double value1; //< Pressure
983  // value
984  configFileOptionsPtr->add_options()(
985  (prefix + ".pressure_flag2").c_str(),
986  po::value<char>(
987  &block_lists[it->getMeshsetId()].pressureBc.data.flag2)
988  ->default_value(0),
989  "flag2")((prefix + ".pressure_magnitude").c_str(),
990  po::value<double>(
991  &block_lists[it->getMeshsetId()].pressureBc.data.value1)
992  ->default_value(0),
993  "value1");
994  }
995  {
996  // char name[8]; //< 8 characters for "HeatFlux" (no space)
997  // char pre1; //< This is always zero
998  // char pre2; //< 0: heat flux is not applied on thin shells (default);
999  // 1: heat flux is applied on thin shells char flag1; //< 0: N/A, 1:
1000  // normal heat flux case (i.e. single value, case without thin shells)
1001  // char flag2; //< 0: N/A, 1: Thin shell top heat flux specified
1002  // char flag3; //< 0: N/A, 1: Thin shell bottom heat flux specidied
1003  // double value1; //< Heat flux value for default case (no thin shells)
1004  // double value2; //< Heat flux (thin shell top)
1005  // double value3; //< Heat flux (thin shell bottom)
1006  configFileOptionsPtr->add_options()(
1007  (prefix + ".heatflux_flag1").c_str(),
1008  po::value<char>(
1009  &block_lists[it->getMeshsetId()].heatFluxBc.data.flag1)
1010  ->default_value(0),
1011  "flag1")((prefix + ".heatflux_magnitude").c_str(),
1012  po::value<double>(
1013  &block_lists[it->getMeshsetId()].heatFluxBc.data.value1)
1014  ->default_value(0),
1015  "value1");
1016  }
1017  // Interface set
1018  {
1019  configFileOptionsPtr->add_options()(
1020  (prefix + ".interface_type").c_str(),
1021  po::value<char>(&block_lists[it->getMeshsetId()].cfgBc.data.type)
1022  ->default_value(0),
1023  "type");
1024  }
1025  }
1026 
1027  map<int, BlockData> block_set_attributes;
1029  block_set_attributes[it->getMeshsetId()].cubitMeshset = it->getMeshset();
1030  block_set_attributes[it->getMeshsetId()].iD = it->getMeshsetId();
1031  block_set_attributes[it->getMeshsetId()].bcType = BLOCKSET;
1032  std::string block_name = it->getName();
1033  block_name.erase(
1034  std::remove_if(block_name.begin(), block_name.end(), ::isspace),
1035  block_name.end());
1036  block_set_attributes[it->getMeshsetId()].nAme = block_name;
1037  // Only blocks which have name
1038  if (block_name.compare("NoNameSet") != 0) {
1039  std::string prefix = "SET_ATTR_" + block_name;
1040  // Block attributes
1041  add_block_attributes(prefix, block_set_attributes, it);
1042  }
1043  }
1044 
1045  po::parsed_options parsed =
1046  parse_config_file(ini_file, *configFileOptionsPtr, true);
1047  store(parsed, vm);
1048  po::notify(vm);
1049 
1050  // Set type from name
1052 
1053  CubitBCType bc_type;
1054  unsigned jj = 0;
1055  while (1 << jj != LASTSET_BC) {
1056  if (string(CubitBCNames[jj + 1]) ==
1057  block_lists[it->getMeshsetId()].addType) {
1058  bc_type = 1 << jj;
1059  }
1060  ++jj;
1061  }
1062  if (bc_type.none()) {
1063  block_lists[it->getMeshsetId()].bcType = UNKNOWNSET;
1064  // Skip the bockset nothing is defined for it
1065  continue;
1066  }
1067 
1068  if (bc_type.to_ulong() == BLOCKSET)
1069  block_lists[it->getMeshsetId()].bcType = BLOCKSET;
1070  else if (bc_type.to_ulong() == NODESET)
1071  block_lists[it->getMeshsetId()].bcType = NODESET;
1072  else if (bc_type.to_ulong() == SIDESET)
1073  block_lists[it->getMeshsetId()].bcType = SIDESET;
1074  else {
1075  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1076  "Not yet implemented type %s\n",
1077  block_lists[it->getMeshsetId()].addType.c_str());
1078  }
1079  if (block_lists[it->getMeshsetId()].iD == -1) {
1080  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1081  "Unset iD number %d\n", block_lists[it->getMeshsetId()].iD);
1082  }
1083  }
1084 
1085  std::vector<std::string> additional_parameters;
1086  additional_parameters =
1087  collect_unrecognized(parsed.options, po::include_positional);
1088  for (std::vector<std::string>::iterator vit = additional_parameters.begin();
1089  vit != additional_parameters.end(); vit++) {
1090  MOFEM_LOG_C("MeshsetMngSelf", Sev::warning, "Unrecognized option %s",
1091  vit->c_str());
1092  }
1093  for (map<int, BlockData>::iterator mit = block_lists.begin();
1094  mit != block_lists.end(); mit++) {
1095  CubitMeshSet_multiIndex::iterator cubit_meshset_it =
1096  cubitMeshsets.find(mit->second.cubitMeshset);
1097  if (cubit_meshset_it == cubitMeshsets.end()) {
1098  SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1099  "Data inconsistency\n");
1100  }
1101  switch (mit->second.bcType) {
1102  case UNKNOWNSET:
1103  break;
1104  case BLOCKSET: {
1105  if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1106  .any() &&
1107  mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1108  // Meshset is the same, only modification
1109  } else {
1110  CHKERR addMeshset(mit->second.bcType, mit->second.iD, mit->second.nAme);
1111  EntityHandle meshset = cubit_meshset_it->getMeshset();
1112  CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1113  &meshset, 1);
1114  }
1115  // Add attributes
1116  CHKERR setAtributes(mit->second.bcType, mit->second.iD, mit->second.aTtr);
1117  // Add material elastic data if value are physical (i.e. Young > 0,
1118  // Poisson in (-1.0.5) and ThermalExpansion>0)
1119  if (mit->second.matElastic.data.Young != -1) {
1120  CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1121  mit->second.matElastic);
1122  }
1123  if (mit->second.matTransIso.data.Youngp != -1) {
1124  CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1125  mit->second.matTransIso);
1126  }
1127  if (mit->second.matThermal.data.Conductivity != -1) {
1128  CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1129  mit->second.matThermal);
1130  }
1131  if (mit->second.matInterf.data.ft != -1) {
1132  CHKERR setAtributesByDataStructure(mit->second.bcType, mit->second.iD,
1133  mit->second.matInterf);
1134  }
1135  } break;
1136  case NODESET: {
1137  if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1138  .any() &&
1139  mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1140  // Meshset is the same, only modification
1141  } else {
1142  CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1143  EntityHandle meshset = cubit_meshset_it->getMeshset();
1144  CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1145  &meshset, 1);
1146  }
1147  // Add displacement bc
1148  if (mit->second.dispBc.data.flag1 || mit->second.dispBc.data.flag2 ||
1149  mit->second.dispBc.data.flag3 || mit->second.dispBc.data.flag4 ||
1150  mit->second.dispBc.data.flag5 || mit->second.dispBc.data.flag6) {
1151  if (mit->second.dispBc.data.flag1 == '0')
1152  mit->second.dispBc.data.flag1 = 0;
1153  if (mit->second.dispBc.data.flag1 == 'N')
1154  mit->second.dispBc.data.flag1 = 0;
1155  if (mit->second.dispBc.data.flag1)
1156  mit->second.dispBc.data.flag1 = 1;
1157  if (mit->second.dispBc.data.flag2 == '0')
1158  mit->second.dispBc.data.flag2 = 0;
1159  if (mit->second.dispBc.data.flag2 == 'N')
1160  mit->second.dispBc.data.flag2 = 0;
1161  if (mit->second.dispBc.data.flag2)
1162  mit->second.dispBc.data.flag2 = 1;
1163  if (mit->second.dispBc.data.flag3 == '0')
1164  mit->second.dispBc.data.flag3 = 0;
1165  if (mit->second.dispBc.data.flag3 == 'N')
1166  mit->second.dispBc.data.flag3 = 0;
1167  if (mit->second.dispBc.data.flag3)
1168  mit->second.dispBc.data.flag3 = 1;
1169  if (mit->second.dispBc.data.flag4 == '0')
1170  mit->second.dispBc.data.flag4 = 0;
1171  if (mit->second.dispBc.data.flag4 == 'N')
1172  mit->second.dispBc.data.flag4 = 0;
1173  if (mit->second.dispBc.data.flag4)
1174  mit->second.dispBc.data.flag4 = 1;
1175  if (mit->second.dispBc.data.flag5 == '0')
1176  mit->second.dispBc.data.flag5 = 0;
1177  if (mit->second.dispBc.data.flag5 == 'N')
1178  mit->second.dispBc.data.flag5 = 0;
1179  if (mit->second.dispBc.data.flag5)
1180  mit->second.dispBc.data.flag5 = 1;
1181  if (mit->second.dispBc.data.flag6 == '0')
1182  mit->second.dispBc.data.flag6 = 0;
1183  if (mit->second.dispBc.data.flag6 == 'N')
1184  mit->second.dispBc.data.flag6 = 0;
1185  if (mit->second.dispBc.data.flag6)
1186  mit->second.dispBc.data.flag6 = 1;
1187  CHKERR setBcData(mit->second.bcType, mit->second.iD,
1188  mit->second.dispBc);
1189  }
1190  if (mit->second.forceBc.data.value1 != 0 ||
1191  mit->second.forceBc.data.value2 != 0) {
1192  CHKERR setBcData(mit->second.bcType, mit->second.iD,
1193  mit->second.forceBc);
1194  }
1195  // Add temperature boundary condition
1196  if (mit->second.temperatureBc.data.flag1) {
1197  if (mit->second.temperatureBc.data.flag1 == '0')
1198  mit->second.temperatureBc.data.flag1 = 0;
1199  if (mit->second.temperatureBc.data.flag1 == 'N')
1200  mit->second.temperatureBc.data.flag1 = 0;
1201  if (mit->second.temperatureBc.data.flag1)
1202  mit->second.temperatureBc.data.flag1 = 1;
1203  CHKERR setBcData(mit->second.bcType, mit->second.iD,
1204  mit->second.temperatureBc);
1205  }
1206  } break;
1207  case SIDESET: {
1208  if ((CubitBCType(mit->second.bcType) & cubit_meshset_it->getBcType())
1209  .any() &&
1210  mit->second.iD == cubit_meshset_it->getMeshsetId()) {
1211  // Meshset is the same, only modification
1212  } else {
1213  CHKERR addMeshset(mit->second.bcType, mit->second.iD);
1214  EntityHandle meshset = cubit_meshset_it->getMeshset();
1215  CHKERR addEntitiesToMeshset(mit->second.bcType, mit->second.iD,
1216  &meshset, 1);
1217  }
1218  // Add pressure
1219  if (mit->second.pressureBc.data.value1 != 0) {
1220  if (mit->second.pressureBc.data.flag2 == '0')
1221  mit->second.pressureBc.data.flag2 = 0;
1222  if (mit->second.pressureBc.data.flag2 == 'N')
1223  mit->second.pressureBc.data.flag2 = 0;
1224  if (mit->second.pressureBc.data.flag2)
1225  mit->second.pressureBc.data.flag2 = 1;
1226  CHKERR setBcData(mit->second.bcType, mit->second.iD,
1227  mit->second.pressureBc);
1228  }
1229  // Add heat flux
1230  if (mit->second.heatFluxBc.data.value1 != 0) {
1231  if (mit->second.heatFluxBc.data.flag1 == '0')
1232  mit->second.heatFluxBc.data.flag1 = 0;
1233  if (mit->second.heatFluxBc.data.flag1 == 'N')
1234  mit->second.heatFluxBc.data.flag1 = 0;
1235  if (mit->second.heatFluxBc.data.flag1)
1236  mit->second.heatFluxBc.data.flag1 = 1;
1237  CHKERR setBcData(mit->second.bcType, mit->second.iD,
1238  mit->second.heatFluxBc);
1239  }
1240  // Add Interface
1241  if (mit->second.cfgBc.data.type != 0) {
1242  CHKERR setBcData(mit->second.bcType, mit->second.iD, mit->second.cfgBc);
1243  }
1244  } break;
1245  default:
1246  SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1247  "Not yet implemented type\n");
1248  }
1249  }
1250 
1251  for (auto set_attr : block_set_attributes) {
1252  // Add attributes
1253  if (set_attr.second.numberOfAttributes > 0) {
1254  MOFEM_LOG("MeshsetMngSelf", Sev::verbose)
1255  << "Set attributes to blockset " << set_attr.second.nAme;
1256  set_attr.second.aTtr.resize(set_attr.second.numberOfAttributes);
1257  CHKERR setAtributes(set_attr.second.bcType, set_attr.second.iD,
1258  set_attr.second.aTtr);
1259  }
1260  }
1261 
1263 }
1264 
1266  Interface &m_field = cOre;
1267  PetscBool flg_file;
1268  char meshset_file_name[255] = "config_file.cfg";
1270  CHKERR PetscOptionsBegin(m_field.get_comm(), "", "Set meshsets form file",
1271  "none");
1272  CHKERR PetscOptionsString("-meshsets_config", "meshsets config file name",
1273  "", "add_cubit_meshsets.in", meshset_file_name, 255,
1274  &flg_file);
1275  if (flg_file == PETSC_TRUE) {
1276  ifstream f(meshset_file_name);
1277  if (!f.good()) {
1278  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1279  "File configuring meshsets ( %s ) can not be open\n",
1280  meshset_file_name);
1281  }
1282  CHKERR setMeshsetFromFile(string(meshset_file_name));
1283  }
1284  ierr = PetscOptionsEnd();
1285  CHKERRG(ierr);
1287 }
1288 
1290  const int ms_id, const unsigned int cubit_bc_type,
1291  const std::string file_name, const std::string file_type,
1292  const std::string options) const {
1293 
1295  MoFEM::Interface &m_field = cOre;
1296  const CubitMeshSets *cubit_meshset_ptr;
1297  CHKERR getCubitMeshsetPtr(ms_id, cubit_bc_type, &cubit_meshset_ptr);
1298  EntityHandle meshset = cubit_meshset_ptr->getMeshset();
1299  CHKERR m_field.get_moab().write_file(file_name.c_str(), file_type.c_str(),
1300  options.c_str(), &meshset, 1);
1302 }
1303 
1305  const int ms_id, const unsigned int cubit_bc_type, const int dim,
1306  const std::string file_name, const bool recursive,
1307  const std::string file_type, const std::string options) const {
1308 
1310  MoFEM::Interface &m_field = cOre;
1311  moab::Interface &moab = m_field.get_moab();
1312  Range entities;
1313  CHKERR getEntitiesByDimension(ms_id, cubit_bc_type, dim, entities, recursive);
1314  EntityHandle meshset;
1315  CHKERR moab.create_meshset(MESHSET_SET, meshset);
1316  CHKERR moab.add_entities(meshset, entities);
1317  CHKERR moab.write_file(file_name.c_str(), file_type.c_str(), options.c_str(),
1318  &meshset, 1);
1319  CHKERR moab.delete_entities(&meshset, 1);
1321 }
1322 
1327  for (_IT_CUBITMESHSETS_FOR_LOOP_((*this), iit)) {
1328  EntityHandle meshset = iit->getMeshset();
1329  for (EntityType t = MBVERTEX; t != MBENTITYSET; ++t)
1330  CHKERR bit_mng->updateMeshsetByEntitiesChildren(meshset, bit, meshset, t,
1331  true);
1332  }
1334 }
1335 
1336 } // namespace MoFEM
static Index< 'p', 3 > p
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:314
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:110
@ MF_EXIST
Definition: definitions.h:113
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:228
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
CubitBC
Types of sets and boundary conditions.
Definition: definitions.h:157
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
Definition: definitions.h:172
@ NODESET
Definition: definitions.h:159
@ SIDESET
Definition: definitions.h:160
@ LASTSET_BC
Definition: definitions.h:179
@ MAT_THERMALSET
block name is "MAT_THERMAL"
Definition: definitions.h:174
@ MAT_MOISTURESET
block name is "MAT_MOISTURE"
Definition: definitions.h:176
@ UNKNOWNSET
Definition: definitions.h:158
@ BLOCKSET
Definition: definitions.h:161
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:47
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
static const char *const CubitBCNames[]
Names of types of sets and boundary conditions.
Definition: definitions.h:188
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
const int dim
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:311
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:342
MoFEMErrorCode getMeshset(const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
get meshset from CUBIT Id and CUBIT type
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
check for CUBIT Id and CUBIT type
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
MoFEMErrorCode addMeshset(const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
add cubit meshset
MoFEMErrorCode getMeshsetsByType(const unsigned int cubit_bc_type, Range &meshsets) const
get all CUBIT meshsets by CUBIT type
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
MoFEMErrorCode getEntitiesByDimension(const int ms_id, const unsigned int cubit_bc_type, const int dimension, Range &entities, const bool recursive=true) const
get entities from CUBIT/meshset of a particular entity dimension
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
auto bit
set bit
FTensor::Index< 'i', SPACE_DIM > i
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
std::bitset< 32 > CubitBCType
Definition: Types.hpp:63
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1965
const double r
rate factor
constexpr double t
plate stiffness
Definition: plate.cpp:76
FTensor::Index< 'm', 3 > m
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:490
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Core (interface) class.
Definition: Core.hpp:92
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:87
Definition of the force bc data structure.
Definition: BCData.hpp:149
Generic attribute data structure.
Generic bc data structure.
Definition: BCData.hpp:31
const CubitBCType tYpe
Type of boundary condition.
Definition: BCData.hpp:70
Definition of the heat flux bc data structure.
Definition: BCData.hpp:437
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.
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 updateAllMeshsetsByEntitiesChildren(const BitRefLevel &bit)
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:389
Definition of the temperature bc data structure.
Definition: BCData.hpp:316
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.