v0.10.0
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Example Struct Reference

[Example] More...

Collaboration diagram for Example:
[legend]

Classes

struct  CommonData
 [Example] More...
 
struct  OpError
 
struct  OpFirst
 
struct  OpFluxRhs
 
struct  OpRadiationLhs
 
struct  OpRadiationRhs
 
struct  OpSecond
 [Operator] More...
 
struct  OpZero
 [Common data] More...
 

Public Member Functions

 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 [Run problem] More...
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 Example (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 

Private Member Functions

MoFEMErrorCode setupProblem ()
 [Set up problem] More...
 
MoFEMErrorCode createCommonData ()
 [Set up problem] More...
 
MoFEMErrorCode bC ()
 [Create common data] More...
 
MoFEMErrorCode OPs ()
 [Boundary condition] More...
 
MoFEMErrorCode kspSolve ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 [Solve] More...
 
MoFEMErrorCode checkResults ()
 [Postprocess results] More...
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode tsSolve ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode tsSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
Range getEntsOnMeshSkin ()
 [Check] More...
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode readMesh ()
 [Read mesh] More...
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode boundaryCondition ()
 [Set up problem] More...
 
MoFEMErrorCode assembleSystem ()
 [Applying essential BC] More...
 
MoFEMErrorCode solveSystem ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode outputResults ()
 [Solve] More...
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUp ()
 [Run all] More...
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode setFieldValues ()
 [Create common data] More...
 
MoFEMErrorCode pushOperators ()
 [Set density distribution] More...
 
MoFEMErrorCode integrateElements ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode readMesh ()
 [Approximated function] More...
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode setIntegrationRules ()
 [Set up problem] More...
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode boundaryCondition ()
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode outputResults ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode readMesh ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode boundaryCondition ()
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode outputResults ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode readMesh ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode boundaryCondition ()
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode outputResults ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode readMesh ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode boundaryCondition ()
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode outputResults ()
 
MoFEMErrorCode checkResults ()
 

Static Private Member Functions

static double approxFunction (const double x, const double y, const double z)
 
static double nablaFunction (const double x, const double y, const double z)
 
static int integrationRule (int, int, int p_data)
 
static int integrationRule (int, int, int p_data)
 
static double approxFunction (const double x, const double y, const double z)
 [Approximated function] More...
 

Private Attributes

MoFEM::InterfacemField
 
MatrixDouble invJac
 
boost::shared_ptr< CommonDatacommonDataPtr
 
boost::shared_ptr< std::vector< bool > > boundaryMarker
 
boost::shared_ptr< VectorDoubleapproxVals
 
boost::shared_ptr< MatrixDoubleapproxGradVals
 
boost::shared_ptr< OpPlasticTools::CommonDatacommonDataPtr
 
boost::shared_ptr< PostProcFaceOnRefinedMeshpostProcFe
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
 
MatrixDouble jAc
 
boost::shared_ptr< OpContactTools::CommonDatacommonDataPtr
 
boost::shared_ptr< PostProcFaceOnRefinedMeshFor2DpostProcFe
 
SimplesimpleInterface
 
boost::shared_ptr< MatrixDoublematGradPtr
 
boost::shared_ptr< MatrixDoublematStrainPtr
 
boost::shared_ptr< MatrixDoublematStressPtr
 
boost::shared_ptr< MatrixDoublematDPtr
 
boost::shared_ptr< MatrixDoublebodyForceMatPtr
 
SmartPetscObj< Mat > M
 
SmartPetscObj< Mat > K
 
SmartPetscObj< EPS > ePS
 
boost::shared_ptr< MatrixDouble > matAccelerationPtr
 
boost::shared_ptr< MatrixDouble > matInertiaPtr
 

Detailed Description

[Example]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, helmholtz.cpp, lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 47 of file lesson3_poisson.cpp.

Constructor & Destructor Documentation

◆ Example() [1/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 49 of file lesson3_poisson.cpp.

49 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [2/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 53 of file lesson6_radiation.cpp.

53 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [3/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 47 of file lesson7_plastic.cpp.

47 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [4/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 46 of file lesson8_contact.cpp.

46 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [5/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 30 of file mian_snippet.cpp.

30 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [6/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 47 of file helmholtz.cpp.

47 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [7/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 39 of file integration.cpp.

39 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [8/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 42 of file approximaton.cpp.

42 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [9/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 51 of file elastic.cpp.

51 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [10/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 66 of file eigen_elastic.cpp.

66 : mField(m_field) {}
MoFEM::Interface & mField

◆ Example() [11/11]

Example::Example ( MoFEM::Interface m_field)

Definition at line 74 of file dynamic_elastic.cpp.

74 : mField(m_field) {}
MoFEM::Interface & mField

Member Function Documentation

◆ approxFunction() [1/2]

static double Example::approxFunction ( const double  x,
const double  y,
const double  z 
)
staticprivate

[Approximated function]

Definition at line 51 of file approximaton.cpp.

51  {
52  return sin(x * 10.) * cos(y * 10.);
53  }

◆ approxFunction() [2/2]

static double Example::approxFunction ( const double  x,
const double  y,
const double  z 
)
staticprivate
Examples
lesson3_poisson.cpp.

Definition at line 56 of file lesson3_poisson.cpp.

56  {
57  return sin(x * 10.) * cos(y * 10.);
58  }

◆ assembleSystem() [1/5]

MoFEMErrorCode Example::assembleSystem ( )
private

[Applying essential BC]

[Boundary condition]

[Push operators to pipeline]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, and helmholtz.cpp.

Definition at line 161 of file helmholtz.cpp.

161  {
164 
165  double k = 90;
166  CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-k", &k, PETSC_NULL);
167 
168  auto beta = [](const double, const double, const double) { return -1; };
169  auto k2 = [k](const double, const double, const double) { return pow(k, 2); };
170  auto kp = [k](const double, const double, const double) { return k; };
171  auto km = [k](const double, const double, const double) { return -k; };
172  auto integration_rule = [](int, int, int p_data) { return 2 * p_data; };
173 
174  auto set_domain = [&]() {
176  pipeline_mng->getOpDomainLhsPipeline().push_back(
178  pipeline_mng->getOpDomainLhsPipeline().push_back(
180 
181  pipeline_mng->getOpDomainLhsPipeline().push_back(
182  new OpSetBc("U_REAL", true, boundaryMarker));
183 
184  pipeline_mng->getOpDomainLhsPipeline().push_back(
185  new OpDomainGradGrad("U_REAL", "U_REAL", beta));
186  pipeline_mng->getOpDomainLhsPipeline().push_back(
187  new OpDomainGradGrad("U_IMAG", "U_IMAG", beta));
188 
189  pipeline_mng->getOpDomainLhsPipeline().push_back(
190  new OpDomainMass("U_REAL", "U_REAL", k2));
191  pipeline_mng->getOpDomainLhsPipeline().push_back(
192  new OpDomainMass("U_IMAG", "U_IMAG", k2));
193 
194  pipeline_mng->getOpDomainLhsPipeline().push_back(new OpUnSetBc("U_REAL"));
195 
196  CHKERR pipeline_mng->setDomainRhsIntegrationRule(integration_rule);
197  CHKERR pipeline_mng->setDomainLhsIntegrationRule(integration_rule);
199  };
200 
201  auto set_boundary = [&]() {
203  pipeline_mng->getOpBoundaryLhsPipeline().push_back(
204  new OpSetBc("U_REAL", true, boundaryMarker));
205  pipeline_mng->getOpBoundaryLhsPipeline().push_back(
206  new OpBoundaryMass("U_IMAG", "U_REAL", kp));
207  pipeline_mng->getOpBoundaryLhsPipeline().push_back(
208  new OpBoundaryMass("U_REAL", "U_IMAG", km));
209  pipeline_mng->getOpBoundaryLhsPipeline().push_back(new OpUnSetBc("U_REAL"));
210 
211  pipeline_mng->getOpBoundaryLhsPipeline().push_back(
212  new OpSetBc("U_REAL", false, boundaryMarker));
213  pipeline_mng->getOpBoundaryLhsPipeline().push_back(
214  new OpBoundaryMass("U_REAL", "U_REAL", beta));
215  pipeline_mng->getOpBoundaryLhsPipeline().push_back(new OpUnSetBc("U_REAL"));
216 
217  pipeline_mng->getOpBoundaryRhsPipeline().push_back(
218  new OpSetBc("U_REAL", false, boundaryMarker));
219  pipeline_mng->getOpBoundaryRhsPipeline().push_back(
220  new OpBoundarySource("U_REAL", beta));
221  pipeline_mng->getOpBoundaryRhsPipeline().push_back(new OpUnSetBc("U_REAL"));
222 
223  CHKERR pipeline_mng->setDomainRhsIntegrationRule(integration_rule);
224  CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(integration_rule);
226  };
227 
228  CHKERR set_domain();
229  CHKERR set_boundary();
230 
232 }
FormsIntegrators< EdgeEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, 1 > OpBoundarySource
Definition: helmholtz.cpp:43
MoFEM::Interface & mField
FormsIntegrators< EdgeEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 1 > OpBoundaryMass
Definition: helmholtz.cpp:41
boost::shared_ptr< std::vector< bool > > boundaryMarker
MoFEMErrorCode setBoundaryLhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
Set indices on entities on finite elementIf indices is marked, set its value to -1....
boost::ptr_vector< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 1 > OpDomainMass
Definition: helmholtz.cpp:39
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Calculate inverse of jacobian for face element.
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
Transform local reference derivatives of shape functions to global derivatives.
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
static Index< 'k', 3 > k
boost::ptr_vector< UserDataOperator > & getOpBoundaryLhsPipeline()
Get the Op Boundary Lhs Pipeline object.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
boost::ptr_vector< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
MatrixDouble invJac
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradGrad< 1, 1, 2 > OpDomainGradGrad
Definition: helmholtz.cpp:37

◆ assembleSystem() [2/5]

MoFEMErrorCode Example::assembleSystem ( )
private

◆ assembleSystem() [3/5]

MoFEMErrorCode Example::assembleSystem ( )
private

◆ assembleSystem() [4/5]

MoFEMErrorCode Example::assembleSystem ( )
private

◆ assembleSystem() [5/5]

MoFEMErrorCode Example::assembleSystem ( )
private

◆ bC() [1/5]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [2/5]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [3/5]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [4/5]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [5/5]

MoFEMErrorCode Example::bC ( )
private

[Create common data]

[Boundary condition]

Examples
lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 130 of file lesson3_poisson.cpp.

130  {
132 
134 
135  auto get_ents_on_mesh_skin = [&]() {
136  Range faces;
137  CHKERR mField.get_moab().get_entities_by_type(0, MBTRI, faces);
138  Skinner skin(&mField.get_moab());
139  Range skin_edges;
140  CHKERR skin.find_skin(0, faces, false, skin_edges);
141  Range skin_verts;
142  CHKERR mField.get_moab().get_connectivity(skin_edges, skin_verts, true);
143  skin_edges.merge(skin_verts);
144  return skin_edges;
145  };
146 
147  auto mark_boundary_dofs = [&](Range &&skin_edges) {
148  auto problem_manager = mField.getInterface<ProblemsManager>();
149  auto marker_ptr = boost::make_shared<std::vector<bool>>();
150  problem_manager->markDofs(simple->getProblemName(), ROW, skin_edges,
151  *marker_ptr);
152  return marker_ptr;
153  };
154 
155  // Get global local vector of marked DOFs. Is global, since is set for all
156  // DOFs on processor. Is local since only DOFs on processor are in the
157  // vector. To access DOFs use local indices.
158  boundaryMarker = mark_boundary_dofs(get_ents_on_mesh_skin());
159 
161 }
Problem manager is used to build and partition problems.
virtual moab::Interface & get_moab()=0
MoFEM::Interface & mField
boost::shared_ptr< std::vector< bool > > boundaryMarker
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const Range ents, std::vector< bool > &marker)
Create vector with marked indices.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ boundaryCondition() [1/5]

MoFEMErrorCode Example::boundaryCondition ( )
private

[Set up problem]

[Create common data]

[Applying essential BC]

[Boundary condition]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, and helmholtz.cpp.

Definition at line 113 of file helmholtz.cpp.

113  {
115 
116  auto get_ents_on_mesh_skin = [&]() {
117  Range boundary_entities;
119  std::string entity_name = it->getName();
120  if (entity_name.compare(0, 2, "BC") == 0) {
121  CHKERR it->getMeshsetIdEntitiesByDimension(mField.get_moab(), 1,
122  boundary_entities, true);
123  }
124  }
125  // Add vertices to boundary entities
126  Range boundary_vertices;
127  CHKERR mField.get_moab().get_connectivity(boundary_entities,
128  boundary_vertices, true);
129  boundary_entities.merge(boundary_vertices);
130 
131  return boundary_entities;
132  };
133 
134  auto mark_boundary_dofs = [&](Range &&skin_edges) {
135  auto problem_manager = mField.getInterface<ProblemsManager>();
136  auto marker_ptr = boost::make_shared<std::vector<bool>>();
137  problem_manager->markDofs(simpleInterface->getProblemName(), ROW,
138  skin_edges, *marker_ptr);
139  return marker_ptr;
140  };
141 
142  auto remove_dofs_from_problem = [&](Range &&skin_edges) {
144  auto problem_manager = mField.getInterface<ProblemsManager>();
145  CHKERR problem_manager->removeDofsOnEntities(
146  simpleInterface->getProblemName(), "U_IMAG", skin_edges, 0, 1);
148  };
149 
150  // Get global local vector of marked DOFs. Is global, since is set for all
151  // DOFs on processor. Is local since only DOFs on processor are in the
152  // vector. To access DOFs use local indices.
153  boundaryMarker = mark_boundary_dofs(get_ents_on_mesh_skin());
154  CHKERR remove_dofs_from_problem(get_ents_on_mesh_skin());
155 
157 }
Problem manager is used to build and partition problems.
virtual moab::Interface & get_moab()=0
MoFEM::Interface & mField
boost::shared_ptr< std::vector< bool > > boundaryMarker
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Simple * simpleInterface
Definition: helmholtz.cpp:53
const std::string getProblemName() const
Get the Problem Name.
Definition: Simple.hpp:302
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const Range ents, std::vector< bool > &marker)
Create vector with marked indices.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ boundaryCondition() [2/5]

MoFEMErrorCode Example::boundaryCondition ( )
private

◆ boundaryCondition() [3/5]

MoFEMErrorCode Example::boundaryCondition ( )
private

◆ boundaryCondition() [4/5]

MoFEMErrorCode Example::boundaryCondition ( )
private

◆ boundaryCondition() [5/5]

MoFEMErrorCode Example::boundaryCondition ( )
private

◆ checkResults() [1/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [2/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [3/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [4/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [5/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [6/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [7/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [8/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [9/11]

MoFEMErrorCode Example::checkResults ( )
private

[Postprocess results]

[Print results]

[Solve]

[Check results]

[Check]

[Test example]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, helmholtz.cpp, lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 225 of file lesson3_poisson.cpp.

225  {
228  pipeline_mng->getDomainLhsFE().reset();
229  pipeline_mng->getDomainRhsFE().reset();
230  pipeline_mng->getBoundaryLhsFE().reset();
231  pipeline_mng->getBoundaryRhsFE().reset();
232  pipeline_mng->getOpDomainRhsPipeline().clear();
233  pipeline_mng->getOpDomainRhsPipeline().push_back(
234  new OpCalculateScalarFieldValues("U", commonDataPtr->approxVals));
235  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpError(commonDataPtr));
237  CHKERR pipeline_mng->loopFiniteElements();
238  CHKERR VecAssemblyBegin(commonDataPtr->L2Vec);
239  CHKERR VecAssemblyEnd(commonDataPtr->L2Vec);
240  CHKERR VecAssemblyBegin(commonDataPtr->resVec);
241  CHKERR VecAssemblyEnd(commonDataPtr->resVec);
242  double nrm2;
243  CHKERR VecNorm(commonDataPtr->resVec, NORM_2, &nrm2);
244  const double *array;
245  CHKERR VecGetArrayRead(commonDataPtr->L2Vec, &array);
246  if (mField.get_comm_rank() == 0)
247  PetscPrintf(PETSC_COMM_SELF, "Error %6.4e Vec norm %6.4e\n", sqrt(array[0]),
248  nrm2);
249  CHKERR VecRestoreArrayRead(commonDataPtr->L2Vec, &array);
250  constexpr double eps = 1e-8;
251  if (nrm2 > eps)
252  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
253  "Not converged solution");
255 }
boost::shared_ptr< FEMethod > & getDomainLhsFE()
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
virtual int get_comm_rank() const =0
boost::shared_ptr< FEMethod > & getDomainRhsFE()
boost::shared_ptr< FEMethod > & getBoundaryRhsFE()
static int integrationRule(int, int, int p_data)
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
boost::shared_ptr< FEMethod > & getBoundaryLhsFE()
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
boost::shared_ptr< CommonData > commonDataPtr
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
static const double eps
Get value at integration points for scalar field.

◆ checkResults() [10/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [11/11]

MoFEMErrorCode Example::checkResults ( )
private

◆ createCommonData() [1/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [2/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [3/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [4/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [5/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [6/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [7/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [8/10]

MoFEMErrorCode Example::createCommonData ( )
private

[Set up problem]

[Set integration rule]

[Create common data]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 117 of file lesson3_poisson.cpp.

117  {
120  commonDataPtr = boost::make_shared<CommonData>();
121  commonDataPtr->resVec = smartCreateDMVector(simple->getDM());
123  mField.get_comm(), (!mField.get_comm_rank()) ? 1 : 0, 1);
124  commonDataPtr->approxVals = boost::make_shared<VectorDouble>();
126 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
auto smartCreateDMVector
Get smart vector from DM.
Definition: DMMoFEM.hpp:939
auto createSmartVectorMPI
Create MPI Vector.
Definition: AuxPETSc.hpp:224
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
virtual int get_comm_rank() const =0
boost::shared_ptr< CommonData > commonDataPtr
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
virtual MPI_Comm & get_comm() const =0

◆ createCommonData() [9/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [10/10]

MoFEMErrorCode Example::createCommonData ( )
private

◆ getEntsOnMeshSkin()

Range Example::getEntsOnMeshSkin ( )
private

[Check]

Examples
lesson8_contact.cpp.

Definition at line 406 of file lesson8_contact.cpp.

406  {
407  Range faces;
408  CHKERR mField.get_moab().get_entities_by_type(0, MBTRI, faces);
409  Skinner skin(&mField.get_moab());
410  Range skin_edges;
411  CHKERR skin.find_skin(0, faces, false, skin_edges);
412  return skin_edges;
413 };
virtual moab::Interface & get_moab()=0
MoFEM::Interface & mField
#define CHKERR
Inline error check.
Definition: definitions.h:604

◆ integrateElements()

MoFEMErrorCode Example::integrateElements ( )
private

[Push operators to pipeline]

[Integrate]

Definition at line 232 of file integration.cpp.

232  {
234  // Zero global vector
235  CHKERR VecZeroEntries(commonDataPtr->petscVec);
236 
237  // Integrate elements by executing operators in the pipeline
239  CHKERR pipeline_mng->loopFiniteElements();
240 
241  // Assemble MPI vector
242  CHKERR VecAssemblyBegin(commonDataPtr->petscVec);
243  CHKERR VecAssemblyEnd(commonDataPtr->petscVec);
245 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
boost::shared_ptr< CommonData > commonDataPtr
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ integrationRule() [1/2]

static int Example::integrationRule ( int  ,
int  ,
int  p_data 
)
staticprivate

Definition at line 60 of file lesson6_radiation.cpp.

60 { return 2 * p_data; };

◆ integrationRule() [2/2]

static int Example::integrationRule ( int  ,
int  ,
int  p_data 
)
staticprivate

Definition at line 63 of file lesson3_poisson.cpp.

63 { return 2 * p_data; };

◆ kspSolve() [1/3]

MoFEMErrorCode Example::kspSolve ( )
private

◆ kspSolve() [2/3]

MoFEMErrorCode Example::kspSolve ( )
private

◆ kspSolve() [3/3]

MoFEMErrorCode Example::kspSolve ( )
private

[Push operators to pipeline]

[Solve]

Examples
lesson3_poisson.cpp, and lesson6_radiation.cpp.

Definition at line 188 of file lesson3_poisson.cpp.

188  {
192  auto solver = pipeline_mng->createKSP();
193  CHKERR KSPSetFromOptions(solver);
194  CHKERR KSPSetUp(solver);
195 
196  auto dm = simple->getDM();
197  auto D = smartCreateDMVector(dm);
198  auto F = smartVectorDuplicate(D);
199 
200  CHKERR KSPSolve(solver, F, D);
201  CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
202  CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
203  CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
205 }
MoFEM::Interface & mField
const double D
diffusivity
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMMoFEM.cpp:445
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
SmartPetscObj< Vec > smartVectorDuplicate(SmartPetscObj< Vec > &vec)
Create duplicate vector of smart vector.
Definition: AuxPETSc.hpp:238
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
auto smartCreateDMVector
Get smart vector from DM.
Definition: DMMoFEM.hpp:939
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ nablaFunction()

static double Example::nablaFunction ( const double  x,
const double  y,
const double  z 
)
staticprivate
Examples
lesson3_poisson.cpp.

Definition at line 59 of file lesson3_poisson.cpp.

59  {
60  return 200 * sin(x * 10.) * cos(y * 10.);
61  }

◆ OPs() [1/5]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [2/5]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [3/5]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [4/5]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [5/5]

MoFEMErrorCode Example::OPs ( )
private

[Boundary condition]

[Push operators to pipeline]

Examples
lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 165 of file lesson3_poisson.cpp.

165  {
168  pipeline_mng->getOpDomainLhsPipeline().push_back(
170  pipeline_mng->getOpDomainLhsPipeline().push_back(new OpSetInvJacH1ForFace(invJac));
171  auto beta = [](const double, const double, const double) { return 1; };
172  pipeline_mng->getOpDomainLhsPipeline().push_back(
173  new OpDomainGradGrad("U", "U", beta, boundaryMarker));
174  pipeline_mng->getOpDomainRhsPipeline().push_back(
178  pipeline_mng->getOpBoundaryLhsPipeline().push_back(new OpBoundaryMass("U", "U", beta));
179  pipeline_mng->getOpBoundaryRhsPipeline().push_back(
180  new OpBoundarySource("U", approxFunction));
184 }
OpTools< DomainEleOp >::OpSource< 2 > OpDomainSource
OpTools< BoundaryEleOp >::OpSource< 2 > OpBoundarySource
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
static double approxFunction(const double x, const double y, const double z)
MoFEM::Interface & mField
boost::shared_ptr< std::vector< bool > > boundaryMarker
MoFEMErrorCode setBoundaryLhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
OpTools< BoundaryEleOp >::OpMass OpBoundaryMass
boost::ptr_vector< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Calculate inverse of jacobian for face element.
static int integrationRule(int, int, int p_data)
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
static double nablaFunction(const double x, const double y, const double z)
Transform local reference derivatives of shape functions to global derivatives.
OpTools< DomainEleOp >::OpGradGrad< 2 > OpDomainGradGrad
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
boost::ptr_vector< UserDataOperator > & getOpBoundaryLhsPipeline()
Get the Op Boundary Lhs Pipeline object.
MoFEMErrorCode setBoundaryRhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
boost::ptr_vector< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
MatrixDouble invJac

◆ outputResults() [1/5]

MoFEMErrorCode Example::outputResults ( )
private

[Solve]

[Postprocess results]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, and helmholtz.cpp.

Definition at line 256 of file helmholtz.cpp.

256  {
259  pipeline_mng->getDomainLhsFE().reset();
260  pipeline_mng->getDomainRhsFE().reset();
261  pipeline_mng->getBoundaryLhsFE().reset();
262  pipeline_mng->getBoundaryRhsFE().reset();
263  auto post_proc_fe = boost::make_shared<PostProcFaceOnRefinedMesh>(mField);
264  post_proc_fe->generateReferenceElementMesh();
265  post_proc_fe->addFieldValuesPostProc("U_REAL");
266  post_proc_fe->addFieldValuesPostProc("U_IMAG");
267  pipeline_mng->getDomainRhsFE() = post_proc_fe;
268  CHKERR pipeline_mng->loopFiniteElements();
269  CHKERR post_proc_fe->writeFile("out_helmholtz.h5m");
271 }
boost::shared_ptr< FEMethod > & getDomainLhsFE()
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
boost::shared_ptr< FEMethod > & getDomainRhsFE()
boost::shared_ptr< FEMethod > & getBoundaryRhsFE()
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
boost::shared_ptr< FEMethod > & getBoundaryLhsFE()
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ outputResults() [2/5]

MoFEMErrorCode Example::outputResults ( )
private

◆ outputResults() [3/5]

MoFEMErrorCode Example::outputResults ( )
private

◆ outputResults() [4/5]

MoFEMErrorCode Example::outputResults ( )
private

◆ outputResults() [5/5]

MoFEMErrorCode Example::outputResults ( )
private

◆ postProcess() [1/6]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [2/6]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [3/6]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [4/6]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [5/6]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [6/6]

MoFEMErrorCode Example::postProcess ( )
private

[Solve]

[Integrate]

[Postprocess results]

[Print results]

Examples
lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 208 of file lesson3_poisson.cpp.

208  {
211  pipeline_mng->getDomainLhsFE().reset();
212  pipeline_mng->getBoundaryLhsFE().reset();
213  pipeline_mng->getBoundaryRhsFE().reset();
214  auto post_proc_fe = boost::make_shared<PostProcFaceOnRefinedMesh>(mField);
215  post_proc_fe->generateReferenceElementMesh();
216  post_proc_fe->addFieldValuesPostProc("U");
217  pipeline_mng->getDomainRhsFE() = post_proc_fe;
218  CHKERR pipeline_mng->loopFiniteElements();
219  CHKERR post_proc_fe->writeFile("out_poisson.h5m");
221 }
boost::shared_ptr< FEMethod > & getDomainLhsFE()
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
boost::shared_ptr< FEMethod > & getDomainRhsFE()
boost::shared_ptr< FEMethod > & getBoundaryRhsFE()
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
boost::shared_ptr< FEMethod > & getBoundaryLhsFE()
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ pushOperators()

MoFEMErrorCode Example::pushOperators ( )
private

[Set density distribution]

[Push operators to pipeline]

Definition at line 202 of file integration.cpp.

202  {
205 
206  // Push an operator which calculates values of density at integration points
207  pipeline_mng->getOpDomainRhsPipeline().push_back(
209  "rho", commonDataPtr->getRhoAtIntegrationPtsPtr()));
210 
211  // Push an operator to pipeline to calculate zero moment of inertia (mass)
212  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpZero(commonDataPtr));
213 
214  // Push an operator to the pipeline to calculate first moment of inertaia
215  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpFirst(commonDataPtr));
216 
217  // Push an operator to the pipeline to calculate second moment of inertaia
218  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpSecond(commonDataPtr));
219 
220  // Set integration rule. Integration rule is equal to the polynomial order of
221  // the density field plus 2, since under the integral of the second moment of
222  // inertia term x*x is present
223  auto integration_rule = [](int, int, int p_data) { return p_data + 2; };
224 
225  // Add integration rule to the element
226  CHKERR pipeline_mng->setDomainRhsIntegrationRule(integration_rule);
228 }
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
boost::shared_ptr< CommonData > commonDataPtr
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
Get value at integration points for scalar field.

◆ readMesh() [1/5]

MoFEMErrorCode Example::readMesh ( )
private

[Approximated function]

◆ readMesh() [2/5]

MoFEMErrorCode Example::readMesh ( )
private

[Read mesh]

[Run problem]

[Run programme]

[Read mesh]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, and helmholtz.cpp.

Definition at line 80 of file helmholtz.cpp.

80  {
82 
86 
88 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Simple * simpleInterface
Definition: helmholtz.cpp:53
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name)
Load mesh file.
Definition: Simple.cpp:212
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:198
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ readMesh() [3/5]

MoFEMErrorCode Example::readMesh ( )
private

◆ readMesh() [4/5]

MoFEMErrorCode Example::readMesh ( )
private

◆ readMesh() [5/5]

MoFEMErrorCode Example::readMesh ( )
private

◆ runProblem() [1/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [2/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [3/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [4/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [5/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [6/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [7/11]

MoFEMErrorCode Example::runProblem ( )

[Run problem]

[Create common data]

[Run programme]

[Operator]

[Run all]

[Run problem]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, helmholtz.cpp, lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 90 of file lesson3_poisson.cpp.

90  {
94  CHKERR bC();
95  CHKERR OPs();
96  CHKERR kspSolve();
100 }
MoFEMErrorCode createCommonData()
[Set up problem]
MoFEMErrorCode setupProblem()
[Set up problem]
MoFEMErrorCode kspSolve()
[Push operators to pipeline]
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode OPs()
[Boundary condition]
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode bC()
[Create common data]
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEMErrorCode postProcess()
[Solve]
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ runProblem() [8/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [9/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [10/11]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [11/11]

MoFEMErrorCode Example::runProblem ( )

◆ setFieldValues()

MoFEMErrorCode Example::setFieldValues ( )
private

[Create common data]

[Set density distribution]

Definition at line 186 of file integration.cpp.

186  {
188  auto set_density = [&](VectorAdaptor &&field_data, double *xcoord,
189  double *ycoord, double *zcoord) {
191  field_data[0] = 1;
193  };
194  FieldBlas *field_blas;
195  CHKERR mField.getInterface(field_blas);
196  CHKERR field_blas->setVertexDofs(set_density, "rho");
198 }
MoFEM::Interface & mField
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Basic algebra on fields.
Definition: FieldBlas.hpp:34
VectorShallowArrayAdaptor< double > VectorAdaptor
Definition: Types.hpp:109
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode setVertexDofs(VertexCoordsFunction lambda, const std::string field_name, Range *verts=nullptr)
Set DOFs on vertices using user functionExample:
Definition: FieldBlas.cpp:175

◆ setIntegrationRules()

MoFEMErrorCode Example::setIntegrationRules ( )
private

[Set up problem]

[Set integration rule]

Definition at line 123 of file approximaton.cpp.

123  {
125 
126  auto rule = [](int, int, int p) -> int { return 2 * p; };
127 
129  CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule);
130  CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
131 
133 }
MoFEM::Interface & mField
static Index< 'p', 3 > p
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)

◆ setUp()

MoFEMErrorCode Example::setUp ( )
private

[Run all]

[Set up problem]

Definition at line 151 of file integration.cpp.

151  {
154  CHKERR simple->getOptions();
155  CHKERR simple->loadFile();
156  // Add field
157  CHKERR simple->addDomainField("rho", H1, AINSWORTH_LEGENDRE_BASE, 1);
158  constexpr int order = 1;
159  CHKERR simple->setFieldOrder("rho", order);
160  CHKERR simple->setUp();
162 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
constexpr int order
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:152
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
continuous field
Definition: definitions.h:177

◆ setupProblem() [1/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [2/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [3/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [4/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [5/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [6/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [7/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [8/10]

MoFEMErrorCode Example::setupProblem ( )
private

[Set up problem]

[Read mesh]

[Run problem]

[Set up problem]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, helmholtz.cpp, lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 103 of file lesson3_poisson.cpp.

103  {
106  // Add field
107  CHKERR simple->addDomainField("U", H1, AINSWORTH_LEGENDRE_BASE, 1);
108  CHKERR simple->addBoundaryField("U", H1, AINSWORTH_LEGENDRE_BASE, 1);
109  constexpr int order = 5;
110  CHKERR simple->setFieldOrder("U", order);
111  CHKERR simple->setUp();
113 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
constexpr int order
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:152
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
continuous field
Definition: definitions.h:177

◆ setupProblem() [9/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ setupProblem() [10/10]

MoFEMErrorCode Example::setupProblem ( )
private

◆ solveSystem() [1/5]

MoFEMErrorCode Example::solveSystem ( )
private

[Push operators to pipeline]

[Solve]

Examples
dynamic_elastic.cpp, eigen_elastic.cpp, and helmholtz.cpp.

Definition at line 236 of file helmholtz.cpp.

236  {
239  auto solver = pipeline_mng->createKSP();
240  CHKERR KSPSetFromOptions(solver);
241  CHKERR KSPSetUp(solver);
242 
243  auto dm = simpleInterface->getDM();
244  auto D = smartCreateDMVector(dm);
245  auto F = smartVectorDuplicate(D);
246 
247  CHKERR KSPSolve(solver, F, D);
248  CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
249  CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
250  CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
252 }
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition: Simple.cpp:706
MoFEM::Interface & mField
const double D
diffusivity
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMMoFEM.cpp:445
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
SmartPetscObj< Vec > smartVectorDuplicate(SmartPetscObj< Vec > &vec)
Create duplicate vector of smart vector.
Definition: AuxPETSc.hpp:238
auto smartCreateDMVector
Get smart vector from DM.
Definition: DMMoFEM.hpp:939
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
Simple * simpleInterface
Definition: helmholtz.cpp:53
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ solveSystem() [2/5]

MoFEMErrorCode Example::solveSystem ( )
private

◆ solveSystem() [3/5]

MoFEMErrorCode Example::solveSystem ( )
private

◆ solveSystem() [4/5]

MoFEMErrorCode Example::solveSystem ( )
private

◆ solveSystem() [5/5]

MoFEMErrorCode Example::solveSystem ( )
private

◆ tsSolve() [1/2]

MoFEMErrorCode Example::tsSolve ( )
private

◆ tsSolve() [2/2]

MoFEMErrorCode Example::tsSolve ( )
private

[Push operators to pipeline]

[Solve]

Examples
lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 274 of file lesson7_plastic.cpp.

274  {
276 
279  ISManager *is_manager = mField.getInterface<ISManager>();
280 
281  auto solver = pipeline_mng->createTS();
282 
283  auto dm = simple->getDM();
284  auto D = smartCreateDMVector(dm);
285 
286  CHKERR TSSetSolution(solver, D);
287  CHKERR TSSetFromOptions(solver);
288  CHKERR TSSetUp(solver);
289 
290  auto set_section_monitor = [&]() {
292  SNES snes;
293  CHKERR TSGetSNES(solver, &snes);
294  PetscViewerAndFormat *vf;
295  CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
296  PETSC_VIEWER_DEFAULT, &vf);
297  CHKERR SNESMonitorSet(
298  snes,
299  (MoFEMErrorCode(*)(SNES, PetscInt, PetscReal, void *))SNESMonitorFields,
300  vf, (MoFEMErrorCode(*)(void **))PetscViewerAndFormatDestroy);
302  };
303 
304  auto create_post_process_element = [&]() {
306  postProcFe = boost::make_shared<PostProcFaceOnRefinedMesh>(mField);
307  postProcFe->generateReferenceElementMesh();
308 
309  postProcFe->getOpPtrVector().push_back(
311  postProcFe->getOpPtrVector().push_back(new OpSetInvJacH1ForFace(invJac));
312  postProcFe->getOpPtrVector().push_back(
314  postProcFe->getOpPtrVector().push_back(new OpStrain("U", commonDataPtr));
315 
316  postProcFe->getOpPtrVector().push_back(
318  postProcFe->getOpPtrVector().push_back(new OpStrain("U", commonDataPtr));
319  postProcFe->getOpPtrVector().push_back(new OpCalculateScalarFieldValues(
320  "TAU", commonDataPtr->plasticTauPtr, MBTRI));
321  postProcFe->getOpPtrVector().push_back(
323  "EP", commonDataPtr->plasticStrainPtr, MBTRI));
324  postProcFe->getOpPtrVector().push_back(
325  new OpPlasticStress("U", commonDataPtr));
326  postProcFe->getOpPtrVector().push_back(
328 
329  postProcFe->getOpPtrVector().push_back(new OpPostProcElastic(
330  "U", postProcFe->postProcMesh, postProcFe->mapGaussPts, commonDataPtr));
331  postProcFe->getOpPtrVector().push_back(new OpPostProcPlastic(
332  "U", postProcFe->postProcMesh, postProcFe->mapGaussPts, commonDataPtr));
333  postProcFe->addFieldValuesPostProc("U");
335  };
336 
337  auto scatter_create = [&](auto coeff) {
339  CHKERR is_manager->isCreateProblemFieldAndRank(simple->getProblemName(),
340  ROW, "U", coeff, coeff, is);
341  int loc_size;
342  CHKERR ISGetLocalSize(is, &loc_size);
343  Vec v;
344  CHKERR VecCreateMPI(mField.get_comm(), loc_size, PETSC_DETERMINE, &v);
345  VecScatter scatter;
346  CHKERR VecScatterCreate(D, is, v, PETSC_NULL, &scatter);
347  return std::make_tuple(SmartPetscObj<Vec>(v),
348  SmartPetscObj<VecScatter>(scatter));
349  };
350 
351  auto set_time_monitor = [&]() {
353  boost::shared_ptr<Monitor> monitor_ptr(
355  boost::shared_ptr<ForcesAndSourcesCore> null;
356  CHKERR DMMoFEMTSSetMonitor(dm, solver, simple->getDomainFEName(),
357  monitor_ptr, null, null);
359  };
360 
361  CHKERR set_section_monitor();
362  CHKERR create_post_process_element();
363  uXScatter = scatter_create(0);
364  uYScatter = scatter_create(1);
365  CHKERR set_time_monitor();
366 
367  CHKERR TSSolve(solver, D);
368 
369  CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
370  CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
371  CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
372 
374 }
MoFEM::Interface & mField
const double D
diffusivity
Section manager is used to create indexes and sectionsFIXME: ISManager is not properly testsed by ato...
Definition: ISManager.hpp:36
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMMoFEM.cpp:445
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
boost::shared_ptr< PostProcFaceOnRefinedMesh > postProcFe
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
auto smartCreateDMVector
Get smart vector from DM.
Definition: DMMoFEM.hpp:939
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
Calculate inverse of jacobian for face element.
Definition: PlasticOps.hpp:203
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:604
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
Definition: DMMMoFEM.cpp:915
Transform local reference derivatives of shape functions to global derivatives.
boost::shared_ptr< CommonData > commonDataPtr
Definition: ElasticOps.hpp:86
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
virtual MPI_Comm & get_comm() const =0
intrusive_ptr for managing petsc objects
Definition: AuxPETSc.hpp:128
Calculate symmetric tensor field values at integration pts.
Get value at integration points for scalar field.
MatrixDouble invJac

Member Data Documentation

◆ approxGradVals

boost::shared_ptr<MatrixDouble> Example::approxGradVals
private

Definition at line 72 of file lesson6_radiation.cpp.

◆ approxVals

boost::shared_ptr<VectorDouble> Example::approxVals
private

Definition at line 71 of file lesson6_radiation.cpp.

◆ bodyForceMatPtr

boost::shared_ptr<MatrixDouble> Example::bodyForceMatPtr
private

Definition at line 72 of file elastic.cpp.

◆ boundaryMarker

boost::shared_ptr< std::vector< bool > > Example::boundaryMarker
private

Definition at line 80 of file lesson3_poisson.cpp.

◆ commonDataPtr [1/3]

boost::shared_ptr<OpContactTools::CommonData> Example::commonDataPtr
private

Definition at line 62 of file lesson8_contact.cpp.

◆ commonDataPtr [2/3]

boost::shared_ptr<OpPlasticTools::CommonData> Example::commonDataPtr
private

Definition at line 63 of file lesson7_plastic.cpp.

◆ commonDataPtr [3/3]

boost::shared_ptr< CommonData > Example::commonDataPtr
private

Definition at line 79 of file lesson3_poisson.cpp.

◆ ePS

SmartPetscObj<EPS> Example::ePS
private

Definition at line 90 of file eigen_elastic.cpp.

◆ invJac

MatrixDouble Example::invJac
private

Definition at line 73 of file lesson3_poisson.cpp.

◆ jAc

MatrixDouble Example::jAc
private

Definition at line 61 of file lesson8_contact.cpp.

◆ K

SmartPetscObj<Mat> Example::K
private

Definition at line 89 of file eigen_elastic.cpp.

◆ M

SmartPetscObj<Mat> Example::M
private

Definition at line 88 of file eigen_elastic.cpp.

◆ matAccelerationPtr

boost::shared_ptr<MatrixDouble> Example::matAccelerationPtr
private

Definition at line 94 of file dynamic_elastic.cpp.

◆ matDPtr

boost::shared_ptr< MatrixDouble > Example::matDPtr
private

Definition at line 71 of file elastic.cpp.

◆ matGradPtr

boost::shared_ptr< MatrixDouble > Example::matGradPtr
private

Definition at line 68 of file elastic.cpp.

◆ matInertiaPtr

boost::shared_ptr<MatrixDouble> Example::matInertiaPtr
private

Definition at line 95 of file dynamic_elastic.cpp.

◆ matStrainPtr

boost::shared_ptr< MatrixDouble > Example::matStrainPtr
private

Definition at line 69 of file elastic.cpp.

◆ matStressPtr

boost::shared_ptr< MatrixDouble > Example::matStressPtr
private

Definition at line 70 of file elastic.cpp.

◆ mField

MoFEM::Interface & Example::mField
private

Definition at line 54 of file lesson3_poisson.cpp.

◆ postProcFe [1/2]

boost::shared_ptr<PostProcFaceOnRefinedMeshFor2D> Example::postProcFe
private

Definition at line 63 of file lesson8_contact.cpp.

◆ postProcFe [2/2]

boost::shared_ptr<PostProcFaceOnRefinedMesh> Example::postProcFe
private

Definition at line 64 of file lesson7_plastic.cpp.

◆ simpleInterface

Simple * Example::simpleInterface
private

Definition at line 53 of file helmholtz.cpp.

◆ uXScatter

std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > Example::uXScatter
private

Definition at line 65 of file lesson7_plastic.cpp.

◆ uYScatter

std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > Example::uYScatter
private

Definition at line 66 of file lesson7_plastic.cpp.


The documentation for this struct was generated from the following files: