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

Public Member Functions

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

Protected Attributes

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

Detailed Description

template<int DIM, typename DomainEleOp>
struct AdolCOps::OpEvalAdolCHuHuImpl< DIM, DomainEleOp >

Definition at line 144 of file AdolCHuHu.cpp.

Constructor & Destructor Documentation

◆ OpEvalAdolCHuHuImpl()

template<int DIM, typename DomainEleOp >
AdolCOps::OpEvalAdolCHuHuImpl< DIM, DomainEleOp >::OpEvalAdolCHuHuImpl ( boost::shared_ptr< PhysicalEquations physical_ptr,
bool  eval_stress,
bool  eval_tangent 
)
inline

Definition at line 146 of file AdolCHuHu.cpp.

148 : DomainEleOp("U", DomainEleOp::OPROW), physicalPtr(physical_ptr),
149 evalStress(eval_stress), evalTangent(eval_tangent) {}
boost::shared_ptr< PhysicalEquations > physicalPtr

Member Function Documentation

◆ doWork()

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

Definition at line 160 of file AdolCHuHu.cpp.

162 {
164 int nb_dofs = data.getIndices().size();
165 if (!nb_dofs)
167 int nb_integration_pts = data.getN().size1();
168
169 constexpr int adolc_return_value = 0;
170
171 auto physics_ptr = physicalPtr;
172
173 auto get_tag = [&]() {
174 if (physics_ptr->tagVsRangePtr) {
175 for (const auto &tag_range_pair : *physics_ptr->tagVsRangePtr) {
176 if (tag_range_pair.second.find(DomainEleOp::getFEEntityHandle()) !=
177 tag_range_pair.second.end()) {
178 return tag_range_pair.first;
179 }
180 }
181 }
182 return physics_ptr->tAg; // Default tag if no range matches
183 };
184
185 auto mat_grad_ptr = physics_ptr->adolcDataPtr->getCommonDataPtr("grad");
186 auto mat_k_ptr = physics_ptr->adolcDataPtr->getCommonDataPtr("k");
187 auto mat_k_dF_ptr = physics_ptr->adolcDataPtr->getCommonDataPtr("k_dF");
188
189#ifndef NDEBUG
190 if (!mat_grad_ptr || !mat_k_ptr || !mat_k_dF_ptr) {
191 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
192 "Missing common data for ADOL-C evaluation");
193 }
194 if (mat_grad_ptr->size1() != DIM * DIM) {
195 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
196 "Inconsistent size of gradient matrix for ADOL-C evaluation");
197 }
198 if (mat_grad_ptr->size2() != nb_integration_pts) {
199 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
200 "Inconsistent size of gradient matrix data for ADOL-C evaluation");
201 }
202#endif
203
204 if (evalStress) {
205 FTENSOR_INDEX(DIM, i);
206 FTENSOR_INDEX(DIM, J);
207 FTENSOR_INDEX(DIM, K);
208 FTENSOR_INDEX(DIM, L);
209
210 auto t_grad_at_pts = getFTensor2FromMat<DIM, DIM>(*mat_grad_ptr);
211 mat_k_ptr->resize(1, nb_integration_pts, false);
212 auto t_k_at_pts = getFTensor1FromMat<1>(*mat_k_ptr);
213
214 auto next = [&]() {
215 ++t_grad_at_pts;
216 ++t_k_at_pts;
217 };
218
220
221 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
222 auto t_F = getFTensor2FromPtr<DIM, DIM>(
223 physics_ptr->adolcDataPtr->getActiveDataPtr("F")->data().data());
224 t_F(i, J) = t_grad_at_pts(i, J) + t_kd(i, J);
225 CHKERR physics_ptr->setActiveContinuousVector();
226 CHKERR physics_ptr->setDependentContinuousVector();
227 CHKERR physics_ptr->setParams(this->getFEEntityHandle(), gg);
228 int r = ::function(get_tag(), physics_ptr->dependentVariables.size(),
229 physics_ptr->activeVariables.size(),
230 physics_ptr->activeVariables.data(),
231 physics_ptr->dependentVariables.data());
232 if (PetscUnlikely(r < adolc_return_value)) {
233 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
234 "ADOL-C function evaluation with error");
235 }
236 CHKERR physics_ptr->getDependentContinuousVector();
237 t_k_at_pts(0) =
238 (*physics_ptr->adolcDataPtr->getDependentDataPtr("k"))(0, 0);
239 next();
240 }
241 }
242
243 if (evalTangent) {
244 FTENSOR_INDEX(DIM, i);
245 FTENSOR_INDEX(DIM, J);
246 FTENSOR_INDEX(DIM, k);
247 FTENSOR_INDEX(DIM, L);
248
249 const int number_of_active_variables = physics_ptr->activeVariables.size();
250 const int number_of_dependent_variables =
251 physics_ptr->dependentVariables.size();
252 CHKERR physics_ptr->setDependentDerivativesContinuousVector();
253 std::vector<double *> jac_ptr(number_of_dependent_variables);
254 for (unsigned int n = 0; n != number_of_dependent_variables; ++n) {
255 jac_ptr[n] = &(
256 physics_ptr
257 ->dependentVariablesDerivatives[n * number_of_active_variables]);
258 }
259
260 auto t_grad_at_pts = getFTensor2FromMat<DIM, DIM>(*mat_grad_ptr);
261 mat_k_dF_ptr->resize(DIM * DIM, nb_integration_pts, false);
262 auto t_k_dF_at_pts = getFTensor2FromMat<DIM, DIM>(*mat_k_dF_ptr);
264
265 auto next = [&]() {
266 ++t_grad_at_pts;
267 ++t_k_dF_at_pts;
268 };
269
270
271 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
272 auto t_F = getFTensor2FromPtr<DIM, DIM>(
273 physics_ptr->adolcDataPtr->getActiveDataPtr("F")->data().data());
274 t_F(i, J) = t_grad_at_pts(i, J) + t_kd(i, J);
275 CHKERR physics_ptr->setActiveContinuousVector();
276 CHKERR physics_ptr->setDependentContinuousVector();
277 CHKERR physics_ptr->setParams(this->getFEEntityHandle(), gg);
278 int r = ::jacobian(get_tag(), number_of_dependent_variables,
279 number_of_active_variables,
280 physics_ptr->activeVariables.data(), jac_ptr.data());
281 if (PetscUnlikely(r < adolc_return_value)) {
282 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
283 "ADOL-C function evaluation with error");
284 }
285 CHKERR physics_ptr->getDependentDerivativesContinuousVector();
286 auto t_k_dF = getFTensor2FromPtr<DIM, DIM>(
287 physics_ptr->adolcDataPtr->getDependentDerivativesDataPtr("k_dF")
288 ->data()
289 .data());
290 t_k_dF_at_pts(i, J) = t_k_dF(i, J);
291 next();
292 }
293 }
294
296}
#define FTENSOR_INDEX(DIM, I)
Kronecker Delta class.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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.
constexpr auto t_kd
FTensor::Index< 'i', SPACE_DIM > i
const double n
refractive index of diffusive medium
FTensor::Index< 'J', DIM1 > J
Definition level_set.cpp:30
FTensor::Index< 'k', 3 > k
int r
Definition sdf.py:205
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorInt & getIndices() const
Get global indices of degrees of freedom on entity.

Member Data Documentation

◆ evalStress

template<int DIM, typename DomainEleOp >
const bool AdolCOps::OpEvalAdolCHuHuImpl< DIM, DomainEleOp >::evalStress
protected

Definition at line 155 of file AdolCHuHu.cpp.

◆ evalTangent

template<int DIM, typename DomainEleOp >
const bool AdolCOps::OpEvalAdolCHuHuImpl< DIM, DomainEleOp >::evalTangent
protected

Definition at line 156 of file AdolCHuHu.cpp.

◆ physicalPtr

template<int DIM, typename DomainEleOp >
boost::shared_ptr<PhysicalEquations> AdolCOps::OpEvalAdolCHuHuImpl< DIM, DomainEleOp >::physicalPtr
protected

Definition at line 154 of file AdolCHuHu.cpp.


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