291BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
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);
447BcManager::removeBlockDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
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);
589BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
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;
840BcManager::pushMarkDOFsOnEntities<BcDisplacementMeshsetType<BLOCKSET>>(
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 std::smatch bc_match;
887 if (std::regex_match(bc_id, bc_match, std::regex(regex_str))) {
890 const auto block_name = bc_match[1].str();
892 if (std::regex_match(block_name, std::regex(
"FIX_X(.*)"))) {
893 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
894 bc->dispBcPtr->data.flag1 = 1;
895 if (bc->bcAttributes.empty()) {
896 bc->dispBcPtr->data.value1 = 0;
898 <<
"Expected one attribute on block but have "
899 << bc->bcAttributes.size();
900 }
else if (bc->bcAttributes.size() >= 1) {
901 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
903 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
904 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
905 }
else if (std::regex_match(block_name, std::regex(
"FIX_Y(.*)"))) {
906 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
907 bc->dispBcPtr->data.flag2 = 1;
908 if (bc->bcAttributes.empty()) {
909 bc->dispBcPtr->data.value2 = 0;
911 <<
"Expected one attribute on block but have "
912 << bc->bcAttributes.size();
913 }
else if (bc->bcAttributes.size() == 1) {
914 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
915 }
else if (bc->bcAttributes.size() >= 2) {
916 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
918 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
919 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
920 }
else if (std::regex_match(block_name, std::regex(
"FIX_Z(.*)"))) {
921 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
922 bc->dispBcPtr->data.flag3 = 1;
923 if (bc->bcAttributes.empty()) {
924 bc->dispBcPtr->data.value3 = 0;
926 <<
"Expected one attribute on block but have "
927 << bc->bcAttributes.size();
928 }
else if (bc->bcAttributes.size() == 1) {
929 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
930 }
else if (bc->bcAttributes.size() == 3) {
931 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
933 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
934 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
935 }
else if (std::regex_match(block_name, std::regex(
"FIX_ALL(.*)"))) {
936 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
937 bc->dispBcPtr->data.flag1 = 1;
938 bc->dispBcPtr->data.flag2 = 1;
939 bc->dispBcPtr->data.flag3 = 1;
940 if (bc->bcAttributes.size() >= 1) {
941 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
943 if (bc->bcAttributes.size() >= 2) {
944 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
946 if (bc->bcAttributes.size() >= 3) {
947 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
949 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
950 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
951 }
else if (std::regex_match(block_name, std::regex(
"ROTATE_X(.*)"))) {
953 boost::make_shared<DisplacementCubitBcDataWithRotation>();
954 bc->dispBcPtr->data.flag4 = 1;
955 bc->dispBcPtr->data.flag5 = 0;
956 bc->dispBcPtr->data.flag6 = 0;
959 if (bc->bcAttributes.empty()) {
960 bc->dispBcPtr->data.value4 = 0;
962 <<
"Expected one attribute on block on block (angle (1 or 3), "
963 "center coords(3) but have "
964 << bc->bcAttributes.size();
965 }
else if (bc->bcAttributes.size() >= 1) {
966 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
968 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
969 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
970 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
971 if (
auto ext_disp_bc =
973 bc->dispBcPtr.get())) {
974 auto &o = ext_disp_bc->rotOffset;
975 for (
int a = 0;
a != 3; ++
a)
976 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
978 <<
"Add Rotate X Center: " << o[0] <<
" " << o[1] <<
" "
982 }
else if (std::regex_match(block_name, std::regex(
"ROTATE_Y(.*)"))) {
984 boost::make_shared<DisplacementCubitBcDataWithRotation>();
985 bc->dispBcPtr->data.flag4 = 0;
986 bc->dispBcPtr->data.flag5 = 1;
987 bc->dispBcPtr->data.flag6 = 0;
990 if (bc->bcAttributes.empty()) {
991 bc->dispBcPtr->data.value5 = 0;
993 <<
"Expected one attribute on block on block (angle (1 or 3), "
994 "center coords(3) but have "
995 << bc->bcAttributes.size();
996 }
else if (bc->bcAttributes.size() == 1 ||
997 bc->bcAttributes.size() == 4) {
998 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
999 }
else if (bc->bcAttributes.size() == 6) {
1000 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1002 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1003 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1004 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1005 if (
auto ext_disp_bc =
1007 bc->dispBcPtr.get())) {
1008 auto &o = ext_disp_bc->rotOffset;
1009 for (
int a = 0;
a != 3; ++
a)
1010 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1012 <<
"Add Rotate Y Center: " << o[0] <<
" " << o[1] <<
" "
1016 }
else if (std::regex_match(block_name, std::regex(
"ROTATE_Z(.*)"))) {
1018 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1019 bc->dispBcPtr->data.flag4 = 0;
1020 bc->dispBcPtr->data.flag5 = 0;
1021 bc->dispBcPtr->data.flag6 = 1;
1024 if (bc->bcAttributes.empty()) {
1025 bc->dispBcPtr->data.value6 = 0;
1027 <<
"Expected one attribute on block (angle (1 or 3), center "
1028 "coords(3) but have "
1029 << bc->bcAttributes.size();
1030 }
else if (bc->bcAttributes.size() == 1 ||
1031 bc->bcAttributes.size() == 4) {
1032 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1033 }
else if (bc->bcAttributes.size() == 3 ||
1034 bc->bcAttributes.size() == 6) {
1035 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1037 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1038 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1039 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1040 if (
auto ext_disp_bc =
1042 bc->dispBcPtr.get())) {
1043 auto &o = ext_disp_bc->rotOffset;
1044 for (
int a = 0;
a != 3; ++
a)
1045 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1047 <<
"Add Rotate Z Center: " << o[0] <<
" " << o[1] <<
" "
1051 }
else if (std::regex_match(block_name, std::regex(
"ROTATE_ALL(.*)"))) {
1053 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1054 bc->dispBcPtr->data.flag4 = 1;
1055 bc->dispBcPtr->data.flag5 = 1;
1056 bc->dispBcPtr->data.flag6 = 1;
1057 if (bc->bcAttributes.size() >= 1) {
1058 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1060 if (bc->bcAttributes.size() >= 2) {
1061 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1063 if (bc->bcAttributes.size() >= 3) {
1064 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1066 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1067 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1068 if (bc->bcAttributes.size() > 3) {
1069 if (
auto ext_disp_bc =
1071 bc->dispBcPtr.get())) {
1072 auto &o = ext_disp_bc->rotOffset;
1073 for (
int a = 0;
a != 3; ++
a)
1074 o[
a] = bc->bcAttributes[3 +
a];
1076 <<
"Add Rotate ALL Center: " << o[0] <<
" " << o[1] <<
" "
1252 const std::string problem_name,
const std::string
field_name,
1253 bool get_low_dim_ents,
bool block_name_field_prefix) {
1258 if (problem_name.empty())
1259 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1261 if (block_name_field_prefix)
1263 <<
"Argument block_name_field_prefix=true has no effect";
1265 auto fix_force = [&]() {
1268 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
1270 for (
auto m : meshset_vec_ptr) {
1271 auto bc = boost::make_shared<BCs>();
1274 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1275 CHKERR m->getBcDataStructure(*(bc->forceBcPtr));
1278 <<
"Found block FORCESET id = " <<
m->getMeshsetId();
1279 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->forceBcPtr;
1282 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1283 <<
" nb. of entities " << bc->bcEnts.size()
1284 <<
" highest dim of entities "
1286 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1289 if (problem_name.size()) {
1291 if (bc->forceBcPtr->data.value2 > 0)
1295 if (bc->forceBcPtr->data.value3 > 0)
1299 if (bc->forceBcPtr->data.value4 > 0)
1304 if (bc->forceBcPtr->data.value5 > 0) {
1313 if (bc->forceBcPtr->data.value5) {
1322 if (bc->forceBcPtr->data.value6) {
1333 if (get_low_dim_ents) {
1336 bc->bcEnts.swap(low_dim_ents);
1341 if (problem_name.size())
1343 bc->bcEnts, bc->bcMarkers);
1345 const std::string bc_id =
1346 problem_name +
"_" +
field_name +
"_FORCESET" +
1347 boost::lexical_cast<std::string>(
m->getMeshsetId());
1348 bcMapByBlockName[bc_id] = bc;
1370 const std::string problem_name,
const std::string
field_name,
1371 bool get_low_dim_ents,
bool block_name_field_prefix) {
1376 if (problem_name.size() == 0)
1377 MOFEM_LOG(
"BcMngWorld", Sev::warning) <<
"Argument problem_name is empty";
1379 auto get_force_block = [&](
auto block_name) {
1385 (boost::format(
"%s(.*)") % block_name).str()
1391 const auto block_name =
m->getName();
1394 <<
"Found force block " << block_name;
1396 auto bc = boost::make_shared<BCs>();
1400 CHKERR m->getAttributes(bc->bcAttributes);
1401 if (bc->bcAttributes.size() < 3) {
1403 "At least three block attributes for force block are expected");
1406 bc->forceBcPtr = boost::make_shared<ForceCubitBcData>();
1409 bc->forceBcPtr->data.value1 = 1;
1410 bc->forceBcPtr->data.value3 = bc->bcAttributes[0];
1411 bc->forceBcPtr->data.value4 = bc->bcAttributes[1];
1412 bc->forceBcPtr->data.value5 = bc->bcAttributes[2];
1414 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->forceBcPtr;
1416 <<
"Found block FORCESET id = " <<
m->getMeshsetId()
1417 <<
" nb. of entities " << bc->bcEnts.size()
1418 <<
" highest dim of entities "
1420 MOFEM_LOG(
"BcMngSync", Sev::noisy) << *bc->forceBcPtr;
1423 if (problem_name.size()) {
1425 if (bc->forceBcPtr->data.value2 > 0)
1429 if (bc->forceBcPtr->data.value3 > 0)
1433 if (bc->forceBcPtr->data.value4 > 0)
1439 if (get_low_dim_ents) {
1442 bc->bcEnts.swap(low_dim_ents);
1447 if (problem_name.size())
1449 bc->bcEnts, bc->bcMarkers);
1451 const std::string bc_id =
1452 problem_name +
"_" +
field_name +
"_" + block_name;
1453 bcMapByBlockName[bc_id] = bc;
1458 CHKERR get_force_block(
"FORCE");