v0.16.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp > Struct Template Reference
Inheritance diagram for MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >:
[legend]
Collaboration diagram for MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >:
[legend]

Public Types

using OP = DomainEleOp
 

Public Member Functions

 OpEvalMatSimpleMaterialImpl (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 

Protected Attributes

boost::shared_ptr< PhysicalEquationsphysicalPtr
 
const bool evalStress
 
const bool evalTangent
 
const bool updateState
 

Detailed Description

template<int DIM, typename DomainEleOp>
struct MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >

Definition at line 40 of file MatElastic.cpp.

Member Typedef Documentation

◆ OP

template<int DIM, typename DomainEleOp >
using MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::OP = DomainEleOp

Definition at line 42 of file MatElastic.cpp.

Constructor & Destructor Documentation

◆ OpEvalMatSimpleMaterialImpl()

template<int DIM, typename DomainEleOp >
MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::OpEvalMatSimpleMaterialImpl ( boost::shared_ptr< PhysicalEquations physical_ptr,
bool  eval_stress,
bool  eval_tangent,
bool  update 
)
inline

Definition at line 44 of file MatElastic.cpp.

47 : DomainEleOp(NOSPACE, DomainEleOp::OPSPACE), physicalPtr(physical_ptr),
48 evalStress(eval_stress), evalTangent(eval_tangent),
49 updateState(update) {}
@ NOSPACE
Definition definitions.h:83
boost::shared_ptr< PhysicalEquations > physicalPtr

Member Function Documentation

◆ doWork()

template<int DIM, typename DomainEleOp >
MoFEMErrorCode MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::doWork ( int  side,
EntityType  type,
EntData data 
)

Definition at line 61 of file MatElastic.cpp.

62 {
64
65 int nb_integration_pts = OP::getGaussPts().size2();
66
67 auto get_tag = [&]() {
68 if (physicalPtr->tagVsRangePtr) {
69 for (const auto &tag_range_pair : *(physicalPtr->tagVsRangePtr)) {
70 if (tag_range_pair.second.find(DomainEleOp::getFEEntityHandle()) !=
71 tag_range_pair.second.end()) {
72 return tag_range_pair.first;
73 }
74 }
75 }
76#ifndef NDEBUG
79 "ADOL-C tag not found " +
80 std::to_string(physicalPtr->tAg));
81 }
82#endif
83 return physicalPtr->tAg; // Default tag if no range matches
84 };
85
86 const int current_tag = get_tag();
87 auto *fe_ptr = const_cast<FEMethod *>(this->getFEMethod());
88 const auto ent = fe_ptr->getFEEntityHandle();
89
90 physicalPtr->matOpsDataPtr->getActiveDataPtr("F")->resize(DIM, DIM, false);
91 physicalPtr->matOpsDataPtr->getDependentDataPtr("P")->resize(DIM, DIM, false);
92 physicalPtr->matOpsDataPtr->getDependentDerivativesDataPtr("P_dF")->resize(
93 DIM * DIM, DIM * DIM, false);
94 auto mat_grad_ptr = physicalPtr->matOpsDataPtr->getCommonDataPtr("grad");
95 auto mat_P_ptr = physicalPtr->matOpsDataPtr->getCommonDataPtr("P");
96 auto mat_P_dF_ptr = physicalPtr->matOpsDataPtr->getCommonDataPtr("P_dF");
97
98#ifndef NDEBUG
99 if (!mat_grad_ptr || !mat_P_ptr || !mat_P_dF_ptr) {
100 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
101 "Missing common data for ADOL-C evaluation");
102 }
103 if (mat_grad_ptr->size2() != DIM * DIM) {
104 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
105 "Inconsistent size of gradient matrix for ADOL-C evaluation");
106 }
107 if (mat_grad_ptr->size1() != nb_integration_pts) {
108 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
109 "Inconsistent size of gradient matrix data for ADOL-C evaluation "
110 "%zu != %d",
111 mat_grad_ptr->size1(), nb_integration_pts);
112 }
113#endif
114
116 auto get_grad_at_pts =
117 MatrixSizeHelper<GetFTensor2FromMatType<DIM, DIM, -1, DL>, DL>::get(
118 *mat_grad_ptr, nb_integration_pts);
119 auto get_P_at_pts =
120 MatrixSizeHelper<GetFTensor2FromMatType<DIM, DIM, -1, DL>, DL>::size(
121 *mat_P_ptr, nb_integration_pts);
122 auto get_P_dF_at_pts =
123 MatrixSizeHelper<GetFTensor4FromMatType<DIM, DIM, DIM, DIM, -1, DL>,
124 DL>::size(*mat_P_dF_ptr, nb_integration_pts);
125
126 if (evalStress) {
127 FTENSOR_INDEX(DIM, i);
128 FTENSOR_INDEX(DIM, J);
129
130 auto t_grad_at_pts = get_grad_at_pts();
131 auto t_P_at_pts = get_P_at_pts();
132
133 auto next = [&]() {
134 ++t_grad_at_pts;
135 ++t_P_at_pts;
136 };
137
138 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
139 auto t_F = getFTensor2FromPtr<DIM, DIM>(
140 physicalPtr->matOpsDataPtr->getActiveDataPtr("F")->data().data());
141 t_F(i, J) = t_grad_at_pts(i, J);
142 CHKERR physicalPtr->setParams(fe_ptr, gg);
143 CHKERR physicalPtr->evaluateVariable(current_tag, ent, gg);
144 auto t_P = getFTensor2FromPtr<DIM, DIM>(
145 physicalPtr->matOpsDataPtr->getDependentDataPtr("P")->data().data());
146 t_P_at_pts(i, J) = t_P(i, J);
147 next();
148 }
149 }
150
151 if (evalTangent) {
152 FTENSOR_INDEX(DIM, i);
153 FTENSOR_INDEX(DIM, J);
154 FTENSOR_INDEX(DIM, k);
155 FTENSOR_INDEX(DIM, L);
156
157 auto t_grad_at_pts = get_grad_at_pts();
158 auto t_P_dF_at_pts = get_P_dF_at_pts();
159 auto next = [&]() {
160 ++t_grad_at_pts;
161 ++t_P_dF_at_pts;
162 };
163
164 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
165 auto t_F = getFTensor2FromPtr<DIM, DIM>(
166 physicalPtr->matOpsDataPtr->getActiveDataPtr("F")->data().data());
167 t_F(i, J) = t_grad_at_pts(i, J);
168 CHKERR physicalPtr->setParams(fe_ptr, gg);
169 CHKERR physicalPtr->evaluateDerivatives(current_tag, ent, gg);
170 auto t_P_dF = getFTensor4FromPtr<DIM, DIM, DIM, DIM>(
171 physicalPtr->matOpsDataPtr->getDependentDerivativesDataPtr("P_dF")
172 ->data()
173 .data());
174 t_P_dF_at_pts(i, J, k, L) = t_P_dF(i, J, k, L);
175 next();
176 }
177 }
178
179 if (updateState) {
180 FTENSOR_INDEX(DIM, i);
181 FTENSOR_INDEX(DIM, J);
182
183 auto t_grad_at_pts = get_grad_at_pts();
184 auto next = [&]() { ++t_grad_at_pts; };
185
186 for (int gg = 0; gg != nb_integration_pts; ++gg) {
187 auto t_F = getFTensor2FromPtr<DIM, DIM>(
188 physicalPtr->matOpsDataPtr->getActiveDataPtr("F")->data().data());
189 t_F(i, J) = t_grad_at_pts(i, J);
190 CHKERR physicalPtr->setParams(fe_ptr, gg);
191 CHKERR physicalPtr->updateState(current_tag, ent, gg);
192 next();
193 }
194 }
195
197}
#define FTENSOR_INDEX(DIM, I)
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'J', DIM1 > J
Definition level_set.cpp:30
FTensor::Index< 'k', 3 > k
DataLayoutTraits< DataLayout::GaussByCoeffs > DL
Definition MatHuHu.hpp:33
decltype(GetFTensor4FromMatImpl< Tensor_Dim0, Tensor_Dim1, Tensor_Dim2, Tensor_Dim3, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor4FromMatType
decltype(GetFTensor2FromMatImpl< Tensor_Dim0, Tensor_Dim1, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2FromMatType
static std::string getTagName(int tag)
Definition MatOps.cpp:83
Structure for user loop methods on finite elements.
EntityHandle getFEEntityHandle() const
Get the entity handle of the current finite element.

Member Data Documentation

◆ evalStress

template<int DIM, typename DomainEleOp >
const bool MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::evalStress
protected

Definition at line 55 of file MatElastic.cpp.

◆ evalTangent

template<int DIM, typename DomainEleOp >
const bool MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::evalTangent
protected

Definition at line 56 of file MatElastic.cpp.

◆ physicalPtr

template<int DIM, typename DomainEleOp >
boost::shared_ptr<PhysicalEquations> MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::physicalPtr
protected

Definition at line 54 of file MatElastic.cpp.

◆ updateState

template<int DIM, typename DomainEleOp >
const bool MatOps::OpEvalMatSimpleMaterialImpl< DIM, DomainEleOp >::updateState
protected

Definition at line 57 of file MatElastic.cpp.


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