v0.15.0
Loading...
Searching...
No Matches
adJointImpl.hpp
Go to the documentation of this file.
1/** \file dHODataOperators.hpp
2 * \brief Operators managing HO geometry derivatives
3
4*/
5
6#ifndef __ADJOINT_IMPL_HPP__
7#define __ADJOINT_IMPL_HPP__
8
9namespace MoFEM {
10
11//! [declarations of templates]
12
13template <int SPACE_DIM, IntegrationType I, typename OpBase>
15
16//! [declarations of templates]
17
18//! [definitions of templates]
19
20template <int SPACE_DIM, typename OpBase>
22 : public OpBase {
23
24 OpGetCoFactorImpl(boost::shared_ptr<MatrixDouble> jac_ptr,
25 boost::shared_ptr<MatrixDouble> diff_jac_ptr,
26 boost::shared_ptr<VectorDouble> diff_out_ptr
27
28 )
29 : OpBase(NOSPACE, OpBase::OPSPACE), jacPtr(jac_ptr),
30 diffJacPtr(diff_jac_ptr), diffOutPtr(diff_out_ptr) {}
31
32 MoFEMErrorCode doWork(int side, EntityType type,
34
35protected:
36 boost::shared_ptr<MatrixDouble> jacPtr;
37 boost::shared_ptr<MatrixDouble> diffJacPtr;
38 boost::shared_ptr<VectorDouble> diffOutPtr;
39};
40
41//! [definitions of templates]
42
43//! [implementations of templates functions]
44
45template <int SPACE_DIM, typename OpBase>
48 int side, EntityType type, EntitiesFieldData::EntData &data) {
50 auto nb_integration_pts = OpBase::getGaussPts().size2();
51 diffOutPtr->resize(nb_integration_pts, false);
54 auto t_jac = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*jacPtr);
55 auto t_diff_jac = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*diffJacPtr);
56 auto t_diff_out = getFTensor0FromVec(*diffOutPtr);
57 for (int gg = 0; gg != nb_integration_pts; gg++) {
58 auto t_det = determinantTensor(t_jac);
60 CHKERR invertTensor(t_jac, t_det, t_inv_jac);
61 // note that integration weight is
62 t_diff_out = (t_inv_jac(j, i) * t_diff_jac(i, j)) * t_det;
63 ++t_jac;
64 ++t_diff_jac;
65 ++t_diff_out;
66 }
68}
69
70//! [implementations of templates functions]
71
72}; // namespace MoFEM
73
74#endif
#define FTENSOR_INDEX(DIM, I)
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.
IntegrationType
Form integrator integration types.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
static MoFEMErrorCode invertTensor(FTensor::Tensor2< T1, DIM, DIM > &t, T2 &det, FTensor::Tensor2< T3, DIM, DIM > &inv_t)
FTensor::Tensor2< FTensor::PackPtr< double *, 1 >, Tensor_Dim1, Tensor_Dim2 > getFTensor2FromMat(MatrixDouble &data)
Get tensor rank 2 (matrix) form data matrix.
static auto determinantTensor(FTensor::Tensor2< T, DIM, DIM > &t)
Calculate the determinant of a tensor of rank DIM.
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Data on single entity (This is passed as argument to DataOperator::doWork)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
OpGetCoFactorImpl(boost::shared_ptr< MatrixDouble > jac_ptr, boost::shared_ptr< MatrixDouble > diff_jac_ptr, boost::shared_ptr< VectorDouble > diff_out_ptr)
[declarations of templates]