v0.14.0
Functions | Variables
crack_mesh_cut.cpp File Reference
#include <tetgen.h>
#include <MoFEM.hpp>
#include <BasicFiniteElements.hpp>
#include <Mortar.hpp>
#include <NeoHookean.hpp>
#include <Hooke.hpp>
#include <CrackFrontElement.hpp>
#include <ComplexConstArea.hpp>
#include <MWLS.hpp>
#include <GriffithForceElement.hpp>
#include <VolumeLengthQuality.hpp>
#include <CrackPropagation.hpp>
#include <CPSolvers.hpp>
#include <CPMeshCut.hpp>
#include <AnalyticalFun.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

static char help []
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 54 of file crack_mesh_cut.cpp.

54  {
55 
56  const char param_file[] = "param_file.petsc";
57  MoFEM::Core::Initialize(&argc, &argv, param_file, help);
58 
59  try {
60 
61  PetscBool flg = PETSC_FALSE;
62  CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-debug", &flg, PETSC_NULL);
63  if (flg == PETSC_TRUE)
65 
66  char mesh_file_name[255];
67  CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
68  255, &flg);
69  moab::Core mb_instance;
70  moab::Interface &moab = mb_instance;
71 
72  // Read mesh file
73  if (flg) {
74  const char *option;
75  option = "";
76  CHKERR moab.load_file(mesh_file_name, 0, option);
77  }
78 
79  // Create mofem database
80  MoFEM::Core core(moab);
81  MoFEM::Interface &m_field = core;
82 
83  auto add_last_twenty = [&]() {
85  BitRefLevel mask;
86  for (int ll = 20; ll != BITREFLEVEL_SIZE; ++ll)
87  mask.set(ll);
89  ->addToDatabaseBitRefLevelByType(MBTET, mask, BitRefLevel().set());
91  };
92 
93  auto add_first_four = [&]() {
95  BitRefLevel mask;
96  for (int ll = 0; ll != 5; ++ll)
97  mask.set(ll);
99  ->addToDatabaseBitRefLevelByType(MBTET, mask, BitRefLevel().set());
101  };
102 
103  CHKERR add_last_twenty();
104  CHKERR add_first_four();
105 
108  ->writeEntitiesAllBitLevelsByType(BitRefLevel().set(), MBTET,
109  "all_start.vtk", "VTK", "");
110 
111  // Create data structure for crack propagation
112  CrackPropagation cp(m_field);
113  CHKERR cp.getOptions();
114 
115  if (string(mesh_file_name).compare(0, 8, "restart_") == 0) {
116  Range ents;
117  CHKERR m_field.getInterface<BitRefManager>()->getAllEntitiesNotInDatabase(
118  ents);
119  if (!ents.empty()) {
120  EntityHandle meshset;
121  CHKERR moab.create_meshset(MESHSET_SET, meshset);
122  CHKERR moab.add_entities(meshset, ents);
123  CHKERR moab.write_file("ents_not_in_database_to_delete.vtk", "VTK", "",
124  &meshset, 1);
125  CHKERR moab.delete_entities(&meshset, 1);
126 
127  Range meshsets;
128  CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
129  for (auto m : meshsets)
130  CHKERR moab.remove_entities(m, ents);
131  CHKERR moab.delete_entities(ents);
132  }
133  CHKERR cp.getInterface<CPMeshCut>()->rebuildCrackSurface(
134  cp.crackAccelerationFactor, "cutting_surface.vtk", QUIET,
136 
137  CHKERR cp.getInterface<CPMeshCut>()->refineMesh(nullptr, false, QUIET,
139  } else {
140 
141  if (!cp.getInterface<CPMeshCut>()->getCutSurfMeshName().empty())
142  CHKERR cp.getInterface<CPMeshCut>()->setCutSurfaceFromFile();
143  CHKERR cp.getInterface<CPMeshCut>()->copySurface("cutting_surface.vtk");
144  Range vol;
145  CHKERR moab.get_entities_by_type(0, MBTET, vol, false);
146  CHKERR cp.getInterface<CPMeshCut>()->refineMesh(&vol, true, QUIET,
148  }
149 
150  CHKERR cp.getInterface<CPMeshCut>()->cutRefineAndSplit(
152 
153  CHKERR moab.write_mesh("cut_mesh_out.h5m");
154 
155  CHKERR core.getInterface<BitRefManager>()->writeBitLevelByType(
156  cp.mapBitLevel["mesh_cut"], BitRefLevel().set(), MBTET,
157  "out_level0.vtk", "VTK", "");
158  CHKERR core.getInterface<BitRefManager>()->writeBitLevelByType(
159  cp.mapBitLevel["spatial_domain"], BitRefLevel().set(), MBTET,
160  "out_level1_tets.vtk", "VTK", "");
161  CHKERR core.getInterface<BitRefManager>()->writeBitLevelByType(
162  cp.mapBitLevel["spatial_domain"], BitRefLevel().set(), MBPRISM,
163  "out_level1_prisms.vtk", "VTK", "");
164 
165  }
166  CATCH_ERRORS;
167 
169 
170  return 0;
171 }

Variable Documentation

◆ help

char help[]
static
Initial value:
= "Calculate crack release energy and crack propagation"
"\n\n"

Definition at line 41 of file crack_mesh_cut.cpp.

MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
EntityHandle
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
FractureMechanics::CPMeshCut
Definition: CPMeshCut.hpp:24
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
FractureMechanics::CPMeshCut::getCutSurfMeshName
const std::string & getCutSurfMeshName() const
Definition: CPMeshCut.hpp:157
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
debug
static const bool debug
Definition: dm_create_subdm.cpp:12
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:22
Range
MoFEM::CoreTmp< 0 >::Initialize
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
BITREFLEVEL_SIZE
#define BITREFLEVEL_SIZE
max number of refinements
Definition: definitions.h:232
FractureMechanics::CrackPropagation
Definition: CrackPropagation.hpp:77
help
static char help[]
Definition: crack_mesh_cut.cpp:41
MoFEM::PetscOptionsGetString
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Definition: DeprecatedPetsc.hpp:172
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
MoFEM::BitRefManager
Managing BitRefLevels.
Definition: BitRefManager.hpp:21
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
QUIET
@ QUIET
Definition: definitions.h:221
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MoFEM::PetscOptionsGetBool
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
Definition: DeprecatedPetsc.hpp:182