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

Public Types

using A = MatElasticImpl< DIM >
 
- Public Types inherited from MatOps::PhysicalEquations
using HookFunction = std::function< MoFEMErrorCode(boost::shared_ptr< MatOpsData >, int, EntityHandle, int)>
 

Public Member Functions

MoFEMErrorCode getOptions (MoFEM::Interface *m_field_ptr=nullptr) override
 
MoFEMErrorCode addBlockParameters (MoFEM::Interface &, const std::string &block_name, int, const Range &block_entities, const std::vector< double > &block_data) override
 
MoFEMErrorCode setParams (FEMethod *fe_ptr, int gg) override
 
MoFEMErrorCode recordTape () override
 
- Public Member Functions inherited from MatOps::MatElasticImpl< DIM >
ForcesAndSourcesCore::UserDataOperator * createOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update) override
 
ForcesAndSourcesCore::UserDataOperator * createOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)
 
ForcesAndSourcesCore::UserDataOperator * createOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)
 
- Public Member Functions inherited from MatOps::MatElastic
MatOpsData::MatrixPtr getEnergyDensityPtr () const
 
- Public Member Functions inherited from MatOps::MatPiolaResponse
 PhysicalEquations ()=delete
 
 PhysicalEquations (boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag, boost::shared_ptr< std::map< int, Range > > tag_vs_range_ptr=nullptr)
 
- Public Member Functions inherited from MatOps::PhysicalEquations
 PhysicalEquations ()=delete
 
 PhysicalEquations (boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag, boost::shared_ptr< std::map< int, Range > > tag_vs_range_ptr=nullptr)
 
virtual ~PhysicalEquations ()=default
 
virtual MoFEMErrorCode evaluateVariable (int tag, EntityHandle entity, int gg)
 
virtual MoFEMErrorCode evaluateDerivatives (int tag, EntityHandle entity, int gg)
 
virtual MoFEMErrorCode updateState (int tag, EntityHandle entity, int gg)
 

Protected Attributes

double alpha = 1
 
double beta = 1
 
double lambda = 1
 
double epsilon = 2
 
std::vector< double > defaultMaterialParameters
 

Additional Inherited Members

- Public Attributes inherited from MatOps::PhysicalEquations
HookFunction hookEvaluateVariable = AdolCEvaluation::evaluateVariable
 
HookFunction hookEvaluateDerivatives = AdolCEvaluation::evaluateDerivatives
 
HookFunction hookUpdateState = AdolCEvaluation::evaluateVariable
 
int tAg
 
boost::shared_ptr< std::map< int, Range > > tagVsRangePtr
 
std::vector< std::pair< Range, std::vector< double > > > paramVecByRange
 
boost::shared_ptr< MatOpsData > matOpsDataPtr
 
- Static Public Attributes inherited from MatOps::MatElastic
static constexpr auto energyDensityDataName = "energy"
 
- Static Public Attributes inherited from MatOps::MatPiolaResponse
static bool useDeformationGradient
 Otherwise the displacement gradient is supplied and I is added.
 

Detailed Description

template<int DIM>
struct MatOps::MatMooneyRivlinWriggersEq63< DIM >

Definition at line 15 of file MatMooneyRivlinWriggersEq63.cpp.

Member Typedef Documentation

◆ A

template<int DIM>
using MatOps::MatMooneyRivlinWriggersEq63< DIM >::A = MatElasticImpl<DIM>

Definition at line 18 of file MatMooneyRivlinWriggersEq63.cpp.

Member Function Documentation

◆ addBlockParameters()

template<int DIM>
MoFEMErrorCode MatOps::MatMooneyRivlinWriggersEq63< DIM >::addBlockParameters ( MoFEM::Interface &  ,
const std::string &  block_name,
int  ,
const Range &  block_entities,
const std::vector< double > &  block_data 
)
inlineoverridevirtual

Reimplemented from MatOps::PhysicalEquations.

Definition at line 76 of file MatMooneyRivlinWriggersEq63.cpp.

78 {
80
81 if (block_data.size() < 4) {
83 "Expected that block has four attributes (alpha, "
84 "beta, lambda, epsilon), but given " +
85 std::to_string(block_data.size()));
86 }
87 if (!std::isfinite(block_data[3]) ||
88 std::abs(block_data[3]) <=
89 std::sqrt(std::numeric_limits<double>::epsilon()))
90 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
91 "MAT_MOONEY_RIVLIN epsilon must be finite and nonzero");
92 std::vector<double> params = {block_data[0], block_data[1], block_data[2],
93 block_data[3]};
94
95 A::paramVecByRange.push_back({block_entities, params});
96
97 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "MatBlock for Mooney-Rivlin")
98 << block_name << " alpha = " << params[0] << " beta = " << params[1]
99 << " lambda = " << params[2] << " epsilon = " << params[3];
100
102 }
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#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_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_INVALID_DATA
Definition definitions.h:36
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
std::vector< std::pair< Range, std::vector< double > > > paramVecByRange
Definition MatOps.hpp:174

◆ getOptions()

template<int DIM>
MoFEMErrorCode MatOps::MatMooneyRivlinWriggersEq63< DIM >::getOptions ( MoFEM::Interface *  m_field_ptr = nullptr)
inlineoverridevirtual

Implements MatOps::PhysicalEquations.

Definition at line 20 of file MatMooneyRivlinWriggersEq63.cpp.

20 {
22
23 MOFEM_LOG_CHANNEL("WORLD");
24
25 PetscOptionsBegin(PETSC_COMM_WORLD, "mooneyrivlin_", "", "none");
26 CHKERR PetscOptionsScalar("-alpha", "Alpha", "", alpha, &alpha,
27 PETSC_NULLPTR);
28 CHKERR PetscOptionsScalar("-beta", "Beta", "", beta, &beta, PETSC_NULLPTR);
29
30 CHKERR PetscOptionsScalar("-lambda", "Lambda", "", lambda, &lambda,
31 PETSC_NULLPTR);
32
33 CHKERR PetscOptionsScalar("-epsilon", "Epsilon", "", epsilon, &epsilon,
34 PETSC_NULLPTR);
35 PetscOptionsEnd();
36
37 if (!std::isfinite(epsilon) ||
38 std::abs(epsilon) <= std::sqrt(std::numeric_limits<double>::epsilon()))
39 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
40 "Mooney-Rivlin epsilon must be finite and nonzero");
41
42 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "Default Mooney-Rivlin parameters:")
43 << " alpha = " << alpha << " beta = " << beta << " lambda = " << lambda
44 << " epsilon = " << epsilon;
46
47 std::string block_name = "MAT_MOONEY_RIVLIN";
48
49 for (auto &m :
50
51 m_field_ptr->getInterface<MeshsetsManager>()->
52
53 getCubitMeshsetPtr(
54 std::regex((boost::format("%s(.*)") % block_name).str()))
55
56 ) {
57
58 std::vector<double> block_data;
59 CHKERR m->getAttributes(block_data);
60 auto get_block_ents = [&]() {
61 Range ents;
62 CHK_MOAB_THROW(m_field_ptr->get_moab().get_entities_by_handle(
63 m->meshset, ents, true),
64 "can not get block entities");
65 return ents;
66 };
67
68 CHKERR addBlockParameters(*m_field_ptr, m->getName(), m->getMeshsetId(),
69 get_block_ents(), block_data);
70 }
71
73 };
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
#define CHKERR
Inline error check.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'm', 3 > m
MoFEMErrorCode addBlockParameters(MoFEM::Interface &, const std::string &block_name, int, const Range &block_entities, const std::vector< double > &block_data) override
virtual moab::Interface & get_moab()=0

◆ recordTape()

template<int DIM>
MoFEMErrorCode MatOps::MatMooneyRivlinWriggersEq63< DIM >::recordTape ( )
inlineoverridevirtual

Implements MatOps::PhysicalEquations.

Definition at line 118 of file MatMooneyRivlinWriggersEq63.cpp.

118 {
120
121 A::matOpsDataPtr->insertCommonData("grad", MatrixDouble());
122 A::matOpsDataPtr->insertCommonData("P", MatrixDouble());
123 A::matOpsDataPtr->insertCommonData("P_dF", MatrixDouble());
124
125 A::matOpsDataPtr->insertActiveData("F", MatrixDouble());
126 A::matOpsDataPtr->insertDependentData("P", MatrixDouble());
127 A::matOpsDataPtr->insertDependentData("energy", MatrixDouble());
128 A::matOpsDataPtr->insertDependentDerivativesData("P_dF", MatrixDouble());
129 A::matOpsDataPtr->insertDependentDerivativesData("energy_dF",
130 MatrixDouble());
131
132 A::matOpsDataPtr->getActiveDataPtr("F")->resize(DIM, DIM, false);
133 A::matOpsDataPtr->getDependentDataPtr("P")->resize(DIM, DIM, false);
134 A::matOpsDataPtr->getDependentDataPtr("energy")->resize(1, 1, false);
135 A::matOpsDataPtr->getDependentDerivativesDataPtr("energy_dF")
136 ->resize(1, DIM * DIM, false);
137
138 auto t_F = getFTensor2FromPtr<DIM, DIM>(
139 A::matOpsDataPtr->getActiveDataPtr("F")->data().data());
140 auto t_P = getFTensor2FromPtr<DIM, DIM>(
141 A::matOpsDataPtr->getDependentDataPtr("P")->data().data());
142 auto energy_ptr = A::matOpsDataPtr->getDependentDataPtr("energy");
143
145
146 FTENSOR_INDEX(DIM, i);
147 FTENSOR_INDEX(DIM, j);
148 FTENSOR_INDEX(DIM, I);
149 FTENSOR_INDEX(DIM, J);
150 FTENSOR_INDEX(DIM, k);
151 FTENSOR_INDEX(DIM, K);
152
153 t_F(i, J) = 0;
154
160 adouble ta_Bj, A, B, ta_energy;
161
162 adouble det_aF;
164
165 trace_on(A::tAg);
166 auto p_alpha = mkparam(alpha);
167 auto p_beta = mkparam(beta);
168 auto p_lambda = mkparam(lambda);
169 auto p_epsilon = mkparam(epsilon);
170 const auto ta_alpha = 1 * p_alpha;
171 const auto ta_beta = 1 * p_beta;
172 const auto ta_lambda = 1 * p_lambda;
173 const auto ta_epsilon = 1 * p_epsilon;
174
175 ta_F(i, J) <<= t_F(i, J);
176 // assume that gradient from approximated displacement, that why we add diagonal
178 ta_F(i, J) += t_kd(i, J);
179 }
180
181 det_aF = determinantTensor(ta_F);
182 CHKERR invertTensor(ta_F, det_aF, ta_invF);
183
184 ta_Cof(i, I) = det_aF * ta_invF(I, i);
185
186 A = ta_F(k, K) * ta_F(k, K);
187 B = ta_Cof(k, K) * ta_Cof(k, K);
188
189 ta_BF(i, I) = 4 * ta_alpha * (A * ta_F(i, I));
190 ta_BCof(i, I) = 4 * ta_beta * (B * ta_Cof(i, I));
191 ta_Bj = (-12 * ta_alpha - 24 * ta_beta) / det_aF +
192 0.5 * (ta_lambda / ta_epsilon) *
193 (pow(det_aF, ta_epsilon - 1) - pow(det_aF, -ta_epsilon - 1));
194
195 ta_P(i, I) = ta_BF(i, I);
196 ta_P(i, I) += (levi_civita(i, j, k) * ta_BCof(j, J)) *
197 (levi_civita(I, J, K) * ta_F(k, K));
198 ta_P(i, I) += ta_Cof(i, I) * ta_Bj;
199
200 ta_energy = ta_alpha * A * A + ta_beta * B * B +
201 (-12 * ta_alpha - 24 * ta_beta) * log(det_aF) +
202 0.5 * (ta_lambda / (ta_epsilon * ta_epsilon)) *
203 (pow(det_aF, ta_epsilon) + pow(det_aF, -ta_epsilon) - 2.) -
204 (DIM * DIM) * (ta_alpha + ta_beta);
205
206 // Set dependent variables to ADOL-C
207 ta_P(i, I) >>= t_P(i, I);
208 ta_energy >>= (*energy_ptr)(0, 0);
209
210 trace_off();
211
213 }
#define FTENSOR_INDEX(DIM, I)
Kronecker Delta class.
constexpr auto t_kd
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'J', DIM1 > J
Definition level_set.cpp:30
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
constexpr std::enable_if<(Dim0<=2 &&Dim1<=2), Tensor2_Expr< Levi_Civita< T >, T, Dim0, Dim1, i, j > >::type levi_civita(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
levi_civita functions to make for easy adhoc use
UBlasMatrix< double > MatrixDouble
Definition Types.hpp:77
static MoFEMErrorCode invertTensor(FTensor::Tensor2< T1, DIM, DIM > &t, T2 &det, FTensor::Tensor2< T3, DIM, DIM > &inv_t)
static auto determinantTensor(FTensor::Tensor2< T, DIM, DIM > &t)
Calculate the determinant of a tensor of rank DIM.
constexpr IntegrationType I
static bool useDeformationGradient
Otherwise the displacement gradient is supplied and I is added.
Definition MatOps.hpp:189
boost::shared_ptr< MatOpsData > matOpsDataPtr
Definition MatOps.hpp:176

◆ setParams()

template<int DIM>
MoFEMErrorCode MatOps::MatMooneyRivlinWriggersEq63< DIM >::setParams ( FEMethod *  fe_ptr,
int  gg 
)
inlineoverridevirtual

Implements MatOps::PhysicalEquations.

Definition at line 104 of file MatMooneyRivlinWriggersEq63.cpp.

104 {
105 (void)gg;
106 const auto ent = fe_ptr->getFEEntityHandle();
107 for (auto &[range, param_vec] : A::paramVecByRange) {
108 if (std::find(range.begin(), range.end(), ent) != range.end()) {
109 set_param_vec(A::tAg, param_vec.size(), param_vec.data());
110 return 0;
111 }
112 }
113 set_param_vec(A::tAg, defaultMaterialParameters.size(),
115 return 0;
116 }

Member Data Documentation

◆ alpha

template<int DIM>
double MatOps::MatMooneyRivlinWriggersEq63< DIM >::alpha = 1
protected

Definition at line 216 of file MatMooneyRivlinWriggersEq63.cpp.

◆ beta

template<int DIM>
double MatOps::MatMooneyRivlinWriggersEq63< DIM >::beta = 1
protected

Definition at line 217 of file MatMooneyRivlinWriggersEq63.cpp.

◆ defaultMaterialParameters

template<int DIM>
std::vector<double> MatOps::MatMooneyRivlinWriggersEq63< DIM >::defaultMaterialParameters
protected
Initial value:

Definition at line 220 of file MatMooneyRivlinWriggersEq63.cpp.

220 {alpha, beta, lambda,
221 epsilon};

◆ epsilon

template<int DIM>
double MatOps::MatMooneyRivlinWriggersEq63< DIM >::epsilon = 2
protected

Definition at line 219 of file MatMooneyRivlinWriggersEq63.cpp.

◆ lambda

template<int DIM>
double MatOps::MatMooneyRivlinWriggersEq63< DIM >::lambda = 1
protected

Definition at line 218 of file MatMooneyRivlinWriggersEq63.cpp.


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