v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
ElasticTieMeshTutorial Struct Reference
Inheritance diagram for ElasticTieMeshTutorial:
[legend]
Collaboration diagram for ElasticTieMeshTutorial:
[legend]

Public Member Functions

MoFEMErrorCode checkResults () override
 [Postprocess results]
 
- Public Member Functions inherited from ElasticTieMeshExample
 ElasticExample (MoFEM::Interface &m_field)
 
- Public Member Functions inherited from ElasticExample
 ElasticExample (MoFEM::Interface &m_field)
 
virtual ~ElasticExample ()=default
 
MoFEMErrorCode runProblem ()
 [Run problem]
 

Private Member Functions

MoFEMErrorCode checkStressError (const int test)
 

Additional Inherited Members

- Protected Types inherited from ElasticExample
using Pipeline = boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator >
 
- Protected Member Functions inherited from ElasticTieMeshExample
MoFEMErrorCode readMesh () override
 [Run problem]
 
MoFEMErrorCode setupProblem () override
 [Read mesh]
 
MoFEMErrorCode setUpSolver (SmartPetscObj< KSP > solver) override
 [Push operators to pipeline]
 
MoFEMErrorCode kspSetUpAndSolve (SmartPetscObj< KSP > solver) override
 
- Protected Member Functions inherited from ElasticExample
virtual MoFEMErrorCode boundaryCondition ()
 [Set up problem]
 
virtual MoFEMErrorCode assembleSystem ()
 
virtual MoFEMErrorCode solveSystem ()
 [Solve]
 
virtual MoFEMErrorCode outputResults ()
 [Solve]
 
virtual MoFEMErrorCode addDomainMaterialOps (Pipeline &lhs_pipeline, Pipeline &rhs_pipeline)
 Add constitutive operators to the domain assembly pipelines.
 
- Protected Attributes inherited from ElasticTieMeshExample
boost::shared_ptr< ElasticTie::CommonData > tieData = nullptr
 
Range physicalBoundaryFaces
 
- Protected Attributes inherited from ElasticExample
MoFEM::Interface & mField
 
boost::shared_ptr< MatrixDouble > vectorFieldPtr = nullptr
 

Detailed Description

Examples
mofem/tutorials/vec-11_elastic_tie_mesh/elastic_tie_mesh.cpp.

Definition at line 39 of file elastic_tie_mesh.cpp.

Member Function Documentation

◆ checkResults()

MoFEMErrorCode ElasticTieMeshTutorial::checkResults ( )
overridevirtual

[Postprocess results]

[Check]

Reimplemented from ElasticTieMeshExample.

Examples
mofem/tutorials/vec-11_elastic_tie_mesh/elastic_tie_mesh.cpp.

Definition at line 135 of file elastic_tie_mesh.cpp.

135 {
137
138 int test = 0;
139 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-test", &test, PETSC_NULLPTR);
140 if (test == 10 || test == 11)
143}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
MoFEMErrorCode checkStressError(const int test)

◆ checkStressError()

MoFEMErrorCode ElasticTieMeshTutorial::checkStressError ( const int  test)
private
Examples
mofem/tutorials/vec-11_elastic_tie_mesh/elastic_tie_mesh.cpp.

Definition at line 49 of file elastic_tie_mesh.cpp.

49 {
51
53
54 auto norm_fe = boost::make_shared<DomainEle>(mField);
55 norm_fe->getRuleHook = [](int, int, int approx_order) {
56 return 2 * approx_order + 1;
57 };
58
60 norm_fe->getOpPtrVector(), {H1}, "GEOMETRY");
61
62 auto common_ptr = HookeOps::commonDataFactory<SPACE_DIM, GAUSS, DomainEle>(
63 mField, norm_fe->getOpPtrVector(), "U", "MAT_ELASTIC", Sev::verbose);
64
65 auto exact_stress_ptr = boost::make_shared<MatrixDouble>();
66
67 constexpr double uniaxial_stress_xx = 1e3 * 0.3 / 3.0;
68 auto uniaxial_stress = [](const double, const double, const double) {
69 MatrixDouble stress((SPACE_DIM * (SPACE_DIM + 1)) / 2, 1);
70 stress.clear();
71 auto t_stress = getFTensor2SymmetricFromMat<
73 t_stress(0, 0) = uniaxial_stress_xx;
74 return stress;
75 };
76
78 lame_solution(0.5, 1.0, 2.0, 1.0, 1e3, 0.3);
79 auto lame_stress = [&lame_solution](const double x, const double y,
80 const double z) {
81 return lame_solution.stress(x, y, z);
82 };
83
84 MatrixFunc stress_func = (test == 11) ? MatrixFunc(lame_stress)
85 : MatrixFunc(uniaxial_stress);
86 norm_fe->getOpPtrVector().push_back(
88 exact_stress_ptr, stress_func));
89
90 enum Norms { STRESS_ERROR_L2 = 0, STRESS_EXACT_L2, LAST_NORM };
91 auto norms_vec =
93 (mField.get_comm_rank() == 0) ? LAST_NORM : 0,
94 LAST_NORM);
95 CHKERR VecZeroEntries(norms_vec);
96
97 norm_fe->getOpPtrVector().push_back(
99 exact_stress_ptr, norms_vec, STRESS_EXACT_L2));
100 norm_fe->getOpPtrVector().push_back(
102 common_ptr->getMatCauchyStress(), norms_vec, STRESS_ERROR_L2,
103 exact_stress_ptr));
104
105 CHKERR DMoFEMLoopFiniteElements(simple->getDM(), simple->getDomainFEName(),
106 norm_fe);
107 CHKERR VecAssemblyBegin(norms_vec);
108 CHKERR VecAssemblyEnd(norms_vec);
109
110 if (mField.get_comm_rank() == 0) {
111 const double *norms;
112 CHKERR VecGetArrayRead(norms_vec, &norms);
113
114 const double error_l2 = std::sqrt(norms[STRESS_ERROR_L2]);
115 const double exact_l2 = std::sqrt(norms[STRESS_EXACT_L2]);
116
117 MOFEM_LOG_C("WORLD", Sev::inform, "STRESS_ERROR_L2 = %.16e\n", error_l2);
118 MOFEM_LOG_C("WORLD", Sev::inform, "STRESS_EXACT_L2 = %.16e\n", exact_l2);
119
120 CHKERR VecRestoreArrayRead(norms_vec, &norms);
121
122 double max_error_l2 = 1e-2;
123 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "", "-stress_error_l2_tol",
124 &max_error_l2, PETSC_NULLPTR);
125 if (error_l2 >= max_error_l2) {
126 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
127 "Stress L2 error %.16e exceeds tolerance %.16e", error_l2,
128 max_error_l2);
129 }
130 }
131
133}
const AnalyticalSolutions::HollowCylinderUnderRadialPressure< SPACE_DIM > lame_solution(0.5, 1.0, 2.0, 1.0, 1e3, 0.3)
#define MOFEM_LOG_C(channel, severity, format,...)
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
constexpr int SPACE_DIM
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:576
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
static auto getFTensor2SymmetricFromMat(M &data)
Get symmetric tensor rank 2 (matrix) form data matrix.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
boost::function< MatrixDouble(const double, const double, const double)> MatrixFunc
static constexpr int approx_order
Lamé analytical solution for a hollow cylinder under radial pressure with a linear isotropic Hooke ma...
MoFEM::Interface & mField
Add operators pushing bases from local to physical configuration.
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Get norm of input MatrixDouble for symmetric Tensor2.
Get values from matrix function in symmetric tensor storage at integration points and save them to Ma...
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

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