29 #include <moab/SpatialLocator.hpp>
30 #include <moab/ElemEvaluator.hpp>
33 using namespace MoFEM;
54 #include <Smoother.hpp>
55 #include <VolumeLengthQuality.hpp>
56 #include <SurfaceSlidingConstrains.hpp>
63 #include <petsc/private/pcimpl.h>
72 PetscViewerAndFormat *vf) {
73 PetscViewer viewer = vf->viewer;
78 PetscReal *lnorms, *norms;
79 PetscInt numFields,
f, pStart, pEnd, p;
85 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 4);
86 CHKERR SNESGetFunction(snes, &res, 0, 0);
87 CHKERR SNESGetDM(snes, &dm);
88 CHKERR DMGetDefaultSection(dm, &s);
89 CHKERR PetscSectionGetNumFields(s, &numFields);
90 CHKERR PetscSectionGetChart(s, &pStart, &pEnd);
91 CHKERR PetscCalloc2(numFields, &lnorms, numFields, &norms);
92 CHKERR VecGetArrayRead(res, &
r);
93 for (p = pStart; p < pEnd; ++p) {
94 for (
f = 0;
f < numFields; ++
f) {
95 PetscInt fdof, foff,
d;
97 CHKERR PetscSectionGetFieldDof(s, p,
f, &fdof);
98 CHKERR PetscSectionGetFieldOffset(s, p,
f, &foff);
99 for (
d = 0;
d < fdof; ++
d)
100 lnorms[
f] += PetscRealPart(PetscSqr(
r[foff +
d]));
103 CHKERR VecRestoreArrayRead(res, &
r);
104 CHKERR MPIU_Allreduce(lnorms, norms, numFields, MPIU_REAL, MPIU_SUM,
105 PetscObjectComm((PetscObject)dm));
106 CHKERR PetscViewerPushFormat(viewer, vf->format);
107 CHKERR PetscViewerASCIIAddTab(viewer, ((PetscObject)snes)->tablevel);
108 CHKERR PetscViewerASCIIPrintf(viewer,
"%3D SNES Function norm %14.12e\n", its,
110 for (
f = 0;
f < numFields; ++
f) {
114 (
double)PetscSqrtReal(norms[
f]));
116 CHKERR PetscViewerASCIISubtractTab(viewer, ((PetscObject)snes)->tablevel);
117 CHKERR PetscViewerPopFormat(viewer);
118 CHKERR PetscFree2(lnorms, norms);
124 namespace po = boost::program_options;
129 boost::shared_ptr<WrapMPIComm> moab_comm_wrap) {
131 std::vector<ParallelComm *> list_pcomms;
132 ParallelComm::get_all_pcomm(&moab, list_pcomms);
140 for (
auto p : list_pcomms) {
145 new ParallelComm(&moab, moab_comm_wrap->get_comm(), &pcomm_id);
151 const int from_proc,
Range &entities,
152 const bool adjacencies,
const bool tags) {
153 ErrorCode result = MB_SUCCESS;
157 auto add_verts = [&](
Range &sent_ents) {
162 std::pair<Range::const_iterator, Range::const_iterator> set_range =
163 sent_ents.equal_range(MBENTITYSET);
164 ErrorCode result = MB_SUCCESS, tmp_result;
165 for (Range::const_iterator rit = set_range.first; rit != set_range.second;
167 tmp_result = moab_tmp.get_entities_by_type(*rit, MBVERTEX, sent_ents);
173 std::copy(sent_ents.begin(), set_range.first, range_inserter(tmp_ents));
174 result = moab_tmp.get_adjacencies(tmp_ents, 0,
false, sent_ents,
175 moab::Interface::UNION);
176 CHK_MOAB_THROW(result,
"Failed to get vertices adj to ghosted ents");
181 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab_tmp,
MYPCOMM_INDEX);
182 auto &procConfig = pcomm->proc_config();
183 const int MAX_BCAST_SIZE = (1 << 28);
185 ParallelComm::Buffer buff(ParallelComm::INITIAL_BUFF_SIZE);
186 buff.reset_ptr(
sizeof(
int));
187 if ((
int)procConfig.proc_rank() == from_proc) {
189 result = add_verts(entities);
192 buff.reset_ptr(
sizeof(
int));
193 result = pcomm->pack_buffer(entities, adjacencies, tags,
false, -1, &buff);
195 "Failed to compute buffer size in broadcast_entities");
196 buff.set_stored_size();
197 buff_size = buff.buff_ptr - buff.mem_ptr;
201 MPI_Bcast(&buff_size, 1, MPI_INT, from_proc, procConfig.proc_comm());
202 if (MPI_SUCCESS != success) {
209 if ((
int)procConfig.proc_rank() != from_proc)
210 buff.reserve(buff_size);
214 int sz = std::min(buff_size, MAX_BCAST_SIZE);
215 success = MPI_Bcast(buff.mem_ptr + offset, sz, MPI_UNSIGNED_CHAR, from_proc,
216 procConfig.proc_comm());
217 if (MPI_SUCCESS != success) {
225 std::vector<std::vector<EntityHandle>> dum1a, dum1b;
226 std::vector<std::vector<int>> dum1p;
227 std::vector<EntityHandle> dum2, dum4;
228 std::vector<unsigned int> dum3;
229 buff.reset_ptr(
sizeof(
int));
230 if ((
int)procConfig.proc_rank() == from_proc) {
231 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
232 result = pcomm->unpack_buffer(buff.buff_ptr,
false, from_proc, -1, dum1a,
233 dum1b, dum1p, dum2, dum2, dum3, dum4);
235 result = pcomm->unpack_buffer(buff.buff_ptr,
false, from_proc, -1, dum1a,
236 dum1b, dum1p, dum2, dum2, dum3, dum4);
238 CHK_MOAB_THROW(result,
"Failed to unpack buffer in broadcast_entities");
239 std::copy(dum4.begin(), dum4.end(), range_inserter(entities));
249 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
255 PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Fixing nodes options",
"none");
257 CHKERR PetscOptionsScalar(
"-gc_fix_threshold",
258 "fix nodes below given threshold",
"",
259 gcFixThreshold, &gcFixThreshold, PETSC_NULL);
260 CHKERR PetscPrintf(PETSC_COMM_WORLD,
261 "### Input parameter: -gc_fix_threshold %6.4e \n",
264 ierr = PetscOptionsEnd();
270 const bool fix_small_g =
true,
271 const bool debug =
false)
const {
276 Range tets_level, prisms_level;
285 tets_level.merge(prisms_level);
288 CHKERR skin.find_skin(0, tets_level,
false, mesh_skin);
290 mesh_skin = mesh_skin.subset_by_type(MBTRI);
292 Range faces_to_remove, contact_faces;
295 faces_to_remove = subtract(faces_to_remove, contact_faces);
297 mesh_skin = subtract(mesh_skin, faces_to_remove);
299 CHKERR m_field.
get_moab().get_connectivity(mesh_skin, fix_material_nodes);
302 Range fixed_edges_nodes;
303 CHKERR m_field.
get_moab().get_connectivity(fixed_edges, fixed_edges_nodes,
306 Range crack_faces_and_fixed_edges_nodes;
308 cP.
crackFaces, crack_faces_and_fixed_edges_nodes,
true);
309 crack_faces_and_fixed_edges_nodes =
310 intersect(crack_faces_and_fixed_edges_nodes, fixed_edges_nodes);
312 Range crack_faces_edges;
314 cP.
crackFaces, 1,
false, crack_faces_edges, moab::Interface::UNION);
315 Range not_fixed_edges = intersect(crack_faces_edges, fixed_edges);
316 Range not_fixed_edges_nodes;
318 not_fixed_edges_nodes,
true);
319 crack_faces_and_fixed_edges_nodes =
320 subtract(crack_faces_and_fixed_edges_nodes, not_fixed_edges_nodes);
321 fix_material_nodes.merge(crack_faces_and_fixed_edges_nodes);
323 Range not_fixed_edges_skin;
324 CHKERR skin.find_skin(0, not_fixed_edges,
false, not_fixed_edges_skin);
325 fix_material_nodes.merge(
331 CHKERR m_field.
get_moab().write_file(
"fixed_faces.vtk",
"VTK",
"",
340 auto bc_fix_nodes = [&m_field,
344 CHKERR m_field.
get_moab().get_entities_by_handle(meshset, ents,
true);
347 fix_material_nodes.merge(nodes);
352 CHKERR bc_fix_nodes(it->getMeshset());
358 CHKERR bc_fix_nodes(it->getMeshset());
366 CHKERR bc_fix_nodes(it->getMeshset());
375 fix_material_nodes.merge(contact_nodes);
381 if (
bit->getName().compare(0, 9,
"SPRING_BC") == 0) {
391 fix_material_nodes.merge(contact_nodes);
396 Range interface_nodes;
399 fix_material_nodes.merge(interface_nodes);
402 auto add_nodes_on_opposite_side_of_prism = [&m_field, &fix_material_nodes,
403 this](
bool only_contact_prisms =
408 fix_material_nodes, 3,
false, adj_prisms, moab::Interface::UNION);
409 adj_prisms = adj_prisms.subset_by_type(MBPRISM);
410 if (only_contact_prisms) {
413 for (
auto p : adj_prisms) {
416 CHKERR m_field.
get_moab().get_connectivity(p, conn, num_nodes,
false);
418 for (
int n = 0;
n != 3; ++
n) {
419 if (fix_material_nodes.find(conn[
n]) != fix_material_nodes.end()) {
420 add_nodes.insert(conn[3 +
n]);
422 if (fix_material_nodes.find(conn[3 +
n]) !=
423 fix_material_nodes.end()) {
424 add_nodes.insert(conn[
n]);
427 fix_material_nodes.merge(add_nodes);
432 CHKERR add_nodes_on_opposite_side_of_prism();
438 auto copy_map = [&fix_material_nodes](
const auto &map) {
439 std::map<EntityHandle, double> map_copy;
440 for (
auto &
m : map) {
441 if (fix_material_nodes.find(
m.first) == fix_material_nodes.end()) {
442 map_copy[
m.first] =
m.second;
448 const std::map<EntityHandle, double> map_j = copy_map(cP.
mapJ);
449 const std::map<EntityHandle, double> map_g1 = copy_map(cP.
mapG1);
451 auto find_max = [](
const auto &map) {
454 max = fmax(
m.second, max);
458 const double max_j = find_max(map_j);
459 const double max_g1 = find_max(map_g1);
461 for (
auto &
m : map_j) {
462 if ((
m.second < gcFixThreshold * max_j) &&
463 (map_g1.at(
m.first) < gcFixThreshold * max_g1)) {
464 fix_material_nodes.insert(
m.first);
472 "No points to move on crack front");
488 CHKERR add_nodes_on_opposite_side_of_prism(
true);
498 CrackPropagation::query_interface(boost::typeindex::type_index type_index,
503 if (type_index == boost::typeindex::type_id<CrackPropagation>()) {
508 if (type_index == boost::typeindex::type_id<CPSolvers>()) {
509 CHKERR cpSolversPtr->query_interface(type_index, iface);
513 if (type_index == boost::typeindex::type_id<CPMeshCut>()) {
514 CHKERR cpMeshCutPtr->query_interface(type_index, iface);
523 const int geometry_order)
524 : mField(m_field), contactPostProcMoab(contactPostProcCore),
525 setSingularCoordinates(false), approxOrder(
approx_order),
526 geometryOrder(geometry_order), gC(0), betaGc(0),
527 isGcHeterogeneous(PETSC_FALSE), isPartitioned(PETSC_FALSE),
528 propagateCrack(PETSC_FALSE), refAtCrackTip(0), refOrderAtTip(0),
529 residualStressBlock(-1), densityMapBlock(-1),
530 addAnalyticalInternalStressOperators(PETSC_FALSE), postProcLevel(0),
531 startStep(0), crackFrontLength(-1), crackSurfaceArea(-1), rHo0(1),
532 nBone(0), cpSolversPtr(new
CPSolvers(*this)),
535 if (!LogManager::checkIfChannelExist(
"CPWorld")) {
536 auto core_log = logging::core::get();
539 LogManager::createSink(LogManager::getStrmWorld(),
"CPWorld"));
541 LogManager::createSink(LogManager::getStrmSync(),
"CPSync"));
543 LogManager::createSink(LogManager::getStrmSelf(),
"CPSelf"));
545 LogManager::setLog(
"CPWorld");
546 LogManager::setLog(
"CPSync");
547 LogManager::setLog(
"CPSelf");
554 MOFEM_LOG(
"CPWorld", Sev::noisy) <<
"CPSolve created";
556 #ifdef GIT_UM_SHA1_NAME
557 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"User module git commit id %s",
564 <<
"Fracture module version " << version.
strVersion();
566 #ifdef GIT_FM_SHA1_NAME
567 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"Fracture module git commit id %s",
571 ierr = registerInterface<CrackPropagation>();
572 CHKERRABORT(PETSC_COMM_SELF,
ierr);
573 ierr = registerInterface<CPSolvers>();
574 CHKERRABORT(PETSC_COMM_SELF,
ierr);
575 ierr = registerInterface<CPMeshCut>();
576 CHKERRABORT(PETSC_COMM_SELF,
ierr);
583 moabCommWorld = boost::make_shared<WrapMPIComm>(PETSC_COMM_WORLD,
false);
593 CHKERR PetscOptionsBool(
"-my_propagate_crack",
598 CHKERR PetscOptionsInt(
"-my_geom_order",
"approximation geometry order",
"",
600 CHKERR PetscOptionsScalar(
"-my_gc",
"release energy",
"",
gC, &
gC,
602 CHKERR PetscOptionsScalar(
"-beta_gc",
"heterogeneous gc beta coefficient",
604 CHKERR PetscOptionsBool(
"-my_is_partitioned",
"true if mesh is partitioned",
606 CHKERR PetscOptionsInt(
"-my_ref",
"crack tip mesh refinement level",
"",
608 CHKERR PetscOptionsInt(
"-my_ref_order",
609 "crack tip refinement approximation order level",
"",
612 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -my_order %d",
616 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -my_gc %6.4e",
620 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -my_ref %d",
622 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -my_ref_order %d",
628 "if false force use of nonlinear element for hooke material",
"",
632 CHKERR PetscOptionsBool(
"-my_add_pressure_ale",
633 "if set surface pressure is considered in ALE",
"",
637 CHKERR PetscOptionsBool(
"-my_add_springs_ale",
638 "if set surface springs is considered in ALE",
"",
642 CHKERR PetscOptionsBool(
"-my_add_surface_force_ale",
643 "if set surface force is considered in ALE",
"",
648 "-my_ignore_material_surface_force",
649 "if set material forces arising from surface force are ignored",
"",
653 CHKERR PetscOptionsBool(
"-my_add_singularity",
654 "if set singularity added to crack front",
"",
660 char file_name[255] =
"mwls.med";
661 CHKERR PetscOptionsString(
662 "-my_mwls_approx_file",
663 "file with data from med file (code-aster) with radiation data",
"",
664 file_name, file_name, 255, &flg);
665 if (flg == PETSC_TRUE) {
668 "### Input parameter: -my_mwls_approx_file %s", file_name);
670 char tag_name[255] =
"SIGP";
671 CHKERR PetscOptionsString(
"-my_internal_stress_name",
672 "name of internal stress tag",
"", tag_name,
673 tag_name, 255, &flg);
675 "### Input parameter: -my_internal_stress_name %s", tag_name);
677 CHKERR PetscOptionsString(
"-my_eigen_stress_name",
678 "name of eigen stress tag",
"", tag_name,
679 tag_name, 255, &flg);
681 "### Input parameter: -my_eigen_stress_name %s", tag_name);
685 "-my_residual_stress_block",
686 "block in mechanical (i.e. cracked) mesh to which residual stress "
687 "and density mapping are applied",
690 "### Input parameter: -my_residual_stress_block %d",
693 CHKERR PetscOptionsInt(
"-my_density_block",
694 "block to which density is mapped",
"",
699 char density_tag_name[255] =
"RHO";
700 CHKERR PetscOptionsString(
"-my_density_tag_name",
701 "name of density tag (RHO)",
"", density_tag_name,
702 density_tag_name, 255, PETSC_NULL);
704 "### Input parameter: -my_density_tag_name %s",
710 char file_name[255] =
"add_cubit_meshsets.in";
711 CHKERR PetscOptionsString(
"-meshsets_config",
712 "meshsets config file name",
"", file_name,
713 file_name, 255, &flg);
714 if (flg == PETSC_TRUE) {
715 ifstream
f(file_name);
718 "File configuring meshsets ( %s ) cannot be open\n",
730 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -material %s",
735 CHKERR PetscOptionsScalar(
"-my_rho0",
"release energy",
"",
rHo0, &
rHo0,
737 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -my_rho0 %6.4e",
740 CHKERR PetscOptionsScalar(
"-my_n_bone",
"release energy",
"",
nBone,
743 "### Input parameter: -my_n_bone %6.4e",
nBone);
747 CHKERR PetscOptionsInt(
"-nb_load_steps",
"number of load steps",
"",
750 CHKERR PetscOptionsInt(
"-nb_cut_steps",
"number of cut mesh steps",
"",
756 "### Input parameter: -load_scale %6.4e",
loadScale);
761 "-other_side_constrain",
762 "Set surface constrain on other side of crack surface",
"",
769 CHKERR PetscOptionsReal(
"-smoother_alpha",
"Control mesh smoother",
"",
771 CHKERR PetscOptionsReal(
"-my_gamma",
"Controls mesh smoother",
"",
775 "### Input parameter: -smoother_alpha %6.4e",
smootherAlpha);
782 CHKERR PetscOptionsReal(
"-arc_alpha",
"Arc length alpha",
"",
arcAlpha,
784 CHKERR PetscOptionsReal(
"-arc_beta",
"Arc length beta",
"",
arcBeta,
786 CHKERR PetscOptionsReal(
"-arc_s",
"Arc length step size",
"",
arcS, &
arcS,
789 "### Input parameter: -arc_alpha %6.4e",
arcAlpha);
791 "### Input parameter: -arc_beta %6.4e",
arcBeta);
792 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -arc_s %6.4e",
805 CHKERR PetscOptionsBool(
"-my_ignore_contact",
"If true ignore contact",
807 CHKERR PetscOptionsBool(
"-my_fix_contact_nodes",
810 CHKERR PetscOptionsBool(
"-my_print_contact_state",
811 "If true print contact state",
"",
814 "-my_contact_output_integ_pts",
815 "If true output data at contact integration points",
"",
817 CHKERR PetscOptionsReal(
"-my_r_value",
"Contact regularisation parameter",
819 CHKERR PetscOptionsReal(
"-my_cn_value",
"Contact augmentation parameter",
821 CHKERR PetscOptionsInt(
"-my_contact_order",
"contact approximation order",
824 "-my_contact_lambda_order",
"contact Lagrange multipliers order",
"",
827 "### Input parameter: -my_cn_value %6.4e",
cnValue);
829 "### Input parameter: -my_contact_order %d",
contactOrder);
831 "### Input parameter: -my_cn_value %6.4e",
cnValue);
833 "### Input parameter: -my_contact_order %d",
contactOrder);
839 CHKERR PetscOptionsBool(
"-cut_mesh",
"If true mesh is cut by surface",
"",
842 CHKERR PetscOptionsReal(
"-cut_factor",
"Crack acceleration factor",
"",
847 "-run_elastic_without_crack",
"If true mesh is cut by surface",
"",
850 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"### Input parameter: -cut_mesh %d",
853 "### Input parameter: -cut_factor %6.4e",
856 "### Input parameter: -run_elastic_without_crack %d",
859 CHKERR PetscOptionsInt(
"-post_proc_level",
"level of output files",
"",
862 "### Input parameter: -post_proc_level %6.4e",
postProcLevel);
866 "-add_analytical_internal_stress_operators",
867 "If true add analytical internal stress operators for mwls test",
"",
872 CHKERR PetscOptionsBool(
"-solve_eigen_problem",
"If true solve eigen problem",
877 "-use_eigen_pos_simple_contact",
878 "If true use eigen positions for matching meshes contact",
"",
882 "### Input parameter: -solve_eigen_problem %d",
885 "### Input parameter: -use_eigen_pos_simple_contact %d",
890 CHKERR PetscOptionsScalar(
"-part_weight_power",
"Partitioning weight power",
896 "-calc_mwls_coeffs_every_propagation_step",
897 "If true recaulculate MWLS coefficients every propagation step",
"",
901 ierr = PetscOptionsEnd();
909 char mumps_options[] =
910 "-mat_mumps_icntl_14 800 -mat_mumps_icntl_24 1 -mat_mumps_icntl_13 1 "
911 "-propagation_fieldsplit_0_mat_mumps_icntl_14 800 "
912 "-propagation_fieldsplit_0_mat_mumps_icntl_24 1 "
913 "-propagation_fieldsplit_0_mat_mumps_icntl_13 1 "
914 "-propagation_fieldsplit_1_mat_mumps_icntl_14 800 "
915 "-propagation_fieldsplit_1_mat_mumps_icntl_24 1 "
916 "-propagation_fieldsplit_1_mat_mumps_icntl_13 1 "
917 "-mat_mumps_icntl_20 0 "
918 "-propagation_fieldsplit_0_mat_mumps_icntl_20 0 "
919 "-propagation_fieldsplit_1_mat_mumps_icntl_20 0";
920 CHKERR PetscOptionsInsertString(NULL, mumps_options);
923 CHKERR getInterface<CPMeshCut>()->getOptions();
924 CHKERR getInterface<CPSolvers>()->getOptions();
933 CIRCULAR_PLATE_IN_INFINITE_BODY,
934 ANGLE_ANALYTICAL_MODE_1,
935 MWLS_INTERNAL_STRESS,
936 MWLS_INTERNAL_STRESS_ANALYTICAL,
941 const char *list[] = {
"analytical_mode_1",
942 "circular_plate_in_infinite_body",
943 "angle_analytical_mode_1",
944 "mwls_internal_stress",
945 "mwls_internal_stress_analytical",
947 "notch_with_density"};
949 int choice_value = ANALYTICAL_MODE_1;
954 &choice_value, &flg);
955 CHKERR PetscOptionsScalar(
"-test_tol",
"test tolerance",
"", test_tol,
956 &test_tol, PETSC_NULL);
957 ierr = PetscOptionsEnd();
960 if (flg == PETSC_TRUE) {
964 switch (choice_value) {
965 case ANALYTICAL_MODE_1: {
967 for (map<EntityHandle, double>::iterator mit =
mapG1.begin();
968 mit !=
mapG1.end(); mit++) {
969 ave_g1 += mit->second;
971 ave_g1 /=
mapG1.size();
973 const double gc = 1e-5;
975 const double error = fabs(ave_g1 - gc) / gc;
978 "ave_gc = %6.4e gc = %6.4e tolerance = %6.4e error = %6.4e\n",
979 ave_g1, gc, test_tol, error);
980 if (error > test_tol || error != error) {
982 "ANALYTICAL_MODE_1 test failed");
985 case CIRCULAR_PLATE_IN_INFINITE_BODY: {
986 const double gc = 1.1672e+01;
987 double max_error = 0;
988 for (map<EntityHandle, double>::iterator mit =
mapG1.begin();
989 mit !=
mapG1.end(); mit++) {
990 const double g = mit->second;
991 const double error = fabs(
g - gc) / gc;
992 max_error = (max_error < error) ? error : max_error;
995 "g = %6.4e gc = %6.4e tolerance = %6.4e error = %6.4e\n",
g, gc,
998 if (max_error > test_tol || max_error != max_error)
1000 "CIRCULAR_PLATE_IN_INFINITE_BODY test failed");
1003 case ANGLE_ANALYTICAL_MODE_1: {
1004 const double gc = 1e-5;
1005 double max_error = 0;
1006 for (map<EntityHandle, double>::iterator mit =
mapG1.begin();
1007 mit !=
mapG1.end(); mit++) {
1008 const double g = mit->second;
1009 const double error = fabs(
g - gc) / gc;
1010 max_error = (max_error < error) ? error : max_error;
1013 "g = %6.4e gc = %6.4e tolerance = %6.4e error = %6.4e\n",
g, gc,
1016 if (max_error > test_tol || max_error != max_error) {
1018 "ANGLE_ANALYTICAL_MODE_1 test failed %6.4e > %6.4e",
1019 max_error, test_tol);
1022 case MWLS_INTERNAL_STRESS: {
1025 double max_error = 0;
1026 for (map<EntityHandle, double>::iterator mit =
mapG1.begin();
1027 mit !=
mapG1.end(); mit++) {
1028 const double g = mit->second;
1029 const double error = fabs(
g - gc) / gc;
1030 max_error = (max_error < error) ? error : max_error;
1033 "g = %6.4e gc = %6.4e tolerance = %6.4e error = %6.4e\n",
g, gc,
1036 if (max_error > test_tol || max_error != max_error) {
1038 "MWLS_INTERNAL_STRESS test failed");
1041 case MWLS_INTERNAL_STRESS_ANALYTICAL: {
1044 double max_error = 0;
1045 for (map<EntityHandle, double>::iterator mit =
mapG1.begin();
1046 mit !=
mapG1.end(); mit++) {
1047 const double g = mit->second;
1048 const double error = fabs(
g - gc) / gc;
1049 max_error = (max_error < error) ? error : max_error;
1052 "g = %6.4e gc = %6.4e tolerance = %6.4e error = %6.4e\n",
g, gc,
1055 if (max_error > test_tol || max_error != max_error) {
1057 "MWLS_INTERNAL_STRESS_ANALYTICAL test failed");
1060 case CUT_CIRCLE_PLATE: {
1064 const double g =
m.second;
1065 max_g = fmax(
g, max_g);
1069 double error = fabs(max_g - gc) / gc;
1070 if (error > test_tol || error != error) {
1072 "CUT_CIRCLE_PLATE test failed");
1075 case NOTCH_WITH_DENSITY: {
1078 for (map<EntityHandle, double>::iterator mit =
mapG1.begin();
1079 mit !=
mapG1.end(); mit++) {
1080 const double g = mit->second;
1081 max_g = fmax(
g, max_g);
1083 const double gc = 1.6642e-04;
1085 double error = fabs(max_g - gc) / gc;
1086 if (error > test_tol || error != error) {
1088 "NOTCH_WITH_DENSITY test failed");
1099 const Range &ents) {
1101 std::ostringstream file;
1107 &meshset_out, 1, NULL, 0);
1121 map<int, Range> layers;
1124 CHKERR moab.get_adjacencies(ref_nodes, 3,
false, tets,
1125 moab::Interface::UNION);
1131 CHKERR moab.get_connectivity(tets, ref_nodes,
false);
1132 CHKERR moab.get_adjacencies(ref_nodes, 3,
false, tets,
1133 moab::Interface::UNION);
1137 layers[ll + 1] = subtract(tets, layers[ll]);
1142 int last = layers.size();
1143 auto rest_elements_in_the_bubble = subtract(tets_bit_2, layers[last - 1]);
1144 if (rest_elements_in_the_bubble.size())
1145 layers[last] = rest_elements_in_the_bubble;
1149 rval = moab.tag_get_handle(
"TETS_WEIGHT", th_tet_weight);
1150 if (
rval == MB_SUCCESS) {
1151 CHKERR moab.tag_delete(th_tet_weight);
1154 CHKERR moab.tag_get_handle(
"TETS_WEIGHT", 1, MB_TYPE_INTEGER, th_tet_weight,
1155 MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
1157 for (
unsigned int ll = 0; ll != layers.size(); ll++) {
1159 CHKERR moab.tag_clear_data(th_tet_weight, layers[ll], &weight);
1172 CHKERR moab.tag_delete(th_tet_weight);
1178 Range &proc_ents,
const int verb,
1184 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
1187 Range all_proc_ents;
1190 Tag part_tag = pcomm->part_tag();
1193 0, MBENTITYSET, &part_tag, NULL, 1, tagged_sets, moab::Interface::UNION);
1194 for (Range::iterator mit = tagged_sets.begin(); mit != tagged_sets.end();
1197 CHKERR moab.tag_get_data(part_tag, &*mit, 1, &part);
1199 CHKERR moab.get_entities_by_dimension(*mit, 3, proc_ents,
true);
1200 CHKERR moab.get_entities_by_handle(*mit, all_proc_ents,
true);
1203 proc_ents = intersect(proc_ents, tets);
1207 CHKERR skin.find_skin(0, tets,
false, tets_skin);
1210 Range proc_ents_skin[4];
1217 bit2_again,
BitRefLevel().set(), MBPRISM, prisms_level);
1221 Range contact_prisms_to_remove =
1223 prisms_level = subtract(prisms_level, contact_prisms_to_remove);
1225 Range face_on_prism;
1226 CHKERR moab.get_adjacencies(contact_prisms, 2,
false, face_on_prism,
1227 moab::Interface::UNION);
1229 Range tris_on_prism = face_on_prism.subset_by_type(MBTRI);
1231 Range adj_vols_to_prisms;
1232 CHKERR moab.get_adjacencies(tris_on_prism, 3,
false, adj_vols_to_prisms,
1233 moab::Interface::UNION);
1237 bit2_again,
BitRefLevel().set(), MBTET, tet_level);
1239 Range contact_tets_from_vols = adj_vols_to_prisms.subset_by_type(MBTET);
1241 contact_tets = intersect(tet_level, contact_tets_from_vols);
1244 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
1245 Range contact_tets_container = contact_tets;
1274 proc_ents.merge(contact_tets);
1276 Range contact_tets_vert;
1277 CHKERR moab.get_adjacencies(contact_tets, 0,
false, contact_tets_vert,
1278 moab::Interface::UNION);
1279 Range contact_tets_edges;
1280 CHKERR moab.get_adjacencies(contact_tets, 1,
false, contact_tets_edges,
1281 moab::Interface::UNION);
1282 Range contact_tets_faces;
1283 CHKERR moab.get_adjacencies(contact_tets, 2,
false, contact_tets_faces,
1284 moab::Interface::UNION);
1285 proc_ents_skin[2].merge(contact_tets_faces);
1286 proc_ents_skin[1].merge(contact_tets_edges);
1287 proc_ents_skin[0].merge(contact_tets_vert);
1290 proc_ents_skin[3] = proc_ents;
1291 CHKERR skin.find_skin(0, proc_ents,
false, proc_ents_skin[2]);
1293 proc_ents_skin[2] = subtract(proc_ents_skin[2], tets_skin);
1301 CHKERR moab.get_adjacencies(proc_ents_skin[2], 1,
false, proc_ents_skin[1],
1302 moab::Interface::UNION);
1303 CHKERR moab.get_connectivity(proc_ents_skin[1], proc_ents_skin[0],
true);
1305 Range crack_faces_nodes;
1307 proc_ents_skin[0].merge(crack_faces_nodes);
1312 Range arc_length_vertices;
1313 CHKERR moab.get_entities_by_type(lambda_meshset, MBVERTEX,
1314 arc_length_vertices,
true);
1315 if (arc_length_vertices.size() != 1) {
1317 "Should be one vertex in <LAMBDA_ARC_LENGTH> field but is %d",
1318 arc_length_vertices.size());
1321 proc_ents_skin[0].merge(arc_length_vertices);
1323 const double coords[] = {0, 0, 0};
1335 Range all_ents_no_on_part;
1336 CHKERR moab.get_entities_by_handle(0, all_ents_no_on_part,
true);
1337 all_ents_no_on_part = subtract(all_ents_no_on_part, all_proc_ents);
1338 for (
int dd = 0;
dd != 4; ++
dd) {
1339 all_ents_no_on_part = subtract(all_ents_no_on_part, proc_ents_skin[
dd]);
1341 all_ents_no_on_part = subtract(
1342 all_ents_no_on_part, all_ents_no_on_part.subset_by_type(MBENTITYSET));
1348 CHKERR moab.get_entities_by_handle(0, all_ents);
1349 std::vector<unsigned char> pstat_tag(all_ents.size(), 0);
1350 CHKERR moab.tag_set_data(pcomm->pstatus_tag(), all_ents,
1351 &*pstat_tag.begin());
1354 CHKERR pcomm->resolve_shared_ents(0, proc_ents, 3, -1, proc_ents_skin);
1359 std::ostringstream file_skin;
1362 CHKERR moab.create_meshset(MESHSET_SET, meshset_skin);
1363 CHKERR moab.add_entities(meshset_skin, proc_ents_skin[2]);
1364 CHKERR moab.add_entities(meshset_skin, proc_ents_skin[1]);
1365 CHKERR moab.add_entities(meshset_skin, proc_ents_skin[0]);
1367 CHKERR moab.write_file(file_skin.str().c_str(),
"VTK",
"", &meshset_skin,
1369 std::ostringstream file_owned;
1372 CHKERR moab.create_meshset(MESHSET_SET, meshset_owned);
1373 CHKERR moab.add_entities(meshset_owned, proc_ents);
1374 CHKERR moab.write_file(file_owned.str().c_str(),
"VTK",
"", &meshset_owned,
1376 CHKERR moab.delete_entities(&meshset_owned, 1);
1382 CHKERR pcomm->get_shared_entities(-1, shared_ents);
1383 std::ostringstream file_shared_owned;
1387 CHKERR moab.create_meshset(MESHSET_SET, meshset_shared_owned);
1388 CHKERR moab.add_entities(meshset_shared_owned, shared_ents);
1389 CHKERR moab.write_file(file_shared_owned.str().c_str(),
"VTK",
"",
1390 &meshset_shared_owned, 1);
1391 CHKERR moab.delete_entities(&meshset_shared_owned, 1);
1401 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
1409 std::ostringstream file_owned;
1412 CHKERR moab.create_meshset(MESHSET_SET, meshset);
1413 CHKERR moab.add_entities(meshset,
bitEnts.subset_by_dimension(3));
1414 CHKERR moab.write_file(file_owned.str().c_str(),
"VTK",
"", &meshset, 1);
1415 CHKERR moab.delete_entities(&meshset, 1);
1419 Tag part_tag = pcomm->part_tag();
1422 0, MBENTITYSET, &part_tag, NULL, 1, tagged_sets,
1423 moab::Interface::UNION);
1432 tris_level = intersect(tris_level, prisms_sides);
1437 for (Range::iterator mit = tagged_sets.begin(); mit != tagged_sets.end();
1440 CHKERR moab.get_entities_by_type(*mit, MBTRI, part_tris);
1441 part_tris = intersect(part_tris, tris_level);
1443 CHKERR moab.get_adjacencies(part_tris, 3,
false, adj_prisms,
1444 moab::Interface::UNION);
1445 adj_prisms = intersect(adj_prisms, prisms_level);
1446 prisms_level = subtract(prisms_level, adj_prisms);
1449 CHKERR moab.tag_get_data(part_tag, &*mit, 1, &part);
1450 std::vector<int> tag(adj_prisms.size(), part);
1451 CHKERR moab.tag_set_data(part_tag, adj_prisms, &*tag.begin());
1452 CHKERR moab.add_entities(*mit, adj_prisms);
1462 const bool build_fields,
const int verb,
const bool debug) {
1466 auto write_file = [&](
const std::string file_name,
Range ents) {
1479 Range tets_level, tets_level_all;
1481 bit, mask, MBTET, tets_level_all);
1483 tets_level = intersect(
bitProcEnts, tets_level_all);
1488 bit, mask, MBPRISM, prisms_level);
1490 prisms_level = intersect(prisms_level,
bitProcEnts);
1492 Range prisms_level_tris;
1494 prisms_level, 2,
false, prisms_level_tris, moab::Interface::UNION);
1496 if (
rval != MB_SUCCESS &&
rval != MB_MULTIPLE_ENTITIES_FOUND) {
1501 prisms_level_tris = intersect(prisms_level_tris,
crackFaces);
1502 Range proc_ents = tets_level;
1503 proc_ents.merge(prisms_level_tris);
1506 MB_TAG_SPARSE,
MF_ZERO, verb);
1513 MB_TAG_SPARSE,
MF_ZERO, verb);
1517 dofs_ents.merge(proc_ents);
1518 for (
int dd = 1;
dd != 3; ++
dd) {
1519 CHKERR moab.get_adjacencies(proc_ents,
dd,
false, dofs_ents,
1520 moab::Interface::UNION);
1524 CHKERR moab.get_connectivity(proc_ents, dofs_nodes,
true);
1530 ents_to_remove_from_field;
1533 ents_to_remove_from_field);
1534 ents_to_remove_from_field = subtract(ents_to_remove_from_field, dofs_nodes);
1535 ents_to_remove_from_field = subtract(ents_to_remove_from_field, dofs_ents);
1537 ents_to_remove_from_field, verb);
1539 ents_to_remove_from_field, verb);
1542 ents_to_remove_from_field, verb);
1545 auto add_spatial_field_ents = [&](
const auto field_name) {
1559 CHKERR add_spatial_field_ents(
"SPATIAL_POSITION");
1561 CHKERR add_spatial_field_ents(
"EIGEN_SPATIAL_POSITIONS");
1564 Range current_field_ents;
1566 current_field_ents);
1567 dofs_nodes = current_field_ents.subset_by_type(MBVERTEX);
1568 dofs_ents = subtract(current_field_ents, dofs_nodes);
1570 "MESH_NODE_POSITIONS", verb);
1572 auto set_spatial_field_order = [&](
const auto field_name) {
1578 CHKERR set_spatial_field_order(
"SPATIAL_POSITION");
1580 CHKERR set_spatial_field_order(
"EIGEN_SPATIAL_POSITIONS");
1597 non_ref_ents.merge(dofs_ents);
1599 Range contact_faces;
1609 bit, mask, MBTET, proc_ents);
1610 map<int, Range> layers;
1614 CHKERR moab.get_adjacencies(ref_nodes, 3,
false, tets,
1615 moab::Interface::UNION);
1616 tets = intersect(tets_level_all, tets);
1618 Range ref_order_ents;
1619 CHKERR moab.get_adjacencies(tets, 2,
false, ref_order_ents,
1620 moab::Interface::UNION);
1621 CHKERR moab.get_adjacencies(tets, 1,
false, ref_order_ents,
1622 moab::Interface::UNION);
1623 layers[ll].merge(ref_order_ents);
1624 CHKERR moab.get_connectivity(tets, ref_nodes,
false);
1626 if (!contact_faces.empty()) {
1627 Range contact_layer = intersect(layers[ll], contact_faces);
1628 for (Range::iterator tit = contact_layer.begin();
1629 tit != contact_layer.end(); tit++) {
1630 Range contact_prisms, contact_tris;
1631 CHKERR moab.get_adjacencies(&*tit, 1, 3,
false, contact_prisms,
1632 moab::Interface::UNION);
1633 contact_prisms = contact_prisms.subset_by_type(MBPRISM);
1635 Range contact_elements;
1639 contact_elements = intersect(contact_prisms, contact_elements);
1640 if (contact_elements.empty()) {
1642 "Expecting adjacent contact prism(s), but none found");
1644 CHKERR moab.get_adjacencies(contact_elements, 2,
false,
1645 contact_tris, moab::Interface::UNION);
1646 contact_tris = contact_tris.subset_by_type(MBTRI);
1647 if (contact_tris.size() < 2) {
1650 "Expecting 2 or more adjacent contact tris, but %d found",
1651 contact_tris.size());
1655 layers[ll].merge(contact_tris);
1656 Range contact_edges, contact_nodes;
1657 CHKERR moab.get_adjacencies(contact_tris, 1,
false, contact_edges,
1658 moab::Interface::UNION);
1659 layers[ll].merge(contact_edges);
1660 CHKERR moab.get_connectivity(contact_tris, contact_nodes,
false);
1661 ref_nodes.merge(contact_nodes);
1666 for (map<int, Range>::reverse_iterator mit = layers.rbegin();
1667 mit != layers.rend(); mit++, poo++) {
1668 mit->second = intersect(mit->second, dofs_ents);
1671 non_ref_ents = subtract(non_ref_ents, mit->second);
1683 Range cont_ents, cont_adj_ent;
1689 CHKERR moab.get_adjacencies(cont_ents, 1,
false, cont_adj_ent,
1690 moab::Interface::UNION);
1691 cont_ents.merge(cont_adj_ent);
1692 cont_ents = intersect(cont_ents, non_ref_ents);
1727 const bool build_fields,
1736 if (vit == refined_ents_ptr->get<
Ent_mi_tag>().end()) {
1738 "Vertex of arc-length field not found");
1740 *(
const_cast<RefEntity *
>(vit->get())->getBitRefLevelPtr()) |=
bit;
1742 FieldEntity::getLocalUniqueIdCalculate(
1746 "Arc length field entity not found");
1748 MOFEM_LOG(
"CPWorld", Sev::noisy) << **fit;
1749 MOFEM_LOG_C(
"CPWorld", Sev::inform,
"Arc-Length field lambda = %3.4e",
1750 (*fit)->getEntFieldData()[0]);
1755 MB_TAG_SPARSE,
MF_ZERO, verb);
1759 std::pair<RefEntity_multiIndex::iterator, bool> p_ent =
1761 ->insert(boost::make_shared<RefEntity>(
1763 *(
const_cast<RefEntity *
>(p_ent.first->get())->getBitRefLevelPtr()) |=
1772 const bool proc_only,
1773 const bool build_fields,
1785 Range body_skin_proc_tris;
1786 body_skin_proc_tris = intersect(
bodySkin, level_tris);
1791 moab::Interface::UNION);
1792 body_skin_proc_tris = intersect(body_skin_proc_tris, proc_tris);
1809 "LAMBDA_SURFACE" + boost::lexical_cast<std::string>(
1810 getInterface<CPMeshCut>()->getSkinOfTheBodyId());
1812 CHKERR moab.get_connectivity(body_skin_proc_tris, dofs_nodes,
true);
1818 MB_TAG_SPARSE,
MF_ZERO, verb);
1820 Range ents_to_remove;
1822 ents_to_remove = subtract(ents_to_remove, dofs_nodes);
1837 const bool proc_only,
1838 const bool build_fields,
1847 CHKERR bit_ref_manager_ptr->getEntitiesByTypeAndRefLevel(
1850 if (meshset_manager_ptr->checkMeshset(
1851 getInterface<CPMeshCut>()->getEdgesBlockSet(),
BLOCKSET)) {
1853 CHKERR meshset_manager_ptr->getEntitiesByDimension(
1854 getInterface<CPMeshCut>()->getEdgesBlockSet(),
BLOCKSET, 1,
1855 meshset_ents,
true);
1856 edges_ents = intersect(meshset_ents, level_edges);
1862 moab::Interface::UNION);
1863 edges_ents = intersect(edges_ents, proc_edges);
1867 Range other_side_crack_faces_nodes;
1869 other_side_crack_faces_nodes,
true);
1870 other_side_crack_faces_nodes =
1874 CHKERR moab.get_connectivity(edges_ents, dofs_nodes,
true);
1875 dofs_nodes = subtract(dofs_nodes, other_side_crack_faces_nodes);
1882 MB_TAG_SPARSE,
MF_ZERO, verb);
1884 Range ents_to_remove;
1886 ents_to_remove = subtract(ents_to_remove, dofs_nodes);
1893 auto get_fields_multi_index = [
this]() {
1898 for (
auto field : get_fields_multi_index()) {
1899 if (field->getName().compare(0, 14,
"LAMBDA_SURFACE") == 0) {
1912 const BitRefLevel bit,
const bool proc_only,
const bool build_fields,
1913 const int verb,
const bool debug) {
1923 crack_surface_ents = intersect(crack_surface_ents, level_tris);
1928 moab::Interface::UNION);
1929 crack_surface_ents = intersect(crack_surface_ents, proc_tris);
1946 "LAMBDA_SURFACE" + boost::lexical_cast<std::string>(
1947 getInterface<CPMeshCut>()->getCrackSurfaceId());
1949 CHKERR moab.get_connectivity(crack_surface_ents, dofs_nodes,
true);
1956 MB_TAG_SPARSE,
MF_ZERO, verb);
1957 Range ents_to_remove;
1959 ents_to_remove = subtract(ents_to_remove, dofs_nodes);
1975 const bool proc_only,
const bool build_fields,
const int verb,
1979 auto add_both_sides_field = [&](
const std::string lambda_field_name,
1989 std::ostringstream file;
1990 file << lambda_field_name <<
".vtk";
2000 Range ents_to_remove;
2003 ents_to_remove = subtract(ents_to_remove, master_nodes);
2016 lambda_field_name, 1);
2030 for (
auto const &field : (*fields_ptr)) {
2031 const std::string
field_name = field->getName();
2032 if (
field_name.compare(0, 14,
"LAMBDA_SURFACE") == 0) {
2035 if (
field_name.compare(0, 11,
"LAMBDA_EDGE") == 0) {
2042 auto write_file = [&](
const std::string file_name,
Range ents) {
2055 auto get_prisms_level_nodes = [&](
auto bit) {
2060 prisms_level = intersect(
bitProcEnts, prisms_level);
2062 Range prisms_level_nodes;
2065 return prisms_level_nodes;
2068 auto get_other_side_crack_faces_nodes = [&](
auto prisms_level_nodes) {
2069 Range other_side_crack_faces_nodes;
2072 other_side_crack_faces_nodes =
2073 intersect(other_side_crack_faces_nodes, prisms_level_nodes);
2074 other_side_crack_faces_nodes =
2077 return other_side_crack_faces_nodes;
2080 auto prisms_level_nodes = get_prisms_level_nodes(bit_material);
2081 auto other_side_crack_faces_nodes =
2082 get_other_side_crack_faces_nodes(prisms_level_nodes);
2084 CHKERR add_both_sides_field(
"LAMBDA_BOTH_SIDES", other_side_crack_faces_nodes,
2085 other_side_crack_faces_nodes,
false);
2088 Range other_side_crack_faces_edges;
2091 other_side_crack_faces_edges,
2092 moab::Interface::UNION);
2093 other_side_crack_faces_edges =
2094 subtract(other_side_crack_faces_edges,
crackFront);
2097 other_side_crack_faces_edges.merge(
2098 get_other_side_crack_faces_nodes(get_prisms_level_nodes(bit_spatial)));
2099 CHKERR add_both_sides_field(
"LAMBDA_CLOSE_CRACK",
2100 other_side_crack_faces_edges,
Range(),
true);
2111 Range contact_both_sides_slave_nodes;
2114 Range contact_prisms;
2116 &*nit, 1, 3,
false, contact_prisms, moab::Interface::UNION);
2120 int side_number, other_side_number, sense, offset, number_nodes = 0;
2124 if (side_number < 3)
2125 contact_both_sides_slave_nodes.insert(conn[side_number + 3]);
2127 contact_both_sides_slave_nodes.insert(conn[side_number - 3]);
2129 contact_both_sides_slave_nodes =
2130 intersect(contact_both_sides_slave_nodes, prisms_level_nodes);
2133 CHKERR write_file(
"contact_both_sides_slave_nodes.vtk",
2134 contact_both_sides_slave_nodes);
2137 CHKERR add_both_sides_field(
"LAMBDA_BOTH_SIDES_CONTACT",
2139 contact_both_sides_slave_nodes,
false);
2146 const bool build_fields,
2156 Range crack_front_nodes;
2157 CHKERR moab.get_connectivity(crack_front_edges, crack_front_nodes,
true);
2160 1, MB_TAG_SPARSE,
MF_ZERO, verb);
2163 Range ents_to_remove;
2166 ents_to_remove = subtract(ents_to_remove, crack_front_nodes);
2168 ents_to_remove, verb);
2170 "LAMBDA_CRACKFRONT_AREA", verb);
2182 Range skin_crack_front;
2183 rval = skin.find_skin(0, crack_front_edges,
false, skin_crack_front);
2184 Range field_ents = subtract(crack_front_nodes, skin_crack_front);
2186 Range ents_to_remove;
2189 ents_to_remove = subtract(ents_to_remove, field_ents);
2191 ents_to_remove, verb);
2193 field_ents, MBVERTEX,
"LAMBDA_CRACKFRONT_AREA_TANGENT", verb);
2207 const BitRefLevel mask2,
const bool add_forces,
const bool proc_only,
2213 bit1, mask1, MBTET, tets_level1);
2215 tets_level1 = intersect(
bitProcEnts, tets_level1);
2217 Range tets_not_level2;
2219 bit2, mask2, MBTET, tets_not_level2);
2220 tets_not_level2 = subtract(tets_level1, tets_not_level2);
2225 "SPATIAL_POSITION");
2227 "SPATIAL_POSITION");
2229 "SPATIAL_POSITION");
2231 "MESH_NODE_POSITIONS");
2235 Range current_ents_with_fe;
2237 current_ents_with_fe);
2238 Range ents_to_remove;
2239 ents_to_remove = subtract(current_ents_with_fe, tets_level1);
2250 "SPATIAL_POSITION");
2252 "SPATIAL_POSITION");
2254 "SPATIAL_POSITION");
2256 "MESH_NODE_POSITIONS");
2260 Range current_ents_with_fe;
2262 current_ents_with_fe);
2263 Range ents_to_remove;
2264 ents_to_remove = subtract(current_ents_with_fe, tets_not_level2);
2278 Range proc_tris, skin_tris, tets_level;
2280 moab::Interface::UNION);
2283 bit1, mask1, MBTET, tets_level);
2285 CHKERR skin.find_skin(0, tets_level,
false, skin_tris);
2286 skin_tris = intersect(skin_tris, proc_tris);
2291 "SPATIAL_POSITION");
2293 "SPATIAL_POSITION");
2295 "SPATIAL_POSITION");
2297 "MESH_NODE_POSITIONS");
2300 "SKIN",
"EIGEN_SPATIAL_POSITIONS");
2306 "MESH_NODE_POSITIONS");
2309 auto cn_value_ptr = boost::make_shared<double>(
cnValue);
2326 "MORTAR_CONTACT",
"SPATIAL_POSITION",
"LAMBDA_CONTACT",
2328 "EIGEN_SPATIAL_POSITIONS");
2332 Range all_slave_tris;
2337 "CONTACT_POST_PROC",
"SPATIAL_POSITION",
"LAMBDA_CONTACT",
2338 "MESH_NODE_POSITIONS", all_slave_tris);
2349 Range arc_fe_meshsets;
2352 arc_fe_meshsets.insert(fit->get()->getEnt());
2353 if (
auto ptr = fit->get()->getPartProcPtr())
2364 "LAMBDA_ARC_LENGTH");
2366 "LAMBDA_ARC_LENGTH");
2369 "LAMBDA_ARC_LENGTH");
2381 "ARC_LENGTH",
false);
2386 if (
auto ptr = fit->get()->getPartProcPtr())
2394 const bool proc_only) {
2400 bit, mask, MBTET, tets_level);
2407 dofs_ents.merge(tets_level);
2408 for (
int dd = 1;
dd != 3;
dd++) {
2409 CHKERR moab.get_adjacencies(tets_level,
dd,
false, dofs_ents,
2410 moab::Interface::UNION);
2413 rval = moab.get_connectivity(tets_level, dofs_nodes,
true);
2415 Range lower_dim_ents = unite(dofs_ents, dofs_nodes);
2417 #ifdef __ANALITICAL_TRACTION__
2421 "SPATIAL_POSITION");
2423 "SPATIAL_POSITION");
2425 "SPATIAL_POSITION");
2427 "MESH_NODE_POSITIONS");
2430 if (meshset_manager_ptr->
checkMeshset(
"ANALITICAL_TRACTION")) {
2433 &cubit_meshset_ptr);
2437 tris = intersect(tris, lower_dim_ents);
2439 "ANALITICAL_TRACTION");
2443 #endif //__ANALITICAL_TRACTION__
2447 "SPATIAL_POSITION");
2449 "SPATIAL_POSITION");
2451 "SPATIAL_POSITION");
2453 "MESH_NODE_POSITIONS");
2464 moab::Interface::UNION);
2472 nodes = subtract(nodes, tris_nodes);
2473 nodes = subtract(nodes, edges_nodes);
2474 nodes = intersect(lower_dim_ents, nodes);
2475 edges = subtract(edges, tris_edges);
2476 edges = intersect(lower_dim_ents, edges);
2477 tris = intersect(lower_dim_ents, tris);
2485 const string block_set_force_name(
"FORCE");
2488 if (it->getName().compare(0, block_set_force_name.length(),
2489 block_set_force_name) == 0) {
2490 std::vector<double> mydata;
2491 CHKERR it->getAttributes(mydata);
2494 for (
unsigned int ii = 0; ii < mydata.size(); ii++) {
2495 force[ii] = mydata[ii];
2497 if (force.size() != 3) {
2499 "Force vector not given");
2513 "SPATIAL_POSITION");
2515 "SPATIAL_POSITION");
2517 "SPATIAL_POSITION");
2519 "MESH_NODE_POSITIONS");
2525 tris = intersect(lower_dim_ents, tris);
2529 const string block_set_linear_pressure_name(
"LINEAR_PRESSURE");
2531 if (it->getName().compare(0, block_set_linear_pressure_name.length(),
2532 block_set_linear_pressure_name) == 0) {
2536 tris = intersect(lower_dim_ents, tris);
2544 const string block_set_pressure_name(
"PRESSURE");
2546 if (it->getName().compare(0, block_set_pressure_name.length(),
2547 block_set_pressure_name) == 0) {
2548 std::vector<double> mydata;
2549 CHKERR it->getAttributes(mydata);
2551 for (
unsigned int ii = 0; ii < mydata.size(); ii++) {
2552 pressure[ii] = mydata[ii];
2554 if (pressure.empty()) {
2556 "Pressure not given");
2569 #ifdef __ANALITICAL_DISPLACEMENT__
2573 if (meshset_manager_ptr->
checkMeshset(
"ANALITICAL_DISP")) {
2576 &cubit_meshset_ptr);
2580 if (!tris.empty()) {
2583 "SPATIAL_POSITION");
2585 "SPATIAL_POSITION");
2587 "SPATIAL_POSITION");
2589 "BC_FE",
"MESH_NODE_POSITIONS");
2590 tris = intersect(lower_dim_ents, tris);
2596 #endif //__ANALITICAL_DISPLACEMENT__
2603 const bool proc_only) {
2610 bit, mask, MBTET, tets_level);
2616 dofs_ents.merge(tets_level);
2617 for (
int dd = 1;
dd != 3;
dd++) {
2618 CHKERR moab.get_adjacencies(tets_level,
dd,
false, dofs_ents,
2619 moab::Interface::UNION);
2622 rval = moab.get_connectivity(tets_level, dofs_nodes,
true);
2624 Range lower_dim_ents = unite(dofs_ents, dofs_nodes);
2628 "SPATIAL_POSITION");
2630 "SPATIAL_POSITION");
2632 "SPATIAL_POSITION");
2634 "MESH_NODE_POSITIONS");
2636 "MESH_NODE_POSITIONS");
2638 "MESH_NODE_POSITIONS");
2646 tris = intersect(lower_dim_ents, tris);
2647 ents_to_add.merge(tris);
2650 Range current_ents_with_fe;
2652 current_ents_with_fe);
2653 Range ents_to_remove;
2654 ents_to_remove = subtract(current_ents_with_fe, ents_to_add);
2671 bit, mask, MBTET, tets_level);
2677 dofs_ents.merge(tets_level);
2678 for (
int dd = 1;
dd != 3;
dd++) {
2679 CHKERR moab.get_adjacencies(tets_level,
dd,
false, dofs_ents,
2680 moab::Interface::UNION);
2683 rval = moab.get_connectivity(tets_level, dofs_nodes,
true);
2685 Range lower_dim_ents = unite(dofs_ents, dofs_nodes);
2689 "SPATIAL_POSITION");
2691 "SPATIAL_POSITION");
2693 "SPATIAL_POSITION");
2695 "MESH_NODE_POSITIONS");
2697 "MESH_NODE_POSITIONS");
2699 "MESH_NODE_POSITIONS");
2707 tris = intersect(lower_dim_ents, tris);
2708 ents_to_add.merge(tris);
2711 const string block_set_force_name(
"FORCE");
2713 if (it->getName().compare(0, block_set_force_name.length(),
2714 block_set_force_name) == 0) {
2718 tris = intersect(lower_dim_ents, tris);
2719 ents_to_add.merge(tris);
2723 Range current_ents_with_fe;
2725 current_ents_with_fe);
2726 Range ents_to_remove;
2727 ents_to_remove = subtract(current_ents_with_fe, ents_to_add);
2738 const bool proc_only) {
2745 bit, mask, MBTET, tets_level);
2751 dofs_ents.merge(tets_level);
2752 for (
int dd = 1;
dd != 3;
dd++) {
2753 CHKERR moab.get_adjacencies(tets_level,
dd,
false, dofs_ents,
2754 moab::Interface::UNION);
2757 rval = moab.get_connectivity(tets_level, dofs_nodes,
true);
2759 Range lower_dim_ents = unite(dofs_ents, dofs_nodes);
2763 "SPATIAL_POSITION");
2765 "SPATIAL_POSITION");
2767 "SPATIAL_POSITION");
2769 "MESH_NODE_POSITIONS");
2771 "MESH_NODE_POSITIONS");
2773 "MESH_NODE_POSITIONS");
2777 if (
bit->getName().compare(0, 9,
"SPRING_BC") == 0) {
2781 tris = intersect(lower_dim_ents, tris);
2782 ents_to_add.merge(tris);
2786 Range current_ents_with_fe;
2788 current_ents_with_fe);
2789 Range ents_to_remove;
2790 ents_to_remove = subtract(current_ents_with_fe, ents_to_add);
2807 bit, mask, MBPRISM, prisms_level);
2810 prisms_level = intersect(
bitProcEnts, prisms_level);
2816 "SIMPLE_CONTACT_ALE",
"SPATIAL_POSITION",
"LAMBDA_CONTACT",
2818 "EIGEN_SPATIAL_POSITIONS");
2822 Range face_on_prism;
2823 CHKERR moab.get_adjacencies(contact_prisms, 2,
false, face_on_prism,
2824 moab::Interface::UNION);
2826 Range tris_on_prism = face_on_prism.subset_by_type(MBTRI);
2831 Range adj_vols_to_prisms;
2832 CHKERR moab.get_adjacencies(check_tris, 3,
false, adj_vols_to_prisms,
2833 moab::Interface::UNION);
2837 bit, mask, MBTET, tet_level);
2839 Range contact_tets_from_vols = adj_vols_to_prisms.subset_by_type(MBTET);
2841 Range contact_tets = intersect(tet_level, contact_tets_from_vols);
2845 "SPATIAL_POSITION");
2847 "SPATIAL_POSITION");
2849 "MESH_NODE_POSITIONS");
2851 "MESH_NODE_POSITIONS");
2853 "SPATIAL_POSITION");
2855 "MESH_NODE_POSITIONS");
2857 Range current_ale_tets;
2860 Range ale_tets_to_remove;
2861 ale_tets_to_remove = subtract(current_ale_tets, contact_tets);
2863 ale_tets_to_remove);
2874 const bool proc_only,
2880 bit, mask, MBTET, tets_level);
2888 "SPATIAL_POSITION");
2890 "SPATIAL_POSITION");
2892 "MESH_NODE_POSITIONS");
2894 "MESH_NODE_POSITIONS");
2896 "SPATIAL_POSITION");
2898 "MESH_NODE_POSITIONS");
2901 Range current_ents_with_fe;
2903 current_ents_with_fe);
2904 Range ents_to_remove;
2905 ents_to_remove = subtract(current_ents_with_fe, tets_level);
2919 const bool proc_only,
2926 "MESH_NODE_POSITIONS");
2928 "MESH_NODE_POSITIONS");
2930 "MESH_NODE_POSITIONS");
2931 Range crack_front_adj_tris;
2933 crackFrontNodes, 2,
false, crack_front_adj_tris, moab::Interface::UNION);
2934 crack_front_adj_tris = intersect(crack_front_adj_tris,
crackFaces);
2937 bit, mask, MBTRI, tris_level);
2938 crack_front_adj_tris = intersect(crack_front_adj_tris, tris_level);
2940 Range ents_to_remove;
2943 ents_to_remove = subtract(ents_to_remove, crack_front_adj_tris);
2945 ents_to_remove, verb);
2948 "GRIFFITH_FORCE_ELEMENT");
2950 &crack_front_adj_tris, verb);
2952 #ifdef __ANALITICAL_TRACTION__
2956 bit, mask, MBTET, tets_level);
2962 dofs_ents.merge(tets_level);
2963 for (
int dd = 1;
dd != 3;
dd++) {
2964 CHKERR moab.get_adjacencies(tets_level,
dd,
false, dofs_ents,
2965 moab::Interface::UNION);
2968 CHKERR moab.get_connectivity(tets_level, dofs_nodes,
true);
2969 Range lower_dim_ents = unite(dofs_ents, dofs_nodes);
2973 "ANALITICAL_METERIAL_TRACTION",
"MESH_NODE_POSITIONS");
2975 "ANALITICAL_METERIAL_TRACTION",
"MESH_NODE_POSITIONS");
2977 "ANALITICAL_METERIAL_TRACTION",
"SPATIAL_POSITION");
2979 "ANALITICAL_METERIAL_TRACTION",
"MESH_NODE_POSITIONS");
2983 if (meshset_manager_ptr->
checkMeshset(
"ANALITICAL_TRACTION")) {
2986 &cubit_meshset_ptr);
2990 tris = intersect(tris, lower_dim_ents);
2992 tris, MBTRI,
"ANALITICAL_METERIAL_TRACTION");
2997 #endif //__ANALITICAL_TRACTION__
3003 const BitRefLevel mask,
const bool proc_only,
const bool verb) {
3006 auto get_prisms_level = [&](
auto bit) {
3009 bit, mask, MBPRISM, prisms_level);
3011 prisms_level = intersect(
bitProcEnts, prisms_level);
3013 return prisms_level;
3016 auto get_crack_prisms = [&](
auto prisms_level) {
3019 return crack_prisms;
3022 auto add_both_sides_fe = [&](
const std::string fe_name,
3023 const std::string lambda_field_name,
3024 const std::string spatial_field,
Range ents) {
3029 if (!ents.empty()) {
3052 CHKERR add_both_sides_fe(
"CLOSE_CRACK",
"LAMBDA_CLOSE_CRACK",
3054 get_crack_prisms(get_prisms_level(bit_spatial)));
3056 CHKERR add_both_sides_fe(
"BOTH_SIDES_OF_CRACK",
"LAMBDA_BOTH_SIDES",
3057 "MESH_NODE_POSITIONS",
3058 get_crack_prisms(get_prisms_level(bit_material)));
3060 Range contact_prisms =
3062 CHKERR add_both_sides_fe(
"BOTH_SIDES_OF_CONTACT",
3063 "LAMBDA_BOTH_SIDES_CONTACT",
"MESH_NODE_POSITIONS",
3071 const bool proc_only,
3076 bit, mask, MBTET, tets_level);
3084 "MESH_NODE_POSITIONS");
3086 "MESH_NODE_POSITIONS");
3088 "MESH_NODE_POSITIONS");
3090 "SPATIAL_POSITION");
3092 "SMOOTHING",
"LAMBDA_CRACKFRONT_AREA_TANGENT");
3094 "SMOOTHING",
"LAMBDA_CRACKFRONT_AREA_TANGENT");
3097 Range ents_to_remove;
3100 ents_to_remove = subtract(ents_to_remove, tets_level);
3112 const std::vector<int> &ids,
const bool proc_only,
const int verb,
3130 moab::Interface::UNION);
3131 surface_ents = intersect(surface_ents, proc_tris);
3136 "MESH_NODE_POSITIONS");
3138 "MESH_NODE_POSITIONS");
3140 "MESH_NODE_POSITIONS");
3142 for (std::vector<int>::const_iterator it = ids.begin(); it != ids.end();
3145 "LAMBDA_SURFACE" + boost::lexical_cast<std::string>(*it);
3150 CHKERR moab.get_adjacencies(&ent, 1, 2,
false, adj_tris);
3151 adj_tris = intersect(adj_tris,
bodySkin);
3152 surface_ents.merge(adj_tris);
3164 Range ents_to_remove;
3167 ents_to_remove = subtract(ents_to_remove, surface_ents);
3181 const int verb,
const bool debug) {
3186 auto get_edges_block_ents = [
this, meshset_manager_ptr]() {
3187 EntityHandle edge_block_set = getInterface<CPMeshCut>()->getEdgesBlockSet();
3189 if (meshset_manager_ptr->checkMeshset(edge_block_set,
BLOCKSET)) {
3190 CHKERR meshset_manager_ptr->getEntitiesByDimension(
3191 edge_block_set,
BLOCKSET, 1, meshset_ents,
true);
3193 return meshset_ents;
3196 auto get_skin = [
this, bit_ref_manager_ptr]() {
3198 CHKERR bit_ref_manager_ptr->getEntitiesByTypeAndRefLevel(
3202 CHKERR skin.find_skin(0, tets,
false, skin_faces);
3206 auto intersect_with_skin_edges = [
this, get_edges_block_ents, get_skin]() {
3209 moab::Interface::UNION);
3210 return intersect(get_edges_block_ents(), adj_edges);
3212 Range edges_ents = intersect_with_skin_edges();
3214 Range contact_faces;
3219 boost::shared_ptr<SurfaceSlidingConstrains::DriverElementOrientation>(
3229 Range faces = get_skin();
3234 auto intersect_with_bit_level_edges = [bit_ref_manager_ptr, &
bit,
3237 CHKERR bit_ref_manager_ptr->getEntitiesByTypeAndRefLevel(
3239 return intersect(edges_ents, level_edges);
3241 edges_ents = intersect_with_bit_level_edges();
3243 auto intersect_with_proc_edges = [
this, &edges_ents, proc_only]() {
3247 bitProcEnts, 1,
false, proc_edges, moab::Interface::UNION);
3248 return intersect(edges_ents, proc_edges);
3252 edges_ents = intersect_with_proc_edges();
3259 auto add_field = [
this, &fe_name](std::string &&
field_name) {
3266 CHKERR add_field(
"MESH_NODE_POSITIONS");
3267 CHKERR add_field(
"LAMBDA_EDGE");
3272 "edges_normals_on_proc_" +
3278 Range ents_to_remove;
3280 ents_to_remove = subtract(ents_to_remove, edges_ents);
3291 const bool proc_only,
const int verb,
const bool debug) {
3299 bit, mask, MBTRI, level_tris);
3300 Range crack_surface;
3305 moab::Interface::UNION);
3306 crack_surface = intersect(crack_surface, proc_tris);
3308 Range crack_front_adj_tris;
3310 crackFrontNodes, 2,
false, crack_front_adj_tris, moab::Interface::UNION);
3311 crack_front_adj_tris = intersect(crack_front_adj_tris,
crackFaces);
3312 crack_front_adj_tris = intersect(crack_front_adj_tris, level_tris);
3315 "LAMBDA_SURFACE" + boost::lexical_cast<std::string>(
3316 getInterface<CPMeshCut>()->getCrackSurfaceId());
3323 "MESH_NODE_POSITIONS");
3327 "MESH_NODE_POSITIONS");
3331 "MESH_NODE_POSITIONS");
3334 crack_surface,
QUIET);
3340 ents = subtract(ents, crack_surface);
3341 if (!ents.empty()) {
3351 std::ostringstream file;
3354 CHKERR moab.create_meshset(MESHSET_SET, meshset);
3355 CHKERR moab.add_entities(meshset, crack_surface);
3356 CHKERR moab.write_file(file.str().c_str(),
"VTK",
"", &meshset, 1);
3357 CHKERR moab.delete_entities(&meshset, 1);
3363 "LAMBDA_CRACKFRONT_AREA");
3365 "MESH_NODE_POSITIONS");
3367 "LAMBDA_CRACKFRONT_AREA");
3369 "MESH_NODE_POSITIONS");
3371 "MESH_NODE_POSITIONS");
3373 "LAMBDA_CRACKFRONT_AREA");
3378 "CRACKFRONT_AREA_TANGENT_ELEM",
"LAMBDA_CRACKFRONT_AREA_TANGENT");
3380 "CRACKFRONT_AREA_TANGENT_ELEM",
"MESH_NODE_POSITIONS");
3382 "CRACKFRONT_AREA_TANGENT_ELEM",
"LAMBDA_CRACKFRONT_AREA_TANGENT");
3384 "CRACKFRONT_AREA_TANGENT_ELEM",
"MESH_NODE_POSITIONS");
3386 "CRACKFRONT_AREA_TANGENT_ELEM",
"MESH_NODE_POSITIONS");
3388 "CRACKFRONT_AREA_TANGENT_ELEM",
"LAMBDA_CRACKFRONT_AREA_TANGENT");
3392 crack_front_adj_tris,
QUIET);
3394 auto remeve_ents_from_fe =
3395 [
this, &crack_front_adj_tris](
const std::string fe_name) {
3399 ents = subtract(ents, crack_front_adj_tris);
3400 if (!ents.empty()) {
3405 CHKERR remeve_ents_from_fe(
"CRACKFRONT_AREA_ELEM");
3406 CHKERR remeve_ents_from_fe(
"CRACKFRONT_AREA_TANGENT_ELEM");
3409 "CRACKFRONT_AREA_ELEM");
3411 crack_front_adj_tris, MBTRI,
"CRACKFRONT_AREA_TANGENT_ELEM");
3414 std::ostringstream file;
3417 CHKERR moab.create_meshset(MESHSET_SET, meshset);
3418 CHKERR moab.add_entities(meshset, crack_front_adj_tris);
3419 CHKERR moab.write_file(file.str().c_str(),
"VTK",
"", &meshset, 1);
3420 CHKERR moab.delete_entities(&meshset, 1);
3424 &crack_front_adj_tris, verb);
3426 &crack_front_adj_tris, verb);
3435 const std::vector<std::string> fe_list) {
3471 for (std::vector<std::string>::const_iterator it = fe_list.begin();
3472 it != fe_list.end(); it++)
3478 #ifdef __ANALITICAL_TRACTION__
3500 PetscSection section;
3502 CHKERR DMSetDefaultSection(dm, section);
3503 CHKERR DMSetDefaultGlobalSection(dm, section);
3505 CHKERR PetscSectionDestroy(§ion);
3511 const std::string prb_name,
3529 #ifdef __ANALITICAL_TRACTION__
3540 PetscSection section;
3542 CHKERR DMSetDefaultSection(dm, section);
3543 CHKERR DMSetDefaultGlobalSection(dm, section);
3545 CHKERR PetscSectionDestroy(§ion);
3552 arcCtx = boost::make_shared<ArcLengthCtx>(
mField, problem_ptr->getName(),
3553 "LAMBDA_ARC_LENGTH");
3555 auto arc_snes_ctx = boost::make_shared<ArcLengthSnesCtx>(
3581 #ifdef __ANALITICAL_TRACTION__
3590 auto remove_higher_dofs_than_approx_dofs_from_eigen_elastic = [&]() {
3595 CHKERR prb_mng->removeDofsOnEntities(
"EIGEN_ELASTIC",
"SPATIAL_POSITION",
3599 CHKERR remove_higher_dofs_than_approx_dofs_from_eigen_elastic();
3603 PetscSection section;
3605 CHKERR DMSetDefaultSection(dm, section);
3606 CHKERR DMSetDefaultGlobalSection(dm, section);
3608 CHKERR PetscSectionDestroy(§ion);
3616 "LAMBDA_ARC_LENGTH");
3618 auto arc_snes_ctx = boost::make_shared<ArcLengthSnesCtx>(
3626 const std::string prb_name,
3635 #ifdef __ANALITICAL_DISPLACEMENT__
3636 if (meshset_manager_ptr->
checkMeshset(
"ANALITICAL_DISP")) {
3639 &cubit_meshset_ptr);
3643 if (!tris.empty()) {
3655 #endif //__ANALITICAL_DISPLACEMENT__
3661 const BitRefLevel mask,
const std::vector<std::string> fe_list,
3669 for (
auto &fe : fe_list)
3675 #ifdef __ANALITICAL_TRACTION__
3694 PetscSection section;
3696 CHKERR DMSetDefaultSection(dm, section);
3697 CHKERR DMSetDefaultGlobalSection(dm, section);
3699 CHKERR PetscSectionDestroy(§ion);
3702 std::vector<std::string> fe_lists;
3707 for (FiniteElement_multiIndex::iterator fit = fe_ptr->begin();
3708 fit != fe_ptr->end(); fit++) {
3709 if ((fit->get()->getId() & problem_ptr->
getBitFEId()).any()) {
3710 std::string fe_name = fit->get()->getName();
3713 prb_name, fe_name, &meshset);
3715 (prb_name +
"_" + fe_name +
".h5m").c_str(),
"MOAB",
3716 "PARALLEL=WRITE_PART", &meshset, 1);
3726 const std::string prb_name,
const int verb) {
3738 #ifdef __ANALITICAL_TRACTION__
3749 const std::string prb_name,
const std::vector<int> surface_ids,
3750 std::vector<std::string> fe_list,
const int verb) {
3756 for (
auto id : surface_ids) {
3758 dm, (
"LAMBDA_SURFACE" + boost::lexical_cast<std::string>(
id)).c_str());
3761 for (
auto fe : fe_list) {
3764 auto get_edges_block_set = [
this]() {
3765 return getInterface<CPMeshCut>()->getEdgesBlockSet();
3767 if (get_edges_block_set()) {
3778 const std::string prb_name,
const bool verb) {
3796 const int verb,
const bool debug) {
3804 feRhs = boost::make_shared<CrackFrontElement>(
3809 feLhs = boost::make_shared<CrackFrontElement>(
3815 feRhs->meshPositionsFieldName =
"NONE";
3816 feLhs->meshPositionsFieldName =
"NONE";
3817 feRhs->addToRule = 0;
3818 feLhs->addToRule = 0;
3823 boost::shared_ptr<map<int, BlockData>> block_sets_ptr(
3831 CHKERR it->getAttributeDataStructure(mydata);
3832 int id = it->getMeshsetId();
3835 meshset, MBTET,
elasticFe->setOfBlocks[
id].tEts,
true);
3838 elasticFe->setOfBlocks[id].PoissonRatio = mydata.
data.Poisson;
3841 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"\nMaterial block %d \n",
id);
3842 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"\tYoung's modulus %6.4e \n",
3844 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"\tPoisson's ratio %6.4e \n\n",
3845 mydata.
data.Poisson);
3850 elasticFe->setOfBlocks[id].materialDoublePtr =
3851 boost::make_shared<Hooke<double>>();
3852 elasticFe->setOfBlocks[id].materialAdoublePtr =
3853 boost::make_shared<Hooke<adouble>>();
3856 elasticFe->setOfBlocks[id].materialDoublePtr = boost::make_shared<
3859 elasticFe->setOfBlocks[id].materialAdoublePtr = boost::make_shared<
3865 elasticFe->setOfBlocks[id].materialDoublePtr =
3866 boost::make_shared<NeoHookean<double>>();
3867 elasticFe->setOfBlocks[id].materialAdoublePtr =
3868 boost::make_shared<NeoHookean<adouble>>();
3872 elasticFe->setOfBlocks[id].materialDoublePtr =
3873 boost::make_shared<Hooke<double>>();
3874 elasticFe->setOfBlocks[id].materialAdoublePtr =
3875 boost::make_shared<Hooke<adouble>>();
3879 "Material type not yet implemented");
3886 elasticFe->commonData.spatialPositions =
"SPATIAL_POSITION";
3887 elasticFe->commonData.meshPositions =
"MESH_NODE_POSITIONS";
3889 auto data_hooke_element_at_pts =
3890 boost::make_shared<HookeElement::DataAtIntegrationPts>();
3893 auto mat_pos_at_pts_ptr = boost::make_shared<MatrixDouble>();
3895 "MESH_NODE_POSITIONS", mat_pos_at_pts_ptr));
3896 boost::shared_ptr<MatrixDouble> mat_grad_pos_at_pts_ptr;
3898 mat_grad_pos_at_pts_ptr = boost::make_shared<MatrixDouble>();
3899 feRhs->getOpPtrVector().push_back(
3901 mat_grad_pos_at_pts_ptr));
3910 "SPATIAL_POSITION",
elasticFe->commonData,
feRhs->singularElement,
3913 feRhs->getOpPtrVector().push_back(
3915 "MESH_NODE_POSITIONS",
elasticFe->commonData));
3920 map<int, NonlinearElasticElement::BlockData>::iterator sit =
3922 for (; sit !=
elasticFe->setOfBlocks.end(); sit++) {
3924 feRhs->getOpPtrVector().push_back(
3926 "SPATIAL_POSITION", sit->second,
elasticFe->commonData,
3929 feRhs->getOpPtrVector().push_back(
3931 "SPATIAL_POSITION", sit->second,
elasticFe->commonData));
3934 feRhs->getOpPtrVector().push_back(
3936 "MESH_NODE_POSITIONS", data_hooke_element_at_pts->HMat));
3937 mat_grad_pos_at_pts_ptr = data_hooke_element_at_pts->HMat;
3952 th_rho) != MB_SUCCESS) {
3954 "Density tag name %s cannot be found. Please "
3955 "provide the correct name.",
3969 feRhs->getOpPtrVector().push_back(
3971 "SPATIAL_POSITION", data_hooke_element_at_pts->hMat,
3974 if (
mwlsApprox->getUseGlobalBaseAtMaterialReferenceConfiguration())
3979 feRhs->getOpPtrVector().push_back(
3981 mat_pos_at_pts_ptr, mat_grad_pos_at_pts_ptr,
feRhs,
3983 feRhs->getOpPtrVector().push_back(
3985 mat_pos_at_pts_ptr, mat_grad_pos_at_pts_ptr,
feRhs,
3989 feRhs->getOpPtrVector().push_back(
3990 new HookeElement::OpCalculateStiffnessScaledByDensityField(
3991 "SPATIAL_POSITION",
"SPATIAL_POSITION", block_sets_ptr,
3994 feRhs->getOpPtrVector().push_back(
3995 new HookeElement::OpCalculateStrainAle(
"SPATIAL_POSITION",
3997 data_hooke_element_at_pts));
3998 feRhs->getOpPtrVector().push_back(
3999 new HookeElement::OpCalculateStress<1>(
"SPATIAL_POSITION",
4001 data_hooke_element_at_pts));
4003 feRhs->getOpPtrVector().push_back(
4004 new HookeElement::OpCalculateHomogeneousStiffness<0>(
4005 "SPATIAL_POSITION",
"SPATIAL_POSITION", block_sets_ptr,
4006 data_hooke_element_at_pts));
4010 feRhs->getOpPtrVector().push_back(
4012 "SPATIAL_POSITION", data_hooke_element_at_pts->hMat,
4014 feRhs->getOpPtrVector().push_back(
4015 new HookeElement::OpCalculateStrainAle(
"SPATIAL_POSITION",
4017 data_hooke_element_at_pts));
4018 feRhs->getOpPtrVector().push_back(
4019 new HookeElement::OpCalculateStress<0>(
"SPATIAL_POSITION",
4021 data_hooke_element_at_pts));
4026 feRhs->getOpPtrVector().push_back(
new HookeElement::OpAleRhs_dx(
4027 "SPATIAL_POSITION",
"SPATIAL_POSITION", data_hooke_element_at_pts));
4042 if (
mwlsApprox->mwlsMoab.tag_get_handle(mwls_stress_tag_name.c_str(),
4043 th) != MB_SUCCESS) {
4045 "Internal stress tag name %s cannot be found. Please "
4046 "provide the correct name.",
4047 mwls_stress_tag_name.substr(4).c_str());
4052 if (
mwlsApprox->mwlsMoab.tag_get_handle(mwls_stress_tag_name.c_str(),
4053 th) != MB_SUCCESS) {
4055 "Internal stress tag name %s cannot be found. Please "
4056 "provide the correct name.",
4057 mwls_stress_tag_name.substr(4).c_str());
4064 if (
mwlsApprox->getUseGlobalBaseAtMaterialReferenceConfiguration())
4065 feRhs->getOpPtrVector().push_back(
4068 mwls_stress_tag_name,
false));
4070 feRhs->getOpPtrVector().push_back(
4072 mat_pos_at_pts_ptr, mat_grad_pos_at_pts_ptr,
feRhs,
4074 feRhs->getOpPtrVector().push_back(
4077 mwls_stress_tag_name,
false));
4084 feRhs->getOpPtrVector().push_back(
4085 new HookeElement::OpAnalyticalInternalAleStrain_dx<0>(
4086 "SPATIAL_POSITION", data_hooke_element_at_pts,
4088 boost::shared_ptr<MatrixDouble>(
4099 "SPATIAL_POSITION",
elasticFe->commonData,
feLhs->singularElement,
4102 feLhs->getOpPtrVector().push_back(
4104 "MESH_NODE_POSITIONS",
elasticFe->commonData));
4109 map<int, NonlinearElasticElement::BlockData>::iterator sit =
4111 for (; sit !=
elasticFe->setOfBlocks.end(); sit++) {
4113 feLhs->getOpPtrVector().push_back(
4115 "SPATIAL_POSITION", sit->second,
elasticFe->commonData,
4118 feLhs->getOpPtrVector().push_back(
4120 "SPATIAL_POSITION",
"SPATIAL_POSITION", sit->second,
4126 "MESH_NODE_POSITIONS", mat_pos_at_pts_ptr));
4127 boost::shared_ptr<MatrixDouble> mat_grad_pos_at_pts_ptr;
4129 mat_grad_pos_at_pts_ptr = boost::make_shared<MatrixDouble>();
4130 feLhs->getOpPtrVector().push_back(
4132 mat_grad_pos_at_pts_ptr));
4135 feLhs->getOpPtrVector().push_back(
4137 "MESH_NODE_POSITIONS", data_hooke_element_at_pts->HMat));
4138 mat_grad_pos_at_pts_ptr = data_hooke_element_at_pts->HMat;
4143 "mwlsApprox not allocated");
4154 feLhs->getOpPtrVector().push_back(
4156 "SPATIAL_POSITION", data_hooke_element_at_pts->hMat,
4160 if (
mwlsApprox->getUseGlobalBaseAtMaterialReferenceConfiguration())
4165 feLhs->getOpPtrVector().push_back(
4167 mat_pos_at_pts_ptr, mat_grad_pos_at_pts_ptr,
feLhs,
4169 feLhs->getOpPtrVector().push_back(
4171 mat_pos_at_pts_ptr, mat_grad_pos_at_pts_ptr,
feLhs,
4175 feLhs->getOpPtrVector().push_back(
4176 new HookeElement::OpCalculateStiffnessScaledByDensityField(
4177 "SPATIAL_POSITION",
"SPATIAL_POSITION", block_sets_ptr,
4180 feLhs->getOpPtrVector().push_back(
4181 new HookeElement::OpCalculateStrainAle(
"SPATIAL_POSITION",
4183 data_hooke_element_at_pts));
4184 feLhs->getOpPtrVector().push_back(
4185 new HookeElement::OpCalculateStress<1>(
"SPATIAL_POSITION",
4187 data_hooke_element_at_pts));
4191 feLhs->getOpPtrVector().push_back(
new HookeElement::OpAleLhs_dx_dx<1>(
4192 "SPATIAL_POSITION",
"SPATIAL_POSITION", data_hooke_element_at_pts));
4195 feLhs->getOpPtrVector().push_back(
4196 new HookeElement::OpCalculateHomogeneousStiffness<0>(
4197 "SPATIAL_POSITION",
"SPATIAL_POSITION", block_sets_ptr,
4198 data_hooke_element_at_pts));
4202 feLhs->getOpPtrVector().push_back(
4204 "SPATIAL_POSITION", data_hooke_element_at_pts->hMat,
4206 feLhs->getOpPtrVector().push_back(
4207 new HookeElement::OpCalculateStrainAle(
"SPATIAL_POSITION",
4209 data_hooke_element_at_pts));
4210 feLhs->getOpPtrVector().push_back(
4211 new HookeElement::OpCalculateStress<0>(
"SPATIAL_POSITION",
4213 data_hooke_element_at_pts));
4218 feLhs->getOpPtrVector().push_back(
new HookeElement::OpAleLhs_dx_dx<0>(
4219 "SPATIAL_POSITION",
"SPATIAL_POSITION", data_hooke_element_at_pts));
4227 boost::make_shared<boost::ptr_map<string, NeumannForcesSurface>>();
4230 string fe_name_str =
"FORCE_FE";
4233 auto &fe = nf.getLoopFe();
4240 .addForce(
"SPATIAL_POSITION", PETSC_NULL, it->getMeshsetId(),
true);
4243 const string block_set_force_name(
"FORCE");
4246 if (it->getName().compare(0, block_set_force_name.length(),
4247 block_set_force_name) == 0) {
4249 .addForce(
"SPATIAL_POSITION", PETSC_NULL, (it->getMeshsetId()),
4257 boost::make_shared<boost::ptr_map<string, NeumannForcesSurface>>();
4259 boost::make_shared<NeumannForcesSurface::DataAtIntegrationPts>();
4262 string fe_name_str =
"FORCE_FE_ALE";
4266 auto &fe_lhs = nf.getLoopFeLhs();
4267 auto &fe_mat_rhs = nf.getLoopFeMatRhs();
4268 auto &fe_mat_lhs = nf.getLoopFeMatLhs();
4277 .addForceAle(
"SPATIAL_POSITION",
"MESH_NODE_POSITIONS",
4279 PETSC_NULL,
bit->getMeshsetId(),
true,
false,
4283 const string block_set_force_name(
"FORCE");
4286 if (it->getName().compare(0, block_set_force_name.length(),
4287 block_set_force_name) == 0) {
4289 .addForceAle(
"SPATIAL_POSITION",
"MESH_NODE_POSITIONS",
4291 PETSC_NULL, it->getMeshsetId(),
true,
true,
4299 boost::make_shared<boost::ptr_map<string, NeumannForcesSurface>>();
4301 string fe_name_str =
"PRESSURE_FE";
4305 auto &fe = nf.getLoopFe();
4313 .addPressure(
"SPATIAL_POSITION", PETSC_NULL, it->getMeshsetId(),
4317 const string block_set_pressure_name(
"PRESSURE");
4319 if (it->getName().compare(0, block_set_pressure_name.length(),
4320 block_set_pressure_name) == 0) {
4322 .addPressure(
"SPATIAL_POSITION", PETSC_NULL, it->getMeshsetId(),
4327 const string block_set_linear_pressure_name(
"LINEAR_PRESSURE");
4329 if (it->getName().compare(0, block_set_linear_pressure_name.length(),
4330 block_set_linear_pressure_name) == 0) {
4332 .addLinearPressure(
"SPATIAL_POSITION", PETSC_NULL,
4333 it->getMeshsetId(),
true);
4340 boost::make_shared<boost::ptr_map<string, NeumannForcesSurface>>();
4342 boost::make_shared<NeumannForcesSurface::DataAtIntegrationPts>();
4344 string fe_name_str =
"PRESSURE_ALE";
4348 auto &fe_lhs = nf.getLoopFeLhs();
4349 auto &fe_mat_rhs = nf.getLoopFeMatRhs();
4350 auto &fe_mat_lhs = nf.getLoopFeMatLhs();
4360 .addPressureAle(
"SPATIAL_POSITION",
"MESH_NODE_POSITIONS",
4362 PETSC_NULL, it->getMeshsetId(),
true);
4368 boost::make_shared<FaceElementForcesAndSourcesCore>(
mField);
4371 boost::make_shared<FaceElementForcesAndSourcesCore>(
mField);
4373 boost::make_shared<FaceElementForcesAndSourcesCore>(
mField);
4375 boost::make_shared<MetaSpringBC::DataAtIntegrationPtsSprings>(
mField);
4386 feSpringLhsPtr = boost::shared_ptr<FaceElementForcesAndSourcesCore>(
4388 feSpringRhsPtr = boost::shared_ptr<FaceElementForcesAndSourcesCore>(
4393 "MESH_NODE_POSITIONS");
4395 bool use_eigen_pos =
4398 bool use_eigen_pos_simple_contact =
4403 boost::make_shared<SimpleContactProblem::SimpleContactElement>(
mField);
4405 boost::make_shared<SimpleContactProblem::SimpleContactElement>(
mField);
4407 boost::make_shared<SimpleContactProblem::CommonDataSimpleContact>(
mField);
4416 "LAMBDA_CONTACT",
false, use_eigen_pos_simple_contact,
4417 "EIGEN_SPATIAL_POSITIONS");
4420 "LAMBDA_CONTACT",
false, use_eigen_pos_simple_contact,
4421 "EIGEN_SPATIAL_POSITIONS");
4425 "LAMBDA_CONTACT",
false, use_eigen_pos_simple_contact,
4426 "EIGEN_SPATIAL_POSITIONS");
4430 "LAMBDA_CONTACT",
false, use_eigen_pos_simple_contact,
4431 "EIGEN_SPATIAL_POSITIONS");
4438 mField,
"LAMBDA_CLOSE_CRACK",
"SPATIAL_POSITION"));
4447 boost::make_shared<SimpleContactProblem::SimpleContactElement>(
mField);
4449 boost::make_shared<SimpleContactProblem::SimpleContactElement>(
mField);
4451 boost::make_shared<SimpleContactProblem::SimpleContactElement>(
mField);
4453 boost::make_shared<SimpleContactProblem::CommonDataSimpleContact>(
4460 "SPATIAL_POSITION",
"MESH_NODE_POSITIONS",
"LAMBDA_CONTACT",
4465 "SPATIAL_POSITION",
"MESH_NODE_POSITIONS",
"LAMBDA_CONTACT",
4470 "MESH_NODE_POSITIONS",
"LAMBDA_CONTACT", use_eigen_pos_simple_contact,
4471 "EIGEN_SPATIAL_POSITIONS");
4475 boost::make_shared<MortarContactProblem::MortarContactElement>(
4477 "MESH_NODE_POSITIONS");
4479 boost::make_shared<MortarContactProblem::MortarContactElement>(
4481 "MESH_NODE_POSITIONS");
4483 boost::make_shared<MortarContactProblem::CommonDataMortarContact>(
mField);
4492 "LAMBDA_CONTACT",
false, use_eigen_pos,
"EIGEN_SPATIAL_POSITIONS");
4496 "LAMBDA_CONTACT",
false, use_eigen_pos,
"EIGEN_SPATIAL_POSITIONS");
4500 "LAMBDA_CONTACT",
false, use_eigen_pos,
"EIGEN_SPATIAL_POSITIONS");
4504 "LAMBDA_CONTACT",
false, use_eigen_pos,
"EIGEN_SPATIAL_POSITIONS");
4510 boost::make_shared<SimpleContactProblem::SimpleContactElement>(
mField);
4513 boost::make_shared<MortarContactProblem::MortarContactElement>(
4515 "MESH_NODE_POSITIONS");
4521 use_eigen_pos_simple_contact,
"EIGEN_SPATIAL_POSITIONS");
4526 use_eigen_pos,
"EIGEN_SPATIAL_POSITIONS");
4530 nodalForces = boost::make_shared<boost::ptr_map<string, NodalForce>>();
4532 string fe_name_str =
"FORCE_FE";
4537 .addForce(
"SPATIAL_POSITION", PETSC_NULL, it->getMeshsetId(),
false);
4541 edgeForces = boost::make_shared<boost::ptr_map<string, EdgeForce>>();