v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ContactOps::ContactPressureNormCheck Struct Referenceabstract

#include "tutorials/adv-1_contact/src/TestingContact.hpp"

Inheritance diagram for ContactOps::ContactPressureNormCheck:
[legend]
Collaboration diagram for ContactOps::ContactPressureNormCheck:
[legend]

Public Member Functions

 ContactPressureNormCheck (MoFEM::Interface &m_field, double tol_norm, std::string check_name)
 
virtual ~ContactPressureNormCheck ()=default
 
MoFEMErrorCode operator() (DM dm)
 

Protected Member Functions

virtual double analyticalPressure (double x, double y, double z) const =0
 

Protected Attributes

MoFEM::Interface & mField
 
double tolNorm
 
std::string checkName
 

Detailed Description

Compare the magnitude of the contact traction against an analytical pressure distribution, integrated as an L2 error over the contact boundary, using the final accepted field state.

Definition at line 10 of file TestingContact.hpp.

Constructor & Destructor Documentation

◆ ContactPressureNormCheck()

ContactOps::ContactPressureNormCheck::ContactPressureNormCheck ( MoFEM::Interface &  m_field,
double  tol_norm,
std::string  check_name 
)
inline

Definition at line 12 of file TestingContact.hpp.

14 : mField(m_field), tolNorm(tol_norm), checkName(std::move(check_name)) {
15 }

◆ ~ContactPressureNormCheck()

virtual ContactOps::ContactPressureNormCheck::~ContactPressureNormCheck ( )
virtualdefault

Member Function Documentation

◆ analyticalPressure()

virtual double ContactOps::ContactPressureNormCheck::analyticalPressure ( double  x,
double  y,
double  z 
) const
protectedpure virtual

Analytical pressure at a boundary gauss point's physical coordinates.

Implemented in ContactOps::HertzPlaneStrainPressureNormCheck, and ContactOps::HertzAxisymmetricPressureNormCheck.

◆ operator()()

MoFEMErrorCode ContactOps::ContactPressureNormCheck::operator() ( DM  dm)
inline

Definition at line 19 of file TestingContact.hpp.

19 {
21
22 Range contact_range;
23 for (auto m : mField.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(
24 std::regex((boost::format("%s(.*)") % "CONTACT").str()))) {
25 auto meshset = m->getMeshset();
26 Range contact_meshset_range;
27 CHKERR mField.get_moab().get_entities_by_dimension(
28 meshset, SPACE_DIM - 1, contact_meshset_range, true);
29 CHKERR mField.getInterface<CommInterface>()->synchroniseEntities(
30 contact_meshset_range);
31 contact_range.merge(contact_meshset_range);
32 }
33 auto contact_range_ptr = boost::make_shared<Range>(contact_range);
34
35 struct OpCalcTractionMagnitude : public BoundaryEleOp {
36 OpCalcTractionMagnitude(boost::shared_ptr<MatrixDouble> traction_ptr,
37 boost::shared_ptr<VectorDouble> mag_ptr)
38 : BoundaryEleOp(NOSPACE, OPSPACE), tractionPtr(traction_ptr),
39 magPtr(mag_ptr) {}
40 MoFEMErrorCode doWork(int, EntityType, EntitiesFieldData::EntData &) {
42 const auto nb_gauss_pts = getGaussPts().size2();
43 magPtr->resize(nb_gauss_pts);
44 using DL = DataLayoutTraits<DataLayout::GaussByCoeffs>;
45 auto t_traction = MatrixSizeHelper<
47 *tractionPtr, nb_gauss_pts)();
48 auto t_mag = getFTensor0FromVec(*magPtr);
49 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
50 t_mag = t_traction.l2();
51 ++t_traction;
52 ++t_mag;
53 }
55 }
56
57 private:
58 boost::shared_ptr<MatrixDouble> tractionPtr;
59 boost::shared_ptr<VectorDouble> magPtr;
60 };
61
62 auto fe = boost::make_shared<BoundaryEle>(mField);
63 CHKERR AddHOOps<SPACE_DIM - 1, SPACE_DIM, SPACE_DIM>::add(
64 fe->getOpPtrVector(), {HDIV}, "GEOMETRY");
65 // We have to integrate on curved face geometry, thus integration weight
66 // have to adjusted.
67 fe->getOpPtrVector().push_back(new OpSetHOWeightsOnSubDim<SPACE_DIM>());
68 fe->getRuleHook = [](int, int, int approx_order) {
69 return 2 * approx_order + geom_order - 1;
70 };
71
72 struct OpResetTraction : public BoundaryEleOp {
73 boost::shared_ptr<MatrixDouble> tractionPtr;
74 OpResetTraction(boost::shared_ptr<MatrixDouble> ptr)
75 : BoundaryEleOp(NOSPACE, OPSPACE), tractionPtr(ptr) {}
76 MoFEMErrorCode doWork(int, EntityType, EntitiesFieldData::EntData &) override {
78 using DL = DataLayoutTraits<DataLayout::GaussByCoeffs>;
79 MatrixSizeHelper<GetFTensor1FromMatType<SPACE_DIM, -1, DL>, DL>::size(
80 *tractionPtr, getGaussPts().size2());
81 tractionPtr->clear();
83 }
84 };
85 auto common_data_ptr = boost::make_shared<ContactOps::CommonData>();
86 fe->getOpPtrVector().push_back(
87 new OpResetTraction(common_data_ptr->contactTractionPtr()));
88 fe->getOpPtrVector().push_back(
89 new OpCalculateHVecTensorTrace<SPACE_DIM, BoundaryEleOp>(
90 "SIGMA", common_data_ptr->contactTractionPtr()));
91
92 auto mag_traction_ptr = boost::make_shared<VectorDouble>();
93 fe->getOpPtrVector().push_back(new OpCalcTractionMagnitude(
94 common_data_ptr->contactTractionPtr(), mag_traction_ptr));
95
96 auto analytical_pressure_ptr = boost::make_shared<VectorDouble>();
97 fe->getOpPtrVector().push_back(new OpGetTensor0fromFunc(
98 analytical_pressure_ptr,
99 [this](double x, double y, double z) {
100 return analyticalPressure(x, y, z);
101 }));
102
103 enum { NORM, LAST_NORM };
104 auto norm_vec = createVectorMPI(
105 mField.get_comm(), (mField.get_comm_rank() == 0) ? LAST_NORM : 0,
106 LAST_NORM);
107 fe->getOpPtrVector().push_back(new OpCalcNormL2Tensor0(
108 mag_traction_ptr, norm_vec, NORM, analytical_pressure_ptr,
109 contact_range_ptr));
110
111 CHKERR VecZeroEntries(norm_vec);
112 CHKERR DMoFEMLoopFiniteElements(dm, "bFE", fe);
113 CHKERR VecAssemblyBegin(norm_vec);
114 CHKERR VecAssemblyEnd(norm_vec);
115
116 double norm = 0.;
117 if (!mField.get_comm_rank()) {
118 const double *norm_ptr;
119 CHKERR VecGetArrayRead(norm_vec, &norm_ptr);
120 norm = std::sqrt(norm_ptr[NORM]);
121 CHKERR VecRestoreArrayRead(norm_vec, &norm_ptr);
122 }
123 CHKERR MPI_Bcast(&norm, 1, MPI_DOUBLE, 0, mField.get_comm());
124
125 CHKERR mField.getInterface<TestingInterface>()
126 ->checkError<TestType::SCALAR>(checkName, norm, 0., {tolNorm, 0.});
127
129 }
PetscInt size
constexpr int SPACE_DIM
@ NOSPACE
Definition definitions.h:83
#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 DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:605
DataLayoutTraits< DataLayout::GaussByCoeffs > DL
Definition MatHuHu.hpp:33
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
decltype(GetFTensor1FromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor1FromMatType
int geom_order
Order if fixed.
Definition plastic.cpp:142
static constexpr int approx_order
FTensor::Index< 'm', 3 > m
virtual double analyticalPressure(double x, double y, double z) const =0
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

Member Data Documentation

◆ checkName

std::string ContactOps::ContactPressureNormCheck::checkName
protected

Definition at line 137 of file TestingContact.hpp.

◆ mField

MoFEM::Interface& ContactOps::ContactPressureNormCheck::mField
protected

Definition at line 135 of file TestingContact.hpp.

◆ tolNorm

double ContactOps::ContactPressureNormCheck::tolNorm
protected

Definition at line 136 of file TestingContact.hpp.


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