19 auto core_log = logging::core::get();
37 MOFEM_LOG(
"BcMngWorld", Sev::noisy) <<
"BC manager created";
42 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"BcManager options",
"none");
43 ierr = PetscOptionsEnd();
49 const std::string problem_name,
const std::string block_name,
50 const std::string
field_name,
int lo,
int hi,
bool get_low_dim_ents,
51 bool is_distributed_mesh) {
59 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
61 if (is_distributed_mesh)
62 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
65 return prb_mng->removeDofsOnEntitiesNotDistributed(
72 (boost::format(
"%s(.*)") % block_name).str()
77 const std::string bc_id =
78 problem_name +
"_" +
field_name +
"_" +
m->getName();
87 const std::string block_name,
90 bool get_low_dim_ents) {
95 auto get_dim = [&](
const Range &ents) {
96 for (
auto d : {3, 2, 1})
97 if (ents.num_of_dimension(d))
102 auto get_adj_ents = [&](
const Range &ents) {
105 const auto dim = get_dim(ents);
106 for (
size_t d = 1; d <
dim; ++d)
108 moab::Interface::UNION);
114 auto fix_disp = [&]() {
117 auto mark_fix_dofs = [&](std::vector<unsigned char> &marked_field_dofs,
118 const auto lo,
const auto hi) {
119 return prb_mng->modifyMarkDofs(problem_name,
ROW,
field_name, lo, hi,
124 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
126 for (
auto m : meshset_vec_ptr) {
127 auto bc = boost::make_shared<BCs>();
132 CHKERR m->getAttributes(bc->bcAttributes);
135 <<
"Found block " <<
m->getName() <<
" number of entities "
136 << bc->bcEnts.size() <<
" number of attributes "
137 << bc->bcAttributes.size() <<
" highest dim of entities "
138 << get_dim(bc->bcEnts);
139 CHKERR mark_fix_dofs(bc->bcMarkers, lo, hi);
140 if (get_low_dim_ents) {
141 auto low_dim_ents = get_adj_ents(bc->bcEnts);
143 low_dim_ents, bc->bcMarkers);
144 bc->bcEnts.swap(low_dim_ents);
147 bc->bcEnts, bc->bcMarkers);
149 const std::string bc_id =
150 problem_name +
"_" +
field_name +
"_" +
m->getName();
160 (boost::format(
"%s(.*)") % block_name).str()
174boost::shared_ptr<BcManager::BCs>
178 auto bc = bc_it->second;
182 return boost::shared_ptr<BCs>();
190 for (
auto ®_name : bc_regex_vec) {
191 if (std::regex_match(b.first, reg_name)) {
192 if (!boundary_marker_ptr)
193 boundary_marker_ptr =
194 boost::make_shared<std::vector<char unsigned>>();
195 boundary_marker_ptr->resize(b.second->bcMarkers.size(), 0);
196 for (
int i = 0;
i != b.second->bcMarkers.size(); ++
i) {
197 (*boundary_marker_ptr)[
i] |= b.second->bcMarkers[
i];
203 return boundary_marker_ptr;
207 const std::vector<BcManager::BcMarkerPtr> &boundary_markers_ptr_vec) {
208 auto boundary_marker_ptr = boost::make_shared<std::vector<char unsigned>>();
209 for (
auto &bcm : boundary_markers_ptr_vec) {
210 boundary_marker_ptr->resize(bcm->size(), 0);
211 for (
int i = 0;
i != bcm->size(); ++
i)
212 (*boundary_marker_ptr)[
i] |= (*bcm)[
i];
214 return boundary_marker_ptr;
218 const std::string block_name,
220 const std::string problem_name,
int lo,
224 const std::string bc_id =
225 block_prefix +
"_" +
field_name +
"_" + block_name +
"(.*)";
229 if (std::regex_match(bc.first, std::regex(bc_id))) {
230 bc_ents.merge(*(bc.second->getBcEntsPtr()));
232 <<
"Get entities from block and add to IS. Block name " << bc.first;
237 auto get_is = [&]() {
244 CHKERR ISExpand(is_bc, is_expand, &is_tmp);
258 const std::string block_name,
267BcManager::removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
268 const std::string problem_name,
const std::string
field_name,
269 bool get_low_dim_ents,
bool block_name_field_prefix,
270 bool is_distributed_mesh) {
275 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
276 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
278 std::array<Range, 3> ents_to_remove;
285 const std::string bc_id =
286 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
287 boost::lexical_cast<std::string>(
m->getMeshsetId());
289 auto bc = bcMapByBlockName.at(bc_id);
292 if (bc->dispBcPtr->data.flag1) {
293 ents_to_remove[0].merge(bc->bcEnts);
295 if (bc->dispBcPtr->data.flag2) {
296 ents_to_remove[1].merge(bc->bcEnts);
298 if (bc->dispBcPtr->data.flag3) {
299 ents_to_remove[2].merge(bc->bcEnts);
301 if (bc->dispBcPtr->data.flag4) {
302 ents_to_remove[1].merge(bc->bcEnts);
303 ents_to_remove[2].merge(bc->bcEnts);
305 if (bc->dispBcPtr->data.flag5) {
306 ents_to_remove[0].merge(bc->bcEnts);
307 ents_to_remove[2].merge(bc->bcEnts);
309 if (bc->dispBcPtr->data.flag6) {
310 ents_to_remove[0].merge(bc->bcEnts);
311 ents_to_remove[1].merge(bc->bcEnts);
314 bc->bcMarkers = std::vector<unsigned char>();
317 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
319 if (is_distributed_mesh)
320 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
323 return prb_mng->removeDofsOnEntitiesNotDistributed(
327 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
328 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
329 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
336BcManager::removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
337 const std::string problem_name,
const std::string
field_name,
338 bool get_low_dim_ents,
bool block_name_field_prefix,
339 bool is_distributed_mesh) {
344 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
345 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
347 Range ents_to_remove;
355 const std::string bc_id =
356 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
357 boost::lexical_cast<std::string>(
m->getMeshsetId());
358 auto bc = bcMapByBlockName.at(bc_id);
359 ents_to_remove.merge(bc->bcEnts);
360 bc->bcMarkers = std::vector<unsigned char>();
363 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
365 if (is_distributed_mesh)
366 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
369 return prb_mng->removeDofsOnEntitiesNotDistributed(
380 const std::string problem_name,
const std::string
field_name,
381 bool get_low_dim_ents,
bool block_name_field_prefix,
382 bool is_distributed_mesh) {
387 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
388 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
390 Range ents_to_remove;
398 const std::string bc_id =
399 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
400 boost::lexical_cast<std::string>(
m->getMeshsetId());
401 auto bc = bcMapByBlockName.at(bc_id);
402 ents_to_remove.merge(bc->bcEnts);
403 bc->bcMarkers = std::vector<unsigned char>();
406 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
408 if (is_distributed_mesh)
409 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
412 return prb_mng->removeDofsOnEntitiesNotDistributed(
423BcManager::removeBlockDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
424 const std::string problem_name,
const std::string
field_name,
425 bool get_low_dim_ents,
bool block_name_field_prefix,
426 bool is_distributed_mesh) {
431 CHKERR pushMarkDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
432 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
434 std::array<Range, 3> ents_to_remove;
440 const auto block_name =
m->getName();
442 std::string bc_id = problem_name +
"_" +
field_name +
"_" + block_name;
443 std::string regex_str;
444 if (block_name_field_prefix) {
445 regex_str = (boost::format(
"%s_%s_%s_((FIX_(ALL|X|Y|Z))|("
446 "DISPLACEMENT|ROTATE))(.*)") %
450 regex_str = (boost::format(
"%s_%s_((FIX_(ALL|X|Y|Z))|("
451 "DISPLACEMENT|ROTATE))(.*)") %
456 if (std::regex_match(bc_id, std::regex(regex_str))) {
458 auto bc = bcMapByBlockName.at(bc_id);
460 if (
auto disp_bc = bc->dispBcPtr) {
461 if (disp_bc->data.flag1) {
462 ents_to_remove[0].merge(bc->bcEnts);
464 if (disp_bc->data.flag2) {
465 ents_to_remove[1].merge(bc->bcEnts);
467 if (disp_bc->data.flag3) {
468 ents_to_remove[2].merge(bc->bcEnts);
470 if (disp_bc->data.flag4) {
471 ents_to_remove[1].merge(bc->bcEnts);
472 ents_to_remove[2].merge(bc->bcEnts);
474 if (disp_bc->data.flag5) {
475 ents_to_remove[0].merge(bc->bcEnts);
476 ents_to_remove[2].merge(bc->bcEnts);
478 if (disp_bc->data.flag6) {
479 ents_to_remove[0].merge(bc->bcEnts);
480 ents_to_remove[1].merge(bc->bcEnts);
484 "BC type not implemented");
489 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
491 if (is_distributed_mesh)
492 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
495 return prb_mng->removeDofsOnEntitiesNotDistributed(
499 CHKERR remove_dofs_on_ents(ents_to_remove[0], 0, 0);
500 CHKERR remove_dofs_on_ents(ents_to_remove[1], 1, 1);
501 CHKERR remove_dofs_on_ents(ents_to_remove[2], 2, 2);
508BcManager::removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
509 const std::string problem_name,
const std::string block_name,
510 const std::string
field_name,
bool get_low_dim_ents,
511 bool is_distributed_mesh) {
516 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
517 problem_name, block_name,
field_name, get_low_dim_ents);
519 Range ents_to_remove;
525 std::string bc_id = problem_name +
"_" +
field_name +
"_" +
m->getName();
527 auto str = boost::format(
"%s_%s_%s(.*)")
531 if (std::regex_match(bc_id, std::regex(str.str()))) {
533 auto bc = bcMapByBlockName.at(bc_id);
535 if (
auto disp_bc = bc->tempBcPtr) {
536 if (disp_bc->data.flag1) {
537 ents_to_remove.merge(bc->bcEnts);
541 "BC type not implemented");
546 auto remove_dofs_on_ents = [&](
const Range &ents,
const int lo,
548 if (is_distributed_mesh)
549 return prb_mng->removeDofsOnEntities(problem_name,
field_name, ents, lo,
552 return prb_mng->removeDofsOnEntitiesNotDistributed(
563BcManager::pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
564 const std::string problem_name,
const std::string
field_name,
565 bool get_low_dim_ents,
bool block_name_field_prefix) {
570 if (block_name_field_prefix)
572 <<
"Argument block_name_field_prefix=true has no effect";
574 auto get_dim = [&](
const Range &ents) {
575 for (
auto d : {3, 2, 1})
576 if (ents.num_of_dimension(d))
581 auto get_adj_ents = [&](
const Range &ents) {
584 const auto dim = get_dim(ents);
585 for (
size_t d = 1; d <
dim; ++d)
587 moab::Interface::UNION);
593 auto fix_disp = [&]() {
596 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
598 for (
auto m : meshset_vec_ptr) {
599 auto bc = boost::make_shared<BCs>();
603 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
604 CHKERR m->getBcDataStructure(*(bc->dispBcPtr));
607 <<
"Found block DISPLACEMENTSET number of entities "
608 << bc->bcEnts.size() <<
" highest dim of entities "
609 << get_dim(bc->bcEnts);
610 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->dispBcPtr;
612 if (bc->dispBcPtr->data.flag1)
616 if (bc->dispBcPtr->data.flag2)
620 if (bc->dispBcPtr->data.flag3)
624 if (bc->dispBcPtr->data.flag4) {
633 if (bc->dispBcPtr->data.flag5) {
642 if (bc->dispBcPtr->data.flag6) {
652 if (get_low_dim_ents) {
653 auto low_dim_ents = get_adj_ents(bc->bcEnts);
655 low_dim_ents, bc->bcMarkers);
656 bc->bcEnts.swap(low_dim_ents);
659 bc->bcEnts, bc->bcMarkers);
661 const std::string bc_id =
662 problem_name +
"_" +
field_name +
"_DISPLACEMENTSET" +
663 boost::lexical_cast<std::string>(
m->getMeshsetId());
664 bcMapByBlockName[bc_id] = bc;
686 const std::string problem_name,
const std::string
field_name,
687 bool get_low_dim_ents,
bool block_name_field_prefix) {
692 if (block_name_field_prefix)
694 <<
"Argument block_name_field_prefix=true has no effect";
696 auto get_dim = [&](
const Range &ents) {
697 for (
auto d : {3, 2, 1})
698 if (ents.num_of_dimension(d))
703 auto get_adj_ents = [&](
const Range &ents) {
706 const auto dim = get_dim(ents);
707 for (
size_t d = 1; d <
dim; ++d)
709 moab::Interface::UNION);
715 auto fix_temp = [&]() {
718 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
720 for (
auto m : meshset_vec_ptr) {
721 auto bc = boost::make_shared<BCs>();
724 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
725 CHKERR m->getBcDataStructure(*(bc->tempBcPtr));
728 <<
"Found block TEMPERATURESET number of entities "
729 << bc->bcEnts.size() <<
" highest dim of entities "
730 << get_dim(bc->bcEnts);
731 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->tempBcPtr;
733 CHKERR prb_mng->modifyMarkDofs(
737 if (get_low_dim_ents) {
738 auto low_dim_ents = get_adj_ents(bc->bcEnts);
740 low_dim_ents, bc->bcMarkers);
741 bc->bcEnts.swap(low_dim_ents);
744 bc->bcEnts, bc->bcMarkers);
746 const std::string bc_id =
747 problem_name +
"_" +
field_name +
"_TEMPERATURESET" +
748 boost::lexical_cast<std::string>(
m->getMeshsetId());
749 bcMapByBlockName[bc_id] = bc;
771 const std::string problem_name,
const std::string
field_name,
772 bool get_low_dim_ents,
bool block_name_field_prefix) {
777 if (block_name_field_prefix)
779 <<
"Argument block_name_field_prefix=true has no effect";
781 auto get_dim = [&](
const Range &ents) {
782 for (
auto d : {3, 2, 1})
783 if (ents.num_of_dimension(d))
788 auto get_adj_ents = [&](
const Range &ents) {
791 const auto dim = get_dim(ents);
792 for (
size_t d = 1; d <
dim; ++d)
794 moab::Interface::UNION);
800 auto fix_disp = [&]() {
803 auto iterate_meshsets = [&](
auto &&meshset_vec_ptr) {
805 for (
auto m : meshset_vec_ptr) {
806 auto bc = boost::make_shared<BCs>();
809 bc->heatFluxBcPtr = boost::make_shared<HeatFluxCubitBcData>();
810 CHKERR m->getBcDataStructure(*(bc->heatFluxBcPtr));
813 <<
"Found block HEATFLUX number of entities " << bc->bcEnts.size()
814 <<
" highest dim of entities " << get_dim(bc->bcEnts);
815 MOFEM_LOG(
"BcMngWorld", Sev::verbose) << *bc->heatFluxBcPtr;
817 CHKERR prb_mng->modifyMarkDofs(
821 if (get_low_dim_ents) {
822 auto low_dim_ents = get_adj_ents(bc->bcEnts);
824 low_dim_ents, bc->bcMarkers);
825 bc->bcEnts.swap(low_dim_ents);
828 bc->bcEnts, bc->bcMarkers);
830 const std::string bc_id =
831 problem_name +
"_" +
field_name +
"_HEATFLUXSET" +
832 boost::lexical_cast<std::string>(
m->getMeshsetId());
833 bcMapByBlockName[bc_id] = bc;
855 const std::string problem_name,
const std::string
field_name,
856 bool get_low_dim_ents,
bool block_name_field_prefix) {
859 auto mark_dofs = [&](
const string block_name,
const int &idx_0,
862 if (block_name_field_prefix) {
863 const string field_block =
field_name +
"_" + block_name;
865 idx_0, idx_1, get_low_dim_ents);
869 idx_1, get_low_dim_ents);
875 CHKERR mark_dofs(
"FIX_X", 0, 0);
876 CHKERR mark_dofs(
"FIX_Y", 1, 1);
877 CHKERR mark_dofs(
"FIX_Z", 2, 2);
881 CHKERR mark_dofs(
"ROTATE_X", 1, 1);
882 CHKERR mark_dofs(
"ROTATE_X", 2, 2);
883 CHKERR mark_dofs(
"ROTATE_Y", 0, 0);
884 CHKERR mark_dofs(
"ROTATE_Y", 2, 2);
885 CHKERR mark_dofs(
"ROTATE_Z", 0, 0);
886 CHKERR mark_dofs(
"ROTATE_Z", 1, 1);
889 std::string regex_str;
890 if (block_name_field_prefix) {
891 regex_str = (boost::format(
"%s_%s_%s_(.*)") % problem_name %
field_name %
895 regex_str = (boost::format(
"%s_%s_(.*)") % problem_name %
field_name).str();
898 for (
auto &
m : bcMapByBlockName) {
899 auto &bc_id =
m.first;
900 if (std::regex_match(bc_id, std::regex(regex_str))) {
902 if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_X(.*)"))) {
903 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
904 bc->dispBcPtr->data.flag1 = 1;
905 if (bc->bcAttributes.empty()) {
906 bc->dispBcPtr->data.value1 = 0;
908 <<
"Expected one attribute on block but have "
909 << bc->bcAttributes.size();
910 }
else if (bc->bcAttributes.size() >= 1) {
911 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
913 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
914 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
915 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Y(.*)"))) {
916 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
917 bc->dispBcPtr->data.flag2 = 1;
918 if (bc->bcAttributes.empty()) {
919 bc->dispBcPtr->data.value2 = 0;
921 <<
"Expected one attribute on block but have "
922 << bc->bcAttributes.size();
923 }
else if (bc->bcAttributes.size() == 1) {
924 bc->dispBcPtr->data.value2 = bc->bcAttributes[0];
925 }
else if (bc->bcAttributes.size() >= 2) {
926 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
928 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
929 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
930 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_Z(.*)"))) {
931 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
932 bc->dispBcPtr->data.flag3 = 1;
933 if (bc->bcAttributes.empty()) {
934 bc->dispBcPtr->data.value3 = 0;
936 <<
"Expected one attribute on block but have "
937 << bc->bcAttributes.size();
938 }
else if (bc->bcAttributes.size() == 1) {
939 bc->dispBcPtr->data.value3 = bc->bcAttributes[0];
940 }
else if (bc->bcAttributes.size() == 3) {
941 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
943 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
944 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
945 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_FIX_ALL(.*)"))) {
946 bc->dispBcPtr = boost::make_shared<DisplacementCubitBcData>();
947 bc->dispBcPtr->data.flag1 = 1;
948 bc->dispBcPtr->data.flag2 = 1;
949 bc->dispBcPtr->data.flag3 = 1;
950 if (bc->bcAttributes.size() >= 1) {
951 bc->dispBcPtr->data.value1 = bc->bcAttributes[0];
953 if (bc->bcAttributes.size() >= 2) {
954 bc->dispBcPtr->data.value2 = bc->bcAttributes[1];
956 if (bc->bcAttributes.size() >= 3) {
957 bc->dispBcPtr->data.value3 = bc->bcAttributes[2];
959 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
960 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
961 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_X(.*)"))) {
963 boost::make_shared<DisplacementCubitBcDataWithRotation>();
964 bc->dispBcPtr->data.flag4 = 1;
965 bc->dispBcPtr->data.flag5 = 0;
966 bc->dispBcPtr->data.flag6 = 0;
969 if (bc->bcAttributes.empty()) {
970 bc->dispBcPtr->data.value4 = 0;
972 <<
"Expected one attribute on block on block (angle (1 or 3), "
973 "center coords(3) but have "
974 << bc->bcAttributes.size();
975 }
else if (bc->bcAttributes.size() >= 1) {
976 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
978 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add X " << bc_id;
979 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *bc->dispBcPtr;
980 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
981 if (
auto ext_disp_bc =
983 bc->dispBcPtr.get())) {
984 auto &
o = ext_disp_bc->rotOffset;
985 for (
int a = 0;
a != 3; ++
a)
986 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
988 <<
"Add Rotate X Center: " <<
o[0] <<
" " <<
o[1] <<
" "
992 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Y(.*)"))) {
994 boost::make_shared<DisplacementCubitBcDataWithRotation>();
995 bc->dispBcPtr->data.flag4 = 0;
996 bc->dispBcPtr->data.flag5 = 1;
997 bc->dispBcPtr->data.flag6 = 0;
1000 if (bc->bcAttributes.empty()) {
1001 bc->dispBcPtr->data.value5 = 0;
1003 <<
"Expected one attribute on block on block (angle (1 or 3), "
1004 "center coords(3) but have "
1005 << bc->bcAttributes.size();
1006 }
else if (bc->bcAttributes.size() == 1 ||
1007 bc->bcAttributes.size() == 4) {
1008 bc->dispBcPtr->data.value5 = bc->bcAttributes[0];
1009 }
else if (bc->bcAttributes.size() == 6) {
1010 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1012 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Y " << bc_id;
1013 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1014 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1015 if (
auto ext_disp_bc =
1017 bc->dispBcPtr.get())) {
1018 auto &
o = ext_disp_bc->rotOffset;
1019 for (
int a = 0;
a != 3; ++
a)
1020 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1022 <<
"Add Rotate Y Center: " <<
o[0] <<
" " <<
o[1] <<
" "
1026 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_Z(.*)"))) {
1028 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1029 bc->dispBcPtr->data.flag4 = 0;
1030 bc->dispBcPtr->data.flag5 = 0;
1031 bc->dispBcPtr->data.flag6 = 1;
1034 if (bc->bcAttributes.empty()) {
1035 bc->dispBcPtr->data.value6 = 0;
1037 <<
"Expected one attribute on block (angle (1 or 3), center "
1038 "coords(3) but have "
1039 << bc->bcAttributes.size();
1040 }
else if (bc->bcAttributes.size() == 1 ||
1041 bc->bcAttributes.size() == 4) {
1042 bc->dispBcPtr->data.value6 = bc->bcAttributes[0];
1043 }
else if (bc->bcAttributes.size() == 3 ||
1044 bc->bcAttributes.size() == 6) {
1045 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1047 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add Z " << bc_id;
1048 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1049 if (bc->bcAttributes.size() == 4 || bc->bcAttributes.size() == 6) {
1050 if (
auto ext_disp_bc =
1052 bc->dispBcPtr.get())) {
1053 auto &
o = ext_disp_bc->rotOffset;
1054 for (
int a = 0;
a != 3; ++
a)
1055 o[
a] = bc->bcAttributes[bc->bcAttributes.size() - 3 +
a];
1057 <<
"Add Rotate Z Center: " <<
o[0] <<
" " <<
o[1] <<
" "
1061 }
else if (std::regex_match(bc_id, std::regex(
"(.*)_ROTATE_ALL(.*)"))) {
1063 boost::make_shared<DisplacementCubitBcDataWithRotation>();
1064 bc->dispBcPtr->data.flag4 = 1;
1065 bc->dispBcPtr->data.flag5 = 1;
1066 bc->dispBcPtr->data.flag6 = 1;
1067 if (bc->bcAttributes.size() >= 1) {
1068 bc->dispBcPtr->data.value4 = bc->bcAttributes[0];
1070 if (bc->bcAttributes.size() >= 2) {
1071 bc->dispBcPtr->data.value5 = bc->bcAttributes[1];
1073 if (bc->bcAttributes.size() >= 3) {
1074 bc->dispBcPtr->data.value6 = bc->bcAttributes[2];
1076 MOFEM_LOG(
"BcMngWorld", Sev::inform) <<
"Add ALL " << bc_id;
1077 MOFEM_LOG(
"BcMngWorld", Sev::inform) << *(bc->dispBcPtr);
1078 if (bc->bcAttributes.size() > 3) {
1079 if (
auto ext_disp_bc =
1081 bc->dispBcPtr.get())) {
1082 auto &
o = ext_disp_bc->rotOffset;
1083 for (
int a = 0;
a != 3; ++
a)
1084 o[
a] = bc->bcAttributes[3 +
a];
1086 <<
"Add Rotate ALL Center: " <<
o[0] <<
" " <<
o[1] <<
" "
1099 const std::string problem_name,
const std::string block_name,
1100 const std::string
field_name,
bool get_low_dim_ents) {
1107 (boost::format(
"%s_%s_%s(.*)") % problem_name %
field_name % block_name)
1110 for (
auto &
m : bcMapByBlockName) {
1112 auto &bc_id =
m.first;
1114 if (std::regex_match(bc_id, std::regex(regex_str))) {
1116 auto &bc =
m.second;
1117 bc->tempBcPtr = boost::make_shared<TemperatureCubitBcData>();
1118 bc->tempBcPtr->data.flag1 = 1;
1119 if (bc->bcAttributes.empty()) {
1120 bc->tempBcPtr->data.value1 = 0;
1122 <<
"Expected one attribute on block but have "
1123 << bc->bcAttributes.size();
1124 }
else if (bc->bcAttributes.size() >= 1) {
1125 bc->tempBcPtr->data.value1 = bc->bcAttributes[0];
1135 const std::string problem_name,
const std::string
field_name,
1136 bool get_low_dim_ents,
bool block_name_field_prefix) {
1139 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1140 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1142 CHKERR pushMarkDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
1143 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1149 const std::string problem_name,
const std::string
field_name,
1150 bool get_low_dim_ents,
bool block_name_field_prefix,
1151 bool is_distributed_mesh) {
1154 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<DISPLACEMENTSET>>(
1155 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1156 is_distributed_mesh);
1158 CHKERR removeBlockDOFsOnEntities<BcVectorMeshsetType<BLOCKSET>>(
1159 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1160 is_distributed_mesh);
1167 const std::string problem_name,
const std::string
field_name,
1168 bool get_low_dim_ents,
bool block_name_field_prefix) {
1170 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1171 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1173 auto get_block_name = [&]() {
1174 if (block_name_field_prefix)
1175 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1180 CHKERR pushMarkDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1181 problem_name, get_block_name(),
field_name, get_low_dim_ents);
1187 const std::string problem_name,
const std::string
field_name,
1188 bool get_low_dim_ents,
bool block_name_field_prefix,
1189 bool is_distributed_mesh) {
1191 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<TEMPERATURESET>>(
1192 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1193 is_distributed_mesh);
1195 auto get_block_name = [&]() {
1196 if (block_name_field_prefix)
1197 return (boost::format(
"%s_FIX_SCALAR") %
field_name).str();
1202 CHKERR removeBlockDOFsOnEntities<BcScalarMeshsetType<BLOCKSET>>(
1203 problem_name, get_block_name(),
field_name, get_low_dim_ents,
1204 is_distributed_mesh);
1210 const std::string problem_name,
const std::string
field_name,
1211 bool get_low_dim_ents,
bool block_name_field_prefix) {
1213 CHKERR pushMarkDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1214 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix);
1220 const std::string problem_name,
const std::string
field_name,
1221 bool get_low_dim_ents,
bool block_name_field_prefix,
1222 bool is_distributed_mesh) {
1224 CHKERR removeBlockDOFsOnEntities<BcMeshsetType<HEATFLUXSET>>(
1225 problem_name,
field_name, get_low_dim_ents, block_name_field_prefix,
1226 is_distributed_mesh);
1230std::pair<std::string, std::string>
1232 const std::string prb_name) {
1236 auto field_rgx_str =
1237 (boost::format(
"%s_([a-zA-Z0-9]*)_(.*)") % prb_name).str();
1238 std::regex field_rgx(field_rgx_str);
1239 std::smatch match_field_name;
1241 std::string block_name;
1243 if (std::regex_search(block_id, match_field_name, field_rgx)) {
1245 block_name = match_field_name[2];
1248 "Field name and block name can not be resolved");
1251 return std::make_pair(
field_name, block_name);
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
FTensor::Index< 'm', SPACE_DIM > m
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
FTensor::Index< 'i', SPACE_DIM > i
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
constexpr auto field_name
Simple interface for fast problem set-up.
boost::shared_ptr< std::vector< char unsigned > > BcMarkerPtr
MoFEMErrorCode getOptions()
get options
BcMarkerPtr getMergedBlocksMarker(std::vector< std::regex > bc_regex_vec)
Get the Merged Boundary Marker object.
static std::pair< std::string, std::string > extractStringFromBlockId(const std::string block_id, const std::string prb_name)
Extract block name and block name form block id.
BcMapByBlockName bcMapByBlockName
SmartPetscObj< IS > getBlockIS(const std::string block_prefix, const std::string block_name, const std::string field_name, const std::string problem_name, int lo, int hi, SmartPetscObj< IS > is_expand=SmartPetscObj< IS >())
Get block IS.
MoFEMErrorCode removeBlockDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true, bool is_distributed_mesh=true)
Remove DOFs from problem.
BcManager(const MoFEM::Core &core)
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
boost::shared_ptr< BCs > popMarkDOFsOnEntities(const std::string block_name)
Get bc data and remove element.
MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true)
Mark block DOFs.
BcMapByBlockName & getBcMapByBlockName()
Get the bc map.
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
A specialized version of DisplacementCubitBcData that includes an additional rotation offset.
Section manager is used to create indexes and sections.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Interface for managing meshsets containing materials and boundary conditions.
Problem manager is used to build and partition problems.
intrusive_ptr for managing petsc objects
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.