v0.14.0
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
mofem_manager.cpp File Reference
#include <BasicFiniteElements.hpp>
#include <ElasticMaterials.hpp>
#include <NonlinearElasticElementInterface.hpp>
#include <BasicBoundaryConditionsInterface.hpp>
#include <SurfacePressureComplexForLazy.hpp>
#include <MoFEMManager.hpp>

Go to the source code of this file.

Typedefs

using DomainEle = VolumeElementForcesAndSourcesCore
 
using DomainEleOp = DomainEle::UserDataOperator
 
using BoundaryEle = FaceElementForcesAndSourcesCore
 
using BoundaryEleOp = BoundaryEle::UserDataOperator
 
using PostProcEle = PostProcVolumeOnRefinedMesh
 
using PostProcSkinEle = PostProcFaceOnRefinedMesh
 

Functions

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

Variables

constexpr size_t SPACE_DIM = 3
 
static char help [] = "...\n\n"
 

Typedef Documentation

◆ BoundaryEle

Definition at line 38 of file mofem_manager.cpp.

◆ BoundaryEleOp

Definition at line 39 of file mofem_manager.cpp.

◆ DomainEle

Definition at line 36 of file mofem_manager.cpp.

◆ DomainEleOp

Definition at line 37 of file mofem_manager.cpp.

◆ PostProcEle

Definition at line 40 of file mofem_manager.cpp.

◆ PostProcSkinEle

Definition at line 41 of file mofem_manager.cpp.

Function Documentation

◆ main()

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

Definition at line 51 of file mofem_manager.cpp.

51 {
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}
const std::string default_options
std::string param_file
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
#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[]
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.

Variable Documentation

◆ help

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

Definition at line 45 of file mofem_manager.cpp.

◆ SPACE_DIM

constexpr size_t SPACE_DIM = 3
constexpr

Definition at line 43 of file mofem_manager.cpp.