292 const std::string problem_name,
const std::string
field_name,
293 bool get_low_dim_ents,
bool block_name_field_prefix,
294 bool is_distributed_mesh) {
299 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
300 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
302 std::array<Range, 3> ents_to_remove;
309 const std::string bc_id =
310 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
311 boost::lexical_cast<std::string>(
m->getMeshsetId());
313 auto bc = bcMapByBlockName.at(bc_id);
316 if (bc->dispBcPtr->data.flag1) {
317 ents_to_remove[0].merge(bc->bcEnts);
319 if (bc->dispBcPtr->data.flag2) {
320 ents_to_remove[1].merge(bc->bcEnts);
322 if (bc->dispBcPtr->data.flag3) {
323 ents_to_remove[2].merge(bc->bcEnts);
325 if (bc->dispBcPtr->data.flag4) {
326 ents_to_remove[1].merge(bc->bcEnts);
327 ents_to_remove[2].merge(bc->bcEnts);
329 if (bc->dispBcPtr->data.flag5) {
330 ents_to_remove[0].merge(bc->bcEnts);
331 ents_to_remove[2].merge(bc->bcEnts);
333 if (bc->dispBcPtr->data.flag6) {
334 ents_to_remove[0].merge(bc->bcEnts);
335 ents_to_remove[1].merge(bc->bcEnts);
338 bc->bcMarkers = std::vector<unsigned char>();
341 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
343 if (is_distributed_mesh)
344 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
347 return prb_mng->removeDofsOnEntitiesNotDistributed(
351 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
352 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
353 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
448 const std::string problem_name,
const std::string
field_name,
449 bool get_low_dim_ents,
bool block_name_field_prefix,
450 bool is_distributed_mesh) {
455 CHKERR pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
456 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
458 std::array<Range, 3> ents_to_remove;
465 const auto block_name =
m->getName();
467 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
468 std::string regex_str;
469 if (block_name_field_prefix) {
470 regex_str = (boost::format(
"%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
471 "DISPLACEMENT|ROTATE))(.*)") %
475 regex_str = (boost::format(
"%s_%s_((FIX_(ALL|X|Y|Z))|("
476 "DISPLACEMENT|ROTATE))(.*)") %
481 if (std::regex_match(bc_id, std::regex(regex_str))) {
483 auto bc = bcMapByBlockName.at(bc_id);
485 if (
auto disp_bc = bc->dispBcPtr) {
486 if (disp_bc->data.flag1) {
487 ents_to_remove[0].merge(bc->bcEnts);
489 if (disp_bc->data.flag2) {
490 ents_to_remove[1].merge(bc->bcEnts);
492 if (disp_bc->data.flag3) {
493 ents_to_remove[2].merge(bc->bcEnts);
495 if (disp_bc->data.flag4) {
496 ents_to_remove[1].merge(bc->bcEnts);
497 ents_to_remove[2].merge(bc->bcEnts);
499 if (disp_bc->data.flag5) {
500 ents_to_remove[0].merge(bc->bcEnts);
501 ents_to_remove[2].merge(bc->bcEnts);
503 if (disp_bc->data.flag6) {
504 ents_to_remove[0].merge(bc->bcEnts);
505 ents_to_remove[1].merge(bc->bcEnts);
509 "BC type not implemented");
514 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
516 if (is_distributed_mesh)
517 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
520 return prb_mng->removeDofsOnEntitiesNotDistributed(
524 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
525 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
526 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
590 const std::string problem_name,
const std::string
field_name,
591 bool get_low_dim_ents,
bool block_name_field_prefix) {
600 if (block_name_field_prefix)
602 <<
"Argument block_name_field_prefix=true has no effect";
604 auto fix_disp = [&]() {
607 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
609 for (
auto m : meshset_vec_ptr) {
610 auto bc = boost::make_shared<BCs>();
613 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
614 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
617 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId();
618 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
621 <<
"Found block DISPLACEMENTSET id = " <<
m->getMeshsetId()
622 <<
" nb. of entities " << bc->bcEnts.size()
623 <<
" highest dim of entities "
625 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->dispBcPtr;
628 if (problem_name.size()) {
630 if (bc->dispBcPtr->data.flag1)
634 if (bc->dispBcPtr->data.flag2)
638 if (bc->dispBcPtr->data.flag3)
642 if (bc->dispBcPtr->data.flag4) {
651 if (bc->dispBcPtr->data.flag5) {
660 if (bc->dispBcPtr->data.flag6) {
671 if (get_low_dim_ents) {
674 bc->bcEnts.swap(low_dim_ents);
679 if (problem_name.size())
681 bc->bcEnts, bc->bcMarkers);
683 const std::string bc_id =
684 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
685 boost::lexical_cast<std::string>(
m->getMeshsetId());
686 bcMapByBlockName[bc_id] = bc;
841 const std::string problem_name,
const std::string
field_name,
842 bool get_low_dim_ents,
bool block_name_field_prefix) {
845 auto mark_dofs = [&](
const string block_name,
const int &idx_0,
848 if (block_name_field_prefix) {
849 const string field_block =
field_name +
"_" + block_name;
851 idx_0, idx_1, get_low_dim_ents);
855 idx_1, get_low_dim_ents);
861 CHKERR mark_dofs(
"FIX_X", 0, 0);
862 CHKERR mark_dofs(
"FIX_Y", 1, 1);
863 CHKERR mark_dofs(
"FIX_Z", 2, 2);
867 CHKERR mark_dofs(
"ROTATE_X", 1, 1);
868 CHKERR mark_dofs(
"ROTATE_X", 2, 2);
869 CHKERR mark_dofs(
"ROTATE_Y", 0, 0);
870 CHKERR mark_dofs(
"ROTATE_Y", 2, 2);
871 CHKERR mark_dofs(
"ROTATE_Z", 0, 0);
872 CHKERR mark_dofs(
"ROTATE_Z", 1, 1);
875 std::string regex_str;
876 if (block_name_field_prefix) {
877 regex_str = (boost::format(
"%s_%s_%s_(.*)") % problem_name %
field_name %
881 regex_str = (boost::format(
"%s_%s_(.*)") % problem_name %
field_name).str();
884 for (
auto &
m : bcMapByBlockName) {
885 auto &bc_id =
m.first;
886 if (std::regex_match(bc_id, std::regex(regex_str))) {
888 if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_X(.*)"))) {
889 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
890 bc->dispBcPtr->data.flag1 = 1;
891 if (bc->bcAttributes.empty()) {
892 bc->dispBcPtr->data.value1 = 0;
894 <<
"Expected one attribute on block but have "
895 << bc->bcAttributes.size();
896 }
else if (bc->bcAttributes.size() >= 1) {
897 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
899 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
900 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
901 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Y(.*)"))) {
902 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
903 bc->dispBcPtr->data.flag2 = 1;
904 if (bc->bcAttributes.empty()) {
905 bc->dispBcPtr->data.value2 = 0;
907 <<
"Expected one attribute on block but have "
908 << bc->bcAttributes.size();
909 }
else if (bc->bcAttributes.size() == 1) {
910 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
911 }
else if (bc->bcAttributes.size() >= 2) {
912 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
914 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
915 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
916 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Z(.*)"))) {
917 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
918 bc->dispBcPtr->data.flag3 = 1;
919 if (bc->bcAttributes.empty()) {
920 bc->dispBcPtr->data.value3 = 0;
922 <<
"Expected one attribute on block but have "
923 << bc->bcAttributes.size();
924 }
else if (bc->bcAttributes.size() == 1) {
925 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
926 }
else if (bc->bcAttributes.size() == 3) {
927 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
929 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
930 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
931 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_ALL(.*)"))) {
932 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
933 bc->dispBcPtr->data.flag1 = 1;
934 bc->dispBcPtr->data.flag2 = 1;
935 bc->dispBcPtr->data.flag3 = 1;
936 if (bc->bcAttributes.size() >= 1) {
937 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
939 if (bc->bcAttributes.size() >= 2) {
940 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
942 if (bc->bcAttributes.size() >= 3) {
943 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
945 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
946 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
947 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_X(.*)"))) {
949 boost::make_shared<DisplacementCubitBcDataWithRotation>();
950 bc->dispBcPtr->data.flag4 = 1;
951 bc->dispBcPtr->data.flag5 = 0;
952 bc->dispBcPtr->data.flag6 = 0;
955 if (bc->bcAttributes.empty()) {
956 bc->dispBcPtr->data.value4 = 0;
958 <<
"Expected one attribute on block on block (angle (1 or 3), "
959 "center coords(3) but have "
960 << bc->bcAttributes.size();
961 }
else if (bc->bcAttributes.size() >= 1) {
962 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
964 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
965 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
966 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
967 if (
auto ext_disp_bc =
969 bc->dispBcPtr.get())) {
970 auto &o = ext_disp_bc->rotOffset;
971 for (
int a = 0;
a != 3; ++
a)
972 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
974 <<
"Add Rotate X Center: " << o[0] <<
" " << o[1] <<
" "
978 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Y(.*)"))) {
980 boost::make_shared<DisplacementCubitBcDataWithRotation>();
981 bc->dispBcPtr->data.flag4 = 0;
982 bc->dispBcPtr->data.flag5 = 1;
983 bc->dispBcPtr->data.flag6 = 0;
986 if (bc->bcAttributes.empty()) {
987 bc->dispBcPtr->data.value5 = 0;
989 <<
"Expected one attribute on block on block (angle (1 or 3), "
990 "center coords(3) but have "
991 << bc->bcAttributes.size();
992 }
else if (bc->bcAttributes.size() == 1 ||
993 bc->bcAttributes.size() == 4) {
994 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
995 }
else if (bc->bcAttributes.size() == 6) {
996 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
998 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
999 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1000 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1001 if (
auto ext_disp_bc =
1003 bc->dispBcPtr.get())) {
1004 auto &o = ext_disp_bc->rotOffset;
1005 for (
int a = 0;
a != 3; ++
a)
1006 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1008 <<
"Add Rotate Y Center: " << o[0] <<
" " << o[1] <<
" "
1012 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Z(.*)"))) {
1014 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1015 bc->dispBcPtr->data.flag4 = 0;
1016 bc->dispBcPtr->data.flag5 = 0;
1017 bc->dispBcPtr->data.flag6 = 1;
1020 if (bc->bcAttributes.empty()) {
1021 bc->dispBcPtr->data.value6 = 0;
1023 <<
"Expected one attribute on block (angle (1 or 3), center "
1024 "coords(3) but have "
1025 << bc->bcAttributes.size();
1026 }
else if (bc->bcAttributes.size() == 1 ||
1027 bc->bcAttributes.size() == 4) {
1028 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1029 }
else if (bc->bcAttributes.size() == 3 ||
1030 bc->bcAttributes.size() == 6) {
1031 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1033 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1034 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1035 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1036 if (
auto ext_disp_bc =
1038 bc->dispBcPtr.get())) {
1039 auto &o = ext_disp_bc->rotOffset;
1040 for (
int a = 0;
a != 3; ++
a)
1041 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1043 <<
"Add Rotate Z Center: " << o[0] <<
" " << o[1] <<
" "
1047 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_ALL(.*)"))) {
1049 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1050 bc->dispBcPtr->data.flag4 = 1;
1051 bc->dispBcPtr->data.flag5 = 1;
1052 bc->dispBcPtr->data.flag6 = 1;
1053 if (bc->bcAttributes.size() >= 1) {
1054 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1056 if (bc->bcAttributes.size() >= 2) {
1057 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1059 if (bc->bcAttributes.size() >= 3) {
1060 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1062 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1063 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1064 if (bc->bcAttributes.size() > 3) {
1065 if (
auto ext_disp_bc =
1067 bc->dispBcPtr.get())) {
1068 auto &o = ext_disp_bc->rotOffset;
1069 for (
int a = 0;
a != 3; ++
a)
1070 o[
a] = bc->bcAttributes[3 +
a];
1072 <<
"Add Rotate ALL Center: " << o[0] <<
" " << o[1] <<
" "
1248 const std::string problem_name,
const std::string
field_name,
1249 bool get_low_dim_ents,
bool block_name_field_prefix) {
1254 if (problem_name.empty())
1255 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1257 if (block_name_field_prefix)
1259 <<
"Argument block_name_field_prefix=true has no effect";
1261 auto fix_force = [&]() {
1264 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1266 for (
auto m : meshset_vec_ptr) {
1267 auto bc = boost::make_shared<BCs>();
1270 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1271 CHKERR m->getBcDataStructure(*(bc->forceBcPtr));
1274 <<
"Found block FORCESET id = " <<
m->getMeshsetId();
1275 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->forceBcPtr;
1278 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1279 <<
" nb. of entities " << bc->bcEnts.size()
1280 <<
" highest dim of entities "
1282 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1285 if (problem_name.size()) {
1287 if (bc->forceBcPtr->data.value2 > 0)
1291 if (bc->forceBcPtr->data.value3 > 0)
1295 if (bc->forceBcPtr->data.value4 > 0)
1300 if (bc->forceBcPtr->data.value5 > 0) {
1309 if (bc->forceBcPtr->data.value5) {
1318 if (bc->forceBcPtr->data.value6) {
1329 if (get_low_dim_ents) {
1332 bc->bcEnts.swap(low_dim_ents);
1337 if (problem_name.size())
1339 bc->bcEnts, bc->bcMarkers);
1341 const std::string bc_id =
1342 problem_name +
"_" +
field_name +
"_FORCESET" +
1343 boost::lexical_cast<std::string>(
m->getMeshsetId());
1344 bcMapByBlockName[bc_id] = bc;
1366 const std::string problem_name,
const std::string
field_name,
1367 bool get_low_dim_ents,
bool block_name_field_prefix) {
1372 if (problem_name.size() == 0)
1373 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1375 auto get_force_block = [&](
auto block_name) {
1381 (boost::format(
"%s(.*)") % block_name).str()
1387 const auto block_name =
m->getName();
1390 <<
"Found force block " << block_name;
1392 auto bc = boost::make_shared<BCs>();
1396 CHKERR m->getAttributes(bc->bcAttributes);
1397 if (bc->bcAttributes.size() < 3) {
1399 "At least three block attributes for force block are expected");
1402 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1405 bc->forceBcPtr->data.value1 = 1;
1406 bc->forceBcPtr->data.value3 = bc->bcAttributes[0];
1407 bc->forceBcPtr->data.value4 = bc->bcAttributes[1];
1408 bc->forceBcPtr->data.value5 = bc->bcAttributes[2];
1410 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->forceBcPtr;
1412 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1413 <<
" nb. of entities " << bc->bcEnts.size()
1414 <<
" highest dim of entities "
1416 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1419 if (problem_name.size()) {
1421 if (bc->forceBcPtr->data.value2 > 0)
1425 if (bc->forceBcPtr->data.value3 > 0)
1429 if (bc->forceBcPtr->data.value4 > 0)
1435 if (get_low_dim_ents) {
1438 bc->bcEnts.swap(low_dim_ents);
1443 if (problem_name.size())
1445 bc->bcEnts, bc->bcMarkers);
1447 const std::string bc_id =
1448 problem_name +
"_" +
field_name +
"_" + block_name;
1449 bcMapByBlockName[bc_id] = bc;
1454 CHKERR get_force_block(
"FORCE");