v0.15.0
Loading...
Searching...
No Matches
debug_crack_mesh.cpp
Go to the documentation of this file.
1/**
2 * \file ep.cpp
3 * \example ep.cpp
4 *
5 * \brief Implementation of mix-element for Large strains
6 *
7 * \todo Implementation of plasticity
8 *
9 */
10
11/* This file is part of MoFEM.
12 * MoFEM is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation, either version 3 of the License, or (at your
15 * option) any later version.
16 *
17 * MoFEM is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
24
25constexpr int adolc_tag = 1;
26
27#define SINGULARITY
28
29#include <MoFEM.hpp>
30using namespace MoFEM;
31using namespace boost::multi_index;
32using namespace boost::multiprecision;
33using namespace boost::numeric;
34#include <cmath>
35
36#include <cholesky.hpp>
37#ifdef ENABLE_PYTHON_BINDING
38 #include <boost/python.hpp>
39 #include <boost/python/def.hpp>
40 #include <boost/python/numpy.hpp>
41namespace bp = boost::python;
42namespace np = boost::python::numpy;
43#endif
44
46using namespace EshelbianPlasticity;
47
48static char help[] = "...\n\n";
49
50int main(int argc, char *argv[]) {
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
155 CHKERR ep.createExchangeVectors(Sev::inform);
156
158 CHKERR ep.addCrackSurfaces(true);
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}
Eshelbian plasticity interface.
int main()
constexpr int SPACE_DIM
cholesky decomposition
static char help[]
constexpr int adolc_tag
#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
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
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.
MoFEMErrorCode createCrackSurfaceMeshset()
MoFEMErrorCode projectGeometry(const EntityHandle meshset=0)
MoFEMErrorCode addCrackSurfaces(const bool debug=false)
MoFEMErrorCode createExchangeVectors(Sev sev)
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.