v0.13.2
Loading...
Searching...
No Matches
BcManager.cpp
Go to the documentation of this file.
1/** \file BcManager.cpp
2 * \brief Manages boundary conditions
3 * \ingroup bc_manager
4 */
5
6namespace MoFEM {
7
9BcManager::query_interface(boost::typeindex::type_index type_index,
10 UnknownInterface **iface) const {
12 *iface = const_cast<BcManager *>(this);
14}
15
16BcManager::BcManager(const Core &core) : cOre(const_cast<Core &>(core)) {
17
18 if (!LogManager::checkIfChannelExist("BcMngWorld")) {
19 auto core_log = logging::core::get();
20
21 core_log->add_sink(
23 core_log->add_sink(
25 core_log->add_sink(
27
28 LogManager::setLog("BcMngWorld");
29 LogManager::setLog("BcMngSync");
30 LogManager::setLog("BcMngSelf");
31
32 MOFEM_LOG_TAG("BcMngWorld", "BcMng");
33 MOFEM_LOG_TAG("BcMngSync", "BcMng");
34 MOFEM_LOG_TAG("BcMngSelf", "BcMng");
35 }
36
37 MOFEM_LOG("BcMngWorld", Sev::noisy) << "BC manager created";
38}
39
42 ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "BcManager options", "none");
43 ierr = PetscOptionsEnd();
46}
47
49 const std::string problem_name, const std::string block_name,
50 const std::string field_name, int lo, int hi, bool get_low_dim_ents,
51 bool is_distributed_mesh) {
52 Interface &m_field = cOre;
53 auto prb_mng = m_field.getInterface<ProblemsManager>();
55
56 CHKERR pushMarkDOFsOnEntities(problem_name, block_name, field_name, lo, hi,
57 get_low_dim_ents);
58
59 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
60 const int hi) {
61 if (is_distributed_mesh)
62 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
63 hi);
64 else
65 return prb_mng->removeDofsOnEntitiesNotDistributed(
66 problem_name, field_name, ents, lo, hi);
67 };
68
69 for (auto m :
70 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
71
72 (boost::format("%s(.*)") % block_name).str()
73
74 ))
75
76 ) {
77 const std::string bc_id =
78 problem_name + "_" + field_name + "_" + m->getName();
79 CHKERR remove_dofs_on_ents(bcMapByBlockName.at(bc_id)->bcEnts, lo, hi);
80 bcMapByBlockName.at(bc_id)->bcMarkers = std::vector<unsigned char>();
81 }
82
84}
85
87 const std::string block_name,
88 const std::string field_name,
89 int lo, int hi,
90 bool get_low_dim_ents) {
91 Interface &m_field = cOre;
92 auto prb_mng = m_field.getInterface<ProblemsManager>();
94
95 auto get_dim = [&](const Range &ents) {
96 for (auto d : {3, 2, 1})
97 if (ents.num_of_dimension(d))
98 return d;
99 return 0;
100 };
101
102 auto get_adj_ents = [&](const Range &ents) {
103 Range verts;
104 CHKERR m_field.get_moab().get_connectivity(ents, verts, true);
105 const auto dim = get_dim(ents);
106 for (size_t d = 1; d < dim; ++d)
107 CHKERR m_field.get_moab().get_adjacencies(ents, d, false, verts,
108 moab::Interface::UNION);
109 verts.merge(ents);
110 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(verts);
111 return verts;
112 };
113
114 auto fix_disp = [&]() {
116
117 auto mark_fix_dofs = [&](std::vector<unsigned char> &marked_field_dofs,
118 const auto lo, const auto hi) {
119 return prb_mng->modifyMarkDofs(problem_name, ROW, field_name, lo, hi,
121 marked_field_dofs);
122 };
123
124 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
126 for (auto m : meshset_vec_ptr) {
127 auto bc = boost::make_shared<BCs>();
128 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
129 bc->bcEnts, true);
130 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
131 bc->bcEnts);
132 CHKERR m->getAttributes(bc->bcAttributes);
133
134 MOFEM_LOG("BcMngWorld", Sev::verbose)
135 << "Found block " << m->getName() << " number of entities "
136 << bc->bcEnts.size() << " number of attributes "
137 << bc->bcAttributes.size() << " highest dim of entities "
138 << get_dim(bc->bcEnts);
139 CHKERR mark_fix_dofs(bc->bcMarkers, lo, hi);
140 if (get_low_dim_ents) {
141 auto low_dim_ents = get_adj_ents(bc->bcEnts);
142 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
143 low_dim_ents, bc->bcMarkers);
144 bc->bcEnts.swap(low_dim_ents);
145 } else
146 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
147 bc->bcEnts, bc->bcMarkers);
148
149 const std::string bc_id =
150 problem_name + "_" + field_name + "_" + m->getName();
151 bcMapByBlockName[bc_id] = bc;
152 }
154 };
155
156 CHKERR iterate_meshsets(
157
158 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
159
160 (boost::format("%s(.*)") % block_name).str()
161
162 ))
163
164 );
165
167 };
168
169 CHKERR fix_disp();
170
172}
173
174boost::shared_ptr<BcManager::BCs>
175BcManager::popMarkDOFsOnEntities(const std::string block_name) {
176 auto bc_it = bcMapByBlockName.find(block_name);
177 if (bc_it != bcMapByBlockName.end()) {
178 auto bc = bc_it->second;
179 bcMapByBlockName.erase(bc_it);
180 return bc;
181 }
182 return boost::shared_ptr<BCs>();
183}
184
186BcManager::getMergedBlocksMarker(std::vector<std::regex> bc_regex_vec) {
187 BcManager::BcMarkerPtr boundary_marker_ptr;
188 if (bcMapByBlockName.size()) {
189 for (auto b : bcMapByBlockName) {
190 for (auto &reg_name : bc_regex_vec) {
191 if (std::regex_match(b.first, reg_name)) {
192 if (!boundary_marker_ptr)
193 boundary_marker_ptr =
194 boost::make_shared<std::vector<char unsigned>>();
195 boundary_marker_ptr->resize(b.second->bcMarkers.size(), 0);
196 for (int i = 0; i != b.second->bcMarkers.size(); ++i) {
197 (*boundary_marker_ptr)[i] |= b.second->bcMarkers[i];
198 }
199 }
200 }
201 }
202 }
203 return boundary_marker_ptr;
204}
205
207 const std::vector<BcManager::BcMarkerPtr> &boundary_markers_ptr_vec) {
208 auto boundary_marker_ptr = boost::make_shared<std::vector<char unsigned>>();
209 for (auto &bcm : boundary_markers_ptr_vec) {
210 boundary_marker_ptr->resize(bcm->size(), 0);
211 for (int i = 0; i != bcm->size(); ++i)
212 (*boundary_marker_ptr)[i] |= (*bcm)[i];
213 }
214 return boundary_marker_ptr;
215}
216
217SmartPetscObj<IS> BcManager::getBlockIS(const std::string block_prefix,
218 const std::string block_name,
219 const std::string field_name,
220 const std::string problem_name, int lo,
221 int hi, SmartPetscObj<IS> is_expand) {
222 Interface &m_field = cOre;
223
224 const std::string bc_id =
225 block_prefix + "_" + field_name + "_" + block_name + "(.*)";
226
227 Range bc_ents;
228 for (auto bc : getBcMapByBlockName()) {
229 if (std::regex_match(bc.first, std::regex(bc_id))) {
230 bc_ents.merge(*(bc.second->getBcEntsPtr()));
231 MOFEM_LOG("BcMngWorld", Sev::verbose)
232 << "Get entities from block and add to IS. Block name " << bc.first;
233 }
234 }
235
236 SmartPetscObj<IS> is_bc;
237 auto get_is = [&]() {
239 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(bc_ents);
240 CHKERR m_field.getInterface<ISManager>()->isCreateProblemFieldAndRank(
241 problem_name, ROW, field_name, lo, hi, is_bc, &bc_ents);
242 if (is_expand) {
243 IS is_tmp;
244 CHKERR ISExpand(is_bc, is_expand, &is_tmp);
245 is_bc = SmartPetscObj<IS>(is_tmp);
246 }
247 CHKERR ISSort(is_bc);
249 };
250
251 if (get_is())
252 CHK_THROW_MESSAGE(MOFEM_DATA_INCONSISTENCY, "IS is not created");
253
254 return is_bc;
255}
256
257SmartPetscObj<IS> BcManager::getBlockIS(const std::string problem_name,
258 const std::string block_name,
259 const std::string field_name, int lo,
260 int hi, SmartPetscObj<IS> is_expand) {
261 return getBlockIS(problem_name, block_name, field_name, problem_name, lo, hi,
262 is_expand);
263}
264
265template <>
267BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
268 const std::string problem_name, const std::string field_name,
269 bool get_low_dim_ents, bool block_name_field_prefix,
270 bool is_distributed_mesh) {
271 Interface &m_field = cOre;
272 auto prb_mng = m_field.getInterface<ProblemsManager>();
274
275 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
276 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
277
278 std::array<Range, 3> ents_to_remove;
279
280 for (auto m :
281
284
285 const std::string bc_id =
286 problem_name + "_" + field_name + "_DISPLACEMENTSET" +
287 boost::lexical_cast<std::string>(m->getMeshsetId());
288
289 auto bc = bcMapByBlockName.at(bc_id);
290
291 if (bc->dispBcPtr) {
292 if (bc->dispBcPtr->data.flag1) {
293 ents_to_remove[0].merge(bc->bcEnts);
294 }
295 if (bc->dispBcPtr->data.flag2) {
296 ents_to_remove[1].merge(bc->bcEnts);
297 }
298 if (bc->dispBcPtr->data.flag3) {
299 ents_to_remove[2].merge(bc->bcEnts);
300 }
301 if (bc->dispBcPtr->data.flag4) {
302 ents_to_remove[1].merge(bc->bcEnts);
303 ents_to_remove[2].merge(bc->bcEnts);
304 }
305 if (bc->dispBcPtr->data.flag5) {
306 ents_to_remove[0].merge(bc->bcEnts);
307 ents_to_remove[2].merge(bc->bcEnts);
308 }
309 if (bc->dispBcPtr->data.flag6) {
310 ents_to_remove[0].merge(bc->bcEnts);
311 ents_to_remove[1].merge(bc->bcEnts);
312 }
313 }
314 bc->bcMarkers = std::vector<unsigned char>();
315 }
316
317 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
318 const int hi) {
319 if (is_distributed_mesh)
320 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
321 hi);
322 else
323 return prb_mng->removeDofsOnEntitiesNotDistributed(
324 problem_name, field_name, ents, lo, hi);
325 };
326
327 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
328 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
329 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
330
332}
333
334template <>
336BcManager::removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
337 const std::string problem_name, const std::string field_name,
338 bool get_low_dim_ents, bool block_name_field_prefix,
339 bool is_distributed_mesh) {
340 Interface &m_field = cOre;
341 auto prb_mng = m_field.getInterface<ProblemsManager>();
343
344 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
345 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
346
347 Range ents_to_remove;
348
349 for (auto m :
350
353
354 ) {
355 const std::string bc_id =
356 problem_name + "_" + field_name + "_TEMPERATURESET" +
357 boost::lexical_cast<std::string>(m->getMeshsetId());
358 auto bc = bcMapByBlockName.at(bc_id);
359 ents_to_remove.merge(bc->bcEnts);
360 bc->bcMarkers = std::vector<unsigned char>();
361 }
362
363 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
364 const int hi) {
365 if (is_distributed_mesh)
366 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
367 hi);
368 else
369 return prb_mng->removeDofsOnEntitiesNotDistributed(
370 problem_name, field_name, ents, lo, hi);
371 };
372
373 CHKERR remove_dofs_on_ents(ents_to_remove, 0, MAX_DOFS_ON_ENTITY);
374
376}
377
378template <>
379MoFEMErrorCode BcManager::removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
380 const std::string problem_name, const std::string field_name,
381 bool get_low_dim_ents, bool block_name_field_prefix,
382 bool is_distributed_mesh) {
383 Interface &m_field = cOre;
384 auto prb_mng = m_field.getInterface<ProblemsManager>();
386
387 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
388 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
389
390 Range ents_to_remove;
391
392 for (auto m :
393
396
397 ) {
398 const std::string bc_id =
399 problem_name + "_" + field_name + "_HEATFLUXSET" +
400 boost::lexical_cast<std::string>(m->getMeshsetId());
401 auto bc = bcMapByBlockName.at(bc_id);
402 ents_to_remove.merge(bc->bcEnts);
403 bc->bcMarkers = std::vector<unsigned char>();
404 }
405
406 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
407 const int hi) {
408 if (is_distributed_mesh)
409 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
410 hi);
411 else
412 return prb_mng->removeDofsOnEntitiesNotDistributed(
413 problem_name, field_name, ents, lo, hi);
414 };
415
416 CHKERR remove_dofs_on_ents(ents_to_remove, 0, MAX_DOFS_ON_ENTITY);
417
419}
420
421template <>
423BcManager::removeBlockDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
424 const std::string problem_name, const std::string field_name,
425 bool get_low_dim_ents, bool block_name_field_prefix,
426 bool is_distributed_mesh) {
427 Interface &m_field = cOre;
428 auto prb_mng = m_field.getInterface<ProblemsManager>();
430
431 CHKERR pushMarkDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
432 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
433
434 std::array<Range, 3> ents_to_remove;
435
436 for (auto m :
437
439
440 const auto block_name = m->getName();
441
442 std::string bc_id = problem_name + "_" + field_name + "_" + block_name;
443 std::string regex_str;
444 if (block_name_field_prefix) {
445 regex_str = (boost::format("%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
446 "DISPLACEMENT|ROTATE))(.*)") %
447 problem_name % field_name % field_name)
448 .str();
449 } else {
450 regex_str = (boost::format("%s_%s_((FIX_(ALL|X|Y|Z))|("
451 "DISPLACEMENT|ROTATE))(.*)") %
452 problem_name % field_name)
453 .str();
454 }
455
456 if (std::regex_match(bc_id, std::regex(regex_str))) {
457
458 auto bc = bcMapByBlockName.at(bc_id);
459
460 if (auto disp_bc = bc->dispBcPtr) {
461 if (disp_bc->data.flag1) {
462 ents_to_remove[0].merge(bc->bcEnts);
463 }
464 if (disp_bc->data.flag2) {
465 ents_to_remove[1].merge(bc->bcEnts);
466 }
467 if (disp_bc->data.flag3) {
468 ents_to_remove[2].merge(bc->bcEnts);
469 }
470 if (disp_bc->data.flag4) {
471 ents_to_remove[1].merge(bc->bcEnts);
472 ents_to_remove[2].merge(bc->bcEnts);
473 }
474 if (disp_bc->data.flag5) {
475 ents_to_remove[0].merge(bc->bcEnts);
476 ents_to_remove[2].merge(bc->bcEnts);
477 }
478 if (disp_bc->data.flag6) {
479 ents_to_remove[0].merge(bc->bcEnts);
480 ents_to_remove[1].merge(bc->bcEnts);
481 }
482 } else {
483 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
484 "BC type not implemented");
485 }
486 }
487 }
488
489 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
490 const int hi) {
491 if (is_distributed_mesh)
492 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
493 hi);
494 else
495 return prb_mng->removeDofsOnEntitiesNotDistributed(
496 problem_name, field_name, ents, lo, hi);
497 };
498
499 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
500 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
501 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
502
504}
505
506template <>
508BcManager::removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
509 const std::string problem_name, const std::string block_name,
510 const std::string field_name, bool get_low_dim_ents,
511 bool is_distributed_mesh) {
512 Interface &m_field = cOre;
513 auto prb_mng = m_field.getInterface<ProblemsManager>();
515
516 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
517 problem_name, block_name, field_name, get_low_dim_ents);
518
519 Range ents_to_remove;
520
521 for (auto m :
522
524
525 std::string bc_id = problem_name + "_" + field_name + "_" + m->getName();
526
527 auto str = boost::format("%s_%s_%s(.*)")
528
529 % problem_name % field_name % block_name;
530
531 if (std::regex_match(bc_id, std::regex(str.str()))) {
532
533 auto bc = bcMapByBlockName.at(bc_id);
534
535 if (auto disp_bc = bc->tempBcPtr) {
536 if (disp_bc->data.flag1) {
537 ents_to_remove.merge(bc->bcEnts);
538 }
539 } else {
540 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
541 "BC type not implemented");
542 }
543 }
544 }
545
546 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
547 const int hi) {
548 if (is_distributed_mesh)
549 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
550 hi);
551 else
552 return prb_mng->removeDofsOnEntitiesNotDistributed(
553 problem_name, field_name, ents, lo, hi);
554 };
555
556 CHKERR remove_dofs_on_ents(ents_to_remove, 0, MAX_DOFS_ON_ENTITY);
557
559}
560
561template <>
563BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
564 const std::string problem_name, const std::string field_name,
565 bool get_low_dim_ents, bool block_name_field_prefix) {
566 Interface &m_field = cOre;
567 auto prb_mng = m_field.getInterface<ProblemsManager>();
569
570 if (block_name_field_prefix)
571 MOFEM_LOG("BcMngWorld", Sev::warning)
572 << "Argument block_name_field_prefix=true has no effect";
573
574 auto get_dim = [&](const Range &ents) {
575 for (auto d : {3, 2, 1})
576 if (ents.num_of_dimension(d))
577 return d;
578 return 0;
579 };
580
581 auto get_adj_ents = [&](const Range &ents) {
582 Range verts;
583 CHKERR m_field.get_moab().get_connectivity(ents, verts, true);
584 const auto dim = get_dim(ents);
585 for (size_t d = 1; d < dim; ++d)
586 CHKERR m_field.get_moab().get_adjacencies(ents, d, false, verts,
587 moab::Interface::UNION);
588 verts.merge(ents);
589 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(verts);
590 return verts;
591 };
592
593 auto fix_disp = [&]() {
595
596 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
598 for (auto m : meshset_vec_ptr) {
599 auto bc = boost::make_shared<BCs>();
600 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
601 bc->bcEnts, true);
602
603 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
604 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
605
606 MOFEM_LOG("BcMngWorld", Sev::verbose)
607 << "Found block DISPLACEMENTSET number of entities "
608 << bc->bcEnts.size() << " highest dim of entities "
609 << get_dim(bc->bcEnts);
610 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
611
612 if (bc->dispBcPtr->data.flag1)
613 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
615 bc->bcMarkers);
616 if (bc->dispBcPtr->data.flag2)
617 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
619 bc->bcMarkers);
620 if (bc->dispBcPtr->data.flag3)
621 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
623 bc->bcMarkers);
624 if (bc->dispBcPtr->data.flag4) {
625
626 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
628 bc->bcMarkers);
629 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
631 bc->bcMarkers);
632 }
633 if (bc->dispBcPtr->data.flag5) {
634
635 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
637 bc->bcMarkers);
638 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
640 bc->bcMarkers);
641 }
642 if (bc->dispBcPtr->data.flag6) {
643
644 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
646 bc->bcMarkers);
647 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
649 bc->bcMarkers);
650 }
651
652 if (get_low_dim_ents) {
653 auto low_dim_ents = get_adj_ents(bc->bcEnts);
654 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
655 low_dim_ents, bc->bcMarkers);
656 bc->bcEnts.swap(low_dim_ents);
657 } else
658 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
659 bc->bcEnts, bc->bcMarkers);
660
661 const std::string bc_id =
662 problem_name + "_" + field_name + "_DISPLACEMENTSET" +
663 boost::lexical_cast<std::string>(m->getMeshsetId());
664 bcMapByBlockName[bc_id] = bc;
665 }
667 };
668
669 CHKERR iterate_meshsets(
670
673
674 );
675
677 };
678
679 CHKERR fix_disp();
680
682}
683
684template <>
685MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
686 const std::string problem_name, const std::string field_name,
687 bool get_low_dim_ents, bool block_name_field_prefix) {
688 Interface &m_field = cOre;
689 auto prb_mng = m_field.getInterface<ProblemsManager>();
691
692 if (block_name_field_prefix)
693 MOFEM_LOG("BcMngWorld", Sev::warning)
694 << "Argument block_name_field_prefix=true has no effect";
695
696 auto get_dim = [&](const Range &ents) {
697 for (auto d : {3, 2, 1})
698 if (ents.num_of_dimension(d))
699 return d;
700 return 0;
701 };
702
703 auto get_adj_ents = [&](const Range &ents) {
704 Range verts;
705 CHKERR m_field.get_moab().get_connectivity(ents, verts, true);
706 const auto dim = get_dim(ents);
707 for (size_t d = 1; d < dim; ++d)
708 CHKERR m_field.get_moab().get_adjacencies(ents, d, false, verts,
709 moab::Interface::UNION);
710 verts.merge(ents);
711 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(verts);
712 return verts;
713 };
714
715 auto fix_temp = [&]() {
717
718 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
720 for (auto m : meshset_vec_ptr) {
721 auto bc = boost::make_shared<BCs>();
722 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
723 bc->bcEnts, true);
724 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
725 CHKERR m->getBcDataStructure(*(bc->tempBcPtr));
726
727 MOFEM_LOG("BcMngWorld", Sev::verbose)
728 << "Found block TEMPERATURESET number of entities "
729 << bc->bcEnts.size() << " highest dim of entities "
730 << get_dim(bc->bcEnts);
731 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->tempBcPtr;
732
733 CHKERR prb_mng->modifyMarkDofs(
734 problem_name, ROW, field_name, 0, MAX_DOFS_ON_ENTITY,
735 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
736
737 if (get_low_dim_ents) {
738 auto low_dim_ents = get_adj_ents(bc->bcEnts);
739 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
740 low_dim_ents, bc->bcMarkers);
741 bc->bcEnts.swap(low_dim_ents);
742 } else
743 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
744 bc->bcEnts, bc->bcMarkers);
745
746 const std::string bc_id =
747 problem_name + "_" + field_name + "_TEMPERATURESET" +
748 boost::lexical_cast<std::string>(m->getMeshsetId());
749 bcMapByBlockName[bc_id] = bc;
750 }
752 };
753
754 CHKERR iterate_meshsets(
755
758
759 );
760
762 };
763
764 CHKERR fix_temp();
765
767}
768
769template <>
770MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
771 const std::string problem_name, const std::string field_name,
772 bool get_low_dim_ents, bool block_name_field_prefix) {
773 Interface &m_field = cOre;
774 auto prb_mng = m_field.getInterface<ProblemsManager>();
776
777 if (block_name_field_prefix)
778 MOFEM_LOG("BcMngWorld", Sev::warning)
779 << "Argument block_name_field_prefix=true has no effect";
780
781 auto get_dim = [&](const Range &ents) {
782 for (auto d : {3, 2, 1})
783 if (ents.num_of_dimension(d))
784 return d;
785 return 0;
786 };
787
788 auto get_adj_ents = [&](const Range &ents) {
789 Range verts;
790 CHKERR m_field.get_moab().get_connectivity(ents, verts, true);
791 const auto dim = get_dim(ents);
792 for (size_t d = 1; d < dim; ++d)
793 CHKERR m_field.get_moab().get_adjacencies(ents, d, false, verts,
794 moab::Interface::UNION);
795 verts.merge(ents);
796 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(verts);
797 return verts;
798 };
799
800 auto fix_disp = [&]() {
802
803 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
805 for (auto m : meshset_vec_ptr) {
806 auto bc = boost::make_shared<BCs>();
807 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
808 bc->bcEnts, true);
809 bc->heatFluxBcPtr = boost::make_shared<HeatFluxCubitBcData>();
810 CHKERR m->getBcDataStructure(*(bc->heatFluxBcPtr));
811
812 MOFEM_LOG("BcMngWorld", Sev::verbose)
813 << "Found block HEATFLUX number of entities " << bc->bcEnts.size()
814 << " highest dim of entities " << get_dim(bc->bcEnts);
815 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->heatFluxBcPtr;
816
817 CHKERR prb_mng->modifyMarkDofs(
818 problem_name, ROW, field_name, 0, MAX_DOFS_ON_ENTITY,
819 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
820
821 if (get_low_dim_ents) {
822 auto low_dim_ents = get_adj_ents(bc->bcEnts);
823 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
824 low_dim_ents, bc->bcMarkers);
825 bc->bcEnts.swap(low_dim_ents);
826 } else
827 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
828 bc->bcEnts, bc->bcMarkers);
829
830 const std::string bc_id =
831 problem_name + "_" + field_name + "_HEATFLUXSET" +
832 boost::lexical_cast<std::string>(m->getMeshsetId());
833 bcMapByBlockName[bc_id] = bc;
834 }
836 };
837
838 CHKERR iterate_meshsets(
839
842
843 );
844
846 };
847
848 CHKERR fix_disp();
849
851}
852
853template <>
854MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
855 const std::string problem_name, const std::string field_name,
856 bool get_low_dim_ents, bool block_name_field_prefix) {
858
859 auto mark_dofs = [&](const string block_name, const int &idx_0,
860 const int &idx_1) {
862 if (block_name_field_prefix) {
863 const string field_block = field_name + "_" + block_name;
864 CHKERR pushMarkDOFsOnEntities(problem_name, field_block, field_name,
865 idx_0, idx_1, get_low_dim_ents);
866 } else {
867
868 CHKERR pushMarkDOFsOnEntities(problem_name, block_name, field_name, idx_0,
869 idx_1, get_low_dim_ents);
870 }
872 };
873
874 // displacement
875 CHKERR mark_dofs("FIX_X", 0, 0);
876 CHKERR mark_dofs("FIX_Y", 1, 1);
877 CHKERR mark_dofs("FIX_Z", 2, 2);
878 CHKERR mark_dofs("FIX_ALL", 0, MAX_DOFS_ON_ENTITY);
879
880 // rotation
881 CHKERR mark_dofs("ROTATE_X", 1, 1);
882 CHKERR mark_dofs("ROTATE_X", 2, 2);
883 CHKERR mark_dofs("ROTATE_Y", 0, 0);
884 CHKERR mark_dofs("ROTATE_Y", 2, 2);
885 CHKERR mark_dofs("ROTATE_Z", 0, 0);
886 CHKERR mark_dofs("ROTATE_Z", 1, 1);
887 CHKERR mark_dofs("ROTATE_ALL", 0, MAX_DOFS_ON_ENTITY);
888
889 std::string regex_str;
890 if (block_name_field_prefix) {
891 regex_str = (boost::format("%s_%s_%s_(.*)") % problem_name % field_name %
893 .str();
894 } else {
895 regex_str = (boost::format("%s_%s_(.*)") % problem_name % field_name).str();
896 }
897
898 for (auto &m : bcMapByBlockName) {
899 auto &bc_id = m.first;
900 if (std::regex_match(bc_id, std::regex(regex_str))) {
901 auto &bc = m.second;
902 if (std::regex_match(bc_id, std::regex("(.*)_FIX_X(.*)"))) {
903 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
904 bc->dispBcPtr->data.flag1 = 1;
905 if (bc->bcAttributes.empty()) {
906 bc->dispBcPtr->data.value1 = 0;
907 MOFEM_LOG("BcMngWorld", Sev::warning)
908 << "Expected one attribute on block but have "
909 << bc->bcAttributes.size();
910 } else if (bc->bcAttributes.size() >= 1) {
911 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
912 }
913 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add X " << bc_id;
914 MOFEM_LOG("BcMngWorld", Sev::inform) << *bc->dispBcPtr;
915 } else if (std::regex_match(bc_id, std::regex("(.*)_FIX_Y(.*)"))) {
916 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
917 bc->dispBcPtr->data.flag2 = 1;
918 if (bc->bcAttributes.empty()) {
919 bc->dispBcPtr->data.value2 = 0;
920 MOFEM_LOG("BcMngWorld", Sev::warning)
921 << "Expected one attribute on block but have "
922 << bc->bcAttributes.size();
923 } else if (bc->bcAttributes.size() == 1) {
924 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
925 } else if (bc->bcAttributes.size() >= 2) {
926 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
927 }
928 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Y " << bc_id;
929 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
930 } else if (std::regex_match(bc_id, std::regex("(.*)_FIX_Z(.*)"))) {
931 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
932 bc->dispBcPtr->data.flag3 = 1;
933 if (bc->bcAttributes.empty()) {
934 bc->dispBcPtr->data.value3 = 0;
935 MOFEM_LOG("BcMngWorld", Sev::warning)
936 << "Expected one attribute on block but have "
937 << bc->bcAttributes.size();
938 } else if (bc->bcAttributes.size() == 1) {
939 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
940 } else if (bc->bcAttributes.size() == 3) {
941 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
942 }
943 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Z " << bc_id;
944 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
945 } else if (std::regex_match(bc_id, std::regex("(.*)_FIX_ALL(.*)"))) {
946 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
947 bc->dispBcPtr->data.flag1 = 1;
948 bc->dispBcPtr->data.flag2 = 1;
949 bc->dispBcPtr->data.flag3 = 1;
950 if (bc->bcAttributes.size() >= 1) {
951 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
952 }
953 if (bc->bcAttributes.size() >= 2) {
954 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
955 }
956 if (bc->bcAttributes.size() >= 3) {
957 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
958 }
959 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add ALL " << bc_id;
960 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
961 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_X(.*)"))) {
962 bc->dispBcPtr =
963 boost::make_shared<DisplacementCubitBcDataWithRotation>();
964 bc->dispBcPtr->data.flag4 = 1;
965 bc->dispBcPtr->data.flag5 = 0;
966 bc->dispBcPtr->data.flag6 = 0;
967 // for the ROTATE_X block the angles can be specified with either one or
968 // three attributes, e.g. 1, coords or 1,0,0,coords
969 if (bc->bcAttributes.empty()) {
970 bc->dispBcPtr->data.value4 = 0;
971 MOFEM_LOG("BcMngWorld", Sev::warning)
972 << "Expected one attribute on block on block (angle (1 or 3), "
973 "center coords(3) but have "
974 << bc->bcAttributes.size();
975 } else if (bc->bcAttributes.size() >= 1) {
976 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
977 }
978 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add X " << bc_id;
979 MOFEM_LOG("BcMngWorld", Sev::inform) << *bc->dispBcPtr;
980 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
981 if (auto ext_disp_bc =
983 bc->dispBcPtr.get())) {
984 auto &o = ext_disp_bc->rotOffset;
985 for (int a = 0; a != 3; ++a)
986 o[a] = bc->bcAttributes[bc->bcAttributes.size() - 3 + a];
987 MOFEM_LOG("BcMngWorld", Sev::inform)
988 << "Add Rotate X Center: " << o[0] << " " << o[1] << " "
989 << o[2];
990 }
991 }
992 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_Y(.*)"))) {
993 bc->dispBcPtr =
994 boost::make_shared<DisplacementCubitBcDataWithRotation>();
995 bc->dispBcPtr->data.flag4 = 0;
996 bc->dispBcPtr->data.flag5 = 1;
997 bc->dispBcPtr->data.flag6 = 0;
998 // for the ROTATE_Y block the angles can be specified with either one or
999 // three attributes, e.g. 1, coords or 0,1,0,coords
1000 if (bc->bcAttributes.empty()) {
1001 bc->dispBcPtr->data.value5 = 0;
1002 MOFEM_LOG("BcMngWorld", Sev::warning)
1003 << "Expected one attribute on block on block (angle (1 or 3), "
1004 "center coords(3) but have "
1005 << bc->bcAttributes.size();
1006 } else if (bc->bcAttributes.size() == 1 ||
1007 bc->bcAttributes.size() == 4) {
1008 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
1009 } else if (bc->bcAttributes.size() == 6) {
1010 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1011 }
1012 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Y " << bc_id;
1013 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1014 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1015 if (auto ext_disp_bc =
1017 bc->dispBcPtr.get())) {
1018 auto &o = ext_disp_bc->rotOffset;
1019 for (int a = 0; a != 3; ++a)
1020 o[a] = bc->bcAttributes[bc->bcAttributes.size() - 3 + a];
1021 MOFEM_LOG("BcMngWorld", Sev::inform)
1022 << "Add Rotate Y Center: " << o[0] << " " << o[1] << " "
1023 << o[2];
1024 }
1025 }
1026 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_Z(.*)"))) {
1027 bc->dispBcPtr =
1028 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1029 bc->dispBcPtr->data.flag4 = 0;
1030 bc->dispBcPtr->data.flag5 = 0;
1031 bc->dispBcPtr->data.flag6 = 1;
1032 // for the ROTATE_Z block the angles can be specified with either one or
1033 // three attributes, e.g. 1, coords or 0,0,1,coords
1034 if (bc->bcAttributes.empty()) {
1035 bc->dispBcPtr->data.value6 = 0;
1036 MOFEM_LOG("BcMngWorld", Sev::warning)
1037 << "Expected one attribute on block (angle (1 or 3), center "
1038 "coords(3) but have "
1039 << bc->bcAttributes.size();
1040 } else if (bc->bcAttributes.size() == 1 ||
1041 bc->bcAttributes.size() == 4) {
1042 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1043 } else if (bc->bcAttributes.size() == 3 ||
1044 bc->bcAttributes.size() == 6) {
1045 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1046 }
1047 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Z " << bc_id;
1048 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1049 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1050 if (auto ext_disp_bc =
1052 bc->dispBcPtr.get())) {
1053 auto &o = ext_disp_bc->rotOffset;
1054 for (int a = 0; a != 3; ++a)
1055 o[a] = bc->bcAttributes[bc->bcAttributes.size() - 3 + a];
1056 MOFEM_LOG("BcMngWorld", Sev::inform)
1057 << "Add Rotate Z Center: " << o[0] << " " << o[1] << " "
1058 << o[2];
1059 }
1060 }
1061 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_ALL(.*)"))) {
1062 bc->dispBcPtr =
1063 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1064 bc->dispBcPtr->data.flag4 = 1;
1065 bc->dispBcPtr->data.flag5 = 1;
1066 bc->dispBcPtr->data.flag6 = 1;
1067 if (bc->bcAttributes.size() >= 1) {
1068 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1069 }
1070 if (bc->bcAttributes.size() >= 2) {
1071 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1072 }
1073 if (bc->bcAttributes.size() >= 3) {
1074 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1075 }
1076 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add ALL " << bc_id;
1077 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1078 if (bc->bcAttributes.size() > 3) {
1079 if (auto ext_disp_bc =
1081 bc->dispBcPtr.get())) {
1082 auto &o = ext_disp_bc->rotOffset;
1083 for (int a = 0; a != 3; ++a)
1084 o[a] = bc->bcAttributes[3 + a];
1085 MOFEM_LOG("BcMngWorld", Sev::inform)
1086 << "Add Rotate ALL Center: " << o[0] << " " << o[1] << " "
1087 << o[2];
1088 }
1089 }
1090 }
1091 }
1092 }
1093
1095}
1096
1097template <>
1098MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1099 const std::string problem_name, const std::string block_name,
1100 const std::string field_name, bool get_low_dim_ents) {
1102
1103 CHKERR pushMarkDOFsOnEntities(problem_name, block_name, field_name, 0,
1104 MAX_DOFS_ON_ENTITY, get_low_dim_ents);
1105
1106 auto regex_str =
1107 (boost::format("%s_%s_%s(.*)") % problem_name % field_name % block_name)
1108 .str();
1109
1110 for (auto &m : bcMapByBlockName) {
1111
1112 auto &bc_id = m.first;
1113
1114 if (std::regex_match(bc_id, std::regex(regex_str))) {
1115
1116 auto &bc = m.second;
1117 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
1118 bc->tempBcPtr->data.flag1 = 1;
1119 if (bc->bcAttributes.empty()) {
1120 bc->tempBcPtr->data.value1 = 0;
1121 MOFEM_LOG("BcMngWorld", Sev::warning)
1122 << "Expected one attribute on block but have "
1123 << bc->bcAttributes.size();
1124 } else if (bc->bcAttributes.size() >= 1) {
1125 bc->tempBcPtr->data.value1 = bc->bcAttributes[0];
1126 }
1127 }
1128 }
1129
1131}
1132
1133template <>
1134MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<DisplacementCubitBcData>(
1135 const std::string problem_name, const std::string field_name,
1136 bool get_low_dim_ents, bool block_name_field_prefix) {
1138 // that marks DOFs and create data when are set by cubit nodesets.
1139 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1140 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1141 // that marks DOFs and create data when are set by blocsket.
1142 CHKERR pushMarkDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
1143 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1145}
1146
1147template <>
1148MoFEMErrorCode BcManager::removeBlockDOFsOnEntities<DisplacementCubitBcData>(
1149 const std::string problem_name, const std::string field_name,
1150 bool get_low_dim_ents, bool block_name_field_prefix,
1151 bool is_distributed_mesh) {
1153 // that remove DOFs when are set by cubit nodesets.
1154 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1155 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1156 is_distributed_mesh);
1157 // that remove DOFs when are by blocksets
1158 CHKERR removeBlockDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
1159 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1160 is_distributed_mesh);
1161 // add more ways to remove bcs when appropiate
1163}
1164
1165template <>
1166MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<TemperatureCubitBcData>(
1167 const std::string problem_name, const std::string field_name,
1168 bool get_low_dim_ents, bool block_name_field_prefix) {
1170 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1171 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1172
1173 auto get_block_name = [&]() {
1174 if (block_name_field_prefix)
1175 return (boost::format("%s_FIX_SCALAR") % field_name).str();
1176 else
1177 return field_name;
1178 };
1179
1180 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1181 problem_name, get_block_name(), field_name, get_low_dim_ents);
1183}
1184
1185template <>
1186MoFEMErrorCode BcManager::removeBlockDOFsOnEntities<TemperatureCubitBcData>(
1187 const std::string problem_name, const std::string field_name,
1188 bool get_low_dim_ents, bool block_name_field_prefix,
1189 bool is_distributed_mesh) {
1191 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1192 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1193 is_distributed_mesh);
1194
1195 auto get_block_name = [&]() {
1196 if (block_name_field_prefix)
1197 return (boost::format("%s_FIX_SCALAR") % field_name).str();
1198 else
1199 return field_name;
1200 };
1201
1202 CHKERR removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1203 problem_name, get_block_name(), field_name, get_low_dim_ents,
1204 is_distributed_mesh);
1206}
1207
1208template <>
1209MoFEMErrorCode BcManager::pushMarkDOFsOnEntities<HeatFluxCubitBcData>(
1210 const std::string problem_name, const std::string field_name,
1211 bool get_low_dim_ents, bool block_name_field_prefix) {
1213 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1214 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1216}
1217
1218template <>
1219MoFEMErrorCode BcManager::removeBlockDOFsOnEntities<HeatFluxCubitBcData>(
1220 const std::string problem_name, const std::string field_name,
1221 bool get_low_dim_ents, bool block_name_field_prefix,
1222 bool is_distributed_mesh) {
1224 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1225 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1226 is_distributed_mesh);
1228}
1229
1230std::pair<std::string, std::string>
1231BcManager::extractStringFromBlockId(const std::string block_id,
1232 const std::string prb_name) {
1233
1234 // Assumes that field name is consist with letters and numbers.
1235 // No special characters.
1236 auto field_rgx_str =
1237 (boost::format("%s_([a-zA-Z0-9]*)_(.*)") % prb_name).str();
1238 std::regex field_rgx(field_rgx_str);
1239 std::smatch match_field_name;
1240 std::string field_name;
1241 std::string block_name;
1242
1243 if (std::regex_search(block_id, match_field_name, field_rgx)) {
1244 field_name = match_field_name[1];
1245 block_name = match_field_name[2];
1246 } else {
1248 "Field name and block name can not be resolved");
1249 }
1250
1251 return std::make_pair(field_name, block_name);
1252}
1253
1254} // namespace MoFEM
static Index< 'o', 3 > o
constexpr double a
@ ROW
Definition: definitions.h:123
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:236
#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 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
@ TEMPERATURESET
Definition: definitions.h:155
@ HEATFLUXSET
Definition: definitions.h:156
@ NODESET
Definition: definitions.h:146
@ SIDESET
Definition: definitions.h:147
@ DISPLACEMENTSET
Definition: definitions.h:150
@ BLOCKSET
Definition: definitions.h:148
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#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
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:389
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
FTensor::Index< 'i', SPACE_DIM > i
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr auto field_name
Simple interface for fast problem set-up.
Definition: BcManager.hpp:24
boost::shared_ptr< std::vector< char unsigned > > BcMarkerPtr
Definition: BcManager.hpp:182
MoFEMErrorCode getOptions()
get options
Definition: BcManager.cpp:40
BcMarkerPtr getMergedBlocksMarker(std::vector< std::regex > bc_regex_vec)
Get the Merged Boundary Marker object.
Definition: BcManager.cpp:186
static std::pair< std::string, std::string > extractStringFromBlockId(const std::string block_id, const std::string prb_name)
Extract block name and block name form block id.
Definition: BcManager.cpp:1231
MoFEM::Core & cOre
Definition: BcManager.hpp:299
BcMapByBlockName bcMapByBlockName
Definition: BcManager.hpp:301
SmartPetscObj< IS > getBlockIS(const std::string block_prefix, const std::string block_name, const std::string field_name, const std::string problem_name, int lo, int hi, SmartPetscObj< IS > is_expand=SmartPetscObj< IS >())
Get block IS.
Definition: BcManager.cpp:217
MoFEMErrorCode removeBlockDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true, bool is_distributed_mesh=true)
Remove DOFs from problem.
Definition: BcManager.cpp:48
BcManager(const MoFEM::Core &core)
Definition: BcManager.cpp:16
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: BcManager.cpp:9
boost::shared_ptr< BCs > popMarkDOFsOnEntities(const std::string block_name)
Get bc data and remove element.
Definition: BcManager.cpp:175
MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true)
Mark block DOFs.
Definition: BcManager.cpp:86
BcMapByBlockName & getBcMapByBlockName()
Get the bc map.
Definition: BcManager.hpp:198
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
Core (interface) class.
Definition: Core.hpp:82
Deprecated interface functions.
A specialized version of DisplacementCubitBcData that includes an additional rotation offset.
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Definition: LogManager.cpp:348
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
Definition: LogManager.cpp:399
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Definition: LogManager.cpp:340
Interface for managing meshsets containing materials and boundary conditions.
Problem manager is used to build and partition problems.
intrusive_ptr for managing petsc objects
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.