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 ()
 [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 ()
 

Private Member Functions

MoFEMErrorCode setUP ()
 [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 setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode tsSolve ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
Range getEntsOnMeshSkin ()
 [Check] More...
 
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 integrateElements ()
 [Push operators to pipeline] More...
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode setUP ()
 
MoFEMErrorCode createCommonData ()
 
MoFEMErrorCode bC ()
 
MoFEMErrorCode OPs ()
 
MoFEMErrorCode tsSolve ()
 
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 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
 
MatrixDouble jAc
 
boost::shared_ptr< OpContactTools::CommonDatacommonDataPtr
 
boost::shared_ptr< PostProcFaceOnRefinedMeshFor2DpostProcFe
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
 
boost::shared_ptr< OpPlasticTools::CommonDatacommonDataPtr
 
boost::shared_ptr< PostProcFaceOnRefinedMeshpostProcFe
 
boost::shared_ptr< std::vector< bool > > boundaryMarker
 
boost::shared_ptr< VectorDoubleapproxVals
 
boost::shared_ptr< MatrixDoubleapproxGradVals
 

Detailed Description

[Example]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 41 of file basic_approx.cpp.

Constructor & Destructor Documentation

◆ Example() [1/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 43 of file basic_approx.cpp.

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

◆ Example() [2/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 46 of file basic_contact.cpp.

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

◆ Example() [3/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 42 of file basic_elastic.cpp.

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

◆ Example() [4/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 48 of file basic_helmholtz.cpp.

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

◆ Example() [5/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 42 of file basic_moment_of_inertia.cpp.

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

◆ Example() [6/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 47 of file basic_plastic.cpp.

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

◆ Example() [7/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 47 of file basic_poisson.cpp.

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

◆ Example() [8/9]

Example::Example ( MoFEM::Interface m_field)

Definition at line 53 of file basic_radiation.cpp.

53 : 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
basic_approx.cpp, and basic_poisson.cpp.

Definition at line 50 of file basic_approx.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 basic_poisson.cpp.

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

◆ bC() [1/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [2/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [3/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [4/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [5/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [6/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [7/9]

MoFEMErrorCode Example::bC ( )
private

[Create common data]

[Set up problem]

[Boundary condition]

[Applying essential BC]

[Set inital density]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 117 of file basic_approx.cpp.

117 { return 0; }

◆ bC() [8/9]

MoFEMErrorCode Example::bC ( )
private

◆ bC() [9/9]

MoFEMErrorCode Example::bC ( )
private

◆ checkResults() [1/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ checkResults() [2/8]

MoFEMErrorCode Example::checkResults ( )
private

◆ 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

[Postprocess results]

[Print results]

[Solve]

[Check]

[Test example]

[Check results]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 170 of file basic_approx.cpp.

170  {
172  Basic *basic = mField.getInterface<Basic>();
173  basic->getDomainLhsFE().reset();
174  basic->getDomainRhsFE().reset();
175  basic->getOpDomainRhsPipeline().clear();
176  basic->getOpDomainRhsPipeline().push_back(
177  new OpCalculateScalarFieldValues("U", commonDataPtr->approxVals));
178  basic->getOpDomainRhsPipeline().push_back(new OpError(commonDataPtr));
180  CHKERR basic->loopFiniteElements();
181  CHKERR VecAssemblyBegin(commonDataPtr->L2Vec);
182  CHKERR VecAssemblyEnd(commonDataPtr->L2Vec);
183  CHKERR VecAssemblyBegin(commonDataPtr->resVec);
184  CHKERR VecAssemblyEnd(commonDataPtr->resVec);
185  double nrm2;
186  CHKERR VecNorm(commonDataPtr->resVec, NORM_2, &nrm2);
187  const double *array;
188  CHKERR VecGetArrayRead(commonDataPtr->L2Vec, &array);
189  if (mField.get_comm_rank() == 0)
190  PetscPrintf(PETSC_COMM_SELF, "Error %6.4e Vec norm %6.4e\n", sqrt(array[0]),
191  nrm2);
192  CHKERR VecRestoreArrayRead(commonDataPtr->L2Vec, &array);
193  constexpr double eps = 1e-8;
194  if (nrm2 > eps)
195  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
196  "Not converged solution");
198 }
MoFEM::Interface & mField
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
Definition: Basic.hpp:466
boost::shared_ptr< FEMethod > & getDomainLhsFE()
Definition: Basic.hpp:272
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Basic interface.
Definition: Basic.hpp:36
virtual int get_comm_rank() const =0
static int integrationRule(int, int, int p_data)
boost::shared_ptr< FEMethod > & getDomainRhsFE()
Definition: Basic.hpp:274
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
Definition: Basic.cpp:36
#define CHKERR
Inline error check.
Definition: definitions.h:601
boost::shared_ptr< CommonData > commonDataPtr
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Definition: Basic.hpp:311
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412
static const double eps
Get value at integration points for scalar field.

◆ 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

◆ 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

[Set up problem]

[Create common data]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 104 of file basic_approx.cpp.

104  {
107  commonDataPtr = boost::make_shared<CommonData>();
108  commonDataPtr->resVec = smartCreateDMVector(simple->getDM());
110  mField.get_comm(), (!mField.get_comm_rank()) ? 1 : 0, 1);
111  commonDataPtr->approxVals = boost::make_shared<VectorDouble>();
113 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
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:412
virtual MPI_Comm & get_comm() const =0

◆ createCommonData() [7/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ createCommonData() [8/8]

MoFEMErrorCode Example::createCommonData ( )
private

◆ getEntsOnMeshSkin()

Range Example::getEntsOnMeshSkin ( )
private

[Check]

Examples
basic_contact.cpp.

Definition at line 393 of file basic_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:601

◆ integrateElements()

MoFEMErrorCode Example::integrateElements ( )
private

[Push operators to pipeline]

[Integrate]

Examples
basic_moment_of_inertia.cpp.

Definition at line 234 of file basic_moment_of_inertia.cpp.

234  {
236 
237  // Zero global vector
238  CHKERR VecZeroEntries(commonDataPtr->petscVec);
239 
240  // Integrate elements by executing operators in the pipeline
241  Basic *basic = mField.getInterface<Basic>();
242  CHKERR basic->loopFiniteElements();
243 
244  // Assemble vector
245  CHKERR VecAssemblyBegin(commonDataPtr->petscVec);
246  CHKERR VecAssemblyEnd(commonDataPtr->petscVec);
248 }
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Basic interface.
Definition: Basic.hpp:36
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
Definition: Basic.cpp:36
#define CHKERR
Inline error check.
Definition: definitions.h:601
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:412

◆ integrationRule() [1/3]

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

Definition at line 53 of file basic_approx.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 basic_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 basic_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
basic_approx.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 135 of file basic_approx.cpp.

135  {
138  Basic *basic = mField.getInterface<Basic>();
139  auto solver = basic->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:482
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
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
Definition: Basic.cpp:68
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
Basic interface.
Definition: Basic.hpp:36
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

◆ 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
basic_poisson.cpp.

Definition at line 57 of file basic_poisson.cpp.

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

◆ OPs() [1/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [2/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [3/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [4/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [5/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [6/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [7/9]

MoFEMErrorCode Example::OPs ( )
private

[Boundary condition]

[Set inital density]

[Applying essential BC]

[Push operators to pipeline]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 121 of file basic_approx.cpp.

121  {
123  Basic *basic = mField.getInterface<Basic>();
124  auto beta = [](const double, const double, const double) { return 1; };
125  basic->getOpDomainLhsPipeline().push_back(new OpDomainMass("U", "U", beta));
126  basic->getOpDomainRhsPipeline().push_back(
131 }
static double approxFunction(const double x, const double y, const double z)
MoFEM::Interface & mField
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
Definition: Basic.hpp:466
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
boost::ptr_vector< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
Definition: Basic.hpp:442
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Basic interface.
Definition: Basic.hpp:36
OpTools< DomainEleOp >::OpSource< 2 > OpDomainSource
static int integrationRule(int, int, int p_data)
OpTools< DomainEleOp >::OpMass OpDomainMass
#define CHKERR
Inline error check.
Definition: definitions.h:601
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Definition: Basic.hpp:285
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Definition: Basic.hpp:311
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

◆ OPs() [8/9]

MoFEMErrorCode Example::OPs ( )
private

◆ OPs() [9/9]

MoFEMErrorCode Example::OPs ( )
private

◆ postProcess() [1/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [2/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ 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

[Solve]

[Integrate]

[Postprocess results]

[Print results]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 155 of file basic_approx.cpp.

155  {
157  Basic *basic = mField.getInterface<Basic>();
158  basic->getDomainLhsFE().reset();
159  auto post_proc_fe = boost::make_shared<PostProcFaceOnRefinedMesh>(mField);
160  post_proc_fe->generateReferenceElementMesh();
161  post_proc_fe->addFieldValuesPostProc("U");
162  basic->getDomainRhsFE() = post_proc_fe;
163  CHKERR basic->loopFiniteElements();
164  CHKERR post_proc_fe->writeFile("out_approx.h5m");
166 }
MoFEM::Interface & mField
boost::shared_ptr< FEMethod > & getDomainLhsFE()
Definition: Basic.hpp:272
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Basic interface.
Definition: Basic.hpp:36
boost::shared_ptr< FEMethod > & getDomainRhsFE()
Definition: Basic.hpp:274
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
Definition: Basic.cpp:36
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

◆ postProcess() [8/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ postProcess() [9/9]

MoFEMErrorCode Example::postProcess ( )
private

◆ runProblem() [1/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [2/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [3/9]

MoFEMErrorCode Example::runProblem ( )

◆ runProblem() [4/9]

MoFEMErrorCode Example::runProblem ( )

[Run problem]

[Operator]

[Run all]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 78 of file basic_approx.cpp.

78  {
80  CHKERR setUP();
82  CHKERR bC();
83  CHKERR OPs();
84  CHKERR kspSolve();
88 }
MoFEMErrorCode createCommonData()
[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:482
MoFEMErrorCode OPs()
[Boundary condition]
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode bC()
[Create common data]
#define CHKERR
Inline error check.
Definition: definitions.h:601
MoFEMErrorCode setUP()
[Set up problem]
MoFEMErrorCode postProcess()
[Solve]
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

◆ 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 ( )

◆ setUP() [1/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [2/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [3/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [4/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [5/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [6/9]

MoFEMErrorCode Example::setUP ( )
private

[Set up problem]

[Run all]

[Run problem]

[Set up problem]

Examples
basic_approx.cpp, basic_contact.cpp, basic_elastic.cpp, basic_helmholtz.cpp, basic_moment_of_inertia.cpp, basic_plastic.cpp, basic_poisson.cpp, and basic_radiation.cpp.

Definition at line 91 of file basic_approx.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:482
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
#define CHKERR
Inline error check.
Definition: definitions.h:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412
continuous field
Definition: definitions.h:176

◆ setUP() [7/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [8/9]

MoFEMErrorCode Example::setUP ( )
private

◆ setUP() [9/9]

MoFEMErrorCode Example::setUP ( )
private

◆ tsSolve() [1/2]

MoFEMErrorCode Example::tsSolve ( )
private

[Push operators to pipeline]

[Solve]

Examples
basic_contact.cpp, and basic_plastic.cpp.

Definition at line 282 of file basic_contact.cpp.

282  {
284 
286  Basic *basic = mField.getInterface<Basic>();
287  ISManager *is_manager = mField.getInterface<ISManager>();
288 
289  auto solver = basic->createTS();
290 
291  auto dm = simple->getDM();
292  auto D = smartCreateDMVector(dm);
293 
294  CHKERR TSSetSolution(solver, D);
295  CHKERR TSSetFromOptions(solver);
296  CHKERR TSSetUp(solver);
297 
298  auto set_section_monitor = [&]() {
300  SNES snes;
301  CHKERR TSGetSNES(solver, &snes);
302  PetscViewerAndFormat *vf;
303  CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
304  PETSC_VIEWER_DEFAULT, &vf);
305  CHKERR SNESMonitorSet(
306  snes,
307  (MoFEMErrorCode(*)(SNES, PetscInt, PetscReal, void *))SNESMonitorFields,
308  vf, (MoFEMErrorCode(*)(void **))PetscViewerAndFormatDestroy);
310  };
311 
312  auto create_post_process_element = [&]() {
314  postProcFe = boost::make_shared<PostProcFaceOnRefinedMeshFor2D>(mField);
315  postProcFe->generateReferenceElementMesh();
316 
317  postProcFe->getOpPtrVector().push_back(new OpCalculateJacForFace(jAc));
318  postProcFe->getOpPtrVector().push_back(
320  postProcFe->getOpPtrVector().push_back(new OpSetInvJacH1ForFace(invJac));
321  postProcFe->getOpPtrVector().push_back(new OpMakeHdivFromHcurl());
322  postProcFe->getOpPtrVector().push_back(
324  postProcFe->getOpPtrVector().push_back(new OpSetInvJacHcurlFace(invJac));
325 
326  postProcFe->getOpPtrVector().push_back(
328  postProcFe->getOpPtrVector().push_back(new OpStrain("U", commonDataPtr));
329  postProcFe->getOpPtrVector().push_back(new OpStress("U", commonDataPtr));
330  postProcFe->getOpPtrVector().push_back(
332  "SIGMA", commonDataPtr->contactStressDivergencePtr));
333  postProcFe->getOpPtrVector().push_back(new OpCalculateHVecTensorField<2, 2>(
334  "SIGMA", commonDataPtr->contactStressPtr));
335 
336  postProcFe->getOpPtrVector().push_back(new OpPostProcElastic(
337  "U", postProcFe->postProcMesh, postProcFe->mapGaussPts, commonDataPtr));
338  postProcFe->getOpPtrVector().push_back(
339  new OpPostProcContact("SIGMA", postProcFe->postProcMesh,
340  postProcFe->mapGaussPts, commonDataPtr));
341  postProcFe->addFieldValuesPostProc("U");
343  };
344 
345  auto scatter_create = [&](auto coeff) {
347  CHKERR is_manager->isCreateProblemFieldAndRank(simple->getProblemName(),
348  ROW, "U", coeff, coeff, is);
349  int loc_size;
350  CHKERR ISGetLocalSize(is, &loc_size);
351  Vec v;
352  CHKERR VecCreateMPI(mField.get_comm(), loc_size, PETSC_DETERMINE, &v);
353  VecScatter scatter;
354  CHKERR VecScatterCreate(D, is, v, PETSC_NULL, &scatter);
355  return std::make_tuple(SmartPetscObj<Vec>(v),
356  SmartPetscObj<VecScatter>(scatter));
357  };
358 
359  auto set_time_monitor = [&]() {
361  boost::shared_ptr<Monitor> monitor_ptr(
363  boost::shared_ptr<ForcesAndSourcesCore> null;
364  CHKERR DMMoFEMTSSetMonitor(dm, solver, simple->getDomainFEName(),
365  monitor_ptr, null, null);
367  };
368 
369  CHKERR set_section_monitor();
370  CHKERR create_post_process_element();
371  uXScatter = scatter_create(0);
372  uYScatter = scatter_create(1);
373  CHKERR set_time_monitor();
374 
375  CHKERR TSSolve(solver, D);
376 
377  CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
378  CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
379  CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
380 
382 }
boost::shared_ptr< PostProcFaceOnRefinedMeshFor2D > postProcFe
Definition: ContactOps.hpp:856
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
Calculate tenor field using vectorial base, i.e. Hdiv/Hcurl.
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:482
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
Basic interface.
Definition: Basic.hpp:36
Calculate inverse of jacobian for face element.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
MatrixDouble jAc
Calculate divergence of tonsorial field using vectorial base.
#define CHKERR
Inline error check.
Definition: definitions.h:601
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
brief Transform local reference derivatives of shape function to global derivatives for face
Definition: ElasticOps.hpp:86
Apply contravariant (Piola) transfer to Hdiv space on face.
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:412
virtual MPI_Comm & get_comm() const =0
Calculate jacobian for face element.
intrusive_ptr for managing petsc objects
Definition: AuxPETSc.hpp:128
MatrixDouble invJac
Make Hdiv space from Hcurl space in 2d.

◆ tsSolve() [2/2]

MoFEMErrorCode Example::tsSolve ( )
private

Member Data Documentation

◆ approxGradVals

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

Definition at line 72 of file basic_radiation.cpp.

◆ approxVals

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

Definition at line 71 of file basic_radiation.cpp.

◆ boundaryMarker

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

Definition at line 78 of file basic_poisson.cpp.

◆ commonDataPtr [1/3]

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

Definition at line 62 of file basic_contact.cpp.

◆ commonDataPtr [2/3]

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

Definition at line 63 of file basic_plastic.cpp.

◆ commonDataPtr [3/3]

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

Definition at line 68 of file basic_approx.cpp.

◆ invJac

MatrixDouble Example::invJac
private

Definition at line 61 of file basic_contact.cpp.

◆ jAc

MatrixDouble Example::jAc
private

Definition at line 61 of file basic_contact.cpp.

◆ mField

MoFEM::Interface & Example::mField
private

Definition at line 48 of file basic_approx.cpp.

◆ postProcFe [1/2]

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

Definition at line 63 of file basic_contact.cpp.

◆ postProcFe [2/2]

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

Definition at line 64 of file basic_plastic.cpp.

◆ uXScatter

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

Definition at line 64 of file basic_contact.cpp.

◆ uYScatter

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

Definition at line 65 of file basic_contact.cpp.


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