v0.9.1
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 ()
 [Operator] 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 ()
 

Private Member Functions

MoFEMErrorCode setUp ()
 [Run all] More...
 
MoFEMErrorCode createCommonData ()
 [Set up problem] More...
 
MoFEMErrorCode setFieldValues ()
 [Create common data] More...
 
MoFEMErrorCode pushOperators ()
 [Set density distribution] More...
 
MoFEMErrorCode integrateElements ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 [Integrate] More...
 
MoFEMErrorCode checkResults ()
 [Print results] More...
 
MoFEMErrorCode setUP ()
 [Set up problem] More...
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 [Create common data] More...
 
MoFEMErrorCode OPs ()
 [Boundary condition] More...
 
MoFEMErrorCode kspSolve ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode tsSolve ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode tsSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
Range getEntsOnMeshSkin ()
 [Check] More...
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode kspSolve ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 

Static Private Member Functions

static double approxFunction (const double x, const double y, const double z)
 
static int integrationRule (int, int, int p_data)
 
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)
 

Private Attributes

MoFEM::InterfacemField
 
boost::shared_ptr< CommonDatacommonDataPtr
 
MatrixDouble invJac
 
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
 

Detailed Description

[Example]

Examples
lesson1_moment_of_inertia.cpp, lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 37 of file lesson1_moment_of_inertia.cpp.

Constructor & Destructor Documentation

◆ Example() [1/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 39 of file lesson1_moment_of_inertia.cpp.

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

◆ Example() [2/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 43 of file lesson2_approximaton.cpp.

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

◆ Example() [3/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 47 of file lesson3_poisson.cpp.

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

◆ Example() [4/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 42 of file lesson4_elastic.cpp.

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

◆ Example() [5/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 48 of file lesson5_helmholtz.cpp.

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

◆ Example() [6/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 53 of file lesson6_radiation.cpp.

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

◆ Example() [7/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 47 of file lesson7_plastic.cpp.

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

◆ Example() [8/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 46 of file lesson8_contact.cpp.

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

◆ Example() [9/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 30 of file mian_snippet.cpp.

30 : 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
Examples
lesson2_approximaton.cpp, and lesson3_poisson.cpp.

Definition at line 50 of file lesson2_approximaton.cpp.

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

◆ approxFunction() [2/2]

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

Definition at line 54 of file lesson3_poisson.cpp.

54  {
55  return sin(x * 10.) * cos(y * 10.);
56  }

◆ bC() [1/8]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [2/8]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [3/8]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [4/8]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [5/8]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [6/8]

MoFEMErrorCode Example::bC ( )
private

[Create common data]

[Set up problem]

[Boundary condition]

[Applying essential BC]

Examples
lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 117 of file lesson2_approximaton.cpp.

117 { return 0; }

◆ bC() [7/8]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [8/8]

MoFEMErrorCode Example::bC ( )
private

◆ checkResults() [1/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [2/8]

MoFEMErrorCode Example::checkResults ( )
private

[Print results]

[Postprocess results]

[Test example]

[Solve]

[Check]

[Check results]

Examples
lesson1_moment_of_inertia.cpp, lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 271 of file lesson1_moment_of_inertia.cpp.

271  {
273  const double *array;
274  CHKERR VecGetArrayRead(commonDataPtr->petscVec, &array);
275 
276  PetscBool test = PETSC_FALSE;
277  CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-test", &test, PETSC_NULL);
278  if (mField.get_comm_rank() == 0 && test) {
279  constexpr double eps = 1e-8;
280  constexpr double expected_volume = 1.;
281  constexpr double expected_first_moment = 0.;
282  constexpr double expected_second_moment = 1. / 12.;
283  if (std::abs(array[CommonData::ZERO] - expected_volume) > eps)
284  SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
285  "Wrong area %6.4e != %6.4e", expected_volume,
286  array[CommonData::ZERO]);
287  for (auto i :
289  if (std::abs(array[i] - expected_first_moment) > eps)
290  SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
291  "Wrong first moment %6.4e != %6.4e", expected_first_moment,
292  array[i]);
293  }
296  if (std::abs(array[i] - expected_second_moment) > eps)
297  SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
298  "Wrong second moment %6.4e != %6.4e", expected_second_moment,
299  array[i]);
300  }
301  }
302  CHKERR VecRestoreArrayRead(commonDataPtr->petscVec, &array);
303 
305 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
virtual int get_comm_rank() const =0
#define CHKERR
Inline error check.
Definition: definitions.h:602
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:413
static const double eps
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
FTensor::Index< 'i', 2 > i
[Common data]
Definition: ContactOps.hpp:26

◆ checkResults() [3/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [4/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [5/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [6/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [7/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [8/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ createCommonData() [1/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [2/8]

MoFEMErrorCode Example::createCommonData ( )
private

[Set up problem]

[Create common data]

Examples
lesson1_moment_of_inertia.cpp, lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 166 of file lesson1_moment_of_inertia.cpp.

166  {
168  commonDataPtr = boost::make_shared<CommonData>();
169 
170  int local_size;
171  if (mField.get_comm_rank() == 0) // get_comm_rank() gets processor number
172  // processor 0
173  local_size = CommonData::LAST_ELEMENT; // last element gives size of vector
174  else
175  // other processors (e.g. 1, 2, 3, etc.)
176  local_size = 0; // local size of vector is zero on other processors
177 
178  commonDataPtr->petscVec = createSmartVectorMPI(mField.get_comm(), local_size,
180 
182 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
auto createSmartVectorMPI
Create MPI Vector.
Definition: AuxPETSc.hpp:224
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:413
virtual MPI_Comm & get_comm() const =0

◆ createCommonData() [3/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [4/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [5/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [6/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [7/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [8/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ getEntsOnMeshSkin()

Range Example::getEntsOnMeshSkin ( )
private

[Check]

Examples
lesson8_contact.cpp.

Definition at line 393 of file lesson8_contact.cpp.

393  {
394  Range faces;
395  CHKERR mField.get_moab().get_entities_by_type(0, MBTRI, faces);
396  Skinner skin(&mField.get_moab());
397  Range skin_edges;
398  CHKERR skin.find_skin(0, faces, false, skin_edges);
399  return skin_edges;
400 };
virtual moab::Interface & get_moab()=0
MoFEM::Interface & mField
#define CHKERR
Inline error check.
Definition: definitions.h:602

◆ integrateElements()

MoFEMErrorCode Example::integrateElements ( )
private

[Push operators to pipeline]

[Integrate]

Examples
lesson1_moment_of_inertia.cpp.

Definition at line 231 of file lesson1_moment_of_inertia.cpp.

231  {
233  // Zero global vector
234  CHKERR VecZeroEntries(commonDataPtr->petscVec);
235 
236  // Integrate elements by executing operators in the pipeline
238  CHKERR pipeline_mng->loopFiniteElements();
239 
240  // Assemble MPI vector
241  CHKERR VecAssemblyBegin(commonDataPtr->petscVec);
242  CHKERR VecAssemblyEnd(commonDataPtr->petscVec);
244 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
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:602
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:413

◆ integrationRule() [1/3]

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

Definition at line 53 of file lesson2_approximaton.cpp.

53 { return 2 * p_data; };

◆ integrationRule() [2/3]

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() [3/3]

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

Definition at line 61 of file lesson3_poisson.cpp.

61 { return 2 * p_data; };

◆ kspSolve() [1/6]

MoFEMErrorCode Example::kspSolve ( )
private

◆ kspSolve() [2/6]

MoFEMErrorCode Example::kspSolve ( )
private

◆ kspSolve() [3/6]

MoFEMErrorCode Example::kspSolve ( )
private

◆ kspSolve() [4/6]

MoFEMErrorCode Example::kspSolve ( )
private

[Push operators to pipeline]

[Solve]

Examples
lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, and lesson6_radiation.cpp.

Definition at line 135 of file lesson2_approximaton.cpp.

135  {
139  auto solver = pipeline_mng->createKSP();
140  CHKERR KSPSetFromOptions(solver);
141  CHKERR KSPSetUp(solver);
142 
143  auto dm = simple->getDM();
144  auto D = smartCreateDMVector(dm);
145  auto F = smartVectorDuplicate(D);
146 
147  CHKERR KSPSolve(solver, F, D);
148  CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
149  CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
150  CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
152 }
MoFEM::Interface & mField
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:483
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:602
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413

◆ kspSolve() [5/6]

MoFEMErrorCode Example::kspSolve ( )
private

◆ kspSolve() [6/6]

MoFEMErrorCode Example::kspSolve ( )
private

◆ nablaFunction()

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

Definition at line 57 of file lesson3_poisson.cpp.

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

◆ OPs() [1/8]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [2/8]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [3/8]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [4/8]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [5/8]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [6/8]

MoFEMErrorCode Example::OPs ( )
private

[Boundary condition]

[Applying essential BC]

[Push operators to pipeline]

Examples
lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 121 of file lesson2_approximaton.cpp.

121  {
124  auto beta = [](const double, const double, const double) { return 1; };
125  pipeline_mng->getOpDomainLhsPipeline().push_back(new OpDomainMass("U", "U", beta));
126  pipeline_mng->getOpDomainRhsPipeline().push_back(
131 }
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
OpTools< DomainEleOp >::OpMass OpDomainMass
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
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.
static int integrationRule(int, int, int p_data)
PipelineManager interface.
#define CHKERR
Inline error check.
Definition: definitions.h:602
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:413
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
OpTools< DomainEleOp >::OpSource< 2 > OpDomainSource

◆ OPs() [7/8]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [8/8]

MoFEMErrorCode Example::OPs ( )
private

◆ postProcess() [1/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [2/9]

MoFEMErrorCode Example::postProcess ( )
private

[Integrate]

[Solve]

[Print results]

[Postprocess results]

Examples
lesson1_moment_of_inertia.cpp, lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 248 of file lesson1_moment_of_inertia.cpp.

248  {
250  const double *array;
251  CHKERR VecGetArrayRead(commonDataPtr->petscVec, &array);
252  if (mField.get_comm_rank() == 0) {
253  PetscPrintf(PETSC_COMM_SELF, "Mass %6.4e\n", array[CommonData::ZERO]);
254  PetscPrintf(PETSC_COMM_SELF,
255  "First moment of inertia [ %6.4e, %6.4e, %6.4e ] \n",
257  array[CommonData::FIRST_Z]);
258  PetscPrintf(PETSC_COMM_SELF,
259  "Second moment of inertia [ %6.4e, %6.4e, %6.4e; %6.4e %6.4e; "
260  "%6.4e ]\n",
264  }
265  CHKERR VecRestoreArrayRead(commonDataPtr->petscVec, &array);
267 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
virtual int get_comm_rank() const =0
#define CHKERR
Inline error check.
Definition: definitions.h:602
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:413

◆ postProcess() [3/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [4/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [5/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [6/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [7/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [8/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [9/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ pushOperators()

MoFEMErrorCode Example::pushOperators ( )
private

[Set density distribution]

[Push operators to pipeline]

Examples
lesson1_moment_of_inertia.cpp.

Definition at line 202 of file lesson1_moment_of_inertia.cpp.

202  {
205 
206  // Push an operator which calculates values of density at integration points
207  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpCalculateScalarFieldValues(
208  "rho", commonDataPtr->getRhoAtIntegrationPtsPtr()));
209 
210  // Push an operator to pipeline to calculate zero moment of inertia (mass)
211  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpZero(commonDataPtr));
212 
213  // Push an operator to the pipeline to calculate first moment of inertaia
214  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpFirst(commonDataPtr));
215 
216  // Push an operator to the pipeline to calculate second moment of inertaia
217  pipeline_mng->getOpDomainRhsPipeline().push_back(new OpSecond(commonDataPtr));
218 
219  // Set integration rule. Integration rule is equal to the polynomial order of
220  // the density field plus 2, since under the integral of the second moment of
221  // inertia term x*x is present
222  auto integration_rule = [](int, int, int p_data) { return p_data + 2; };
223 
224  // Add integration rule to the element
225  CHKERR pipeline_mng->setDomainRhsIntegrationRule(integration_rule);
227 }
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:483
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:602
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:413
Get value at integration points for scalar field.

◆ runProblem() [1/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [2/9]

MoFEMErrorCode Example::runProblem ( )

[Operator]

[Run problem]

[Run all]

Examples
lesson1_moment_of_inertia.cpp, lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 137 of file lesson1_moment_of_inertia.cpp.

137  {
139  CHKERR setUp();
147 }
MoFEMErrorCode createCommonData()
[Set up problem]
MoFEMErrorCode integrateElements()
[Push operators to pipeline]
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
MoFEMErrorCode checkResults()
[Print results]
MoFEMErrorCode pushOperators()
[Set density distribution]
MoFEMErrorCode setFieldValues()
[Create common data]
#define CHKERR
Inline error check.
Definition: definitions.h:602
MoFEMErrorCode postProcess()
[Integrate]
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413
MoFEMErrorCode setUp()
[Run all]

◆ runProblem() [3/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [4/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [5/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [6/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [7/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [8/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [9/9]

MoFEMErrorCode Example::runProblem ( )

◆ setFieldValues()

MoFEMErrorCode Example::setFieldValues ( )
private

[Create common data]

[Set density distribution]

Examples
lesson1_moment_of_inertia.cpp.

Definition at line 186 of file lesson1_moment_of_inertia.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:507
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
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:108
#define CHKERR
Inline error check.
Definition: definitions.h:602
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413
MoFEMErrorCode setVertexDofs(VertexCoordsFunction lambda, const std::string field_name, Range *verts=nullptr)
Set DOFs on vertices using user functionExample:
Definition: FieldBlas.cpp:172

◆ setUP() [1/8]

MoFEMErrorCode Example::setUP ( )
private

◆ setUp()

MoFEMErrorCode Example::setUp ( )
private

[Run all]

[Set up problem]

Examples
lesson1_moment_of_inertia.cpp.

Definition at line 151 of file lesson1_moment_of_inertia.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:483
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
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:152
#define CHKERR
Inline error check.
Definition: definitions.h:602
constexpr int order
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413
continuous field
Definition: definitions.h:177

◆ setUP() [2/8]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [3/8]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [4/8]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [5/8]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [6/8]

MoFEMErrorCode Example::setUP ( )
private

[Set up problem]

[Run problem]

[Set up problem]

Examples
lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, and lesson8_contact.cpp.

Definition at line 91 of file lesson2_approximaton.cpp.

91  {
94  // Add field
95  CHKERR simple->addDomainField("U", H1, AINSWORTH_BERNSTEIN_BEZIER_BASE, 1);
96  constexpr int order = 4;
97  CHKERR simple->setFieldOrder("U", order);
98  CHKERR simple->setUp();
100 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
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:602
constexpr int order
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413
continuous field
Definition: definitions.h:177

◆ setUP() [7/8]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [8/8]

MoFEMErrorCode Example::setUP ( )
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
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:483
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:602
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:413
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.

◆ boundaryMarker

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

Definition at line 78 of file lesson3_poisson.cpp.

◆ commonDataPtr [1/3]

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

Definition at line 54 of file lesson1_moment_of_inertia.cpp.

◆ commonDataPtr [2/3]

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

Definition at line 62 of file lesson8_contact.cpp.

◆ commonDataPtr [3/3]

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

Definition at line 63 of file lesson7_plastic.cpp.

◆ invJac

MatrixDouble Example::invJac
private

Definition at line 71 of file lesson3_poisson.cpp.

◆ jAc

MatrixDouble Example::jAc
private

Definition at line 61 of file lesson8_contact.cpp.

◆ mField

MoFEM::Interface & Example::mField
private

Definition at line 44 of file lesson1_moment_of_inertia.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.

◆ 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: