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) {
194 if (block_name_field_prefix)
196 <<
"Argument block_name_field_prefix=true has no effect";
197 if (is_distributed_mesh)
199 <<
"Argument is_distributed_mesh=true has no effect";
200 if (get_low_dim_ents)
202 <<
"Argument get_low_dim_ents=true has no effect";
205 for (
auto d : {3, 2, 1})
206 if (ents.num_of_dimension(
d))
211 auto mark_fix_dofs = [&](std::vector<unsigned char> &marked_field_dofs,
212 const auto lo,
const auto hi) {
213 return prb_mng->modifyMarkDofs(problem_name,
ROW,
field_name, lo, hi,
214 ProblemsManager::MarkOP::OR, 1,
218 auto iterate_mpc_meshsets = [&]() {
221 auto mpc_meshset_ptr =
223 std::regex((boost::format(
"%s(.*)") %
"MPC_(.*)").str()));
225 for (
auto m : mpc_meshset_ptr) {
227 if (std::regex_match(
m->getName(),
228 std::regex(
"(.*)COUPLING_LINKS(.*)"))) {
230 auto bc = boost::make_shared<BCs>();
231 bc->mpcPtr = boost::make_shared<MPCsType>();
234 std::string
const corresponding_master_ms =
235 std::regex_replace(
m->getName(), std::regex(
"LINKS"),
"MASTER");
243 corresponding_master_ms)) {
246 corresponding_master_ms, &
l);
247 bc->mpcPtr->isReprocitical =
false;
251 l->getMeshset(), master_nodes,
true);
258 low_dim_ents = low_dim_ents.subset_by_dimension(0);
259 master_nodes.swap(low_dim_ents);
264 <<
"Found block MASTER LINKS block: " <<
l->getName()
265 <<
" Entities size: " << master_nodes.size();
269 <<
"MASTER LINKS block not found: " << corresponding_master_ms
270 <<
" setting reprocitical constraint. ("
271 << bc->mpcPtr->isReprocitical <<
").";
280 for (
auto &link : links_ents.subset_by_dimension(1)) {
282 CHKERR m_field.
get_moab().get_connectivity(&link, 1, verts,
true);
284 if (bc->mpcPtr->isReprocitical) {
285 bc->mpcPtr->mpcMasterEnts.insert(verts[0]);
286 bc->mpcPtr->mpcSlaveEnts.insert(verts[1]);
288 for (
auto &m_node : verts)
289 if (master_nodes.find(m_node) != master_nodes.end()) {
291 bc->mpcPtr->mpcMasterEnts.insert(m_node);
292 bc->mpcPtr->mpcSlaveEnts.merge(subtract(verts,
Range(m_node, m_node)));
299 <<
"Found block MPC LINKS block: " <<
m->getName()
300 <<
" Entities size (edges): " << links_ents.size()
301 <<
" Entities size (nodes): " << bc->mpcPtr->mpcMasterEnts.size() + bc->mpcPtr->mpcSlaveEnts.size()
302 <<
" (" << bc->mpcPtr->mpcMasterEnts.size() <<
" " << bc->mpcPtr->mpcSlaveEnts.size() <<
")";
304 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->mpcPtr;
311 vector<double> mAttributes;
312 CHKERR m->getAttributes(mAttributes);
314 auto setFlags = [&](
const auto &flags) {
315 auto &
d = bc->mpcPtr->data;
317 d.flag1 =
d.flag2 =
d.flag3 =
d.flag4 =
d.flag5 =
d.flag6 =
321 for (
size_t i = 0;
i < std::min(flags.size(),
size_t(6)); ++
i)
322 (&
d.flag1)[
i] = flags[
i] > 0.0;
325 setFlags(mAttributes);
328 <<
"Found block " <<
m->getName() <<
" number of entities "
329 << bc->mpcPtr->mpcMasterEnts.size() <<
" number of attributes "
330 << mAttributes.size() <<
" highest dim of entities "
331 <<
get_dim(bc->mpcPtr->mpcMasterEnts);
343 const std::string bc_id =
344 problem_name +
"_" +
field_name +
"_" +
m->getName();
351 CHKERR iterate_mpc_meshsets();
356 boost::shared_ptr<BcManager::BCs>
360 auto bc = bc_it->second;
364 return boost::shared_ptr<BCs>();
371 for (
auto ®_name : bc_regex_vec) {
372 if (std::regex_match(b.first, reg_name)) {
373 ents.merge(b.second->bcEnts);
386 for (
auto ®_name : bc_regex_vec) {
387 if (std::regex_match(b.first, reg_name)) {
388 if (!boundary_marker_ptr)
389 boundary_marker_ptr =
390 boost::make_shared<std::vector<char unsigned>>();
391 boundary_marker_ptr->resize(b.second->bcMarkers.size(), 0);
392 for (
int i = 0;
i != b.second->bcMarkers.size(); ++
i) {
393 (*boundary_marker_ptr)[
i] |= b.second->bcMarkers[
i];
399 return boundary_marker_ptr;
403 const std::vector<BcManager::BcMarkerPtr> &boundary_markers_ptr_vec) {
404 auto boundary_marker_ptr = boost::make_shared<std::vector<char unsigned>>();
405 for (
auto &bcm : boundary_markers_ptr_vec) {
406 boundary_marker_ptr->resize(bcm->size(), 0);
407 for (
int i = 0;
i != bcm->size(); ++
i)
408 (*boundary_marker_ptr)[
i] |= (*bcm)[
i];
410 return boundary_marker_ptr;
414 const std::string block_name,
416 const std::string problem_name,
int lo,
420 const std::string bc_id =
421 block_prefix +
"_" +
field_name +
"_" + block_name +
"(.*)";
425 if (std::regex_match(bc.first, std::regex(bc_id))) {
426 bc_ents.merge(*(bc.second->getBcEntsPtr()));
428 <<
"Get entities from block and add to IS. Block name " << bc.first;
433 auto get_is = [&]() {
440 CHKERR ISExpand(is_bc, is_expand, &is_tmp);
454 const std::string block_name,
463 BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
464 const std::string problem_name,
const std::string
field_name,
465 bool get_low_dim_ents,
bool block_name_field_prefix,
466 bool is_distributed_mesh) {
471 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
472 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
474 std::array<Range, 3> ents_to_remove;
481 const std::string bc_id =
482 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
483 boost::lexical_cast<std::string>(
m->getMeshsetId());
485 auto bc = bcMapByBlockName.at(bc_id);
488 if (bc->dispBcPtr->data.flag1) {
489 ents_to_remove[0].merge(bc->bcEnts);
491 if (bc->dispBcPtr->data.flag2) {
492 ents_to_remove[1].merge(bc->bcEnts);
494 if (bc->dispBcPtr->data.flag3) {
495 ents_to_remove[2].merge(bc->bcEnts);
497 if (bc->dispBcPtr->data.flag4) {
498 ents_to_remove[1].merge(bc->bcEnts);
499 ents_to_remove[2].merge(bc->bcEnts);
501 if (bc->dispBcPtr->data.flag5) {
502 ents_to_remove[0].merge(bc->bcEnts);
503 ents_to_remove[2].merge(bc->bcEnts);
505 if (bc->dispBcPtr->data.flag6) {
506 ents_to_remove[0].merge(bc->bcEnts);
507 ents_to_remove[1].merge(bc->bcEnts);
510 bc->bcMarkers = std::vector<unsigned char>();
513 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
515 if (is_distributed_mesh)
516 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
519 return prb_mng->removeDofsOnEntitiesNotDistributed(
523 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
524 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
525 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
532 BcManager::removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
533 const std::string problem_name,
const std::string
field_name,
534 bool get_low_dim_ents,
bool block_name_field_prefix,
535 bool is_distributed_mesh) {
540 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
541 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
543 Range ents_to_remove;
551 const std::string bc_id =
552 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
553 boost::lexical_cast<std::string>(
m->getMeshsetId());
554 auto bc = bcMapByBlockName.at(bc_id);
555 ents_to_remove.merge(bc->bcEnts);
556 bc->bcMarkers = std::vector<unsigned char>();
559 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
561 if (is_distributed_mesh)
562 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
565 return prb_mng->removeDofsOnEntitiesNotDistributed(
576 const std::string problem_name,
const std::string
field_name,
577 bool get_low_dim_ents,
bool block_name_field_prefix,
578 bool is_distributed_mesh) {
583 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
584 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
586 Range ents_to_remove;
594 const std::string bc_id =
595 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
596 boost::lexical_cast<std::string>(
m->getMeshsetId());
597 auto bc = bcMapByBlockName.at(bc_id);
598 ents_to_remove.merge(bc->bcEnts);
599 bc->bcMarkers = std::vector<unsigned char>();
602 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
604 if (is_distributed_mesh)
605 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
608 return prb_mng->removeDofsOnEntitiesNotDistributed(
619 BcManager::removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
620 const std::string problem_name,
const std::string
field_name,
621 bool get_low_dim_ents,
bool block_name_field_prefix,
622 bool is_distributed_mesh) {
627 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
628 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
630 std::array<Range, 3> ents_to_remove;
637 const auto block_name =
m->getName();
639 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
640 std::string regex_str;
641 if (block_name_field_prefix) {
642 regex_str = (boost::format(
"%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
643 "DISPLACEMENT|ROTATE))(.*)") %
647 regex_str = (boost::format(
"%s_%s_((FIX_(ALL|X|Y|Z))|("
648 "DISPLACEMENT|ROTATE))(.*)") %
653 if (std::regex_match(bc_id, std::regex(regex_str))) {
655 auto bc = bcMapByBlockName.at(bc_id);
657 if (
auto disp_bc = bc->dispBcPtr) {
658 if (disp_bc->data.flag1) {
659 ents_to_remove[0].merge(bc->bcEnts);
661 if (disp_bc->data.flag2) {
662 ents_to_remove[1].merge(bc->bcEnts);
664 if (disp_bc->data.flag3) {
665 ents_to_remove[2].merge(bc->bcEnts);
667 if (disp_bc->data.flag4) {
668 ents_to_remove[1].merge(bc->bcEnts);
669 ents_to_remove[2].merge(bc->bcEnts);
671 if (disp_bc->data.flag5) {
672 ents_to_remove[0].merge(bc->bcEnts);
673 ents_to_remove[2].merge(bc->bcEnts);
675 if (disp_bc->data.flag6) {
676 ents_to_remove[0].merge(bc->bcEnts);
677 ents_to_remove[1].merge(bc->bcEnts);
681 "BC type not implemented");
686 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
688 if (is_distributed_mesh)
689 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
692 return prb_mng->removeDofsOnEntitiesNotDistributed(
696 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
697 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
698 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
705 BcManager::removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
706 const std::string problem_name,
const std::string block_name,
707 const std::string
field_name,
bool get_low_dim_ents,
708 bool is_distributed_mesh) {
713 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
714 problem_name, block_name,
field_name, get_low_dim_ents);
716 Range ents_to_remove;
723 std::string bc_id = problem_name +
"_" +
field_name +
"_" +
m->getName();
725 auto str = boost::format(
"%s_%s_%s(.*)")
729 if (std::regex_match(bc_id, std::regex(str.str()))) {
731 auto bc = bcMapByBlockName.at(bc_id);
733 if (
auto temp_bc = bc->tempBcPtr) {
734 if (temp_bc->data.flag1) {
735 ents_to_remove.merge(bc->bcEnts);
739 "BC type not implemented");
744 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
746 if (is_distributed_mesh)
747 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
750 return prb_mng->removeDofsOnEntitiesNotDistributed(
761 BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
762 const std::string problem_name,
const std::string
field_name,
763 bool get_low_dim_ents,
bool block_name_field_prefix) {
772 if (block_name_field_prefix)
774 <<
"Argument block_name_field_prefix=true has no effect";
776 auto fix_disp = [&]() {
779 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
781 for (
auto m : meshset_vec_ptr) {
782 auto bc = boost::make_shared<BCs>();
785 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
786 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
789 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId();
790 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
793 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId()
794 <<
" nb. of entities " << bc->bcEnts.size()
795 <<
" highest dim of entities "
797 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->dispBcPtr;
800 if (problem_name.size()) {
802 if (bc->dispBcPtr->data.flag1)
804 ProblemsManager::MarkOP::OR, 1,
806 if (bc->dispBcPtr->data.flag2)
808 ProblemsManager::MarkOP::OR, 1,
810 if (bc->dispBcPtr->data.flag3)
812 ProblemsManager::MarkOP::OR, 1,
814 if (bc->dispBcPtr->data.flag4) {
817 ProblemsManager::MarkOP::OR, 1,
820 ProblemsManager::MarkOP::OR, 1,
823 if (bc->dispBcPtr->data.flag5) {
826 ProblemsManager::MarkOP::OR, 1,
829 ProblemsManager::MarkOP::OR, 1,
832 if (bc->dispBcPtr->data.flag6) {
835 ProblemsManager::MarkOP::OR, 1,
838 ProblemsManager::MarkOP::OR, 1,
843 if (get_low_dim_ents) {
846 bc->bcEnts.swap(low_dim_ents);
851 if (problem_name.size())
853 bc->bcEnts, bc->bcMarkers);
855 const std::string bc_id =
856 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
857 boost::lexical_cast<std::string>(
m->getMeshsetId());
858 bcMapByBlockName[bc_id] = bc;
880 const std::string problem_name,
const std::string
field_name,
881 bool get_low_dim_ents,
bool block_name_field_prefix) {
886 if (block_name_field_prefix)
888 <<
"Argument block_name_field_prefix=true has no effect";
890 auto fix_temp = [&]() {
893 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
895 for (
auto m : meshset_vec_ptr) {
896 auto bc = boost::make_shared<BCs>();
899 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
900 CHKERR m->getBcDataStructure(*(bc->tempBcPtr));
903 <<
"Found block TEMPERATURESET id = " <<
m->getMeshsetId();
904 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->tempBcPtr;
906 CHKERR prb_mng->modifyMarkDofs(
908 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
910 if (get_low_dim_ents) {
913 bc->bcEnts.swap(low_dim_ents);
919 bc->bcEnts, bc->bcMarkers);
921 const std::string bc_id =
922 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
923 boost::lexical_cast<std::string>(
m->getMeshsetId());
924 bcMapByBlockName[bc_id] = bc;
946 const std::string problem_name,
const std::string
field_name,
947 bool get_low_dim_ents,
bool block_name_field_prefix) {
952 if (block_name_field_prefix)
954 <<
"Argument block_name_field_prefix=true has no effect";
956 auto fix_disp = [&]() {
959 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
961 for (
auto m : meshset_vec_ptr) {
962 auto bc = boost::make_shared<BCs>();
965 bc->heatFluxBcPtr = boost::make_shared<HeatFluxCubitBcData>();
966 CHKERR m->getBcDataStructure(*(bc->heatFluxBcPtr));
968 CHKERR prb_mng->modifyMarkDofs(
970 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
973 <<
"Found block HEATFLUX id = " <<
m->getMeshsetId();
974 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->heatFluxBcPtr;
976 if (get_low_dim_ents) {
979 bc->bcEnts.swap(low_dim_ents);
985 bc->bcEnts, bc->bcMarkers);
987 const std::string bc_id =
988 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
989 boost::lexical_cast<std::string>(
m->getMeshsetId());
990 bcMapByBlockName[bc_id] = bc;
1012 BcManager::pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1013 const std::string problem_name,
const std::string
field_name,
1014 bool get_low_dim_ents,
bool block_name_field_prefix) {
1017 auto mark_dofs = [&](
const string block_name,
const int &idx_0,
1020 if (block_name_field_prefix) {
1021 const string field_block =
field_name +
"_" + block_name;
1023 idx_0, idx_1, get_low_dim_ents);
1027 idx_1, get_low_dim_ents);
1033 CHKERR mark_dofs(
"FIX_X", 0, 0);
1034 CHKERR mark_dofs(
"FIX_Y", 1, 1);
1035 CHKERR mark_dofs(
"FIX_Z", 2, 2);
1039 CHKERR mark_dofs(
"ROTATE_X", 1, 1);
1040 CHKERR mark_dofs(
"ROTATE_X", 2, 2);
1041 CHKERR mark_dofs(
"ROTATE_Y", 0, 0);
1042 CHKERR mark_dofs(
"ROTATE_Y", 2, 2);
1043 CHKERR mark_dofs(
"ROTATE_Z", 0, 0);
1044 CHKERR mark_dofs(
"ROTATE_Z", 1, 1);
1047 std::string regex_str;
1048 if (block_name_field_prefix) {
1049 regex_str = (boost::format(
"%s_%s_%s_(.*)") % problem_name %
field_name %
1053 regex_str = (boost::format(
"%s_%s_(.*)") % problem_name %
field_name).str();
1056 for (
auto &
m : bcMapByBlockName) {
1057 auto &bc_id =
m.first;
1058 if (std::regex_match(bc_id, std::regex(regex_str))) {
1059 auto &bc =
m.second;
1060 if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_X(.*)"))) {
1061 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1062 bc->dispBcPtr->data.flag1 = 1;
1063 if (bc->bcAttributes.empty()) {
1064 bc->dispBcPtr->data.value1 = 0;
1066 <<
"Expected one attribute on block but have "
1067 << bc->bcAttributes.size();
1068 }
else if (bc->bcAttributes.size() >= 1) {
1069 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
1071 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
1072 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
1073 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Y(.*)"))) {
1074 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1075 bc->dispBcPtr->data.flag2 = 1;
1076 if (bc->bcAttributes.empty()) {
1077 bc->dispBcPtr->data.value2 = 0;
1079 <<
"Expected one attribute on block but have "
1080 << bc->bcAttributes.size();
1081 }
else if (bc->bcAttributes.size() == 1) {
1082 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
1083 }
else if (bc->bcAttributes.size() >= 2) {
1084 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
1086 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1087 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1088 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Z(.*)"))) {
1089 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1090 bc->dispBcPtr->data.flag3 = 1;
1091 if (bc->bcAttributes.empty()) {
1092 bc->dispBcPtr->data.value3 = 0;
1094 <<
"Expected one attribute on block but have "
1095 << bc->bcAttributes.size();
1096 }
else if (bc->bcAttributes.size() == 1) {
1097 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
1098 }
else if (bc->bcAttributes.size() == 3) {
1099 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
1101 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1102 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1103 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_ALL(.*)"))) {
1104 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1105 bc->dispBcPtr->data.flag1 = 1;
1106 bc->dispBcPtr->data.flag2 = 1;
1107 bc->dispBcPtr->data.flag3 = 1;
1108 if (bc->bcAttributes.size() >= 1) {
1109 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
1111 if (bc->bcAttributes.size() >= 2) {
1112 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
1114 if (bc->bcAttributes.size() >= 3) {
1115 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
1117 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1118 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1119 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_X(.*)"))) {
1121 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1122 bc->dispBcPtr->data.flag4 = 1;
1123 bc->dispBcPtr->data.flag5 = 0;
1124 bc->dispBcPtr->data.flag6 = 0;
1127 if (bc->bcAttributes.empty()) {
1128 bc->dispBcPtr->data.value4 = 0;
1130 <<
"Expected one attribute on block on block (angle (1 or 3), "
1131 "center coords(3) but have "
1132 << bc->bcAttributes.size();
1133 }
else if (bc->bcAttributes.size() >= 1) {
1134 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1136 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
1137 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
1138 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1139 if (
auto ext_disp_bc =
1141 bc->dispBcPtr.get())) {
1142 auto &o = ext_disp_bc->rotOffset;
1143 for (
int a = 0;
a != 3; ++
a)
1144 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1146 <<
"Add Rotate X Center: " << o[0] <<
" " << o[1] <<
" "
1150 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Y(.*)"))) {
1152 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1153 bc->dispBcPtr->data.flag4 = 0;
1154 bc->dispBcPtr->data.flag5 = 1;
1155 bc->dispBcPtr->data.flag6 = 0;
1158 if (bc->bcAttributes.empty()) {
1159 bc->dispBcPtr->data.value5 = 0;
1161 <<
"Expected one attribute on block on block (angle (1 or 3), "
1162 "center coords(3) but have "
1163 << bc->bcAttributes.size();
1164 }
else if (bc->bcAttributes.size() == 1 ||
1165 bc->bcAttributes.size() == 4) {
1166 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
1167 }
else if (bc->bcAttributes.size() == 6) {
1168 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1170 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1171 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1172 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1173 if (
auto ext_disp_bc =
1175 bc->dispBcPtr.get())) {
1176 auto &o = ext_disp_bc->rotOffset;
1177 for (
int a = 0;
a != 3; ++
a)
1178 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1180 <<
"Add Rotate Y Center: " << o[0] <<
" " << o[1] <<
" "
1184 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Z(.*)"))) {
1186 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1187 bc->dispBcPtr->data.flag4 = 0;
1188 bc->dispBcPtr->data.flag5 = 0;
1189 bc->dispBcPtr->data.flag6 = 1;
1192 if (bc->bcAttributes.empty()) {
1193 bc->dispBcPtr->data.value6 = 0;
1195 <<
"Expected one attribute on block (angle (1 or 3), center "
1196 "coords(3) but have "
1197 << bc->bcAttributes.size();
1198 }
else if (bc->bcAttributes.size() == 1 ||
1199 bc->bcAttributes.size() == 4) {
1200 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1201 }
else if (bc->bcAttributes.size() == 3 ||
1202 bc->bcAttributes.size() == 6) {
1203 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1205 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1206 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1207 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1208 if (
auto ext_disp_bc =
1210 bc->dispBcPtr.get())) {
1211 auto &o = ext_disp_bc->rotOffset;
1212 for (
int a = 0;
a != 3; ++
a)
1213 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1215 <<
"Add Rotate Z Center: " << o[0] <<
" " << o[1] <<
" "
1219 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_ALL(.*)"))) {
1221 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1222 bc->dispBcPtr->data.flag4 = 1;
1223 bc->dispBcPtr->data.flag5 = 1;
1224 bc->dispBcPtr->data.flag6 = 1;
1225 if (bc->bcAttributes.size() >= 1) {
1226 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1228 if (bc->bcAttributes.size() >= 2) {
1229 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1231 if (bc->bcAttributes.size() >= 3) {
1232 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1234 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1235 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1236 if (bc->bcAttributes.size() > 3) {
1237 if (
auto ext_disp_bc =
1239 bc->dispBcPtr.get())) {
1240 auto &o = ext_disp_bc->rotOffset;
1241 for (
int a = 0;
a != 3; ++
a)
1242 o[
a] = bc->bcAttributes[3 +
a];
1244 <<
"Add Rotate ALL Center: " << o[0] <<
" " << o[1] <<
" "
1257 const std::string problem_name,
const std::string block_name,
1258 const std::string
field_name,
bool get_low_dim_ents) {
1265 (boost::format(
"%s_%s_%s(.*)") % problem_name %
field_name % block_name)
1268 for (
auto &
m : bcMapByBlockName) {
1270 auto &bc_id =
m.first;
1272 if (std::regex_match(bc_id, std::regex(regex_str))) {
1274 auto &bc =
m.second;
1275 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
1276 bc->tempBcPtr->data.flag1 = 1;
1277 if (bc->bcAttributes.empty()) {
1278 bc->tempBcPtr->data.value1 = 0;
1280 <<
"Expected one attribute on block but have "
1281 << bc->bcAttributes.size();
1282 }
else if (bc->bcAttributes.size() >= 1) {
1283 bc->tempBcPtr->data.value1 = bc->bcAttributes[0];
1293 const std::string problem_name,
const std::string
field_name,
1294 bool get_low_dim_ents,
bool block_name_field_prefix) {
1297 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1298 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1300 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1301 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1307 const std::string problem_name,
const std::string
field_name,
1308 bool get_low_dim_ents,
bool block_name_field_prefix,
1309 bool is_distributed_mesh) {
1312 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1313 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1314 is_distributed_mesh);
1316 CHKERR removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1317 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1318 is_distributed_mesh);
1325 const std::string problem_name,
const std::string
field_name,
1326 bool get_low_dim_ents,
bool block_name_field_prefix) {
1328 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1329 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1331 auto get_block_name = [&]() {
1332 if (block_name_field_prefix)
1333 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1338 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1339 problem_name, get_block_name(),
field_name, get_low_dim_ents);
1345 const std::string problem_name,
const std::string
field_name,
1346 bool get_low_dim_ents,
bool block_name_field_prefix,
1347 bool is_distributed_mesh) {
1349 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1350 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1351 is_distributed_mesh);
1353 auto get_block_name = [&]() {
1354 if (block_name_field_prefix)
1355 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1360 CHKERR removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1361 problem_name, get_block_name(),
field_name, get_low_dim_ents,
1362 is_distributed_mesh);
1368 const std::string problem_name,
const std::string
field_name,
1369 bool get_low_dim_ents,
bool block_name_field_prefix) {
1371 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1372 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1378 const std::string problem_name,
const std::string
field_name,
1379 bool get_low_dim_ents,
bool block_name_field_prefix,
1380 bool is_distributed_mesh) {
1382 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1383 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1384 is_distributed_mesh);
1388 std::pair<std::string, std::string>
1390 const std::string prb_name) {
1394 auto field_rgx_str =
1395 (boost::format(
"%s_([a-zA-Z0-9]*)_(.*)") % prb_name).str();
1396 std::regex field_rgx(field_rgx_str);
1397 std::smatch match_field_name;
1399 std::string block_name;
1401 if (std::regex_search(block_id, match_field_name, field_rgx)) {
1403 block_name = match_field_name[2];
1406 "Field name and block name can not be resolved");
1409 return std::make_pair(
field_name, block_name);
1414 const std::string problem_name,
const std::string
field_name,
1415 bool get_low_dim_ents,
bool block_name_field_prefix) {
1420 if (problem_name.empty())
1421 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1423 if (block_name_field_prefix)
1425 <<
"Argument block_name_field_prefix=true has no effect";
1427 auto fix_force = [&]() {
1430 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1432 for (
auto m : meshset_vec_ptr) {
1433 auto bc = boost::make_shared<BCs>();
1436 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1437 CHKERR m->getBcDataStructure(*(bc->forceBcPtr));
1440 <<
"Found block FORCESET id = " <<
m->getMeshsetId();
1441 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->forceBcPtr;
1444 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1445 <<
" nb. of entities " << bc->bcEnts.size()
1446 <<
" highest dim of entities "
1448 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1451 if (problem_name.size()) {
1453 if (bc->forceBcPtr->data.value2 > 0)
1455 ProblemsManager::MarkOP::OR, 1,
1457 if (bc->forceBcPtr->data.value3 > 0)
1459 ProblemsManager::MarkOP::OR, 1,
1461 if (bc->forceBcPtr->data.value4 > 0)
1463 ProblemsManager::MarkOP::OR, 1,
1466 if (bc->forceBcPtr->data.value5 > 0) {
1469 ProblemsManager::MarkOP::OR, 1,
1472 ProblemsManager::MarkOP::OR, 1,
1475 if (bc->forceBcPtr->data.value5) {
1478 ProblemsManager::MarkOP::OR, 1,
1481 ProblemsManager::MarkOP::OR, 1,
1484 if (bc->forceBcPtr->data.value6) {
1487 ProblemsManager::MarkOP::OR, 1,
1490 ProblemsManager::MarkOP::OR, 1,
1495 if (get_low_dim_ents) {
1498 bc->bcEnts.swap(low_dim_ents);
1503 if (problem_name.size())
1505 bc->bcEnts, bc->bcMarkers);
1507 const std::string bc_id =
1508 problem_name +
"_" +
field_name +
"_FORCESET" +
1509 boost::lexical_cast<std::string>(
m->getMeshsetId());
1510 bcMapByBlockName[bc_id] = bc;
1532 const std::string problem_name,
const std::string
field_name,
1533 bool get_low_dim_ents,
bool block_name_field_prefix) {
1538 if (problem_name.size() == 0)
1539 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1541 auto get_force_block = [&](
auto block_name) {
1547 (boost::format(
"%s(.*)") % block_name).str()
1553 const auto block_name =
m->getName();
1556 <<
"Found force block " << block_name;
1558 auto bc = boost::make_shared<BCs>();
1562 CHKERR m->getAttributes(bc->bcAttributes);
1563 if (bc->bcAttributes.size() != 3) {
1565 "Expect three block attributes for force block");
1568 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1570 bc->forceBcPtr->data.value1 = 1;
1571 bc->forceBcPtr->data.value3 = bc->bcAttributes[0];
1572 bc->forceBcPtr->data.value4 = bc->bcAttributes[1];
1573 bc->forceBcPtr->data.value5 = bc->bcAttributes[2];
1575 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->forceBcPtr;
1577 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1578 <<
" nb. of entities " << bc->bcEnts.size()
1579 <<
" highest dim of entities "
1581 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1584 if (problem_name.size()) {
1586 if (bc->forceBcPtr->data.value2 > 0)
1588 ProblemsManager::MarkOP::OR, 1,
1590 if (bc->forceBcPtr->data.value3 > 0)
1592 ProblemsManager::MarkOP::OR, 1,
1594 if (bc->forceBcPtr->data.value4 > 0)
1596 ProblemsManager::MarkOP::OR, 1,
1600 if (get_low_dim_ents) {
1603 bc->bcEnts.swap(low_dim_ents);
1608 if (problem_name.size())
1610 bc->bcEnts, bc->bcMarkers);
1612 const std::string bc_id =
1613 problem_name +
"_" +
field_name +
"_" + block_name;
1614 bcMapByBlockName[bc_id] = bc;
1619 CHKERR get_force_block(
"FORCE");
1626 const std::string problem_name,
const std::string
field_name,
1627 bool get_low_dim_ents,
bool block_name_field_prefix) {
1630 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1631 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1633 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1634 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1641 const std::string problem_name,
const std::string
field_name,
1642 bool get_low_dim_ents,
bool block_name_field_prefix,
1643 bool is_distributed_mesh) {
1648 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1651 std::array<Range, 3> ents_to_remove;
1658 const auto block_name =
m->getName();
1659 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
1661 auto str = boost::format(
"%s_%s_%s(.*)")
1665 if (std::regex_match(bc_id, std::regex(str.str()))) {
1667 auto bc = bcMapByBlockName.at(bc_id);
1669 if (
auto force_bc = bc->forceBcPtr) {
1670 if (force_bc->data.value3 > 0) {
1671 ents_to_remove[0].merge(bc->bcEnts);
1673 if (force_bc->data.value4 > 0) {
1674 ents_to_remove[1].merge(bc->bcEnts);
1676 if (force_bc->data.value5 > 0) {
1677 ents_to_remove[2].merge(bc->bcEnts);
1681 "BC type not implemented");
1686 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
1688 if (is_distributed_mesh)
1689 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
1692 return prb_mng->removeDofsOnEntitiesNotDistributed(
1696 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1697 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1698 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1705 BcManager::removeBlockDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1706 const std::string problem_name,
const std::string
field_name,
1707 bool get_low_dim_ents,
bool block_name_field_prefix,
1708 bool is_distributed_mesh) {
1713 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1716 std::array<Range, 3> ents_to_remove;
1723 const auto block_name =
m->getName();
1724 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
1726 auto str = boost::format(
"%s_%s_%s(.*)")
1730 if (std::regex_match(bc_id, std::regex(str.str()))) {
1732 auto bc = bcMapByBlockName.at(bc_id);
1734 if (
auto force_bc = bc->forceBcPtr) {
1735 if (force_bc->data.value3 > 0) {
1736 ents_to_remove[0].merge(bc->bcEnts);
1738 if (force_bc->data.value4 > 0) {
1739 ents_to_remove[1].merge(bc->bcEnts);
1741 if (force_bc->data.value5 > 0) {
1742 ents_to_remove[2].merge(bc->bcEnts);
1746 "BC type not implemented");
1751 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
1753 if (is_distributed_mesh)
1754 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
1757 return prb_mng->removeDofsOnEntitiesNotDistributed(
1761 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1762 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1763 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1770 const std::string problem_name,
const std::string
field_name,
1771 bool get_low_dim_ents,
bool block_name_field_prefix,
1772 bool is_distributed_mesh) {
1775 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<FORCESET>>(
1776 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1777 is_distributed_mesh);
1779 CHKERR removeBlockDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1780 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1781 is_distributed_mesh);