v0.14.0
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 50 of file mofem_manager.cpp.

50  {
51 
52  const string default_options = "-ksp_type fgmres \n"
53  "-pc_type lu \n"
54  "-pc_factor_mat_solver_type mumps \n"
55  "-ksp_atol 1e-10 \n"
56  "-ksp_rtol 1e-10 \n"
57  "-snes_monitor \n"
58  "-snes_max_it 100 \n"
59  "-snes_linesearch_type bt \n"
60  "-snes_linesearch_max_it 3 \n"
61  "-snes_atol 1e-8 \n"
62  "-snes_rtol 1e-8 \n"
63  "-ts_monitor \n"
64  "-ts_alpha_radius 1 \n"
65  "-ts_monitor \n"
66  "-mat_mumps_icntl_20 0 \n"
67  "-mat_mumps_icntl_14 800 \n"
68  "-mat_mumps_icntl_24 1 \n"
69  "-mat_mumps_icntl_13 1 \n";
70 
71  string param_file = "param_file.petsc";
72  if (!static_cast<bool>(ifstream(param_file))) {
73  std::ofstream file(param_file.c_str(), std::ios::ate);
74  if (file.is_open()) {
75  file << default_options;
76  file.close();
77  }
78  }
79 
80  MoFEM::Core::Initialize(&argc, &argv, param_file.c_str(), help);
81 
82  // Add logging channel for example
83  auto core_log = logging::core::get();
84  core_log->add_sink(
85  LogManager::createSink(LogManager::getStrmWorld(), "MManager"));
86  LogManager::setLog("MManager");
87  MOFEM_LOG_TAG("MManager", "module_manager");
88 
89  try {
90 
91  moab::Core mb_instance;
92  moab::Interface &moab = mb_instance;
93  MoFEM::Core core(moab);
94  MoFEM::Interface &m_field = core;
95 
96  MFManager md(m_field);
97  CHKERR md.getParams();
98 
99  Simple *simple = m_field.getInterface<Simple>();
100  CHKERR simple->getOptions();
101 
102  if (md.isPartitioned)
103  CHKERR simple->loadFile("");
104  else
105  CHKERR simple->loadFile("", "");
106  simple->getProblemName() = "MoFEM Manager module";
107  simple->getDomainFEName() = "ELASTIC";
108  vector<string> volume_fe_elements{simple->getDomainFEName()};
109  simple->getBoundaryFEName() = "BOUNDARY_ELEMENT";
110 
111  // setup the modules
112  boost::ptr_vector<GenericElementInterface> m_modules;
113 
114  // Basic Boundary Conditions module should always be first (dirichlet)
115  m_modules.push_back(new BasicBoundaryConditionsInterface(
116  m_field, "U", "MESH_NODE_POSITIONS", simple->getProblemName(),
117  simple->getDomainFEName(), true, md.isQuasiStatic, nullptr,
118  md.isPartitioned));
119 
120 #ifdef WITH_MODULE_MORTAR_CONTACT
121  m_modules.push_back(new MortarContactInterface(
122  m_field, "U", "MESH_NODE_POSITIONS", true, md.isQuasiStatic));
123 #endif
124 
125  // // Nonlinear Elastic Element module
126  m_modules.push_back(new NonlinearElasticElementInterface(
127  m_field, "U", "MESH_NODE_POSITIONS", true, md.isQuasiStatic));
128 
129 #ifdef WITH_MODULE_MFRONT_INTERFACE
130  m_modules.push_back(new MFrontMoFEMInterface(
131  m_field, "U", "MESH_NODE_POSITIONS", true, md.isQuasiStatic));
132  volume_fe_elements.push_back("MFRONT_EL");
133 #endif
134 
135 #ifdef WITH_MODULE_HDIV_CONTACT
136  m_modules.push_back(new HdivContactInterface(
137  m_field, "U", "MESH_NODE_POSITIONS", simple->getProblemName(),
138  volume_fe_elements, {simple->getBoundaryFEName()}, PETSC_TRUE,
139  md.isQuasiStatic, md.isPartitioned));
140 #endif
141 
142  CHKERR md.setMainField();
143 
144  for (auto &&mod : m_modules) {
145  CHKERR mod.getCommandLineParameters();
146  CHKERR mod.addElementFields();
147  CHKERR mod.createElements();
148  }
149 
150  CHKERR m_field.build_fields();
151  CHKERR md.defineDM();
152 
153  for (auto &&mod : m_modules)
154  CHKERR mod.addElementsToDM(md.dM);
155 
156  Projection10NodeCoordsOnField ent_method(m_field, "MESH_NODE_POSITIONS");
157  CHKERR m_field.loop_dofs("MESH_NODE_POSITIONS", ent_method);
158  CHKERR m_field.build_finite_elements();
159  CHKERR m_field.build_adjacencies(simple->getBitRefLevel());
160 
161  CHKERR DMSetUp(md.dM);
162 
163  md.monitorPtr->preProcessHook = []() { return 0; };
164  md.monitorPtr->operatorHook = []() { return 0; };
165  md.monitorPtr->postProcessHook = [&]() {
167  auto ts_time = md.monitorPtr->ts_t;
168  auto ts_step = md.monitorPtr->ts_step;
169  auto &ts_u = md.monitorPtr->ts_u;
170 
171  for (auto &&mod : m_modules) {
172  CHKERR mod.updateElementVariables();
173  if (ts_step % md.saveEveryNthStep == 0)
174  CHKERR mod.postProcessElement(ts_step);
175  }
176 
177  if (md.doPrintMaxMin == PETSC_TRUE) {
178  CHKERR md.printMaxMin(md.vScatter[0], "Ux", ts_u, ts_time);
179  CHKERR md.printMaxMin(md.vScatter[1], "Uy", ts_u, ts_time);
180  CHKERR md.printMaxMin(md.vScatter[2], "Uz", ts_u, ts_time);
181  }
182 
184  };
185 
186  auto t_type = md.getTSType();
187  for (auto &&mod : m_modules) {
188  CHKERR mod.setMonitorPtr(md.monitorPtr);
189  CHKERR mod.setOperators();
190  CHKERR mod.setupSolverFunctionTS(t_type);
191  CHKERR mod.setupSolverJacobianTS(t_type);
192  }
193 
194  CHKERR md.tsSetup();
195  CHKERR md.tsSolve();
196  }
197  CATCH_ERRORS;
198 
200  return 0;
201 }

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.

MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::CoreInterface::loop_dofs
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.
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
BasicBoundaryConditionsInterface
Set of functions declaring elements and setting operators for basic boundary conditions interface.
Definition: BasicBoundaryConditionsInterface.hpp:20
md
double md
Definition: free_surface.cpp:174
MortarContactInterface
Definition: MortarContactInterface.hpp:22
MoFEM::Projection10NodeCoordsOnField
Projection of edge entities with one mid-node on hierarchical basis.
Definition: Projection10NodeCoordsOnField.hpp:24
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::Simple
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEMManager::MFManager
Definition: MoFEMManager.hpp:17
MoFEM::CoreInterface::build_finite_elements
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
simple
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
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:372
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
MoFEM::CoreInterface::build_fields
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
MoFEM::CoreInterface::build_adjacencies
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
NonlinearElasticElementInterface
Set of functions declaring elements and setting operators for generic element interface.
Definition: NonlinearElasticElementInterface.hpp:15
help
static char help[]
Definition: mofem_manager.cpp:45