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))
217 auto iterate_mpc_meshsets = [&]() {
220 auto mpc_meshset_ptr =
222 std::regex((boost::format(
"%s(.*)") %
"MPC_(.*)").str()));
224 for (
auto m : mpc_meshset_ptr) {
226 if (std::regex_match(
m->getName(),
227 std::regex(
"(.*)COUPLING_LINKS(.*)"))) {
229 auto bc = boost::make_shared<BCs>();
230 bc->mpcPtr = boost::make_shared<MPCsType>();
233 std::string
const corresponding_master_ms =
234 std::regex_replace(
m->getName(), std::regex(
"LINKS"),
"MASTER");
242 corresponding_master_ms)) {
245 corresponding_master_ms, &
l);
246 bc->mpcPtr->isReprocitical =
false;
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(
293 subtract(verts,
Range(m_node, m_node)));
300 <<
"Found block MPC LINKS block: " <<
m->getName()
301 <<
" Entities size (edges): " << links_ents.size()
302 <<
" Entities size (nodes): "
303 << bc->mpcPtr->mpcMasterEnts.size() +
304 bc->mpcPtr->mpcSlaveEnts.size()
305 <<
" (" << bc->mpcPtr->mpcMasterEnts.size() <<
" "
306 << bc->mpcPtr->mpcSlaveEnts.size() <<
")";
308 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->mpcPtr;
315 vector<double> mAttributes;
316 CHKERR m->getAttributes(mAttributes);
318 auto setFlags = [&](
const auto &flags) {
319 auto &
d = bc->mpcPtr->data;
321 d.flag1 =
d.flag2 =
d.flag3 =
d.flag4 =
d.flag5 =
d.flag6 =
true;
324 for (
size_t i = 0;
i < std::min(flags.size(),
size_t(6)); ++
i)
325 (&
d.flag1)[
i] = flags[
i] > 0.0;
328 setFlags(mAttributes);
331 <<
"Found block " <<
m->getName() <<
" number of entities "
332 << bc->mpcPtr->mpcMasterEnts.size() <<
" number of attributes "
333 << mAttributes.size() <<
" highest dim of entities "
334 <<
get_dim(bc->mpcPtr->mpcMasterEnts);
346 const std::string bc_id =
347 problem_name +
"_" +
field_name +
"_" +
m->getName();
354 CHKERR iterate_mpc_meshsets();
359 boost::shared_ptr<BcManager::BCs>
363 auto bc = bc_it->second;
367 return boost::shared_ptr<BCs>();
374 for (
auto ®_name : bc_regex_vec) {
375 if (std::regex_match(b.first, reg_name)) {
376 ents.merge(b.second->bcEnts);
389 for (
auto ®_name : bc_regex_vec) {
390 if (std::regex_match(b.first, reg_name)) {
391 if (!boundary_marker_ptr)
392 boundary_marker_ptr =
393 boost::make_shared<std::vector<char unsigned>>();
394 boundary_marker_ptr->resize(b.second->bcMarkers.size(), 0);
395 for (
int i = 0;
i != b.second->bcMarkers.size(); ++
i) {
396 (*boundary_marker_ptr)[
i] |= b.second->bcMarkers[
i];
402 return boundary_marker_ptr;
406 const std::vector<BcManager::BcMarkerPtr> &boundary_markers_ptr_vec) {
407 auto boundary_marker_ptr = boost::make_shared<std::vector<char unsigned>>();
408 for (
auto &bcm : boundary_markers_ptr_vec) {
409 boundary_marker_ptr->resize(bcm->size(), 0);
410 for (
int i = 0;
i != bcm->size(); ++
i)
411 (*boundary_marker_ptr)[
i] |= (*bcm)[
i];
413 return boundary_marker_ptr;
417 const std::string block_name,
419 const std::string problem_name,
int lo,
423 const std::string bc_id =
424 block_prefix +
"_" +
field_name +
"_" + block_name +
"(.*)";
428 if (std::regex_match(bc.first, std::regex(bc_id))) {
429 bc_ents.merge(*(bc.second->getBcEntsPtr()));
431 <<
"Get entities from block and add to IS. Block name " << bc.first;
436 auto get_is = [&]() {
443 CHKERR ISExpand(is_bc, is_expand, &is_tmp);
457 const std::string block_name,
466 BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
467 const std::string problem_name,
const std::string
field_name,
468 bool get_low_dim_ents,
bool block_name_field_prefix,
469 bool is_distributed_mesh) {
474 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
475 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
477 std::array<Range, 3> ents_to_remove;
484 const std::string bc_id =
485 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
486 boost::lexical_cast<std::string>(
m->getMeshsetId());
488 auto bc = bcMapByBlockName.at(bc_id);
491 if (bc->dispBcPtr->data.flag1) {
492 ents_to_remove[0].merge(bc->bcEnts);
494 if (bc->dispBcPtr->data.flag2) {
495 ents_to_remove[1].merge(bc->bcEnts);
497 if (bc->dispBcPtr->data.flag3) {
498 ents_to_remove[2].merge(bc->bcEnts);
500 if (bc->dispBcPtr->data.flag4) {
501 ents_to_remove[1].merge(bc->bcEnts);
502 ents_to_remove[2].merge(bc->bcEnts);
504 if (bc->dispBcPtr->data.flag5) {
505 ents_to_remove[0].merge(bc->bcEnts);
506 ents_to_remove[2].merge(bc->bcEnts);
508 if (bc->dispBcPtr->data.flag6) {
509 ents_to_remove[0].merge(bc->bcEnts);
510 ents_to_remove[1].merge(bc->bcEnts);
513 bc->bcMarkers = std::vector<unsigned char>();
516 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
518 if (is_distributed_mesh)
519 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
522 return prb_mng->removeDofsOnEntitiesNotDistributed(
526 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
527 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
528 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
535 BcManager::removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
536 const std::string problem_name,
const std::string
field_name,
537 bool get_low_dim_ents,
bool block_name_field_prefix,
538 bool is_distributed_mesh) {
543 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
544 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
546 Range ents_to_remove;
554 const std::string bc_id =
555 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
556 boost::lexical_cast<std::string>(
m->getMeshsetId());
557 auto bc = bcMapByBlockName.at(bc_id);
558 ents_to_remove.merge(bc->bcEnts);
559 bc->bcMarkers = std::vector<unsigned char>();
562 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
564 if (is_distributed_mesh)
565 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
568 return prb_mng->removeDofsOnEntitiesNotDistributed(
579 const std::string problem_name,
const std::string
field_name,
580 bool get_low_dim_ents,
bool block_name_field_prefix,
581 bool is_distributed_mesh) {
586 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
587 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
589 Range ents_to_remove;
597 const std::string bc_id =
598 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
599 boost::lexical_cast<std::string>(
m->getMeshsetId());
600 auto bc = bcMapByBlockName.at(bc_id);
601 ents_to_remove.merge(bc->bcEnts);
602 bc->bcMarkers = std::vector<unsigned char>();
605 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
607 if (is_distributed_mesh)
608 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
611 return prb_mng->removeDofsOnEntitiesNotDistributed(
622 BcManager::removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
623 const std::string problem_name,
const std::string
field_name,
624 bool get_low_dim_ents,
bool block_name_field_prefix,
625 bool is_distributed_mesh) {
630 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
631 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
633 std::array<Range, 3> ents_to_remove;
640 const auto block_name =
m->getName();
642 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
643 std::string regex_str;
644 if (block_name_field_prefix) {
645 regex_str = (boost::format(
"%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
646 "DISPLACEMENT|ROTATE))(.*)") %
650 regex_str = (boost::format(
"%s_%s_((FIX_(ALL|X|Y|Z))|("
651 "DISPLACEMENT|ROTATE))(.*)") %
656 if (std::regex_match(bc_id, std::regex(regex_str))) {
658 auto bc = bcMapByBlockName.at(bc_id);
660 if (
auto disp_bc = bc->dispBcPtr) {
661 if (disp_bc->data.flag1) {
662 ents_to_remove[0].merge(bc->bcEnts);
664 if (disp_bc->data.flag2) {
665 ents_to_remove[1].merge(bc->bcEnts);
667 if (disp_bc->data.flag3) {
668 ents_to_remove[2].merge(bc->bcEnts);
670 if (disp_bc->data.flag4) {
671 ents_to_remove[1].merge(bc->bcEnts);
672 ents_to_remove[2].merge(bc->bcEnts);
674 if (disp_bc->data.flag5) {
675 ents_to_remove[0].merge(bc->bcEnts);
676 ents_to_remove[2].merge(bc->bcEnts);
678 if (disp_bc->data.flag6) {
679 ents_to_remove[0].merge(bc->bcEnts);
680 ents_to_remove[1].merge(bc->bcEnts);
684 "BC type not implemented");
689 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
691 if (is_distributed_mesh)
692 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
695 return prb_mng->removeDofsOnEntitiesNotDistributed(
699 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
700 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
701 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
708 BcManager::removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
709 const std::string problem_name,
const std::string block_name,
710 const std::string
field_name,
bool get_low_dim_ents,
711 bool is_distributed_mesh) {
716 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
717 problem_name, block_name,
field_name, get_low_dim_ents);
719 Range ents_to_remove;
726 std::string bc_id = problem_name +
"_" +
field_name +
"_" +
m->getName();
728 auto str = boost::format(
"%s_%s_%s(.*)")
732 if (std::regex_match(bc_id, std::regex(str.str()))) {
734 auto bc = bcMapByBlockName.at(bc_id);
736 if (
auto temp_bc = bc->tempBcPtr) {
737 if (temp_bc->data.flag1) {
738 ents_to_remove.merge(bc->bcEnts);
742 "BC type not implemented");
747 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
749 if (is_distributed_mesh)
750 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
753 return prb_mng->removeDofsOnEntitiesNotDistributed(
764 BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
765 const std::string problem_name,
const std::string
field_name,
766 bool get_low_dim_ents,
bool block_name_field_prefix) {
775 if (block_name_field_prefix)
777 <<
"Argument block_name_field_prefix=true has no effect";
779 auto fix_disp = [&]() {
782 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
784 for (
auto m : meshset_vec_ptr) {
785 auto bc = boost::make_shared<BCs>();
788 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
789 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
792 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId();
793 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
796 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId()
797 <<
" nb. of entities " << bc->bcEnts.size()
798 <<
" highest dim of entities "
800 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->dispBcPtr;
803 if (problem_name.size()) {
805 if (bc->dispBcPtr->data.flag1)
807 ProblemsManager::MarkOP::OR, 1,
809 if (bc->dispBcPtr->data.flag2)
811 ProblemsManager::MarkOP::OR, 1,
813 if (bc->dispBcPtr->data.flag3)
815 ProblemsManager::MarkOP::OR, 1,
817 if (bc->dispBcPtr->data.flag4) {
820 ProblemsManager::MarkOP::OR, 1,
823 ProblemsManager::MarkOP::OR, 1,
826 if (bc->dispBcPtr->data.flag5) {
829 ProblemsManager::MarkOP::OR, 1,
832 ProblemsManager::MarkOP::OR, 1,
835 if (bc->dispBcPtr->data.flag6) {
838 ProblemsManager::MarkOP::OR, 1,
841 ProblemsManager::MarkOP::OR, 1,
846 if (get_low_dim_ents) {
849 bc->bcEnts.swap(low_dim_ents);
854 if (problem_name.size())
856 bc->bcEnts, bc->bcMarkers);
858 const std::string bc_id =
859 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
860 boost::lexical_cast<std::string>(
m->getMeshsetId());
861 bcMapByBlockName[bc_id] = bc;
883 const std::string problem_name,
const std::string
field_name,
884 bool get_low_dim_ents,
bool block_name_field_prefix) {
889 if (block_name_field_prefix)
891 <<
"Argument block_name_field_prefix=true has no effect";
893 auto fix_temp = [&]() {
896 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
898 for (
auto m : meshset_vec_ptr) {
899 auto bc = boost::make_shared<BCs>();
902 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
903 CHKERR m->getBcDataStructure(*(bc->tempBcPtr));
906 <<
"Found block TEMPERATURESET id = " <<
m->getMeshsetId();
907 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->tempBcPtr;
909 CHKERR prb_mng->modifyMarkDofs(
911 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
913 if (get_low_dim_ents) {
916 bc->bcEnts.swap(low_dim_ents);
922 bc->bcEnts, bc->bcMarkers);
924 const std::string bc_id =
925 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
926 boost::lexical_cast<std::string>(
m->getMeshsetId());
927 bcMapByBlockName[bc_id] = bc;
949 const std::string problem_name,
const std::string
field_name,
950 bool get_low_dim_ents,
bool block_name_field_prefix) {
955 if (block_name_field_prefix)
957 <<
"Argument block_name_field_prefix=true has no effect";
959 auto fix_disp = [&]() {
962 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
964 for (
auto m : meshset_vec_ptr) {
965 auto bc = boost::make_shared<BCs>();
968 bc->heatFluxBcPtr = boost::make_shared<HeatFluxCubitBcData>();
969 CHKERR m->getBcDataStructure(*(bc->heatFluxBcPtr));
971 CHKERR prb_mng->modifyMarkDofs(
973 ProblemsManager::MarkOP::OR, 1, bc->bcMarkers);
976 <<
"Found block HEATFLUX id = " <<
m->getMeshsetId();
977 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->heatFluxBcPtr;
979 if (get_low_dim_ents) {
982 bc->bcEnts.swap(low_dim_ents);
988 bc->bcEnts, bc->bcMarkers);
990 const std::string bc_id =
991 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
992 boost::lexical_cast<std::string>(
m->getMeshsetId());
993 bcMapByBlockName[bc_id] = bc;
1015 BcManager::pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1016 const std::string problem_name,
const std::string
field_name,
1017 bool get_low_dim_ents,
bool block_name_field_prefix) {
1020 auto mark_dofs = [&](
const string block_name,
const int &idx_0,
1023 if (block_name_field_prefix) {
1024 const string field_block =
field_name +
"_" + block_name;
1026 idx_0, idx_1, get_low_dim_ents);
1030 idx_1, get_low_dim_ents);
1036 CHKERR mark_dofs(
"FIX_X", 0, 0);
1037 CHKERR mark_dofs(
"FIX_Y", 1, 1);
1038 CHKERR mark_dofs(
"FIX_Z", 2, 2);
1042 CHKERR mark_dofs(
"ROTATE_X", 1, 1);
1043 CHKERR mark_dofs(
"ROTATE_X", 2, 2);
1044 CHKERR mark_dofs(
"ROTATE_Y", 0, 0);
1045 CHKERR mark_dofs(
"ROTATE_Y", 2, 2);
1046 CHKERR mark_dofs(
"ROTATE_Z", 0, 0);
1047 CHKERR mark_dofs(
"ROTATE_Z", 1, 1);
1050 std::string regex_str;
1051 if (block_name_field_prefix) {
1052 regex_str = (boost::format(
"%s_%s_%s_(.*)") % problem_name %
field_name %
1056 regex_str = (boost::format(
"%s_%s_(.*)") % problem_name %
field_name).str();
1059 for (
auto &
m : bcMapByBlockName) {
1060 auto &bc_id =
m.first;
1061 if (std::regex_match(bc_id, std::regex(regex_str))) {
1062 auto &bc =
m.second;
1063 if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_X(.*)"))) {
1064 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1065 bc->dispBcPtr->data.flag1 = 1;
1066 if (bc->bcAttributes.empty()) {
1067 bc->dispBcPtr->data.value1 = 0;
1069 <<
"Expected one attribute on block but have "
1070 << bc->bcAttributes.size();
1071 }
else if (bc->bcAttributes.size() >= 1) {
1072 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
1074 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
1075 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
1076 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Y(.*)"))) {
1077 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1078 bc->dispBcPtr->data.flag2 = 1;
1079 if (bc->bcAttributes.empty()) {
1080 bc->dispBcPtr->data.value2 = 0;
1082 <<
"Expected one attribute on block but have "
1083 << bc->bcAttributes.size();
1084 }
else if (bc->bcAttributes.size() == 1) {
1085 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
1086 }
else if (bc->bcAttributes.size() >= 2) {
1087 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
1089 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1090 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1091 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Z(.*)"))) {
1092 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1093 bc->dispBcPtr->data.flag3 = 1;
1094 if (bc->bcAttributes.empty()) {
1095 bc->dispBcPtr->data.value3 = 0;
1097 <<
"Expected one attribute on block but have "
1098 << bc->bcAttributes.size();
1099 }
else if (bc->bcAttributes.size() == 1) {
1100 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
1101 }
else if (bc->bcAttributes.size() == 3) {
1102 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
1104 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1105 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1106 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_ALL(.*)"))) {
1107 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
1108 bc->dispBcPtr->data.flag1 = 1;
1109 bc->dispBcPtr->data.flag2 = 1;
1110 bc->dispBcPtr->data.flag3 = 1;
1111 if (bc->bcAttributes.size() >= 1) {
1112 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
1114 if (bc->bcAttributes.size() >= 2) {
1115 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
1117 if (bc->bcAttributes.size() >= 3) {
1118 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
1120 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1121 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1122 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_X(.*)"))) {
1124 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1125 bc->dispBcPtr->data.flag4 = 1;
1126 bc->dispBcPtr->data.flag5 = 0;
1127 bc->dispBcPtr->data.flag6 = 0;
1130 if (bc->bcAttributes.empty()) {
1131 bc->dispBcPtr->data.value4 = 0;
1133 <<
"Expected one attribute on block on block (angle (1 or 3), "
1134 "center coords(3) but have "
1135 << bc->bcAttributes.size();
1136 }
else if (bc->bcAttributes.size() >= 1) {
1137 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1139 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
1140 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
1141 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1142 if (
auto ext_disp_bc =
1144 bc->dispBcPtr.get())) {
1145 auto &o = ext_disp_bc->rotOffset;
1146 for (
int a = 0;
a != 3; ++
a)
1147 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1149 <<
"Add Rotate X Center: " << o[0] <<
" " << o[1] <<
" "
1153 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Y(.*)"))) {
1155 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1156 bc->dispBcPtr->data.flag4 = 0;
1157 bc->dispBcPtr->data.flag5 = 1;
1158 bc->dispBcPtr->data.flag6 = 0;
1161 if (bc->bcAttributes.empty()) {
1162 bc->dispBcPtr->data.value5 = 0;
1164 <<
"Expected one attribute on block on block (angle (1 or 3), "
1165 "center coords(3) but have "
1166 << bc->bcAttributes.size();
1167 }
else if (bc->bcAttributes.size() == 1 ||
1168 bc->bcAttributes.size() == 4) {
1169 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
1170 }
else if (bc->bcAttributes.size() == 6) {
1171 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1173 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1174 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1175 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1176 if (
auto ext_disp_bc =
1178 bc->dispBcPtr.get())) {
1179 auto &o = ext_disp_bc->rotOffset;
1180 for (
int a = 0;
a != 3; ++
a)
1181 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1183 <<
"Add Rotate Y Center: " << o[0] <<
" " << o[1] <<
" "
1187 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Z(.*)"))) {
1189 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1190 bc->dispBcPtr->data.flag4 = 0;
1191 bc->dispBcPtr->data.flag5 = 0;
1192 bc->dispBcPtr->data.flag6 = 1;
1195 if (bc->bcAttributes.empty()) {
1196 bc->dispBcPtr->data.value6 = 0;
1198 <<
"Expected one attribute on block (angle (1 or 3), center "
1199 "coords(3) but have "
1200 << bc->bcAttributes.size();
1201 }
else if (bc->bcAttributes.size() == 1 ||
1202 bc->bcAttributes.size() == 4) {
1203 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1204 }
else if (bc->bcAttributes.size() == 3 ||
1205 bc->bcAttributes.size() == 6) {
1206 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1208 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1209 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1210 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1211 if (
auto ext_disp_bc =
1213 bc->dispBcPtr.get())) {
1214 auto &o = ext_disp_bc->rotOffset;
1215 for (
int a = 0;
a != 3; ++
a)
1216 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1218 <<
"Add Rotate Z Center: " << o[0] <<
" " << o[1] <<
" "
1222 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_ALL(.*)"))) {
1224 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1225 bc->dispBcPtr->data.flag4 = 1;
1226 bc->dispBcPtr->data.flag5 = 1;
1227 bc->dispBcPtr->data.flag6 = 1;
1228 if (bc->bcAttributes.size() >= 1) {
1229 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1231 if (bc->bcAttributes.size() >= 2) {
1232 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1234 if (bc->bcAttributes.size() >= 3) {
1235 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1237 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1238 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1239 if (bc->bcAttributes.size() > 3) {
1240 if (
auto ext_disp_bc =
1242 bc->dispBcPtr.get())) {
1243 auto &o = ext_disp_bc->rotOffset;
1244 for (
int a = 0;
a != 3; ++
a)
1245 o[
a] = bc->bcAttributes[3 +
a];
1247 <<
"Add Rotate ALL Center: " << o[0] <<
" " << o[1] <<
" "
1260 const std::string problem_name,
const std::string block_name,
1261 const std::string
field_name,
bool get_low_dim_ents) {
1268 (boost::format(
"%s_%s_%s(.*)") % problem_name %
field_name % block_name)
1271 for (
auto &
m : bcMapByBlockName) {
1273 auto &bc_id =
m.first;
1275 if (std::regex_match(bc_id, std::regex(regex_str))) {
1277 auto &bc =
m.second;
1278 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
1279 bc->tempBcPtr->data.flag1 = 1;
1280 if (bc->bcAttributes.empty()) {
1281 bc->tempBcPtr->data.value1 = 0;
1283 <<
"Expected one attribute on block but have "
1284 << bc->bcAttributes.size();
1285 }
else if (bc->bcAttributes.size() >= 1) {
1286 bc->tempBcPtr->data.value1 = bc->bcAttributes[0];
1296 const std::string problem_name,
const std::string
field_name,
1297 bool get_low_dim_ents,
bool block_name_field_prefix) {
1300 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1301 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1303 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1304 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1310 const std::string problem_name,
const std::string
field_name,
1311 bool get_low_dim_ents,
bool block_name_field_prefix,
1312 bool is_distributed_mesh) {
1315 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1316 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1317 is_distributed_mesh);
1319 CHKERR removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
1320 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1321 is_distributed_mesh);
1328 const std::string problem_name,
const std::string
field_name,
1329 bool get_low_dim_ents,
bool block_name_field_prefix) {
1331 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1332 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1334 auto get_block_name = [&]() {
1335 if (block_name_field_prefix)
1336 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1341 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1342 problem_name, get_block_name(),
field_name, get_low_dim_ents);
1348 const std::string problem_name,
const std::string
field_name,
1349 bool get_low_dim_ents,
bool block_name_field_prefix,
1350 bool is_distributed_mesh) {
1352 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1353 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1354 is_distributed_mesh);
1356 auto get_block_name = [&]() {
1357 if (block_name_field_prefix)
1358 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1363 CHKERR removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1364 problem_name, get_block_name(),
field_name, get_low_dim_ents,
1365 is_distributed_mesh);
1371 const std::string problem_name,
const std::string
field_name,
1372 bool get_low_dim_ents,
bool block_name_field_prefix) {
1374 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1375 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1381 const std::string problem_name,
const std::string
field_name,
1382 bool get_low_dim_ents,
bool block_name_field_prefix,
1383 bool is_distributed_mesh) {
1385 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1386 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1387 is_distributed_mesh);
1391 std::pair<std::string, std::string>
1393 const std::string prb_name) {
1397 auto field_rgx_str =
1398 (boost::format(
"%s_([a-zA-Z0-9]*)_(.*)") % prb_name).str();
1399 std::regex field_rgx(field_rgx_str);
1400 std::smatch match_field_name;
1402 std::string block_name;
1404 if (std::regex_search(block_id, match_field_name, field_rgx)) {
1406 block_name = match_field_name[2];
1409 "Field name and block name can not be resolved");
1412 return std::make_pair(
field_name, block_name);
1417 const std::string problem_name,
const std::string
field_name,
1418 bool get_low_dim_ents,
bool block_name_field_prefix) {
1423 if (problem_name.empty())
1424 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1426 if (block_name_field_prefix)
1428 <<
"Argument block_name_field_prefix=true has no effect";
1430 auto fix_force = [&]() {
1433 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1435 for (
auto m : meshset_vec_ptr) {
1436 auto bc = boost::make_shared<BCs>();
1439 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1440 CHKERR m->getBcDataStructure(*(bc->forceBcPtr));
1443 <<
"Found block FORCESET id = " <<
m->getMeshsetId();
1444 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->forceBcPtr;
1447 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1448 <<
" nb. of entities " << bc->bcEnts.size()
1449 <<
" highest dim of entities "
1451 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1454 if (problem_name.size()) {
1456 if (bc->forceBcPtr->data.value2 > 0)
1458 ProblemsManager::MarkOP::OR, 1,
1460 if (bc->forceBcPtr->data.value3 > 0)
1462 ProblemsManager::MarkOP::OR, 1,
1464 if (bc->forceBcPtr->data.value4 > 0)
1466 ProblemsManager::MarkOP::OR, 1,
1469 if (bc->forceBcPtr->data.value5 > 0) {
1472 ProblemsManager::MarkOP::OR, 1,
1475 ProblemsManager::MarkOP::OR, 1,
1478 if (bc->forceBcPtr->data.value5) {
1481 ProblemsManager::MarkOP::OR, 1,
1484 ProblemsManager::MarkOP::OR, 1,
1487 if (bc->forceBcPtr->data.value6) {
1490 ProblemsManager::MarkOP::OR, 1,
1493 ProblemsManager::MarkOP::OR, 1,
1498 if (get_low_dim_ents) {
1501 bc->bcEnts.swap(low_dim_ents);
1506 if (problem_name.size())
1508 bc->bcEnts, bc->bcMarkers);
1510 const std::string bc_id =
1511 problem_name +
"_" +
field_name +
"_FORCESET" +
1512 boost::lexical_cast<std::string>(
m->getMeshsetId());
1513 bcMapByBlockName[bc_id] = bc;
1535 const std::string problem_name,
const std::string
field_name,
1536 bool get_low_dim_ents,
bool block_name_field_prefix) {
1541 if (problem_name.size() == 0)
1542 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1544 auto get_force_block = [&](
auto block_name) {
1550 (boost::format(
"%s(.*)") % block_name).str()
1556 const auto block_name =
m->getName();
1559 <<
"Found force block " << block_name;
1561 auto bc = boost::make_shared<BCs>();
1565 CHKERR m->getAttributes(bc->bcAttributes);
1566 if (bc->bcAttributes.size() != 3) {
1568 "Expect three block attributes for force block");
1571 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1574 bc->forceBcPtr->data.value1 = 1;
1575 bc->forceBcPtr->data.value3 = bc->bcAttributes[0];
1576 bc->forceBcPtr->data.value4 = bc->bcAttributes[1];
1577 bc->forceBcPtr->data.value5 = bc->bcAttributes[2];
1579 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->forceBcPtr;
1581 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1582 <<
" nb. of entities " << bc->bcEnts.size()
1583 <<
" highest dim of entities "
1585 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1588 if (problem_name.size()) {
1590 if (bc->forceBcPtr->data.value2 > 0)
1592 ProblemsManager::MarkOP::OR, 1,
1594 if (bc->forceBcPtr->data.value3 > 0)
1596 ProblemsManager::MarkOP::OR, 1,
1598 if (bc->forceBcPtr->data.value4 > 0)
1600 ProblemsManager::MarkOP::OR, 1,
1604 if (get_low_dim_ents) {
1607 bc->bcEnts.swap(low_dim_ents);
1612 if (problem_name.size())
1614 bc->bcEnts, bc->bcMarkers);
1616 const std::string bc_id =
1617 problem_name +
"_" +
field_name +
"_" + block_name;
1618 bcMapByBlockName[bc_id] = bc;
1623 CHKERR get_force_block(
"FORCE");
1630 const std::string problem_name,
const std::string
field_name,
1631 bool get_low_dim_ents,
bool block_name_field_prefix) {
1634 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1635 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1637 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1638 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1645 const std::string problem_name,
const std::string
field_name,
1646 bool get_low_dim_ents,
bool block_name_field_prefix,
1647 bool is_distributed_mesh) {
1652 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<FORCESET>>(
1655 std::array<Range, 3> ents_to_remove;
1662 const auto block_name =
m->getName();
1663 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
1665 auto str = boost::format(
"%s_%s_%s(.*)")
1669 if (std::regex_match(bc_id, std::regex(str.str()))) {
1671 auto bc = bcMapByBlockName.at(bc_id);
1673 if (
auto force_bc = bc->forceBcPtr) {
1674 if (force_bc->data.value3 > 0) {
1675 ents_to_remove[0].merge(bc->bcEnts);
1677 if (force_bc->data.value4 > 0) {
1678 ents_to_remove[1].merge(bc->bcEnts);
1680 if (force_bc->data.value5 > 0) {
1681 ents_to_remove[2].merge(bc->bcEnts);
1685 "BC type not implemented");
1690 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
1692 if (is_distributed_mesh)
1693 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
1696 return prb_mng->removeDofsOnEntitiesNotDistributed(
1700 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1701 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1702 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1709 BcManager::removeBlockDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1710 const std::string problem_name,
const std::string
field_name,
1711 bool get_low_dim_ents,
bool block_name_field_prefix,
1712 bool is_distributed_mesh) {
1717 CHKERR pushMarkDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1720 std::array<Range, 3> ents_to_remove;
1727 const auto block_name =
m->getName();
1728 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
1730 auto str = boost::format(
"%s_%s_%s(.*)")
1734 if (std::regex_match(bc_id, std::regex(str.str()))) {
1736 auto bc = bcMapByBlockName.at(bc_id);
1738 if (
auto force_bc = bc->forceBcPtr) {
1739 if (force_bc->data.value3 > 0) {
1740 ents_to_remove[0].merge(bc->bcEnts);
1742 if (force_bc->data.value4 > 0) {
1743 ents_to_remove[1].merge(bc->bcEnts);
1745 if (force_bc->data.value5 > 0) {
1746 ents_to_remove[2].merge(bc->bcEnts);
1750 "BC type not implemented");
1755 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
1757 if (is_distributed_mesh)
1758 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
1761 return prb_mng->removeDofsOnEntitiesNotDistributed(
1765 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
1766 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
1767 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
1774 const std::string problem_name,
const std::string
field_name,
1775 bool get_low_dim_ents,
bool block_name_field_prefix,
1776 bool is_distributed_mesh) {
1779 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<FORCESET>>(
1780 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1781 is_distributed_mesh);
1783 CHKERR removeBlockDOFsOnEntities<BcForceMeshsetType<BLOCKSET>>(
1784 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1785 is_distributed_mesh);
1792 const std::string problem_name,
const std::string block_name,
1793 const std::string
field_name,
int bridge_dim,
int lo,
int hi
1799 if (problem_name.empty())
1802 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1805 for (
auto m : meshset_vec_ptr) {
1806 auto bc = boost::make_shared<BCs>();
1809 CHKERR m->getAttributes(bc->bcAttributes);
1811 bc->dofsViewPtr = boost::make_shared<BCs::DofsView>();
1815 CHKERR prb_mng->getSideDofsOnBrokenSpaceEntities(
1816 *(bc->dofsViewPtr), problem_name,
ROW,
field_name, bc->bcEnts,
1817 bridge_dim, lo, hi);
1818 CHKERR prb_mng->markDofs(problem_name,
ROW, *(bc->dofsViewPtr),
1822 <<
"Found block " <<
m->getName() <<
" number of attributes "
1823 << bc->bcAttributes.size() <<
" number of entities "
1824 << bc->bcEnts.size();
1826 const std::string bc_id =
1827 problem_name +
"_" +
field_name +
"_" +
m->getName();
1837 (boost::format(
"%s(.*)") % block_name).str()
1847 const std::string block_name,
1849 int bridge_dim,
int lo,
int hi,
1850 bool is_distributed_mesh) {
1857 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1860 for (
auto m : meshset_vec_ptr) {
1861 const std::string bc_id =
1862 problem_name +
"_" +
field_name +
"_" +
m->getName();
1864 CHKERR prb_mng->removeDofs(problem_name,
ROW, *(bc->dofsViewPtr), lo, hi);
1865 CHKERR prb_mng->removeDofs(problem_name,
COL, *(bc->dofsViewPtr), lo, hi);
1870 if (is_distributed_mesh) {
1876 (boost::format(
"%s(.*)") % block_name).str()