16 static constexpr auto blockLogTag =
"MatBlock for Neohookean";
21 static constexpr auto defaultLogTag =
"Default Topo Neohookean parameters:";
22 static constexpr auto blockLogTag =
"MatBlock for Topo Neohookean";
37 if (!std::isfinite(c10) || c10 <= 0.) {
39 "Neohookean C10 must be finite and positive in %s",
source);
41 if (!std::isfinite(
K) ||
K <= 0.) {
43 "Neohookean bulk modulus K must be finite and positive in %s "
44 "(received C10=%.16g, K=%.16g)",
55 if (!A::paramVecByRange.empty()) {
56 for (
const auto &[range, parameters] : A::paramVecByRange) {
58 if (parameters.size() != 2) {
60 "Neohookean material range needs exactly C10 and K");
63 "preconfigured material range");
68 PetscOptionsBegin(PETSC_COMM_WORLD,
"neo_hookean_",
"",
"none");
69 CHKERR PetscOptionsScalar(
"-c10",
"C10",
"",
C10, &
C10, PETSC_NULLPTR);
70 CHKERR PetscOptionsScalar(
"-K",
"Bulk modulus K",
"",
K, &
K, PETSC_NULLPTR);
75 std::string block_name =
"MAT_NEOHOOKEAN";
82 std::regex((boost::format(
"%s(.*)") % block_name).str()))
86 std::vector<double> block_data;
87 CHKERR m->getAttributes(block_data);
88 auto get_block_ents = [&]() {
91 m->meshset, ents,
true),
92 "can not get block entities");
97 get_block_ents(), block_data);
100 if (A::paramVecByRange.empty()) {
103 "Command line Neohookean parameters")
113 int block_id,
const Range &block_entities,
114 const std::vector<double> &block_data)
override {
117 const auto json_params =
119 "MAT_NEOHOOKEAN", block_id);
120 std::vector<double> params;
121 if (!json_params.empty()) {
122 if (json_params.size() != 2 ||
123 json_params.find(
"c10") == json_params.end() ||
124 json_params.find(
"k") == json_params.end()) {
126 "Neohookean JSON block %s needs exactly C10 and K attributes",
129 params = {json_params.at(
"c10"), json_params.at(
"k")};
131 if (block_data.size() < 2) {
133 "Neohookean block %s has %d attributes; expected C10 and K",
134 block_name.c_str(),
static_cast<int>(block_data.size()));
136 params = {block_data[0], block_data[1]};
141 A::paramVecByRange.push_back({block_entities, params});
144 << block_name <<
" C10 = " << params[0] <<
" K = " << params[1]
167 if (std::find(range.begin(), range.end(), ent) != range.end()) {
168 set_param_vec(
A::tAg, param_vec.size(), param_vec.data());
175 this->commandLineParameters.data());
179 "Neohookean material parameters not found for entity %lu",
180 static_cast<unsigned long>(ent));
201 ->resize(1, DIM * DIM,
false);
203 auto t_F = getFTensor2FromPtr<DIM, DIM>(
205 auto t_P = getFTensor2FromPtr<DIM, DIM>(
225 auto p_c10 = mkparam(this->
C10);
226 auto p_K = mkparam(this->
K);
228 ta_F(
i,
J) <<= t_F(
i,
J);
235 I1 = ta_F(
i,
I) * ta_F(
i,
I);
236 if constexpr (DIM == 2) {
251 const auto jacobian_to_minus_two_thirds = pow(det_aF, -2. / 3.);
252 ta_P(
i,
I) = 2. * p_c10 * jacobian_to_minus_two_thirds *
253 (ta_F(
i,
I) - (I1 / 3.) * ta_invF(
I,
i)) +
254 p_K * det_aF * (det_aF - 1.) * ta_invF(
I,
i);
256 ta_energy = p_c10 * (jacobian_to_minus_two_thirds * I1 - 3.) +
257 0.5 * p_K * (det_aF - 1.) * (det_aF - 1.);
259 ta_P(
i,
I) >>= t_P(
i,
I);
260 ta_energy >>= (*energy_ptr)(0, 0);
269boost::shared_ptr<PhysicalEquations>
271 boost::shared_ptr<MatOpsData> mat_ops_data_ptr,
int tag) {
272 return boost::make_shared<MatNeohookean<3>>(mat_ops_data_ptr, tag);
276boost::shared_ptr<PhysicalEquations>
278 boost::shared_ptr<MatOpsData> mat_ops_data_ptr,
int tag) {
279 return boost::make_shared<MatNeohookean<2>>(mat_ops_data_ptr, tag);
283boost::shared_ptr<PhysicalEquations>
285 boost::shared_ptr<MatOpsData> mat_ops_data_ptr,
int tag) {
286 return boost::make_shared<MatNeohookean<3>>(mat_ops_data_ptr, tag);
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define FTENSOR_INDEX(DIM, I)
#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 ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'J', DIM1 > J
FTensor::Index< 'j', 3 > j
boost::shared_ptr< PhysicalEquations > createMatOpsPhysicalEquationsPtr< ELASTICITY::NEOHOOKEAN, MODEL_AXISYMMETRIC >(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag)
boost::shared_ptr< PhysicalEquations > createMatOpsPhysicalEquationsPtr< ELASTICITY::NEOHOOKEAN, MODEL_3D >(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag)
boost::shared_ptr< PhysicalEquations > createMatOpsPhysicalEquationsPtr< ELASTICITY::NEOHOOKEAN, MODEL_2D_PLANE_STRAIN >(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
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
FTensor::Index< 'm', 3 > m
static double getShearModulus(const double c10)
std::vector< double > commandLineParameters
std::vector< double > defaultMaterialParameters
static MoFEMErrorCode validateMaterialParameters(const double c10, const double K, const char *source)
MoFEMErrorCode getOptions(MoFEM::Interface *m_field_ptr=nullptr) override
static double getAbaqusD1(const double K)
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
static constexpr auto defaultLogTag
static constexpr auto blockLogTag
static constexpr auto optionsPrefix
MoFEMErrorCode recordTape() override
MoFEMErrorCode setParams(FEMethod *fe_ptr, int gg) override
static bool useDeformationGradient
Otherwise the displacement gradient is supplied and I is added.
std::vector< std::pair< Range, std::vector< double > > > paramVecByRange
boost::shared_ptr< MatOpsData > matOpsDataPtr
Deprecated interface functions.
Structure for user loop methods on finite elements.
EntityHandle getFEEntityHandle() const
Get the entity handle of the current finite element.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.