v0.16.3
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
MatOps::MatNeohookean< DIM > Struct Template Reference
Inheritance diagram for MatOps::MatNeohookean< DIM >:
[legend]
Collaboration diagram for MatOps::MatNeohookean< 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 &m_field, const std::string &block_name, int block_id, 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::UserDataOperatorcreateOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update) override
 
ForcesAndSourcesCore::UserDataOperatorcreateOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)
 
ForcesAndSourcesCore::UserDataOperatorcreateOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)
 
- Public Member Functions inherited from MatOps::MatElastic
 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 C10 = 1
 
double K = 1
 
std::vector< doublecommandLineParameters
 

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< MatOpsDatamatOpsDataPtr
 
- Static Public Attributes inherited from MatOps::MatElastic
static bool useDeformationGradient
 

Detailed Description

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

Definition at line 14 of file MatNeohookean.cpp.

Member Typedef Documentation

◆ A

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

Definition at line 17 of file MatNeohookean.cpp.

Member Function Documentation

◆ addBlockParameters()

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

Reimplemented from MatOps::PhysicalEquations.

Definition at line 71 of file MatNeohookean.cpp.

73 {
75
76 const auto json_params =
77 m_field.getInterface<JsonConfigManager>()->getParamsFromBlockset(
78 "MAT_NEOHOOKEAN", block_id);
79 if (!json_params.empty() && (json_params.size() != 2 ||
80 json_params.find("c10") == json_params.end() ||
81 json_params.find("k") == json_params.end())) {
82 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
83 "Neohookean JSON block %s needs exactly C10 and K attributes",
84 block_name.c_str());
85 }
86
87 if (block_data.size() < 2) {
88 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
89 "Neohookean block %s has %d attributes; expected C10 and K",
90 block_name.c_str(), static_cast<int>(block_data.size()));
91 }
92 std::vector<double> params = {block_data[0], block_data[1]};
93
94 A::paramVecByRange.push_back({block_entities, params});
95
96 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "MatBlock for Neohookean")
97 << block_name << " C10 = " << params[0] << " K = " << params[1];
98
100 }
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#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
#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
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ getOptions()

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

Implements MatOps::PhysicalEquations.

Definition at line 19 of file MatNeohookean.cpp.

19 {
21
22 MOFEM_LOG_CHANNEL("WORLD");
23
24 if (!A::paramVecByRange.empty()) {
26 }
27
28 PetscOptionsBegin(PETSC_COMM_WORLD, "neo_hookean_", "", "none");
29 CHKERR PetscOptionsScalar("-c10", "C10", "", C10, &C10, PETSC_NULLPTR);
30 CHKERR PetscOptionsScalar("-K", "Bulk modulus K", "", K, &K,
31 PETSC_NULLPTR);
32 PetscOptionsEnd();
33
34 std::string block_name = "MAT_NEOHOOKEAN";
35
36 for (auto &m :
37
38 m_field_ptr->getInterface<MeshsetsManager>()->
39
40 getCubitMeshsetPtr(
41 std::regex((boost::format("%s(.*)") % block_name).str()))
42
43 ) {
44
45 std::vector<double> block_data;
46 CHKERR m->getAttributes(block_data);
47 auto get_block_ents = [&]() {
48 Range ents;
49 CHK_MOAB_THROW(m_field_ptr->get_moab().get_entities_by_handle(
50 m->meshset, ents, true),
51 "can not get block entities");
52 return ents;
53 };
54
55 CHKERR addBlockParameters(*m_field_ptr, m->getName(),
56 m->getMeshsetId(), get_block_ents(),
57 block_data);
58 }
59
60 if (A::paramVecByRange.empty()) {
62 MOFEM_TAG_AND_LOG("WORLD", Sev::inform,
63 "Command line Neohookean parameters")
64 << "C10 = " << C10 << " K = " << K;
65 }
66
68 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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 &m_field, const std::string &block_name, int block_id, const Range &block_entities, const std::vector< double > &block_data) override
std::vector< double > commandLineParameters
virtual moab::Interface & get_moab()=0

◆ recordTape()

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

Implements MatOps::PhysicalEquations.

Definition at line 122 of file MatNeohookean.cpp.

122 {
124
125 A::matOpsDataPtr->insertCommonData("grad", MatrixDouble());
126 A::matOpsDataPtr->insertCommonData("P", MatrixDouble());
127 A::matOpsDataPtr->insertCommonData("P_dF", MatrixDouble());
128
129 A::matOpsDataPtr->insertActiveData("F", MatrixDouble());
130 A::matOpsDataPtr->insertDependentData("P", MatrixDouble());
131 A::matOpsDataPtr->insertDependentDerivativesData("P_dF", MatrixDouble());
132
133 A::matOpsDataPtr->getActiveDataPtr("F")->resize(DIM, DIM, false);
134 A::matOpsDataPtr->getDependentDataPtr("P")->resize(DIM, DIM, false);
135
136 auto t_F = getFTensor2FromPtr<DIM, DIM>(
137 A::matOpsDataPtr->getActiveDataPtr("F")->data().data());
138 auto t_P = getFTensor2FromPtr<DIM, DIM>(
139 A::matOpsDataPtr->getDependentDataPtr("P")->data().data());
140
142
143 FTENSOR_INDEX(DIM, i);
144 FTENSOR_INDEX(DIM, j);
145 FTENSOR_INDEX(DIM, I);
146 FTENSOR_INDEX(DIM, J);
147
148 t_F(i, J) = 0;
149
152
153 adouble det_aF;
155
156 trace_on(A::tAg);
157 auto p_c10 = mkparam(C10);
158 auto p_K = mkparam(K);
159
160 ta_F(i, J) <<= t_F(i, J);
161 // assume that gradient from approximated displacement, that why we add diagonal
163 ta_F(i, J) += t_kd(i, J);
164 }
165
166 det_aF = determinantTensor(ta_F);
167 CHKERR invertTensor(ta_F, det_aF, ta_invF);
168
169 ta_P(i, I) = 2. * p_c10 * (ta_F(i, I) - ta_invF(i, I)) +
170 p_K * log(det_aF) * ta_invF(i, I);
171
172 ta_P(i, I) >>= t_P(i, I);
173
174 trace_off();
175
177 }
#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
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
boost::shared_ptr< MatOpsData > matOpsDataPtr
Definition MatOps.hpp:176

◆ setParams()

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

Implements MatOps::PhysicalEquations.

Definition at line 102 of file MatNeohookean.cpp.

102 {
103 (void)gg;
104 const auto ent = fe_ptr->getFEEntityHandle();
105 for (auto &[range, param_vec] : A::paramVecByRange) {
106 if (std::find(range.begin(), range.end(), ent) != range.end()) {
107 set_param_vec(A::tAg, param_vec.size(), param_vec.data());
108 return 0;
109 }
110 }
111 // command line overrides block parameters
112 if (!commandLineParameters.empty()) {
113 set_param_vec(A::tAg, commandLineParameters.size(),
114 commandLineParameters.data());
115 return 0;
116 }
117 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
118 "Neohookean material parameters not found for entity %lu",
119 static_cast<unsigned long>(ent));
120 }
MatElasticImpl< DIM > A

Member Data Documentation

◆ C10

template<int DIM>
double MatOps::MatNeohookean< DIM >::C10 = 1
protected

Definition at line 180 of file MatNeohookean.cpp.

◆ commandLineParameters

template<int DIM>
std::vector<double> MatOps::MatNeohookean< DIM >::commandLineParameters
protected

Definition at line 182 of file MatNeohookean.cpp.

◆ K

template<int DIM>
double MatOps::MatNeohookean< DIM >::K = 1
protected

Definition at line 181 of file MatNeohookean.cpp.


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