v0.14.0
Loading...
Searching...
No Matches
mofem_manager.cpp
Go to the documentation of this file.
1/** \file mofem_manager.cpp
2 *
3 */
4/* MoFEM is free software: you can redistribute it and/or modify it under the
5 * terms of the MIT License.
6 */
7
9using namespace MoFEM;
10
11#include <ElasticMaterials.hpp>
14
16
17#ifdef WITH_MODULE_MORTAR_CONTACT
18 #include <Mortar.hpp>
19#endif
20
21#ifdef WITH_MODULE_MFRONT_INTERFACE
22 #include <MFrontMoFEMInterface.hpp>
23#endif
24
25#ifdef WITH_MODULE_HDIV_CONTACT
26using namespace FTensor;
28#include <RigidBodies.hpp>
29#include <BasicFeTools.hpp>
30#include <ContactOperators.hpp>
31using namespace OpContactTools;
32#include <HdivContactInterface.hpp>
33
34#endif
35
42
43constexpr size_t SPACE_DIM = 3;
44
45static char help[] = "...\n\n";
46
47
48#include <MoFEMManager.hpp>
49using namespace MoFEMManager;
50
51int main(int argc, char *argv[]) {
52
53 const string default_options = "-ksp_type fgmres \n"
54 "-pc_type lu \n"
55 "-pc_factor_mat_solver_type mumps \n"
56 "-ksp_atol 1e-10 \n"
57 "-ksp_rtol 1e-10 \n"
58 "-snes_monitor \n"
59 "-snes_max_it 100 \n"
60 "-snes_linesearch_type bt \n"
61 "-snes_linesearch_max_it 3 \n"
62 "-snes_atol 1e-8 \n"
63 "-snes_rtol 1e-8 \n"
64 "-ts_monitor \n"
65 "-ts_alpha_radius 1 \n"
66 "-ts_monitor \n"
67 "-mat_mumps_icntl_20 0 \n"
68 "-mat_mumps_icntl_14 800 \n"
69 "-mat_mumps_icntl_24 1 \n"
70 "-mat_mumps_icntl_13 1 \n";
71
72 string param_file = "param_file.petsc";
73 if (!static_cast<bool>(ifstream(param_file))) {
74 std::ofstream file(param_file.c_str(), std::ios::ate);
75 if (file.is_open()) {
76 file << default_options;
77 file.close();
78 }
79 }
80
81 MoFEM::Core::Initialize(&argc, &argv, param_file.c_str(), help);
82
83 // Add logging channel for example
84 auto core_log = logging::core::get();
85 core_log->add_sink(
87 LogManager::setLog("MManager");
88 MOFEM_LOG_TAG("MManager", "module_manager");
89
90 try {
91
92 moab::Core mb_instance;
93 moab::Interface &moab = mb_instance;
94 MoFEM::Core core(moab);
95 MoFEM::Interface &m_field = core;
96
97 MFManager md(m_field);
98 CHKERR md.getParams();
99
100 Simple *simple = m_field.getInterface<Simple>();
101 CHKERR simple->getOptions();
102
103 if (md.isPartitioned)
104 CHKERR simple->loadFile("");
105 else
106 CHKERR simple->loadFile("","");
107 simple->getProblemName() = "MoFEM Manager module";
108 simple->getDomainFEName() = "ELASTIC";
109 vector<string> volume_fe_elements{simple->getDomainFEName()};
110 simple->getBoundaryFEName() = "BOUNDARY_ELEMENT";
111
112 //setup the modules
113 boost::ptr_vector<GenericElementInterface> m_modules;
114
115 // Basic Boundary Conditions module should always be first (dirichlet)
116 m_modules.push_back(new BasicBoundaryConditionsInterface(
117 m_field, "U", "MESH_NODE_POSITIONS", simple->getProblemName(),
118 simple->getDomainFEName(), true, md.isQuasiStatic, nullptr,
119 md.isPartitioned));
120
121#ifdef WITH_MODULE_MORTAR_CONTACT
122 m_modules.push_back(new MortarContactInterface(
123 m_field, "U", "MESH_NODE_POSITIONS", true, md.isQuasiStatic));
124 // simple->getBitRefLevel() = m_modules[1].getBitRefLevel();
125#endif
126
127 // // Nonlinear Elastic Element module
128 m_modules.push_back(new NonlinearElasticElementInterface(
129 m_field, "U", "MESH_NODE_POSITIONS", true, md.isQuasiStatic));
130
131#ifdef WITH_MODULE_MFRONT_INTERFACE
132 m_modules.push_back(new MFrontMoFEMInterface(
133 m_field, "U", "MESH_NODE_POSITIONS", true, md.isQuasiStatic));
134 volume_fe_elements.push_back("MFRONT_EL");
135#endif
136
137#ifdef WITH_MODULE_HDIV_CONTACT
138 m_modules.push_back(new HdivContactInterface(
139 m_field, "U", "MESH_NODE_POSITIONS", simple->getProblemName(),
140 volume_fe_elements, {simple->getBoundaryFEName()}, PETSC_TRUE,
141 md.isQuasiStatic, md.isPartitioned));
142#endif
143
144 CHKERR md.setMainField();
145
146 for (auto &&mod : m_modules) {
147 CHKERR mod.getCommandLineParameters();
148 CHKERR mod.addElementFields();
149 CHKERR mod.createElements();
150 }
151
152 CHKERR m_field.build_fields();
153 CHKERR md.defineDM();
154
155 for (auto &&mod : m_modules)
156 CHKERR mod.addElementsToDM(md.dM);
157
158 Projection10NodeCoordsOnField ent_method(m_field, "MESH_NODE_POSITIONS");
159 CHKERR m_field.loop_dofs("MESH_NODE_POSITIONS", ent_method);
161 CHKERR m_field.build_adjacencies(simple->getBitRefLevel());
162
163 CHKERR DMSetUp(md.dM);
164
165 auto t_type = md.getTSType();
166 for (auto &&mod : m_modules) {
167 CHKERR mod.setOperators();
168 CHKERR mod.setupSolverFunctionTS(t_type);
169 CHKERR mod.setupSolverJacobianTS(t_type);
170 }
171
172 md.monitorPtr->preProcessHook = []() { return 0; };
173 md.monitorPtr->operatorHook = []() { return 0; };
174 md.monitorPtr->postProcessHook = [&]() {
176 auto ts_time = md.monitorPtr->ts_t;
177 auto ts_step = md.monitorPtr->ts_step;
178 auto &ts_u = md.monitorPtr->ts_u;
179
180 for (auto &&mod : m_modules) {
181 CHKERR mod.updateElementVariables();
182 if (ts_step % md.saveEveryNthStep == 0)
183 CHKERR mod.postProcessElement(ts_step);
184 }
185
186 CHKERR md.printMaxMin(md.vScatter[0], "Ux", ts_u, ts_time);
187 CHKERR md.printMaxMin(md.vScatter[1], "Uy", ts_u, ts_time);
188 CHKERR md.printMaxMin(md.vScatter[2], "Uz", ts_u, ts_time);
189
191 };
192
193 CHKERR md.tsSetup();
194 CHKERR md.tsSolve();
195 }
197
199 return 0;
200}
Header file for BasicBoundaryConditionsInterface element implementation.
const std::string default_options
std::string param_file
Elastic materials.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
int main()
Definition: adol-c_atom.cpp:46
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
double md
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:389
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
static char help[]
constexpr size_t SPACE_DIM
Tensors class implemented by Walter Landry.
Definition: FTensor.hpp:51
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
Set of functions declaring elements and setting operators for basic boundary conditions interface.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
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:112
Deprecated interface functions.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Set of functions declaring elements and setting operators for generic element interface.
Postprocess on face.
Post processing.