v0.15.0
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
8namespace BcManagerImplTools {
9
10auto get_dim(const Range &ents) {
11 for (auto d : {3, 2, 1})
12 if (ents.num_of_dimension(d))
13 return d;
14 return 0;
15};
16
17auto get_adj_ents(moab::Interface &moab, const Range &ents) {
18 Range verts;
19 CHK_MOAB_THROW(moab.get_connectivity(ents, verts, true), "get verts");
20 const auto dim = get_dim(ents);
21 for (size_t d = 1; d < dim; ++d) {
22 for (auto dd = d + 1; dd <= dim; ++dd) {
23 CHK_MOAB_THROW(moab.get_adjacencies(ents.subset_by_dimension(dd), d,
24 false, verts, moab::Interface::UNION),
25 "get adj");
26 }
27 }
28 verts.merge(ents);
29 return verts;
30}
31} // namespace BcManagerImplTools
32
34BcManager::query_interface(boost::typeindex::type_index type_index,
35 UnknownInterface **iface) const {
37 *iface = const_cast<BcManager *>(this);
39}
40
41BcManager::BcManager(const Core &core) : cOre(const_cast<Core &>(core)) {
42
43 if (!LogManager::checkIfChannelExist("BcMngWorld")) {
44 auto core_log = logging::core::get();
45
46 core_log->add_sink(
48 core_log->add_sink(
50 core_log->add_sink(
52
53 LogManager::setLog("BcMngWorld");
54 LogManager::setLog("BcMngSync");
55 LogManager::setLog("BcMngSelf");
56
57 MOFEM_LOG_TAG("BcMngWorld", "BcMng");
58 MOFEM_LOG_TAG("BcMngSync", "BcMng");
59 MOFEM_LOG_TAG("BcMngSelf", "BcMng");
60 }
61
62 MOFEM_LOG("BcMngWorld", Sev::noisy) << "BC manager created";
63}
64
67 PetscOptionsBegin(PETSC_COMM_WORLD, "", "BcManager options", "none");
68 PetscOptionsEnd();
70}
71
73 const std::string problem_name, const std::string block_name,
74 const std::string field_name, int lo, int hi, bool get_low_dim_ents,
75 bool is_distributed_mesh) {
76 Interface &m_field = cOre;
77 auto prb_mng = m_field.getInterface<ProblemsManager>();
79
80 CHKERR pushMarkDOFsOnEntities(problem_name, block_name, field_name, lo, hi,
81 get_low_dim_ents);
82
83 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
84 const int hi) {
85 if (is_distributed_mesh)
86 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
87 hi);
88 else
89 return prb_mng->removeDofsOnEntitiesNotDistributed(
90 problem_name, field_name, ents, lo, hi);
91 };
92
93 for (auto m :
94 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
95
96 (boost::format("%s(.*)") % block_name).str()
97
98 ))
99
100 ) {
101 const std::string bc_id =
102 problem_name + "_" + field_name + "_" + m->getName();
103 CHKERR remove_dofs_on_ents(bcMapByBlockName.at(bc_id)->bcEnts, lo, hi);
104 bcMapByBlockName.at(bc_id)->bcMarkers = std::vector<unsigned char>();
105 }
106
108}
109
111 const std::string block_name,
112 const std::string field_name,
113 int lo, int hi,
114 bool get_low_dim_ents) {
115 Interface &m_field = cOre;
116 auto prb_mng = m_field.getInterface<ProblemsManager>();
118
119 // if(problem_name.size())
120 // MOFEM_LOG("BcMngWorld", Sev::warning)
121 // << "Argument problem_name has no effect";
122
123 auto fix_disp = [&]() {
125
126 auto mark_fix_dofs = [&](std::vector<unsigned char> &marked_field_dofs,
127 const auto lo, const auto hi) {
128 return prb_mng->modifyMarkDofs(problem_name, ROW, field_name, lo, hi,
130 marked_field_dofs);
131 };
132
133 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
135 for (auto m : meshset_vec_ptr) {
136 auto bc = boost::make_shared<BCs>();
137 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
138 bc->bcEnts, true);
139 CHKERR m->getAttributes(bc->bcAttributes);
140
141 if (problem_name.size())
142 CHKERR mark_fix_dofs(bc->bcMarkers, lo, hi);
143 MOFEM_LOG("BcMngWorld", Sev::verbose)
144 << "Found block " << m->getName() << " number of attributes "
145 << bc->bcAttributes.size();
146
147 if (get_low_dim_ents) {
148 auto low_dim_ents =
149 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
150 bc->bcEnts.swap(low_dim_ents);
151 }
152
153 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
154 bc->bcEnts);
155 if (problem_name.size())
156 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
157 bc->bcEnts, bc->bcMarkers);
158
159 const std::string bc_id =
160 problem_name + "_" + field_name + "_" + m->getName();
161 bcMapByBlockName[bc_id] = bc;
162 }
164 };
165
166 CHKERR iterate_meshsets(
167
168 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
169
170 (boost::format("%s(.*)") % block_name).str()
171
172 ))
173
174 );
175
177 };
178
179 CHKERR fix_disp();
180
182}
183
184boost::shared_ptr<BcManager::BCs>
185BcManager::popMarkDOFsOnEntities(const std::string block_name) {
186 auto bc_it = bcMapByBlockName.find(block_name);
187 if (bc_it != bcMapByBlockName.end()) {
188 auto bc = bc_it->second;
189 bcMapByBlockName.erase(bc_it);
190 return bc;
191 }
192 return boost::shared_ptr<BCs>();
193}
194
195Range BcManager::getMergedBlocksRange(std::vector<std::regex> bc_regex_vec) {
196 Range ents;
197 if (bcMapByBlockName.size()) {
198 for (auto b : bcMapByBlockName) {
199 for (auto &reg_name : bc_regex_vec) {
200 if (std::regex_match(b.first, reg_name)) {
201 ents.merge(b.second->bcEnts);
202 }
203 }
204 }
205 }
206 return ents;
207}
208
210BcManager::getMergedBlocksMarker(std::vector<std::regex> bc_regex_vec) {
211 BcManager::BcMarkerPtr boundary_marker_ptr;
212 if (bcMapByBlockName.size()) {
213 for (auto b : bcMapByBlockName) {
214 for (auto &reg_name : bc_regex_vec) {
215 if (std::regex_match(b.first, reg_name)) {
216 if (!boundary_marker_ptr)
217 boundary_marker_ptr =
218 boost::make_shared<std::vector<char unsigned>>();
219 boundary_marker_ptr->resize(b.second->bcMarkers.size(), 0);
220 for (int i = 0; i != b.second->bcMarkers.size(); ++i) {
221 (*boundary_marker_ptr)[i] |= b.second->bcMarkers[i];
222 }
223 }
224 }
225 }
226 }
227 return boundary_marker_ptr;
228}
229
231 const std::vector<BcManager::BcMarkerPtr> &boundary_markers_ptr_vec) {
232 auto boundary_marker_ptr = boost::make_shared<std::vector<char unsigned>>();
233 for (auto &bcm : boundary_markers_ptr_vec) {
234 boundary_marker_ptr->resize(bcm->size(), 0);
235 for (int i = 0; i != bcm->size(); ++i)
236 (*boundary_marker_ptr)[i] |= (*bcm)[i];
237 }
238 return boundary_marker_ptr;
239}
240
241SmartPetscObj<IS> BcManager::getBlockIS(const std::string block_prefix,
242 const std::string block_name,
243 const std::string field_name,
244 const std::string problem_name, int lo,
245 int hi, SmartPetscObj<IS> is_expand) {
246 Interface &m_field = cOre;
247
248 const std::string bc_id =
249 block_prefix + "_" + field_name + "_" + block_name + "(.*)";
250
251 Range bc_ents;
252 for (auto bc : getBcMapByBlockName()) {
253 if (std::regex_match(bc.first, std::regex(bc_id))) {
254 bc_ents.merge(*(bc.second->getBcEntsPtr()));
255 MOFEM_LOG("BcMngWorld", Sev::verbose)
256 << "Get entities from block and add to IS. Block name " << bc.first;
257 }
258 }
259
260 SmartPetscObj<IS> is_bc;
261 auto get_is = [&]() {
263 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(bc_ents);
264 CHKERR m_field.getInterface<ISManager>()->isCreateProblemFieldAndRank(
265 problem_name, ROW, field_name, lo, hi, is_bc, &bc_ents);
266 if (is_expand) {
267 IS is_tmp;
268 CHKERR ISExpand(is_bc, is_expand, &is_tmp);
269 is_bc = SmartPetscObj<IS>(is_tmp);
270 }
271 CHKERR ISSort(is_bc);
273 };
274
275 if (get_is())
276 CHK_THROW_MESSAGE(MOFEM_DATA_INCONSISTENCY, "IS is not created");
277
278 return is_bc;
279}
280
281SmartPetscObj<IS> BcManager::getBlockIS(const std::string problem_name,
282 const std::string block_name,
283 const std::string field_name, int lo,
284 int hi, SmartPetscObj<IS> is_expand) {
285 return getBlockIS(problem_name, block_name, field_name, problem_name, lo, hi,
286 is_expand);
287}
288
289template <>
292 const std::string problem_name, const std::string field_name,
293 bool get_low_dim_ents, bool block_name_field_prefix,
294 bool is_distributed_mesh) {
295 Interface &m_field = cOre;
296 auto prb_mng = m_field.getInterface<ProblemsManager>();
298
299 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
300 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
301
302 std::array<Range, 3> ents_to_remove;
303
304 for (auto m :
305
308
309 const std::string bc_id =
310 problem_name + "_" + field_name + "_DISPLACEMENTSET" +
311 boost::lexical_cast<std::string>(m->getMeshsetId());
312
313 auto bc = bcMapByBlockName.at(bc_id);
314
315 if (bc->dispBcPtr) {
316 if (bc->dispBcPtr->data.flag1) {
317 ents_to_remove[0].merge(bc->bcEnts);
318 }
319 if (bc->dispBcPtr->data.flag2) {
320 ents_to_remove[1].merge(bc->bcEnts);
321 }
322 if (bc->dispBcPtr->data.flag3) {
323 ents_to_remove[2].merge(bc->bcEnts);
324 }
325 if (bc->dispBcPtr->data.flag4) {
326 ents_to_remove[1].merge(bc->bcEnts);
327 ents_to_remove[2].merge(bc->bcEnts);
328 }
329 if (bc->dispBcPtr->data.flag5) {
330 ents_to_remove[0].merge(bc->bcEnts);
331 ents_to_remove[2].merge(bc->bcEnts);
332 }
333 if (bc->dispBcPtr->data.flag6) {
334 ents_to_remove[0].merge(bc->bcEnts);
335 ents_to_remove[1].merge(bc->bcEnts);
336 }
337 }
338 bc->bcMarkers = std::vector<unsigned char>();
339 }
340
341 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
342 const int hi) {
343 if (is_distributed_mesh)
344 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
345 hi);
346 else
347 return prb_mng->removeDofsOnEntitiesNotDistributed(
348 problem_name, field_name, ents, lo, hi);
349 };
350
351 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
352 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
353 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
354
356}
357
358template <>
361 const std::string problem_name, const std::string field_name,
362 bool get_low_dim_ents, bool block_name_field_prefix,
363 bool is_distributed_mesh) {
364 Interface &m_field = cOre;
365 auto prb_mng = m_field.getInterface<ProblemsManager>();
367
368 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
369 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
370
371 Range ents_to_remove;
372
373 for (auto m :
374
377
378 ) {
379 const std::string bc_id =
380 problem_name + "_" + field_name + "_TEMPERATURESET" +
381 boost::lexical_cast<std::string>(m->getMeshsetId());
382 auto bc = bcMapByBlockName.at(bc_id);
383 ents_to_remove.merge(bc->bcEnts);
384 bc->bcMarkers = std::vector<unsigned char>();
385 }
386
387 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
388 const int hi) {
389 if (is_distributed_mesh)
390 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
391 hi);
392 else
393 return prb_mng->removeDofsOnEntitiesNotDistributed(
394 problem_name, field_name, ents, lo, hi);
395 };
396
397 CHKERR remove_dofs_on_ents(ents_to_remove, 0, MAX_DOFS_ON_ENTITY);
398
400}
401
402template <>
404 const std::string problem_name, const std::string field_name,
405 bool get_low_dim_ents, bool block_name_field_prefix,
406 bool is_distributed_mesh) {
407 Interface &m_field = cOre;
408 auto prb_mng = m_field.getInterface<ProblemsManager>();
410
411 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
412 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
413
414 Range ents_to_remove;
415
416 for (auto m :
417
420
421 ) {
422 const std::string bc_id =
423 problem_name + "_" + field_name + "_HEATFLUXSET" +
424 boost::lexical_cast<std::string>(m->getMeshsetId());
425 auto bc = bcMapByBlockName.at(bc_id);
426 ents_to_remove.merge(bc->bcEnts);
427 bc->bcMarkers = std::vector<unsigned char>();
428 }
429
430 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
431 const int hi) {
432 if (is_distributed_mesh)
433 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
434 hi);
435 else
436 return prb_mng->removeDofsOnEntitiesNotDistributed(
437 problem_name, field_name, ents, lo, hi);
438 };
439
440 CHKERR remove_dofs_on_ents(ents_to_remove, 0, MAX_DOFS_ON_ENTITY);
441
443}
444
445template <>
448 const std::string problem_name, const std::string field_name,
449 bool get_low_dim_ents, bool block_name_field_prefix,
450 bool is_distributed_mesh) {
451 Interface &m_field = cOre;
452 auto prb_mng = m_field.getInterface<ProblemsManager>();
454
455 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
456 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
457
458 std::array<Range, 3> ents_to_remove;
459
460 for (auto m :
461
464
465 const auto block_name = m->getName();
466
467 std::string bc_id = problem_name + "_" + field_name + "_" + block_name;
468 std::string regex_str;
469 if (block_name_field_prefix) {
470 regex_str = (boost::format("%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
471 "DISPLACEMENT|ROTATE))(.*)") %
472 problem_name % field_name % field_name)
473 .str();
474 } else {
475 regex_str = (boost::format("%s_%s_((FIX_(ALL|X|Y|Z))|("
476 "DISPLACEMENT|ROTATE))(.*)") %
477 problem_name % field_name)
478 .str();
479 }
480
481 if (std::regex_match(bc_id, std::regex(regex_str))) {
482
483 auto bc = bcMapByBlockName.at(bc_id);
484
485 if (auto disp_bc = bc->dispBcPtr) {
486 if (disp_bc->data.flag1) {
487 ents_to_remove[0].merge(bc->bcEnts);
488 }
489 if (disp_bc->data.flag2) {
490 ents_to_remove[1].merge(bc->bcEnts);
491 }
492 if (disp_bc->data.flag3) {
493 ents_to_remove[2].merge(bc->bcEnts);
494 }
495 if (disp_bc->data.flag4) {
496 ents_to_remove[1].merge(bc->bcEnts);
497 ents_to_remove[2].merge(bc->bcEnts);
498 }
499 if (disp_bc->data.flag5) {
500 ents_to_remove[0].merge(bc->bcEnts);
501 ents_to_remove[2].merge(bc->bcEnts);
502 }
503 if (disp_bc->data.flag6) {
504 ents_to_remove[0].merge(bc->bcEnts);
505 ents_to_remove[1].merge(bc->bcEnts);
506 }
507 } else {
508 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
509 "BC type not implemented");
510 }
511 }
512 }
513
514 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
515 const int hi) {
516 if (is_distributed_mesh)
517 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
518 hi);
519 else
520 return prb_mng->removeDofsOnEntitiesNotDistributed(
521 problem_name, field_name, ents, lo, hi);
522 };
523
524 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
525 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
526 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
527
529}
530
531template <>
534 const std::string problem_name, const std::string block_name,
535 const std::string field_name, bool get_low_dim_ents,
536 bool is_distributed_mesh) {
537 Interface &m_field = cOre;
538 auto prb_mng = m_field.getInterface<ProblemsManager>();
540
541 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
542 problem_name, block_name, field_name, get_low_dim_ents);
543
544 Range ents_to_remove;
545
546 for (auto m :
547
550
551 std::string bc_id = problem_name + "_" + field_name + "_" + m->getName();
552
553 auto str = boost::format("%s_%s_%s(.*)")
554
555 % problem_name % field_name % block_name;
556
557 if (std::regex_match(bc_id, std::regex(str.str()))) {
558
559 auto bc = bcMapByBlockName.at(bc_id);
560
561 if (auto temp_bc = bc->tempBcPtr) {
562 if (temp_bc->data.flag1) {
563 ents_to_remove.merge(bc->bcEnts);
564 }
565 } else {
566 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
567 "BC type not implemented");
568 }
569 }
570 }
571
572 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
573 const int hi) {
574 if (is_distributed_mesh)
575 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
576 hi);
577 else
578 return prb_mng->removeDofsOnEntitiesNotDistributed(
579 problem_name, field_name, ents, lo, hi);
580 };
581
582 CHKERR remove_dofs_on_ents(ents_to_remove, 0, MAX_DOFS_ON_ENTITY);
583
585}
586
587template <>
590 const std::string problem_name, const std::string field_name,
591 bool get_low_dim_ents, bool block_name_field_prefix) {
592 Interface &m_field = cOre;
593 auto prb_mng = m_field.getInterface<ProblemsManager>();
595
596 // if(problem_name.size()==0)
597 // MOFEM_LOG("BcMngWorld", Sev::warning)
598 // << "Argument problem_name has no effect";
599
600 if (block_name_field_prefix)
601 MOFEM_LOG("BcMngWorld", Sev::warning)
602 << "Argument block_name_field_prefix=true has no effect";
603
604 auto fix_disp = [&]() {
606
607 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
609 for (auto m : meshset_vec_ptr) {
610 auto bc = boost::make_shared<BCs>();
611 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
612 bc->bcEnts, true);
613 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
614 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
615
616 MOFEM_LOG("BcMngWorld", Sev::verbose)
617 << "Found block DISPLACEMENTSET id = " << m->getMeshsetId();
618 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
619
620 MOFEM_LOG("BcMngSync", Sev::noisy)
621 << "Found block DISPLACEMENTSET id = " << m->getMeshsetId()
622 << " nb. of entities " << bc->bcEnts.size()
623 << " highest dim of entities "
624 << BcManagerImplTools::get_dim(bc->bcEnts);
625 MOFEM_LOG("BcMngSync", Sev::noisy) << *bc->dispBcPtr;
626 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
627
628 if (problem_name.size()) {
629
630 if (bc->dispBcPtr->data.flag1)
631 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
633 bc->bcMarkers);
634 if (bc->dispBcPtr->data.flag2)
635 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
637 bc->bcMarkers);
638 if (bc->dispBcPtr->data.flag3)
639 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
641 bc->bcMarkers);
642 if (bc->dispBcPtr->data.flag4) {
643
644 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
646 bc->bcMarkers);
647 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
649 bc->bcMarkers);
650 }
651 if (bc->dispBcPtr->data.flag5) {
652
653 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
655 bc->bcMarkers);
656 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
658 bc->bcMarkers);
659 }
660 if (bc->dispBcPtr->data.flag6) {
661
662 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
664 bc->bcMarkers);
665 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
667 bc->bcMarkers);
668 }
669 }
670
671 if (get_low_dim_ents) {
672 auto low_dim_ents =
673 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
674 bc->bcEnts.swap(low_dim_ents);
675 }
676
677 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
678 bc->bcEnts);
679 if (problem_name.size())
680 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
681 bc->bcEnts, bc->bcMarkers);
682
683 const std::string bc_id =
684 problem_name + "_" + field_name + "_DISPLACEMENTSET" +
685 boost::lexical_cast<std::string>(m->getMeshsetId());
686 bcMapByBlockName[bc_id] = bc;
687 }
689 };
690
691 CHKERR iterate_meshsets(
692
695
696 );
697
699 };
700
701 CHKERR fix_disp();
702
704}
705
706template <>
708 const std::string problem_name, const std::string field_name,
709 bool get_low_dim_ents, bool block_name_field_prefix) {
710 Interface &m_field = cOre;
711 auto prb_mng = m_field.getInterface<ProblemsManager>();
713
714 if (block_name_field_prefix)
715 MOFEM_LOG("BcMngWorld", Sev::warning)
716 << "Argument block_name_field_prefix=true has no effect";
717
718 auto fix_temp = [&]() {
720
721 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
723 for (auto m : meshset_vec_ptr) {
724 auto bc = boost::make_shared<BCs>();
725 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
726 bc->bcEnts, true);
727 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
728 CHKERR m->getBcDataStructure(*(bc->tempBcPtr));
729
730 MOFEM_LOG("BcMngWorld", Sev::verbose)
731 << "Found block TEMPERATURESET id = " << m->getMeshsetId();
732 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->tempBcPtr;
733
734 CHKERR prb_mng->modifyMarkDofs(
735 problem_name, ROW, field_name, 0, MAX_DOFS_ON_ENTITY,
736 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
737
738 if (get_low_dim_ents) {
739 auto low_dim_ents =
740 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
741 bc->bcEnts.swap(low_dim_ents);
742 }
743
744 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
745 bc->bcEnts);
746 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
747 bc->bcEnts, bc->bcMarkers);
748
749 const std::string bc_id =
750 problem_name + "_" + field_name + "_TEMPERATURESET" +
751 boost::lexical_cast<std::string>(m->getMeshsetId());
752 bcMapByBlockName[bc_id] = bc;
753 }
755 };
756
757 CHKERR iterate_meshsets(
758
761
762 );
763
765 };
766
767 CHKERR fix_temp();
768
770}
771
772template <>
774 const std::string problem_name, const std::string field_name,
775 bool get_low_dim_ents, bool block_name_field_prefix) {
776 Interface &m_field = cOre;
777 auto prb_mng = m_field.getInterface<ProblemsManager>();
779
780 if (block_name_field_prefix)
781 MOFEM_LOG("BcMngWorld", Sev::warning)
782 << "Argument block_name_field_prefix=true has no effect";
783
784 auto fix_disp = [&]() {
786
787 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
789 for (auto m : meshset_vec_ptr) {
790 auto bc = boost::make_shared<BCs>();
791 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
792 bc->bcEnts, true);
793 bc->heatFluxBcPtr = boost::make_shared<HeatFluxCubitBcData>();
794 CHKERR m->getBcDataStructure(*(bc->heatFluxBcPtr));
795
796 CHKERR prb_mng->modifyMarkDofs(
797 problem_name, ROW, field_name, 0, MAX_DOFS_ON_ENTITY,
798 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
799
800 MOFEM_LOG("BcMngWorld", Sev::inform)
801 << "Found block HEATFLUX id = " << m->getMeshsetId();
802 MOFEM_LOG("BcMngWorld", Sev::inform) << *bc->heatFluxBcPtr;
803
804 if (get_low_dim_ents) {
805 auto low_dim_ents =
806 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
807 bc->bcEnts.swap(low_dim_ents);
808 }
809
810 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
811 bc->bcEnts);
812 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
813 bc->bcEnts, bc->bcMarkers);
814
815 const std::string bc_id =
816 problem_name + "_" + field_name + "_HEATFLUXSET" +
817 boost::lexical_cast<std::string>(m->getMeshsetId());
818 bcMapByBlockName[bc_id] = bc;
819 }
821 };
822
823 CHKERR iterate_meshsets(
824
827
828 );
829
831 };
832
833 CHKERR fix_disp();
834
836}
837
838template <>
841 const std::string problem_name, const std::string field_name,
842 bool get_low_dim_ents, bool block_name_field_prefix) {
844
845 auto mark_dofs = [&](const string block_name, const int &idx_0,
846 const int &idx_1) {
848 if (block_name_field_prefix) {
849 const string field_block = field_name + "_" + block_name;
850 CHKERR pushMarkDOFsOnEntities(problem_name, field_block, field_name,
851 idx_0, idx_1, get_low_dim_ents);
852 } else {
853
854 CHKERR pushMarkDOFsOnEntities(problem_name, block_name, field_name, idx_0,
855 idx_1, get_low_dim_ents);
856 }
858 };
859
860 // displacement
861 CHKERR mark_dofs("FIX_X", 0, 0);
862 CHKERR mark_dofs("FIX_Y", 1, 1);
863 CHKERR mark_dofs("FIX_Z", 2, 2);
864 CHKERR mark_dofs("FIX_ALL", 0, MAX_DOFS_ON_ENTITY);
865
866 // rotation
867 CHKERR mark_dofs("ROTATE_X", 1, 1);
868 CHKERR mark_dofs("ROTATE_X", 2, 2);
869 CHKERR mark_dofs("ROTATE_Y", 0, 0);
870 CHKERR mark_dofs("ROTATE_Y", 2, 2);
871 CHKERR mark_dofs("ROTATE_Z", 0, 0);
872 CHKERR mark_dofs("ROTATE_Z", 1, 1);
873 CHKERR mark_dofs("ROTATE_ALL", 0, MAX_DOFS_ON_ENTITY);
874
875 std::string regex_str;
876 if (block_name_field_prefix) {
877 regex_str = (boost::format("%s_%s_%s_(.*)") % problem_name % field_name %
879 .str();
880 } else {
881 regex_str = (boost::format("%s_%s_(.*)") % problem_name % field_name).str();
882 }
883
884 for (auto &m : bcMapByBlockName) {
885 auto &bc_id = m.first;
886 if (std::regex_match(bc_id, std::regex(regex_str))) {
887 auto &bc = m.second;
888 if (std::regex_match(bc_id, std::regex("(.*)_FIX_X(.*)"))) {
889 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
890 bc->dispBcPtr->data.flag1 = 1;
891 if (bc->bcAttributes.empty()) {
892 bc->dispBcPtr->data.value1 = 0;
893 MOFEM_LOG("BcMngWorld", Sev::warning)
894 << "Expected one attribute on block but have "
895 << bc->bcAttributes.size();
896 } else if (bc->bcAttributes.size() >= 1) {
897 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
898 }
899 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add X " << bc_id;
900 MOFEM_LOG("BcMngWorld", Sev::inform) << *bc->dispBcPtr;
901 } else if (std::regex_match(bc_id, std::regex("(.*)_FIX_Y(.*)"))) {
902 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
903 bc->dispBcPtr->data.flag2 = 1;
904 if (bc->bcAttributes.empty()) {
905 bc->dispBcPtr->data.value2 = 0;
906 MOFEM_LOG("BcMngWorld", Sev::warning)
907 << "Expected one attribute on block but have "
908 << bc->bcAttributes.size();
909 } else if (bc->bcAttributes.size() == 1) {
910 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
911 } else if (bc->bcAttributes.size() >= 2) {
912 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
913 }
914 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Y " << bc_id;
915 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
916 } else if (std::regex_match(bc_id, std::regex("(.*)_FIX_Z(.*)"))) {
917 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
918 bc->dispBcPtr->data.flag3 = 1;
919 if (bc->bcAttributes.empty()) {
920 bc->dispBcPtr->data.value3 = 0;
921 MOFEM_LOG("BcMngWorld", Sev::warning)
922 << "Expected one attribute on block but have "
923 << bc->bcAttributes.size();
924 } else if (bc->bcAttributes.size() == 1) {
925 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
926 } else if (bc->bcAttributes.size() == 3) {
927 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
928 }
929 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Z " << bc_id;
930 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
931 } else if (std::regex_match(bc_id, std::regex("(.*)_FIX_ALL(.*)"))) {
932 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
933 bc->dispBcPtr->data.flag1 = 1;
934 bc->dispBcPtr->data.flag2 = 1;
935 bc->dispBcPtr->data.flag3 = 1;
936 if (bc->bcAttributes.size() >= 1) {
937 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
938 }
939 if (bc->bcAttributes.size() >= 2) {
940 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
941 }
942 if (bc->bcAttributes.size() >= 3) {
943 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
944 }
945 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add ALL " << bc_id;
946 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
947 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_X(.*)"))) {
948 bc->dispBcPtr =
949 boost::make_shared<DisplacementCubitBcDataWithRotation>();
950 bc->dispBcPtr->data.flag4 = 1;
951 bc->dispBcPtr->data.flag5 = 0;
952 bc->dispBcPtr->data.flag6 = 0;
953 // for the ROTATE_X block the angles can be specified with either one or
954 // three attributes, e.g. 1, coords or 1,0,0,coords
955 if (bc->bcAttributes.empty()) {
956 bc->dispBcPtr->data.value4 = 0;
957 MOFEM_LOG("BcMngWorld", Sev::warning)
958 << "Expected one attribute on block on block (angle (1 or 3), "
959 "center coords(3) but have "
960 << bc->bcAttributes.size();
961 } else if (bc->bcAttributes.size() >= 1) {
962 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
963 }
964 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add X " << bc_id;
965 MOFEM_LOG("BcMngWorld", Sev::inform) << *bc->dispBcPtr;
966 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
967 if (auto ext_disp_bc =
969 bc->dispBcPtr.get())) {
970 auto &o = ext_disp_bc->rotOffset;
971 for (int a = 0; a != 3; ++a)
972 o[a] = bc->bcAttributes[bc->bcAttributes.size() - 3 + a];
973 MOFEM_LOG("BcMngWorld", Sev::inform)
974 << "Add Rotate X Center: " << o[0] << " " << o[1] << " "
975 << o[2];
976 }
977 }
978 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_Y(.*)"))) {
979 bc->dispBcPtr =
980 boost::make_shared<DisplacementCubitBcDataWithRotation>();
981 bc->dispBcPtr->data.flag4 = 0;
982 bc->dispBcPtr->data.flag5 = 1;
983 bc->dispBcPtr->data.flag6 = 0;
984 // for the ROTATE_Y block the angles can be specified with either one or
985 // three attributes, e.g. 1, coords or 0,1,0,coords
986 if (bc->bcAttributes.empty()) {
987 bc->dispBcPtr->data.value5 = 0;
988 MOFEM_LOG("BcMngWorld", Sev::warning)
989 << "Expected one attribute on block on block (angle (1 or 3), "
990 "center coords(3) but have "
991 << bc->bcAttributes.size();
992 } else if (bc->bcAttributes.size() == 1 ||
993 bc->bcAttributes.size() == 4) {
994 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
995 } else if (bc->bcAttributes.size() == 6) {
996 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
997 }
998 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Y " << bc_id;
999 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1000 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1001 if (auto ext_disp_bc =
1003 bc->dispBcPtr.get())) {
1004 auto &o = ext_disp_bc->rotOffset;
1005 for (int a = 0; a != 3; ++a)
1006 o[a] = bc->bcAttributes[bc->bcAttributes.size() - 3 + a];
1007 MOFEM_LOG("BcMngWorld", Sev::inform)
1008 << "Add Rotate Y Center: " << o[0] << " " << o[1] << " "
1009 << o[2];
1010 }
1011 }
1012 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_Z(.*)"))) {
1013 bc->dispBcPtr =
1014 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1015 bc->dispBcPtr->data.flag4 = 0;
1016 bc->dispBcPtr->data.flag5 = 0;
1017 bc->dispBcPtr->data.flag6 = 1;
1018 // for the ROTATE_Z block the angles can be specified with either one or
1019 // three attributes, e.g. 1, coords or 0,0,1,coords
1020 if (bc->bcAttributes.empty()) {
1021 bc->dispBcPtr->data.value6 = 0;
1022 MOFEM_LOG("BcMngWorld", Sev::warning)
1023 << "Expected one attribute on block (angle (1 or 3), center "
1024 "coords(3) but have "
1025 << bc->bcAttributes.size();
1026 } else if (bc->bcAttributes.size() == 1 ||
1027 bc->bcAttributes.size() == 4) {
1028 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1029 } else if (bc->bcAttributes.size() == 3 ||
1030 bc->bcAttributes.size() == 6) {
1031 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1032 }
1033 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add Z " << bc_id;
1034 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1035 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1036 if (auto ext_disp_bc =
1038 bc->dispBcPtr.get())) {
1039 auto &o = ext_disp_bc->rotOffset;
1040 for (int a = 0; a != 3; ++a)
1041 o[a] = bc->bcAttributes[bc->bcAttributes.size() - 3 + a];
1042 MOFEM_LOG("BcMngWorld", Sev::inform)
1043 << "Add Rotate Z Center: " << o[0] << " " << o[1] << " "
1044 << o[2];
1045 }
1046 }
1047 } else if (std::regex_match(bc_id, std::regex("(.*)_ROTATE_ALL(.*)"))) {
1048 bc->dispBcPtr =
1049 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1050 bc->dispBcPtr->data.flag4 = 1;
1051 bc->dispBcPtr->data.flag5 = 1;
1052 bc->dispBcPtr->data.flag6 = 1;
1053 if (bc->bcAttributes.size() >= 1) {
1054 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1055 }
1056 if (bc->bcAttributes.size() >= 2) {
1057 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1058 }
1059 if (bc->bcAttributes.size() >= 3) {
1060 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1061 }
1062 MOFEM_LOG("BcMngWorld", Sev::inform) << "Add ALL " << bc_id;
1063 MOFEM_LOG("BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1064 if (bc->bcAttributes.size() > 3) {
1065 if (auto ext_disp_bc =
1067 bc->dispBcPtr.get())) {
1068 auto &o = ext_disp_bc->rotOffset;
1069 for (int a = 0; a != 3; ++a)
1070 o[a] = bc->bcAttributes[3 + a];
1071 MOFEM_LOG("BcMngWorld", Sev::inform)
1072 << "Add Rotate ALL Center: " << o[0] << " " << o[1] << " "
1073 << o[2];
1074 }
1075 }
1076 }
1077 }
1078 }
1079
1081}
1082
1083template <>
1085 const std::string problem_name, const std::string block_name,
1086 const std::string field_name, bool get_low_dim_ents) {
1088
1089 CHKERR pushMarkDOFsOnEntities(problem_name, block_name, field_name, 0,
1090 MAX_DOFS_ON_ENTITY, get_low_dim_ents);
1091
1092 auto regex_str =
1093 (boost::format("%s_%s_%s(.*)") % problem_name % field_name % block_name)
1094 .str();
1095
1096 for (auto &m : bcMapByBlockName) {
1097
1098 auto &bc_id = m.first;
1099
1100 if (std::regex_match(bc_id, std::regex(regex_str))) {
1101
1102 auto &bc = m.second;
1103 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
1104 bc->tempBcPtr->data.flag1 = 1;
1105 if (bc->bcAttributes.empty()) {
1106 bc->tempBcPtr->data.value1 = 0;
1107 MOFEM_LOG("BcMngWorld", Sev::warning)
1108 << "Expected one attribute on block but have "
1109 << bc->bcAttributes.size();
1110 } else if (bc->bcAttributes.size() >= 1) {
1111 bc->tempBcPtr->data.value1 = bc->bcAttributes[0];
1112 }
1113 }
1114 }
1115
1117}
1118
1119template <>
1121 const std::string problem_name, const std::string field_name,
1122 bool get_low_dim_ents, bool block_name_field_prefix) {
1124 // that marks DOFs and create data when are set by cubit nodesets.
1126 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1127 // that marks DOFs and create data when are set by blocsket.
1129 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1130 // get normal displacements boundary conditions.
1132 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1133 // get analytical displacements boundary conditions.
1135 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1137}
1138
1139template <>
1141 const std::string problem_name, const std::string field_name,
1142 bool get_low_dim_ents, bool block_name_field_prefix,
1143 bool is_distributed_mesh) {
1145 // that remove DOFs when are set by cubit nodesets.
1147 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1148 is_distributed_mesh);
1149 // that remove DOFs when are by blocksets
1151 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1152 is_distributed_mesh);
1153 // add more ways to remove bcs when appropiate
1155}
1156
1157template <>
1159 const std::string problem_name, const std::string field_name,
1160 bool get_low_dim_ents, bool block_name_field_prefix) {
1163 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1164
1165 auto get_block_name = [&]() {
1166 if (block_name_field_prefix)
1167 return (boost::format("%s_FIX_SCALAR") % field_name).str();
1168 else
1169 return field_name;
1170 };
1171
1173 problem_name, get_block_name(), field_name, get_low_dim_ents);
1175}
1176
1177template <>
1179 const std::string problem_name, const std::string field_name,
1180 bool get_low_dim_ents, bool block_name_field_prefix,
1181 bool is_distributed_mesh) {
1184 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1185 is_distributed_mesh);
1186
1187 auto get_block_name = [&]() {
1188 if (block_name_field_prefix)
1189 return (boost::format("%s_FIX_SCALAR") % field_name).str();
1190 else
1191 return field_name;
1192 };
1193
1195 problem_name, get_block_name(), field_name, get_low_dim_ents,
1196 is_distributed_mesh);
1198}
1199
1200template <>
1202 const std::string problem_name, const std::string field_name,
1203 bool get_low_dim_ents, bool block_name_field_prefix) {
1206 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1208}
1209
1210template <>
1212 const std::string problem_name, const std::string field_name,
1213 bool get_low_dim_ents, bool block_name_field_prefix,
1214 bool is_distributed_mesh) {
1217 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1218 is_distributed_mesh);
1220}
1221
1222std::pair<std::string, std::string>
1223BcManager::extractStringFromBlockId(const std::string block_id,
1224 const std::string prb_name) {
1225
1226 // Assumes that field name is consist with letters and numbers.
1227 // No special characters.
1228 auto field_rgx_str =
1229 (boost::format("%s_([a-zA-Z0-9]*)_(.*)") % prb_name).str();
1230 std::regex field_rgx(field_rgx_str);
1231 std::smatch match_field_name;
1232 std::string field_name;
1233 std::string block_name;
1234
1235 if (std::regex_search(block_id, match_field_name, field_rgx)) {
1236 field_name = match_field_name[1];
1237 block_name = match_field_name[2];
1238 } else {
1240 "Field name and block name can not be resolved");
1241 }
1242
1243 return std::make_pair(field_name, block_name);
1244}
1245
1246template <>
1248 const std::string problem_name, const std::string field_name,
1249 bool get_low_dim_ents, bool block_name_field_prefix) {
1250 Interface &m_field = cOre;
1251 auto prb_mng = m_field.getInterface<ProblemsManager>();
1253
1254 if (problem_name.empty())
1255 MOFEM_LOG("BcMngWorld", Sev::warning) << "Argument problem_name is empty";
1256
1257 if (block_name_field_prefix)
1258 MOFEM_LOG("BcMngWorld", Sev::warning)
1259 << "Argument block_name_field_prefix=true has no effect";
1260
1261 auto fix_force = [&]() {
1263
1264 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
1266 for (auto m : meshset_vec_ptr) {
1267 auto bc = boost::make_shared<BCs>();
1268 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1269 bc->bcEnts, true);
1270 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1271 CHKERR m->getBcDataStructure(*(bc->forceBcPtr));
1272
1273 MOFEM_LOG("BcMngWorld", Sev::verbose)
1274 << "Found block FORCESET id = " << m->getMeshsetId();
1275 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->forceBcPtr;
1276
1277 MOFEM_LOG("BcMngSync", Sev::noisy)
1278 << "Found block FORCESET id = " << m->getMeshsetId()
1279 << " nb. of entities " << bc->bcEnts.size()
1280 << " highest dim of entities "
1281 << BcManagerImplTools::get_dim(bc->bcEnts);
1282 MOFEM_LOG("BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1283 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
1284
1285 if (problem_name.size()) {
1286
1287 if (bc->forceBcPtr->data.value2 > 0)
1288 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
1290 bc->bcMarkers);
1291 if (bc->forceBcPtr->data.value3 > 0)
1292 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
1294 bc->bcMarkers);
1295 if (bc->forceBcPtr->data.value4 > 0)
1296 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
1298 bc->bcMarkers);
1299
1300 if (bc->forceBcPtr->data.value5 > 0) {
1301
1302 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
1304 bc->bcMarkers);
1305 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
1307 bc->bcMarkers);
1308 }
1309 if (bc->forceBcPtr->data.value5) {
1310
1311 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
1313 bc->bcMarkers);
1314 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
1316 bc->bcMarkers);
1317 }
1318 if (bc->forceBcPtr->data.value6) {
1319
1320 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
1322 bc->bcMarkers);
1323 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
1325 bc->bcMarkers);
1326 }
1327 }
1328
1329 if (get_low_dim_ents) {
1330 auto low_dim_ents =
1331 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
1332 bc->bcEnts.swap(low_dim_ents);
1333 }
1334
1335 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
1336 bc->bcEnts);
1337 if (problem_name.size())
1338 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
1339 bc->bcEnts, bc->bcMarkers);
1340
1341 const std::string bc_id =
1342 problem_name + "_" + field_name + "_FORCESET" +
1343 boost::lexical_cast<std::string>(m->getMeshsetId());
1344 bcMapByBlockName[bc_id] = bc;
1345 }
1347 };
1348
1349 CHKERR iterate_meshsets(
1350
1352 FORCESET)
1353
1354 );
1355
1357 };
1358
1359 CHKERR fix_force();
1360
1362}
1363
1364template <>
1366 const std::string problem_name, const std::string field_name,
1367 bool get_low_dim_ents, bool block_name_field_prefix) {
1368 Interface &m_field = cOre;
1369 auto prb_mng = m_field.getInterface<ProblemsManager>();
1371
1372 if (problem_name.size() == 0)
1373 MOFEM_LOG("BcMngWorld", Sev::warning) << "Argument problem_name is empty";
1374
1375 auto get_force_block = [&](auto block_name) {
1377
1378 for (auto m :
1379 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
1380
1381 (boost::format("%s(.*)") % block_name).str()
1382
1383 ))
1384
1385 ) {
1386
1387 const auto block_name = m->getName();
1388
1389 MOFEM_LOG("BcMngWorld", Sev::inform)
1390 << "Found force block " << block_name;
1391
1392 auto bc = boost::make_shared<BCs>();
1393 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1394 bc->bcEnts, true);
1395
1396 CHKERR m->getAttributes(bc->bcAttributes);
1397 if (bc->bcAttributes.size() < 3) {
1398 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1399 "At least three block attributes for force block are expected");
1400 }
1401
1402 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1403 // For details look at ForceCubitBcData in
1404 // mofem/src/multi_indices/BCData.hpp
1405 bc->forceBcPtr->data.value1 = 1;
1406 bc->forceBcPtr->data.value3 = bc->bcAttributes[0];
1407 bc->forceBcPtr->data.value4 = bc->bcAttributes[1];
1408 bc->forceBcPtr->data.value5 = bc->bcAttributes[2];
1409
1410 MOFEM_LOG("BcMngWorld", Sev::inform) << *bc->forceBcPtr;
1411 MOFEM_LOG("BcMngSync", Sev::noisy)
1412 << "Found block FORCESET id = " << m->getMeshsetId()
1413 << " nb. of entities " << bc->bcEnts.size()
1414 << " highest dim of entities "
1415 << BcManagerImplTools::get_dim(bc->bcEnts);
1416 MOFEM_LOG("BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1417 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
1418
1419 if (problem_name.size()) {
1420
1421 if (bc->forceBcPtr->data.value2 > 0)
1422 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 0, 0,
1424 bc->bcMarkers);
1425 if (bc->forceBcPtr->data.value3 > 0)
1426 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 1, 1,
1428 bc->bcMarkers);
1429 if (bc->forceBcPtr->data.value4 > 0)
1430 CHKERR prb_mng->modifyMarkDofs(problem_name, ROW, field_name, 2, 2,
1432 bc->bcMarkers);
1433 }
1434
1435 if (get_low_dim_ents) {
1436 auto low_dim_ents =
1437 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
1438 bc->bcEnts.swap(low_dim_ents);
1439 }
1440
1441 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
1442 bc->bcEnts);
1443 if (problem_name.size())
1444 CHKERR prb_mng->markDofs(problem_name, ROW, ProblemsManager::AND,
1445 bc->bcEnts, bc->bcMarkers);
1446
1447 const std::string bc_id =
1448 problem_name + "_" + field_name + "_" + block_name;
1449 bcMapByBlockName[bc_id] = bc;
1450 }
1452 };
1453
1454 CHKERR get_force_block("FORCE");
1455
1457}
1458
1459template <>
1461 const std::string problem_name, const std::string field_name,
1462 bool get_low_dim_ents, bool block_name_field_prefix) {
1464
1466 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1467
1469 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1470
1472 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1473
1475 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1476
1478 problem_name, field_name, get_low_dim_ents, block_name_field_prefix);
1479
1481}
1482
1483template <>
1485 const std::string problem_name, const std::string field_name,
1486 bool get_low_dim_ents, bool block_name_field_prefix,
1487 bool is_distributed_mesh) {
1488 Interface &m_field = cOre;
1489 auto prb_mng = m_field.getInterface<ProblemsManager>();
1491
1492 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1493 problem_name, field_name, get_low_dim_ents);
1494
1495 std::array<Range, 3> ents_to_remove;
1496
1497 for (auto m :
1498
1500 FORCESET)) {
1501
1502 const auto block_name = m->getName();
1503 std::string bc_id = problem_name + "_" + field_name + "_" + block_name;
1504
1505 auto str = boost::format("%s_%s_%s(.*)")
1506
1507 % problem_name % field_name % block_name;
1508
1509 if (std::regex_match(bc_id, std::regex(str.str()))) {
1510
1511 auto bc = bcMapByBlockName.at(bc_id);
1512
1513 if (auto force_bc = bc->forceBcPtr) {
1514 if (force_bc->data.value3 > 0) {
1515 ents_to_remove[0].merge(bc->bcEnts);
1516 }
1517 if (force_bc->data.value4 > 0) {
1518 ents_to_remove[1].merge(bc->bcEnts);
1519 }
1520 if (force_bc->data.value5 > 0) {
1521 ents_to_remove[2].merge(bc->bcEnts);
1522 }
1523 } else {
1524 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
1525 "BC type not implemented");
1526 }
1527 }
1528 }
1529
1530 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
1531 const int hi) {
1532 if (is_distributed_mesh)
1533 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
1534 hi);
1535 else
1536 return prb_mng->removeDofsOnEntitiesNotDistributed(
1537 problem_name, field_name, ents, lo, hi);
1538 };
1539
1540 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1541 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1542 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1543
1545}
1546
1547template <>
1550 const std::string problem_name, const std::string field_name,
1551 bool get_low_dim_ents, bool block_name_field_prefix,
1552 bool is_distributed_mesh) {
1553 Interface &m_field = cOre;
1554 auto prb_mng = m_field.getInterface<ProblemsManager>();
1556
1557 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1558 problem_name, field_name, get_low_dim_ents);
1559
1560 std::array<Range, 3> ents_to_remove;
1561
1562 for (auto m :
1563
1565 BLOCKSET | UNKNOWNNAME)) {
1566
1567 const auto block_name = m->getName();
1568 std::string bc_id = problem_name + "_" + field_name + "_" + block_name;
1569
1570 auto str = boost::format("%s_%s_%s(.*)")
1571
1572 % problem_name % field_name % block_name;
1573
1574 if (std::regex_match(bc_id, std::regex(str.str()))) {
1575
1576 auto bc = bcMapByBlockName.at(bc_id);
1577
1578 if (auto force_bc = bc->forceBcPtr) {
1579 if (force_bc->data.value3 > 0) {
1580 ents_to_remove[0].merge(bc->bcEnts);
1581 }
1582 if (force_bc->data.value4 > 0) {
1583 ents_to_remove[1].merge(bc->bcEnts);
1584 }
1585 if (force_bc->data.value5 > 0) {
1586 ents_to_remove[2].merge(bc->bcEnts);
1587 }
1588 } else {
1589 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
1590 "BC type not implemented");
1591 }
1592 }
1593 }
1594
1595 auto remove_dofs_on_ents = [&](const Range &ents, const int lo,
1596 const int hi) {
1597 if (is_distributed_mesh)
1598 return prb_mng->removeDofsOnEntities(problem_name, field_name, ents, lo,
1599 hi);
1600 else
1601 return prb_mng->removeDofsOnEntitiesNotDistributed(
1602 problem_name, field_name, ents, lo, hi);
1603 };
1604
1605 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1606 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1607 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1608
1610}
1611
1612template <>
1614 const std::string problem_name, const std::string field_name,
1615 bool get_low_dim_ents, bool block_name_field_prefix,
1616 bool is_distributed_mesh) {
1618
1620 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1621 is_distributed_mesh);
1622
1624 problem_name, field_name, get_low_dim_ents, block_name_field_prefix,
1625 is_distributed_mesh);
1626
1628};
1629
1631
1632 const std::string problem_name, const std::string block_name,
1633 const std::string field_name, int bridge_dim, int lo, int hi
1634
1635) {
1636 Interface &m_field = cOre;
1638
1639 if (problem_name.empty())
1641
1642 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
1643 auto prb_mng = m_field.getInterface<ProblemsManager>();
1645 for (auto m : meshset_vec_ptr) {
1646 auto bc = boost::make_shared<BCs>();
1647 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1648 bc->bcEnts, true);
1649 CHKERR m->getAttributes(bc->bcAttributes);
1650
1651 bc->dofsViewPtr = boost::make_shared<BCs::DofsView>();
1652
1653 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
1654 bc->bcEnts);
1655 CHKERR prb_mng->getSideDofsOnBrokenSpaceEntities(
1656 *(bc->dofsViewPtr), problem_name, ROW, field_name, bc->bcEnts,
1657 bridge_dim, lo, hi);
1658 CHKERR prb_mng->markDofs(problem_name, ROW, *(bc->dofsViewPtr),
1659 ProblemsManager::OR, bc->bcMarkers);
1660
1661 MOFEM_LOG("BcMngWorld", Sev::inform)
1662 << "Found block " << m->getName() << " number of attributes "
1663 << bc->bcAttributes.size() << " number of entities "
1664 << bc->bcEnts.size();
1665
1666 const std::string bc_id =
1667 problem_name + "_" + field_name + "_" + m->getName();
1668 bcMapByBlockName[bc_id] = bc;
1669 }
1671 };
1672
1673 CHKERR iterate_meshsets(
1674
1675 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
1676
1677 (boost::format("%s(.*)") % block_name).str()
1678
1679 ))
1680
1681 );
1682
1684}
1685
1686MoFEMErrorCode BcManager::removeSideDOFs(const std::string problem_name,
1687 const std::string block_name,
1688 const std::string field_name,
1689 int bridge_dim, int lo, int hi,
1690 bool is_distributed_mesh) {
1691 Interface &m_field = cOre;
1693
1694 CHKERR pushMarkSideDofs(problem_name, block_name, field_name, bridge_dim, lo,
1695 hi);
1696
1697 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
1699 auto prb_mng = m_field.getInterface<ProblemsManager>();
1700 for (auto m : meshset_vec_ptr) {
1701 const std::string bc_id =
1702 problem_name + "_" + field_name + "_" + m->getName();
1703 auto &bc = bcMapByBlockName.at(bc_id);
1704 CHKERR prb_mng->removeDofs(problem_name, ROW, *(bc->dofsViewPtr), lo, hi);
1705 CHKERR prb_mng->removeDofs(problem_name, COL, *(bc->dofsViewPtr), lo, hi);
1706 }
1708 };
1709
1710 if (is_distributed_mesh) {
1711
1712 CHKERR iterate_meshsets(
1713
1714 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
1715
1716 (boost::format("%s(.*)") % block_name).str()
1717
1718 ))
1719
1720 );
1721 } else {
1722 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Not implemented");
1723 }
1724
1726}
1727
1728template <>
1731 const std::string problem_name, const std::string field_name,
1732 bool get_low_dim_ents, bool block_name_field_prefix) {
1733 Interface &m_field = cOre;
1735
1736 if (problem_name.size() == 0)
1737 MOFEM_LOG("BcMngWorld", Sev::warning) << "Argument problem_name is empty";
1738
1739 auto get_normal_disp_block = [&](auto block_name) {
1741
1742 for (auto m :
1743 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
1744
1745 (boost::format("%s(.*)") % block_name).str()
1746
1747 ))
1748
1749 ) {
1750
1751 std::string bc_id =
1752 problem_name + "_" + field_name + "_" + m->getName();
1753 std::string regex_str;
1754 if (block_name_field_prefix) {
1755 regex_str = (boost::format("%s_%s_%s_%s(.*)") % problem_name %
1756 field_name % field_name % block_name)
1757 .str();
1758 } else {
1759 regex_str = (boost::format("%s_%s_%s(.*)") % problem_name % field_name %
1760 block_name)
1761 .str();
1762 }
1763
1764 if (std::regex_match(bc_id, std::regex(regex_str))) {
1765
1766 MOFEM_LOG("BcMngWorld", Sev::inform)
1767 << "Normal displacement block " << m->getName();
1768
1769 auto bc = boost::make_shared<BCs>();
1770 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1771 bc->bcEnts, true);
1772
1773 CHKERR m->getAttributes(bc->bcAttributes);
1774 if (bc->bcAttributes.size() < 1) {
1775 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1776 "At least one block attribute expected");
1777 }
1778
1779 // normal is applied in the current configuration
1780 auto current_normal =
1781 bc->bcAttributes.size() <= 1 ? false : bc->bcAttributes[1];
1782
1783 MOFEM_LOG("BcMngSync", Sev::noisy)
1784 << "Found block NATURAL_DISPLACEMENT id = " << m->getMeshsetId()
1785 << " nb. of entities " << bc->bcEnts.size()
1786 << " highest dim of entities "
1787 << BcManagerImplTools::get_dim(bc->bcEnts) << " value "
1788 << bc->bcAttributes[0] << " current normal " << current_normal;
1789 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
1790
1791 if (get_low_dim_ents) {
1792 auto low_dim_ents =
1793 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
1794 bc->bcEnts.swap(low_dim_ents);
1795 }
1796
1797 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
1798 bc->bcEnts);
1799 bcMapByBlockName[bc_id] = bc;
1800 }
1801 }
1803 };
1804
1805 CHKERR get_normal_disp_block("NORMAL_DISPLACEMENT");
1806
1808}
1809
1810template <>
1813 const std::string problem_name, const std::string field_name,
1814 bool get_low_dim_ents, bool block_name_field_prefix) {
1815 Interface &m_field = cOre;
1817
1818 if (problem_name.size() == 0)
1819 MOFEM_LOG("BcMngWorld", Sev::warning) << "Argument problem_name is empty";
1820
1821 auto get_analytical_disp_block = [&](auto block_name) {
1823
1824 for (auto m :
1825 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
1826
1827 (boost::format("%s(.*)") % block_name).str()
1828
1829 ))
1830
1831 ) {
1832
1833 std::string bc_id = problem_name + "_" + field_name + "_" + m->getName();
1834 std::string regex_str;
1835 if (block_name_field_prefix) {
1836 regex_str = (boost::format("%s_%s_%s_%s(.*)") % problem_name %
1837 field_name % field_name % block_name)
1838 .str();
1839 } else {
1840 regex_str = (boost::format("%s_%s_%s(.*)") % problem_name % field_name %
1841 block_name)
1842 .str();
1843 }
1844
1845 if (std::regex_match(bc_id, std::regex(regex_str))) {
1846
1847 MOFEM_LOG("BcMngWorld", Sev::inform)
1848 << "Found analytical displacement block " << m->getName();
1849
1850 auto bc = boost::make_shared<BCs>();
1851 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1852 bc->bcEnts, true);
1853
1854 CHKERR m->getAttributes(bc->bcAttributes);
1855 if (bc->bcAttributes.size() < 3) {
1856 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1857 "At least three block attribute expected");
1858 }
1859
1860 MOFEM_LOG("BcMngSync", Sev::noisy)
1861 << "Found block ANALYTICAL_DISPLACEMENT id = " << m->getMeshsetId()
1862 << " nb. of entities " << bc->bcEnts.size()
1863 << " highest dim of entities "
1864 << BcManagerImplTools::get_dim(bc->bcEnts) << " value "
1865 << bc->bcAttributes[0] << bc->bcAttributes[1] << bc->bcAttributes[2];
1866 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
1867
1868 if (get_low_dim_ents) {
1869 auto low_dim_ents =
1870 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
1871 bc->bcEnts.swap(low_dim_ents);
1872 }
1873
1874 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
1875 bc->bcEnts);
1876 bcMapByBlockName[bc_id] = bc;
1877 }
1878 }
1880 };
1881
1882 CHKERR get_analytical_disp_block("ANALYTICAL_DISPLACEMENT");
1883
1885}
1886
1887template <>
1889 const std::string problem_name, const std::string field_name,
1890 bool get_low_dim_ents, bool block_name_field_prefix) {
1891 Interface &m_field = cOre;
1893
1894 if (block_name_field_prefix)
1895 MOFEM_LOG("BcMngWorld", Sev::warning)
1896 << "Argument block_name_field_prefix=true has no effect";
1897
1898 auto fix_pressure = [&]() {
1900
1901 auto iterate_meshsets = [&](auto &&meshset_vec_ptr) {
1903 for (auto m : meshset_vec_ptr) {
1904 auto bc = boost::make_shared<BCs>();
1905 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1906 bc->bcEnts, true);
1907 bc->pressureBcPtr = boost::make_shared<PressureCubitBcData>();
1908 CHKERR m->getBcDataStructure(*(bc->pressureBcPtr));
1909
1910 MOFEM_LOG("BcMngWorld", Sev::verbose)
1911 << "Found block FORCESET id = " << m->getMeshsetId();
1912 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->pressureBcPtr;
1913
1914 MOFEM_LOG("BcMngSync", Sev::noisy)
1915 << "Found block FORCESET id = " << m->getMeshsetId()
1916 << " nb. of entities " << bc->bcEnts.size()
1917 << " highest dim of entities "
1918 << BcManagerImplTools::get_dim(bc->bcEnts);
1919 MOFEM_LOG("BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1920 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
1921
1922 if (get_low_dim_ents) {
1923 auto low_dim_ents =
1924 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
1925 bc->bcEnts.swap(low_dim_ents);
1926 }
1927
1928 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
1929 bc->bcEnts);
1930 const std::string bc_id =
1931 problem_name + "_" + field_name + "_FORCESET" +
1932 boost::lexical_cast<std::string>(m->getMeshsetId());
1933 bcMapByBlockName[bc_id] = bc;
1934 }
1936 };
1937
1938 CHKERR iterate_meshsets(
1939
1941 FORCESET)
1942
1943 );
1944
1946 };
1947
1948 CHKERR fix_pressure();
1949
1951}
1952
1953template <>
1956 const std::string problem_name, const std::string field_name,
1957 bool get_low_dim_ents, bool block_name_field_prefix) {
1958 Interface &m_field = cOre;
1960
1961 auto get_pressure_block = [&](auto block_name) {
1963
1964 for (auto m :
1965 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
1966
1967 (boost::format("%s(.*)") % block_name).str()
1968
1969 ))
1970
1971 ) {
1972
1973 std::string bc_id = problem_name + "_" + field_name + "_" + m->getName();
1974 std::string regex_str;
1975 if (block_name_field_prefix) {
1976 regex_str = (boost::format("%s_%s_%s_%s(.*)") % problem_name %
1977 field_name % field_name % block_name)
1978 .str();
1979 } else {
1980 regex_str = (boost::format("%s_%s_%s(.*)") % problem_name % field_name %
1981 block_name)
1982 .str();
1983 }
1984
1985 if (std::regex_match(bc_id, std::regex(regex_str))) {
1986
1987 MOFEM_LOG("BcMngWorld", Sev::inform)
1988 << "Found force block " << block_name;
1989
1990 auto bc = boost::make_shared<BCs>();
1991 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
1992 bc->bcEnts, true);
1993
1994 CHKERR m->getAttributes(bc->bcAttributes);
1995 if (bc->bcAttributes.size() < 1) {
1996 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
1997 "At least one block attribute expected");
1998 }
1999
2000 bc->pressureBcPtr = boost::make_shared<PressureCubitBcData>();
2001 bc->pressureBcPtr->data.value1 = 1;
2002
2003 MOFEM_LOG("BcMngWorld", Sev::verbose)
2004 << "Found block PRESSURE id = " << m->getMeshsetId();
2005 MOFEM_LOG("BcMngWorld", Sev::verbose) << *bc->pressureBcPtr;
2006
2007 MOFEM_LOG("BcMngSync", Sev::noisy)
2008 << "Found block PRESSURE id = " << m->getMeshsetId()
2009 << " nb. of entities " << bc->bcEnts.size()
2010 << " highest dim of entities "
2011 << BcManagerImplTools::get_dim(bc->bcEnts) << " value "
2012 << bc->bcAttributes[0];
2013 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
2014
2015 if (get_low_dim_ents) {
2016 auto low_dim_ents =
2017 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
2018 bc->bcEnts.swap(low_dim_ents);
2019 }
2020
2021 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
2022 bc->bcEnts);
2023 const std::string bc_id =
2024 problem_name + "_" + field_name + "_" + block_name;
2025 bcMapByBlockName[bc_id] = bc;
2026 }
2027 }
2029 };
2030
2031 CHKERR get_pressure_block("PRESSURE");
2032
2034}
2035
2036template <>
2039 const std::string problem_name, const std::string field_name,
2040 bool get_low_dim_ents, bool block_name_field_prefix) {
2041 Interface &m_field = cOre;
2043
2044 auto get_analytical_traction_block = [&](auto block_name) {
2046
2047 for (auto m :
2048 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
2049
2050 (boost::format("%s(.*)") % block_name).str()
2051
2052 ))
2053
2054 ) {
2055
2056 std::string bc_id = problem_name + "_" + field_name + "_" + m->getName();
2057 std::string regex_str;
2058 if (block_name_field_prefix) {
2059 regex_str = (boost::format("%s_%s_%s_%s(.*)") % problem_name %
2060 field_name % field_name % block_name)
2061 .str();
2062 } else {
2063 regex_str = (boost::format("%s_%s_%s(.*)") % problem_name % field_name %
2064 block_name)
2065 .str();
2066 }
2067
2068 if (std::regex_match(bc_id, std::regex(regex_str))) {
2069
2070 MOFEM_LOG("BcMngWorld", Sev::inform)
2071 << "Found analytical traction block " << m->getName();
2072
2073 auto bc = boost::make_shared<BCs>();
2074 CHKERR m_field.get_moab().get_entities_by_handle(m->getMeshset(),
2075 bc->bcEnts, true);
2076
2077 CHKERR m->getAttributes(bc->bcAttributes);
2078 if (bc->bcAttributes.size() < 3) {
2079 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
2080 "At least one block attribute expected");
2081 }
2082
2083 MOFEM_LOG("BcMngSync", Sev::noisy)
2084 << "Found block ANALTICAL_TRACTION id = " << m->getMeshsetId()
2085 << " nb. of entities " << bc->bcEnts.size()
2086 << " highest dim of entities "
2087 << BcManagerImplTools::get_dim(bc->bcEnts) << " values "
2088 << bc->bcAttributes[0] << bc->bcAttributes[1] << bc->bcAttributes[2];
2089 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
2090
2091 if (get_low_dim_ents) {
2092 auto low_dim_ents =
2093 BcManagerImplTools::get_adj_ents(m_field.get_moab(), bc->bcEnts);
2094 bc->bcEnts.swap(low_dim_ents);
2095 }
2096 CHKERR m_field.getInterface<CommInterface>()->synchroniseEntities(
2097 bc->bcEnts);
2098 bcMapByBlockName[bc_id] = bc;
2099 }
2100 }
2102 };
2103 CHKERR get_analytical_traction_block("ANALYTICAL_TRACTION");
2104
2106}
2107
2108} // namespace MoFEM
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
constexpr double a
@ COL
@ ROW
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
@ TEMPERATURESET
@ FORCESET
@ HEATFLUXSET
@ NODESET
@ SIDESET
@ UNKNOWNNAME
@ DISPLACEMENTSET
@ BLOCKSET
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
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
auto get_dim(const Range &ents)
Definition BcManager.cpp:10
auto get_adj_ents(moab::Interface &moab, const Range &ents)
Definition BcManager.cpp:17
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
constexpr auto field_name
FTensor::Index< 'm', 3 > m
Simple interface for fast problem set-up.
Definition BcManager.hpp:29
Range getMergedBlocksRange(std::vector< std::regex > bc_regex_vec)
Merge block ranges.
MoFEMErrorCode getOptions()
get options
Definition BcManager.cpp:65
BcMarkerPtr getMergedBlocksMarker(std::vector< std::regex > bc_regex_vec)
Get the Merged Boundary Marker object.
MoFEMErrorCode removeSideDOFs(const std::string problem_name, const std::string block_name, const std::string field_name, int bridge_dim, int lo, int hi, bool is_distributed_mesh=true)
Remove side DOFs.
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.
MoFEM::Core & cOre
BcMapByBlockName bcMapByBlockName
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.
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:72
BcManager(const MoFEM::Core &core)
Definition BcManager.cpp:41
MoFEMErrorCode pushMarkSideDofs(const std::string problem_name, const std::string block_name, const std::string field_name, int bridge_dim, int lo, int hi)
Mark side DOFs.
boost::shared_ptr< std::vector< char unsigned > > BcMarkerPtr
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition BcManager.cpp:34
boost::shared_ptr< BCs > popMarkDOFsOnEntities(const std::string block_name)
Get bc data and remove element.
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.
BcMapByBlockName & getBcMapByBlockName()
Get the bc map.
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =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.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
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 reference to pointer of interface.