v0.15.0
Loading...
Searching...
No Matches
debug_crack_mesh.cpp File Reference
#include <MoFEM.hpp>
#include <cmath>
#include <cholesky.hpp>
#include <EshelbianPlasticity.hpp>

Go to the source code of this file.

Macros

#define SINGULARITY
 

Functions

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

Variables

constexpr int adolc_tag = 1
 
static char help [] = "...\n\n"
 

Macro Definition Documentation

◆ SINGULARITY

#define SINGULARITY

Definition at line 27 of file debug_crack_mesh.cpp.

Function Documentation

◆ main()

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

Definition at line 50 of file debug_crack_mesh.cpp.

50 {
51
52 // initialize petsc
53 const char param_file[] = "param_file.petsc";
54 MoFEM::Core::Initialize(&argc, &argv, param_file, help);
55
56 // Add logging channel for example
57 auto core_log = logging::core::get();
58 core_log->add_sink(LogManager::createSink(LogManager::getStrmWorld(), "EP"));
60 MOFEM_LOG_TAG("EP", "ep");
61 core_log->add_sink(
63 LogManager::setLog("EPSELF");
64 MOFEM_LOG_TAG("EPSELF", "ep");
65
66#ifdef ENABLE_PYTHON_BINDING
67 Py_Initialize();
68 np::initialize();
69 MOFEM_LOG("EP", Sev::inform) << "Python initialised";
70#else
71 MOFEM_LOG("EP", Sev::inform) << "Python NOT initialised";
72#endif
73
74 core_log->add_sink(
76 LogManager::setLog("EPSYNC");
77 MOFEM_LOG_TAG("EPSYNC", "ep");
78
79 try {
80
81 // Get mesh file
82 PetscBool flg = PETSC_TRUE;
83 char mesh_file_name[255];
84 CHKERR PetscOptionsGetString(PETSC_NULLPTR, "", "-file_name", mesh_file_name,
85 255, &flg);
86 // Register DM Manager
87 DMType dm_name = "DMMOFEM";
88 CHKERR DMRegister_MoFEM(dm_name);
89 DMType dm_name_mg = "DMMOFEM_MG";
91
92 // Create MoAB database
93 moab::Core moab_core;
94 moab::Interface &moab = moab_core;
95
96 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
97 if (pcomm == NULL)
98 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
99 // Read mesh to MOAB
100 PetscBool fully_distributed = PETSC_FALSE;
101 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-fully_distributed",
102 &fully_distributed, PETSC_NULLPTR);
103 if (fully_distributed) {
104 const char *option;
105 if (pcomm->proc_config().proc_size() == 1)
106 option = "";
107 else
108 option = "PARALLEL=READ_PART;"
109 "PARALLEL_RESOLVE_SHARED_ENTS;"
110 "PARTITION=PARALLEL_PARTITION";
111 CHKERR moab.load_file(mesh_file_name, 0, option);
112 } else {
115 }
116
117 // Create MoFEM database and link it to MoAB
118 MoFEM::Core mofem_core(moab);
119 MoFEM::Interface &m_field = mofem_core;
120
121 BitRefLevel bit_level0 = BitRefLevel().set(0);
122 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
123 0, 3, bit_level0);
124
125 // Data structures
126 EshelbianCore ep(m_field);
127
128 auto meshset_ptr = get_temp_meshset_ptr(moab);
129 CHKERR moab.add_entities(
130 *meshset_ptr, CommInterface::getPartEntities(moab, pcomm->rank()));
131 auto get_adj = [&](Range ents, int dim) {
132 Range adj;
133 CHKERR moab.get_adjacencies(ents, dim, false, adj,
134 moab::Interface::UNION);
135 return adj;
136 };
137 CHKERR moab.add_entities(
138 *meshset_ptr,
139 get_adj(CommInterface::getPartEntities(moab, pcomm->rank())
140 .subset_by_dimension(SPACE_DIM),
141 2));
142 CHKERR moab.add_entities(
143 *meshset_ptr,
144 get_adj(CommInterface::getPartEntities(moab, pcomm->rank())
145 .subset_by_dimension(SPACE_DIM),
146 1));
147 CHKERR moab.add_entities(
148 *meshset_ptr,
149 get_adj(CommInterface::getPartEntities(moab, pcomm->rank())
150 .subset_by_dimension(SPACE_DIM),
151 0));
152
153 // create growing crack surface meshset
154 CHKERR ep.createCrackSurfaceMeshset();
155 CHKERR ep.createExchangeVectors(Sev::inform);
156
157 CHKERR ep.projectGeometry();
158 CHKERR ep.addCrackSurfaces(true);
159 CHKERR ep.projectGeometry();
160 }
162
163 // finish work cleaning memory, getting statistics, etc.
165
166#ifdef ENABLE_PYTHON_BINDING
167 if (Py_FinalizeEx() < 0) {
168 exit(120);
169 }
170#endif
171}
constexpr int SPACE_DIM
static char help[]
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERR
Inline error check.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition DMMoFEM.cpp:43
MoFEMErrorCode DMRegister_MGViaApproxOrders(const char sname[])
Register DM for Multi-Grid via approximation orders.
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.
char mesh_file_name[255]
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
Managing BitRefLevels.
static Range getPartEntities(moab::Interface &moab, int part)
static MoFEMErrorCode loadFileRootProcAllRestDistributed(moab::Interface &moab, const char *file_name, int dim, LoadFileFun proc_skin_fun=defaultProcSkinFun, const char *options="PARALLEL=BCAST;PARTITION=")
Root proc has whole mesh, other procs only part of it.
Core (interface) class.
Definition Core.hpp:82
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
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:118
Deprecated interface functions.
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 boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

Variable Documentation

◆ adolc_tag

int adolc_tag = 1
constexpr
Examples
ep.cpp.

Definition at line 25 of file debug_crack_mesh.cpp.

◆ help

char help[] = "...\n\n"
static

Definition at line 48 of file debug_crack_mesh.cpp.