8 namespace BcManagerImplTools {
11 for (
auto d : {3, 2, 1})
12 if (ents.num_of_dimension(
d))
19 CHK_MOAB_THROW(moab.get_connectivity(ents, verts,
true),
"get verts");
21 for (
size_t d = 1;
d < dim; ++
d) {
22 for (
auto dd =
d + 1;
dd <= dim; ++
dd) {
24 false, verts, moab::Interface::UNION),
44 auto core_log = logging::core::get();
62 MOFEM_LOG(
"BcMngWorld", Sev::noisy) <<
"BC manager created";
67 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"BcManager options",
"none");
68 ierr = PetscOptionsEnd();
74 const std::string problem_name,
const std::string block_name,
75 const std::string
field_name,
int lo,
int hi,
bool get_low_dim_ents,
76 bool is_distributed_mesh) {
84 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
86 if (is_distributed_mesh)
87 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
90 return prb_mng->removeDofsOnEntitiesNotDistributed(
97 (boost::format(
"%s(.*)") % block_name).str()
102 const std::string bc_id =
103 problem_name +
"_" +
field_name +
"_" +
m->getName();
112 const std::string block_name,
115 bool get_low_dim_ents) {
124 auto fix_disp = [&]() {
127 auto mark_fix_dofs = [&](std::vector<unsigned char> &marked_field_dofs,
128 const auto lo,
const auto hi) {
129 return prb_mng->modifyMarkDofs(problem_name,
ROW,
field_name, lo, hi,
130 ProblemsManager::MarkOP::OR, 1,
134 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
136 for (
auto m : meshset_vec_ptr) {
137 auto bc = boost::make_shared<BCs>();
140 CHKERR m->getAttributes(bc->bcAttributes);
142 if (problem_name.size())
143 CHKERR mark_fix_dofs(bc->bcMarkers, lo, hi);
145 <<
"Found block " <<
m->getName() <<
" number of attributes "
146 << bc->bcAttributes.size();
148 if (get_low_dim_ents) {
151 bc->bcEnts.swap(low_dim_ents);
156 if (problem_name.size())
158 bc->bcEnts, bc->bcMarkers);
160 const std::string bc_id =
161 problem_name +
"_" +
field_name +
"_" +
m->getName();
171 (boost::format(
"%s(.*)") % block_name).str()
187 bool get_low_dim_ents,
188 bool block_name_field_prefix,
189 bool is_distributed_mesh) {
193 if (block_name_field_prefix)
195 <<
"Argument block_name_field_prefix=true has no effect";
196 if (is_distributed_mesh)
198 <<
"Argument is_distributed_mesh=true has no effect";
199 if (get_low_dim_ents)
201 <<
"Argument get_low_dim_ents=true has no effect";
204 for (
auto d : {3, 2, 1})
205 if (ents.num_of_dimension(
d))
210 auto iterate_mpc_meshsets = [&]() {
213 auto mpc_meshset_ptr =
215 std::regex((boost::format(
"%s(.*)") %
"MPC_(.*)").str()));
217 for (
auto m : mpc_meshset_ptr) {
219 if (std::regex_match(
m->getName(),
220 std::regex(
"(.*)COUPLING_LINKS(.*)"))) {
222 auto bc = boost::make_shared<BCs>();
223 bc->mpcPtr = boost::make_shared<MPCsType>();
226 std::string
const corresponding_master_ms =
227 std::regex_replace(
m->getName(), std::regex(
"LINKS"),
"MASTER");
235 corresponding_master_ms)) {
238 corresponding_master_ms, &
l);
239 bc->mpcPtr->isReprocitical =
false;
248 low_dim_ents = low_dim_ents.subset_by_dimension(0);
249 master_nodes.swap(low_dim_ents);
253 <<
"Found block MASTER LINKS block: " <<
l->getName()
254 <<
" Entities size: " << master_nodes.size();
258 <<
"MASTER LINKS block not found: " << corresponding_master_ms
259 <<
" setting reprocitical constraint. ("
260 << bc->mpcPtr->isReprocitical <<
").";
269 for (
auto &link : links_ents.subset_by_dimension(1)) {
271 CHKERR m_field.
get_moab().get_connectivity(&link, 1, verts,
true);
273 if (bc->mpcPtr->isReprocitical) {
274 bc->mpcPtr->mpcMasterEnts.insert(verts[0]);
275 bc->mpcPtr->mpcSlaveEnts.insert(verts[1]);
277 for (
auto &m_node : verts)
278 if (master_nodes.find(m_node) != master_nodes.end()) {
280 bc->mpcPtr->mpcMasterEnts.insert(m_node);
281 bc->mpcPtr->mpcSlaveEnts.merge(
282 subtract(verts,
Range(m_node, m_node)));
289 <<
"Found block MPC LINKS block: " <<
m->getName()
290 <<
" Entities size (edges): " << links_ents.size()
291 <<
" Entities size (nodes): "
292 << bc->mpcPtr->mpcMasterEnts.size() +
293 bc->mpcPtr->mpcSlaveEnts.size()
294 <<
" (" << bc->mpcPtr->mpcMasterEnts.size() <<
" "
295 << bc->mpcPtr->mpcSlaveEnts.size() <<
")";
297 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->mpcPtr;
304 vector<double> mAttributes;
305 CHKERR m->getAttributes(mAttributes);
307 auto setFlags = [&](
const auto &flags) {
308 auto &
d = bc->mpcPtr->data;
310 d.flag1 =
d.flag2 =
d.flag3 =
d.flag4 =
d.flag5 =
d.flag6 =
true;
313 for (
size_t i = 0;
i < std::min(flags.size(),
size_t(6)); ++
i)
314 (&
d.flag1)[
i] = flags[
i] > 0.0;
317 setFlags(mAttributes);
320 <<
"Found block " <<
m->getName() <<
" number of entities "
321 << bc->mpcPtr->mpcMasterEnts.size() <<
" number of attributes "
322 << mAttributes.size() <<
" highest dim of entities "
323 <<
get_dim(bc->mpcPtr->mpcMasterEnts);
335 const std::string bc_id =
336 problem_name +
"_" +
field_name +
"_" +
m->getName();
343 CHKERR iterate_mpc_meshsets();
348 boost::shared_ptr<BcManager::BCs>
352 auto bc = bc_it->second;
356 return boost::shared_ptr<BCs>();
363 for (
auto ®_name : bc_regex_vec) {
364 if (std::regex_match(b.first, reg_name)) {
365 ents.merge(b.second->bcEnts);
378 for (
auto ®_name : bc_regex_vec) {
379 if (std::regex_match(b.first, reg_name)) {
380 if (!boundary_marker_ptr)
381 boundary_marker_ptr =
382 boost::make_shared<std::vector<char unsigned>>();
383 boundary_marker_ptr->resize(b.second->bcMarkers.size(), 0);
384 for (
int i = 0;
i != b.second->bcMarkers.size(); ++
i) {
385 (*boundary_marker_ptr)[
i] |= b.second->bcMarkers[
i];
391 return boundary_marker_ptr;
395 const std::vector<BcManager::BcMarkerPtr> &boundary_markers_ptr_vec) {
396 auto boundary_marker_ptr = boost::make_shared<std::vector<char unsigned>>();
397 for (
auto &bcm : boundary_markers_ptr_vec) {
398 boundary_marker_ptr->resize(bcm->size(), 0);
399 for (
int i = 0;
i != bcm->size(); ++
i)
400 (*boundary_marker_ptr)[
i] |= (*bcm)[
i];
402 return boundary_marker_ptr;
406 const std::string block_name,
408 const std::string problem_name,
int lo,
412 const std::string bc_id =
413 block_prefix +
"_" +
field_name +
"_" + block_name +
"(.*)";
417 if (std::regex_match(bc.first, std::regex(bc_id))) {
418 bc_ents.merge(*(bc.second->getBcEntsPtr()));
420 <<
"Get entities from block and add to IS. Block name " << bc.first;
425 auto get_is = [&]() {
432 CHKERR ISExpand(is_bc, is_expand, &is_tmp);
446 const std::string block_name,
455 BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
456 const std::string problem_name,
const std::string
field_name,
457 bool get_low_dim_ents,
bool block_name_field_prefix,
458 bool is_distributed_mesh) {
463 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
464 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
466 std::array<Range, 3> ents_to_remove;
473 const std::string bc_id =
474 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
475 boost::lexical_cast<std::string>(
m->getMeshsetId());
477 auto bc = bcMapByBlockName.at(bc_id);
480 if (bc->dispBcPtr->data.flag1) {
481 ents_to_remove[0].merge(bc->bcEnts);
483 if (bc->dispBcPtr->data.flag2) {
484 ents_to_remove[1].merge(bc->bcEnts);
486 if (bc->dispBcPtr->data.flag3) {
487 ents_to_remove[2].merge(bc->bcEnts);
489 if (bc->dispBcPtr->data.flag4) {
490 ents_to_remove[1].merge(bc->bcEnts);
491 ents_to_remove[2].merge(bc->bcEnts);
493 if (bc->dispBcPtr->data.flag5) {
494 ents_to_remove[0].merge(bc->bcEnts);
495 ents_to_remove[2].merge(bc->bcEnts);
497 if (bc->dispBcPtr->data.flag6) {
498 ents_to_remove[0].merge(bc->bcEnts);
499 ents_to_remove[1].merge(bc->bcEnts);
502 bc->bcMarkers = std::vector<unsigned char>();
505 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
507 if (is_distributed_mesh)
508 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
511 return prb_mng->removeDofsOnEntitiesNotDistributed(
515 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
516 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
517 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
524 BcManager::removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
525 const std::string problem_name,
const std::string
field_name,
526 bool get_low_dim_ents,
bool block_name_field_prefix,
527 bool is_distributed_mesh) {
532 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
533 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
535 Range ents_to_remove;
543 const std::string bc_id =
544 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
545 boost::lexical_cast<std::string>(
m->getMeshsetId());
546 auto bc = bcMapByBlockName.at(bc_id);
547 ents_to_remove.merge(bc->bcEnts);
548 bc->bcMarkers = std::vector<unsigned char>();
551 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
553 if (is_distributed_mesh)
554 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
557 return prb_mng->removeDofsOnEntitiesNotDistributed(
568 const std::string problem_name,
const std::string
field_name,
569 bool get_low_dim_ents,
bool block_name_field_prefix,
570 bool is_distributed_mesh) {
575 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
576 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
578 Range ents_to_remove;
586 const std::string bc_id =
587 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
588 boost::lexical_cast<std::string>(
m->getMeshsetId());
589 auto bc = bcMapByBlockName.at(bc_id);
590 ents_to_remove.merge(bc->bcEnts);
591 bc->bcMarkers = std::vector<unsigned char>();
594 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
596 if (is_distributed_mesh)
597 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
600 return prb_mng->removeDofsOnEntitiesNotDistributed(
611 BcManager::removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
612 const std::string problem_name,
const std::string
field_name,
613 bool get_low_dim_ents,
bool block_name_field_prefix,
614 bool is_distributed_mesh) {
619 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
620 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
622 std::array<Range, 3> ents_to_remove;
629 const auto block_name =
m->getName();
631 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
632 std::string regex_str;
633 if (block_name_field_prefix) {
634 regex_str = (boost::format(
"%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
635 "DISPLACEMENT|ROTATE))(.*)") %
639 regex_str = (boost::format(
"%s_%s_((FIX_(ALL|X|Y|Z))|("
640 "DISPLACEMENT|ROTATE))(.*)") %
645 if (std::regex_match(bc_id, std::regex(regex_str))) {
647 auto bc = bcMapByBlockName.at(bc_id);
649 if (
auto disp_bc = bc->dispBcPtr) {
650 if (disp_bc->data.flag1) {
651 ents_to_remove[0].merge(bc->bcEnts);
653 if (disp_bc->data.flag2) {
654 ents_to_remove[1].merge(bc->bcEnts);
656 if (disp_bc->data.flag3) {
657 ents_to_remove[2].merge(bc->bcEnts);
659 if (disp_bc->data.flag4) {
660 ents_to_remove[1].merge(bc->bcEnts);
661 ents_to_remove[2].merge(bc->bcEnts);
663 if (disp_bc->data.flag5) {
664 ents_to_remove[0].merge(bc->bcEnts);
665 ents_to_remove[2].merge(bc->bcEnts);
667 if (disp_bc->data.flag6) {
668 ents_to_remove[0].merge(bc->bcEnts);
669 ents_to_remove[1].merge(bc->bcEnts);
673 "BC type not implemented");
678 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
680 if (is_distributed_mesh)
681 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
684 return prb_mng->removeDofsOnEntitiesNotDistributed(
688 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
689 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
690 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
697 BcManager::removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
698 const std::string problem_name,
const std::string block_name,
699 const std::string
field_name,
bool get_low_dim_ents,
700 bool is_distributed_mesh) {
705 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
706 problem_name, block_name,
field_name, get_low_dim_ents);
708 Range ents_to_remove;
715 std::string bc_id = problem_name +
"_" +
field_name +
"_" +
m->getName();
717 auto str = boost::format(
"%s_%s_%s(.*)")
721 if (std::regex_match(bc_id, std::regex(str.str()))) {
723 auto bc = bcMapByBlockName.at(bc_id);
725 if (
auto temp_bc = bc->tempBcPtr) {
726 if (temp_bc->data.flag1) {
727 ents_to_remove.merge(bc->bcEnts);
731 "BC type not implemented");
736 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
738 if (is_distributed_mesh)
739 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
742 return prb_mng->removeDofsOnEntitiesNotDistributed(
753 BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
754 const std::string problem_name,
const std::string
field_name,
755 bool get_low_dim_ents,
bool block_name_field_prefix) {
764 if (block_name_field_prefix)
766 <<
"Argument block_name_field_prefix=true has no effect";
768 auto fix_disp = [&]() {
771 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
773 for (
auto m : meshset_vec_ptr) {
774 auto bc = boost::make_shared<BCs>();
777 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
778 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
781 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId();
782 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
785 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId()
786 <<
" nb. of entities " << bc->bcEnts.size()
787 <<
" highest dim of entities "
789 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->dispBcPtr;
792 if (problem_name.size()) {
794 if (bc->dispBcPtr->data.flag1)
796 ProblemsManager::MarkOP::OR, 1,
798 if (bc->dispBcPtr->data.flag2)
800 ProblemsManager::MarkOP::OR, 1,
802 if (bc->dispBcPtr->data.flag3)
804 ProblemsManager::MarkOP::OR, 1,
806 if (bc->dispBcPtr->data.flag4) {
809 ProblemsManager::MarkOP::OR, 1,
812 ProblemsManager::MarkOP::OR, 1,
815 if (bc->dispBcPtr->data.flag5) {
818 ProblemsManager::MarkOP::OR, 1,
821 ProblemsManager::MarkOP::OR, 1,
824 if (bc->dispBcPtr->data.flag6) {
827 ProblemsManager::MarkOP::OR, 1,
830 ProblemsManager::MarkOP::OR, 1,
835 if (get_low_dim_ents) {
838 bc->bcEnts.swap(low_dim_ents);
843 if (problem_name.size())
845 bc->bcEnts, bc->bcMarkers);
847 const std::string bc_id =
848 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
849 boost::lexical_cast<std::string>(
m->getMeshsetId());
850 bcMapByBlockName[bc_id] = bc;
872 const std::string problem_name,
const std::string
field_name,
873 bool get_low_dim_ents,
bool block_name_field_prefix) {
878 if (block_name_field_prefix)
880 <<
"Argument block_name_field_prefix=true has no effect";
882 auto fix_temp = [&]() {
885 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
887 for (
auto m : meshset_vec_ptr) {
888 auto bc = boost::make_shared<BCs>();
891 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
892 CHKERR m->getBcDataStructure(*(bc->tempBcPtr));
895 <<
"Found block TEMPERATURESET id = " <<
m->getMeshsetId();
896 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->tempBcPtr;
898 CHKERR prb_mng->modifyMarkDofs(
900 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
902 if (get_low_dim_ents) {
905 bc->bcEnts.swap(low_dim_ents);
911 bc->bcEnts, bc->bcMarkers);
913 const std::string bc_id =
914 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
915 boost::lexical_cast<std::string>(
m->getMeshsetId());
916 bcMapByBlockName[bc_id] = bc;
938 const std::string problem_name,
const std::string
field_name,
939 bool get_low_dim_ents,
bool block_name_field_prefix) {
944 if (block_name_field_prefix)
946 <<
"Argument block_name_field_prefix=true has no effect";
948 auto fix_disp = [&]() {
951 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
953 for (
auto m : meshset_vec_ptr) {
954 auto bc = boost::make_shared<BCs>();
957 bc->heatFluxBcPtr = boost::make_shared<HeatFluxCubitBcData>();
958 CHKERR m->getBcDataStructure(*(bc->heatFluxBcPtr));
960 CHKERR prb_mng->modifyMarkDofs(
962 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
965 <<
"Found block HEATFLUX id = " <<
m->getMeshsetId();
966 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->heatFluxBcPtr;
968 if (get_low_dim_ents) {
971 bc->bcEnts.swap(low_dim_ents);
977 bc->bcEnts, bc->bcMarkers);
979 const std::string bc_id =
980 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
981 boost::lexical_cast<std::string>(
m->getMeshsetId());
982 bcMapByBlockName[bc_id] = bc;
1004 BcManager::pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1005 const std::string problem_name,
const std::string
field_name,
1006 bool get_low_dim_ents,
bool block_name_field_prefix) {
1009 auto mark_dofs = [&](
const string block_name,
const int &idx_0,
1012 if (block_name_field_prefix) {
1013 const string field_block =
field_name +
"_" + block_name;
1015 idx_0, idx_1, get_low_dim_ents);
1019 idx_1, get_low_dim_ents);
1025 CHKERR mark_dofs(
"FIX_X", 0, 0);
1026 CHKERR mark_dofs(
"FIX_Y", 1, 1);
1027 CHKERR mark_dofs(
"FIX_Z", 2, 2);
1031 CHKERR mark_dofs(
"ROTATE_X", 1, 1);
1032 CHKERR mark_dofs(
"ROTATE_X", 2, 2);
1033 CHKERR mark_dofs(
"ROTATE_Y", 0, 0);
1034 CHKERR mark_dofs(
"ROTATE_Y", 2, 2);
1035 CHKERR mark_dofs(
"ROTATE_Z", 0, 0);
1036 CHKERR mark_dofs(
"ROTATE_Z", 1, 1);
1039 std::string regex_str;
1040 if (block_name_field_prefix) {
1041 regex_str = (boost::format(
"%s_%s_%s_(.*)") % problem_name %
field_name %
1045 regex_str = (boost::format(
"%s_%s_(.*)") % problem_name %
field_name).str();
1048 for (
auto &
m : bcMapByBlockName) {
1049 auto &bc_id =
m.first;
1050 if (std::regex_match(bc_id, std::regex(regex_str))) {
1051 auto &bc =
m.second;
1052 if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_X(.*)"))) {
1053 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1054 bc->dispBcPtr->data.flag1 = 1;
1055 if (bc->bcAttributes.empty()) {
1056 bc->dispBcPtr->data.value1 = 0;
1058 <<
"Expected one attribute on block but have "
1059 << bc->bcAttributes.size();
1060 }
else if (bc->bcAttributes.size() >= 1) {
1061 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
1063 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
1064 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
1065 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Y(.*)"))) {
1066 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1067 bc->dispBcPtr->data.flag2 = 1;
1068 if (bc->bcAttributes.empty()) {
1069 bc->dispBcPtr->data.value2 = 0;
1071 <<
"Expected one attribute on block but have "
1072 << bc->bcAttributes.size();
1073 }
else if (bc->bcAttributes.size() == 1) {
1074 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
1075 }
else if (bc->bcAttributes.size() >= 2) {
1076 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
1078 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1079 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1080 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Z(.*)"))) {
1081 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1082 bc->dispBcPtr->data.flag3 = 1;
1083 if (bc->bcAttributes.empty()) {
1084 bc->dispBcPtr->data.value3 = 0;
1086 <<
"Expected one attribute on block but have "
1087 << bc->bcAttributes.size();
1088 }
else if (bc->bcAttributes.size() == 1) {
1089 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
1090 }
else if (bc->bcAttributes.size() == 3) {
1091 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
1093 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1094 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1095 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_ALL(.*)"))) {
1096 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1097 bc->dispBcPtr->data.flag1 = 1;
1098 bc->dispBcPtr->data.flag2 = 1;
1099 bc->dispBcPtr->data.flag3 = 1;
1100 if (bc->bcAttributes.size() >= 1) {
1101 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
1103 if (bc->bcAttributes.size() >= 2) {
1104 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
1106 if (bc->bcAttributes.size() >= 3) {
1107 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
1109 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1110 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1111 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_X(.*)"))) {
1113 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1114 bc->dispBcPtr->data.flag4 = 1;
1115 bc->dispBcPtr->data.flag5 = 0;
1116 bc->dispBcPtr->data.flag6 = 0;
1119 if (bc->bcAttributes.empty()) {
1120 bc->dispBcPtr->data.value4 = 0;
1122 <<
"Expected one attribute on block on block (angle (1 or 3), "
1123 "center coords(3) but have "
1124 << bc->bcAttributes.size();
1125 }
else if (bc->bcAttributes.size() >= 1) {
1126 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1128 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
1129 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
1130 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1131 if (
auto ext_disp_bc =
1133 bc->dispBcPtr.get())) {
1134 auto &o = ext_disp_bc->rotOffset;
1135 for (
int a = 0;
a != 3; ++
a)
1136 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1138 <<
"Add Rotate X Center: " << o[0] <<
" " << o[1] <<
" "
1142 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Y(.*)"))) {
1144 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1145 bc->dispBcPtr->data.flag4 = 0;
1146 bc->dispBcPtr->data.flag5 = 1;
1147 bc->dispBcPtr->data.flag6 = 0;
1150 if (bc->bcAttributes.empty()) {
1151 bc->dispBcPtr->data.value5 = 0;
1153 <<
"Expected one attribute on block on block (angle (1 or 3), "
1154 "center coords(3) but have "
1155 << bc->bcAttributes.size();
1156 }
else if (bc->bcAttributes.size() == 1 ||
1157 bc->bcAttributes.size() == 4) {
1158 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
1159 }
else if (bc->bcAttributes.size() == 6) {
1160 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1162 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1163 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1164 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1165 if (
auto ext_disp_bc =
1167 bc->dispBcPtr.get())) {
1168 auto &o = ext_disp_bc->rotOffset;
1169 for (
int a = 0;
a != 3; ++
a)
1170 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1172 <<
"Add Rotate Y Center: " << o[0] <<
" " << o[1] <<
" "
1176 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Z(.*)"))) {
1178 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1179 bc->dispBcPtr->data.flag4 = 0;
1180 bc->dispBcPtr->data.flag5 = 0;
1181 bc->dispBcPtr->data.flag6 = 1;
1184 if (bc->bcAttributes.empty()) {
1185 bc->dispBcPtr->data.value6 = 0;
1187 <<
"Expected one attribute on block (angle (1 or 3), center "
1188 "coords(3) but have "
1189 << bc->bcAttributes.size();
1190 }
else if (bc->bcAttributes.size() == 1 ||
1191 bc->bcAttributes.size() == 4) {
1192 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1193 }
else if (bc->bcAttributes.size() == 3 ||
1194 bc->bcAttributes.size() == 6) {
1195 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1197 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1198 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1199 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1200 if (
auto ext_disp_bc =
1202 bc->dispBcPtr.get())) {
1203 auto &o = ext_disp_bc->rotOffset;
1204 for (
int a = 0;
a != 3; ++
a)
1205 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1207 <<
"Add Rotate Z Center: " << o[0] <<
" " << o[1] <<
" "
1211 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_ALL(.*)"))) {
1213 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1214 bc->dispBcPtr->data.flag4 = 1;
1215 bc->dispBcPtr->data.flag5 = 1;
1216 bc->dispBcPtr->data.flag6 = 1;
1217 if (bc->bcAttributes.size() >= 1) {
1218 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1220 if (bc->bcAttributes.size() >= 2) {
1221 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1223 if (bc->bcAttributes.size() >= 3) {
1224 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1226 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1227 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1228 if (bc->bcAttributes.size() > 3) {
1229 if (
auto ext_disp_bc =
1231 bc->dispBcPtr.get())) {
1232 auto &o = ext_disp_bc->rotOffset;
1233 for (
int a = 0;
a != 3; ++
a)
1234 o[
a] = bc->bcAttributes[3 +
a];
1236 <<
"Add Rotate ALL Center: " << o[0] <<
" " << o[1] <<
" "
1249 const std::string problem_name,
const std::string block_name,
1250 const std::string
field_name,
bool get_low_dim_ents) {
1257 (boost::format(
"%s_%s_%s(.*)") % problem_name %
field_name % block_name)
1260 for (
auto &
m : bcMapByBlockName) {
1262 auto &bc_id =
m.first;
1264 if (std::regex_match(bc_id, std::regex(regex_str))) {
1266 auto &bc =
m.second;
1267 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
1268 bc->tempBcPtr->data.flag1 = 1;
1269 if (bc->bcAttributes.empty()) {
1270 bc->tempBcPtr->data.value1 = 0;
1272 <<
"Expected one attribute on block but have "
1273 << bc->bcAttributes.size();
1274 }
else if (bc->bcAttributes.size() >= 1) {
1275 bc->tempBcPtr->data.value1 = bc->bcAttributes[0];
1285 const std::string problem_name,
const std::string
field_name,
1286 bool get_low_dim_ents,
bool block_name_field_prefix) {
1289 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1290 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1292 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1293 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1299 const std::string problem_name,
const std::string
field_name,
1300 bool get_low_dim_ents,
bool block_name_field_prefix,
1301 bool is_distributed_mesh) {
1304 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1305 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1306 is_distributed_mesh);
1308 CHKERR removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1309 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1310 is_distributed_mesh);
1317 const std::string problem_name,
const std::string
field_name,
1318 bool get_low_dim_ents,
bool block_name_field_prefix) {
1320 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1321 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1323 auto get_block_name = [&]() {
1324 if (block_name_field_prefix)
1325 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1330 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1331 problem_name, get_block_name(),
field_name, get_low_dim_ents);
1337 const std::string problem_name,
const std::string
field_name,
1338 bool get_low_dim_ents,
bool block_name_field_prefix,
1339 bool is_distributed_mesh) {
1341 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1342 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1343 is_distributed_mesh);
1345 auto get_block_name = [&]() {
1346 if (block_name_field_prefix)
1347 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1352 CHKERR removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1353 problem_name, get_block_name(),
field_name, get_low_dim_ents,
1354 is_distributed_mesh);
1360 const std::string problem_name,
const std::string
field_name,
1361 bool get_low_dim_ents,
bool block_name_field_prefix) {
1363 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1364 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1370 const std::string problem_name,
const std::string
field_name,
1371 bool get_low_dim_ents,
bool block_name_field_prefix,
1372 bool is_distributed_mesh) {
1374 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1375 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1376 is_distributed_mesh);
1380 std::pair<std::string, std::string>
1382 const std::string prb_name) {
1386 auto field_rgx_str =
1387 (boost::format(
"%s_([a-zA-Z0-9]*)_(.*)") % prb_name).str();
1388 std::regex field_rgx(field_rgx_str);
1389 std::smatch match_field_name;
1391 std::string block_name;
1393 if (std::regex_search(block_id, match_field_name, field_rgx)) {
1395 block_name = match_field_name[2];
1398 "Field name and block name can not be resolved");
1401 return std::make_pair(
field_name, block_name);
1406 const std::string problem_name,
const std::string
field_name,
1407 bool get_low_dim_ents,
bool block_name_field_prefix) {
1412 if (problem_name.empty())
1413 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1415 if (block_name_field_prefix)
1417 <<
"Argument block_name_field_prefix=true has no effect";
1419 auto fix_force = [&]() {
1422 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1424 for (
auto m : meshset_vec_ptr) {
1425 auto bc = boost::make_shared<BCs>();
1428 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1429 CHKERR m->getBcDataStructure(*(bc->forceBcPtr));
1432 <<
"Found block FORCESET id = " <<
m->getMeshsetId();
1433 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->forceBcPtr;
1436 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1437 <<
" nb. of entities " << bc->bcEnts.size()
1438 <<
" highest dim of entities "
1440 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1443 if (problem_name.size()) {
1445 if (bc->forceBcPtr->data.value2 > 0)
1447 ProblemsManager::MarkOP::OR, 1,
1449 if (bc->forceBcPtr->data.value3 > 0)
1451 ProblemsManager::MarkOP::OR, 1,
1453 if (bc->forceBcPtr->data.value4 > 0)
1455 ProblemsManager::MarkOP::OR, 1,
1458 if (bc->forceBcPtr->data.value5 > 0) {
1461 ProblemsManager::MarkOP::OR, 1,
1464 ProblemsManager::MarkOP::OR, 1,
1467 if (bc->forceBcPtr->data.value5) {
1470 ProblemsManager::MarkOP::OR, 1,
1473 ProblemsManager::MarkOP::OR, 1,
1476 if (bc->forceBcPtr->data.value6) {
1479 ProblemsManager::MarkOP::OR, 1,
1482 ProblemsManager::MarkOP::OR, 1,
1487 if (get_low_dim_ents) {
1490 bc->bcEnts.swap(low_dim_ents);
1495 if (problem_name.size())
1497 bc->bcEnts, bc->bcMarkers);
1499 const std::string bc_id =
1500 problem_name +
"_" +
field_name +
"_FORCESET" +
1501 boost::lexical_cast<std::string>(
m->getMeshsetId());
1502 bcMapByBlockName[bc_id] = bc;
1524 const std::string problem_name,
const std::string
field_name,
1525 bool get_low_dim_ents,
bool block_name_field_prefix) {
1530 if (problem_name.size() == 0)
1531 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1533 auto get_force_block = [&](
auto block_name) {
1539 (boost::format(
"%s(.*)") % block_name).str()
1545 const auto block_name =
m->getName();
1548 <<
"Found force block " << block_name;
1550 auto bc = boost::make_shared<BCs>();
1554 CHKERR m->getAttributes(bc->bcAttributes);
1555 if (bc->bcAttributes.size() != 3) {
1557 "Expect three block attributes for force block");
1560 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1563 bc->forceBcPtr->data.value1 = 1;
1564 bc->forceBcPtr->data.value3 = bc->bcAttributes[0];
1565 bc->forceBcPtr->data.value4 = bc->bcAttributes[1];
1566 bc->forceBcPtr->data.value5 = bc->bcAttributes[2];
1568 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->forceBcPtr;
1570 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1571 <<
" nb. of entities " << bc->bcEnts.size()
1572 <<
" highest dim of entities "
1574 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1577 if (problem_name.size()) {
1579 if (bc->forceBcPtr->data.value2 > 0)
1581 ProblemsManager::MarkOP::OR, 1,
1583 if (bc->forceBcPtr->data.value3 > 0)
1585 ProblemsManager::MarkOP::OR, 1,
1587 if (bc->forceBcPtr->data.value4 > 0)
1589 ProblemsManager::MarkOP::OR, 1,
1593 if (get_low_dim_ents) {
1596 bc->bcEnts.swap(low_dim_ents);
1601 if (problem_name.size())
1603 bc->bcEnts, bc->bcMarkers);
1605 const std::string bc_id =
1606 problem_name +
"_" +
field_name +
"_" + block_name;
1607 bcMapByBlockName[bc_id] = bc;
1612 CHKERR get_force_block(
"FORCE");
1619 const std::string problem_name,
const std::string
field_name,
1620 bool get_low_dim_ents,
bool block_name_field_prefix) {
1623 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1624 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1626 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1627 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1634 const std::string problem_name,
const std::string
field_name,
1635 bool get_low_dim_ents,
bool block_name_field_prefix,
1636 bool is_distributed_mesh) {
1641 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1644 std::array<Range, 3> ents_to_remove;
1651 const auto block_name =
m->getName();
1652 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
1654 auto str = boost::format(
"%s_%s_%s(.*)")
1658 if (std::regex_match(bc_id, std::regex(str.str()))) {
1660 auto bc = bcMapByBlockName.at(bc_id);
1662 if (
auto force_bc = bc->forceBcPtr) {
1663 if (force_bc->data.value3 > 0) {
1664 ents_to_remove[0].merge(bc->bcEnts);
1666 if (force_bc->data.value4 > 0) {
1667 ents_to_remove[1].merge(bc->bcEnts);
1669 if (force_bc->data.value5 > 0) {
1670 ents_to_remove[2].merge(bc->bcEnts);
1674 "BC type not implemented");
1679 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
1681 if (is_distributed_mesh)
1682 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
1685 return prb_mng->removeDofsOnEntitiesNotDistributed(
1689 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1690 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1691 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1698 BcManager::removeBlockDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1699 const std::string problem_name,
const std::string
field_name,
1700 bool get_low_dim_ents,
bool block_name_field_prefix,
1701 bool is_distributed_mesh) {
1706 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1709 std::array<Range, 3> ents_to_remove;
1716 const auto block_name =
m->getName();
1717 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
1719 auto str = boost::format(
"%s_%s_%s(.*)")
1723 if (std::regex_match(bc_id, std::regex(str.str()))) {
1725 auto bc = bcMapByBlockName.at(bc_id);
1727 if (
auto force_bc = bc->forceBcPtr) {
1728 if (force_bc->data.value3 > 0) {
1729 ents_to_remove[0].merge(bc->bcEnts);
1731 if (force_bc->data.value4 > 0) {
1732 ents_to_remove[1].merge(bc->bcEnts);
1734 if (force_bc->data.value5 > 0) {
1735 ents_to_remove[2].merge(bc->bcEnts);
1739 "BC type not implemented");
1744 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
1746 if (is_distributed_mesh)
1747 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
1750 return prb_mng->removeDofsOnEntitiesNotDistributed(
1754 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1755 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1756 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1763 const std::string problem_name,
const std::string
field_name,
1764 bool get_low_dim_ents,
bool block_name_field_prefix,
1765 bool is_distributed_mesh) {
1768 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<FORCESET>>(
1769 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1770 is_distributed_mesh);
1772 CHKERR removeBlockDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1773 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1774 is_distributed_mesh);
1781 const std::string problem_name,
const std::string block_name,
1782 const std::string
field_name,
int bridge_dim,
int lo,
int hi
1788 if (problem_name.empty())
1791 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1794 for (
auto m : meshset_vec_ptr) {
1795 auto bc = boost::make_shared<BCs>();
1798 CHKERR m->getAttributes(bc->bcAttributes);
1800 bc->dofsViewPtr = boost::make_shared<BCs::DofsView>();
1804 CHKERR prb_mng->getSideDofsOnBrokenSpaceEntities(
1805 *(bc->dofsViewPtr), problem_name,
ROW,
field_name, bc->bcEnts,
1806 bridge_dim, lo, hi);
1807 CHKERR prb_mng->markDofs(problem_name,
ROW, *(bc->dofsViewPtr),
1811 <<
"Found block " <<
m->getName() <<
" number of attributes "
1812 << bc->bcAttributes.size() <<
" number of entities "
1813 << bc->bcEnts.size();
1815 const std::string bc_id =
1816 problem_name +
"_" +
field_name +
"_" +
m->getName();
1826 (boost::format(
"%s(.*)") % block_name).str()
1836 const std::string block_name,
1838 int bridge_dim,
int lo,
int hi,
1839 bool is_distributed_mesh) {
1846 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1849 for (
auto m : meshset_vec_ptr) {
1850 const std::string bc_id =
1851 problem_name +
"_" +
field_name +
"_" +
m->getName();
1853 CHKERR prb_mng->removeDofs(problem_name,
ROW, *(bc->dofsViewPtr), lo, hi);
1854 CHKERR prb_mng->removeDofs(problem_name,
COL, *(bc->dofsViewPtr), lo, hi);
1859 if (is_distributed_mesh) {
1865 (boost::format(
"%s(.*)") % block_name).str()