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

Public Types

using A = M
 

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
 

Static Public Member Functions

static double getShearModulus (const double c10)
 
static double getAbaqusD1 (const double K)
 
static MoFEMErrorCode validateMaterialParameters (const double c10, const double K, const char *source)
 

Protected Attributes

double C10 = 1
 
double K = 2
 
std::vector< double > defaultMaterialParameters = {C10, K}
 
std::vector< double > commandLineParameters
 

Detailed Description

template<typename M>
struct MatOps::MatNeohookeanGeneric< M >

Definition at line 25 of file MatNeohookean.cpp.

Member Typedef Documentation

◆ A

template<typename M >
using MatOps::MatNeohookeanGeneric< M >::A = M

Definition at line 26 of file MatNeohookean.cpp.

Member Function Documentation

◆ addBlockParameters()

template<typename M >
MoFEMErrorCode MatOps::MatNeohookeanGeneric< M >::addBlockParameters ( MoFEM::Interface &  m_field,
const std::string &  block_name,
int  block_id,
const Range &  block_entities,
const std::vector< double > &  block_data 
)
inlineoverride

Definition at line 112 of file MatNeohookean.cpp.

114 {
116
117 const auto json_params =
118 m_field.getInterface<JsonConfigManager>()->getParamsFromBlockset(
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()) {
125 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
126 "Neohookean JSON block %s needs exactly C10 and K attributes",
127 block_name.c_str());
128 }
129 params = {json_params.at("c10"), json_params.at("k")};
130 } else {
131 if (block_data.size() < 2) {
132 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
133 "Neohookean block %s has %d attributes; expected C10 and K",
134 block_name.c_str(), static_cast<int>(block_data.size()));
135 }
136 params = {block_data[0], block_data[1]};
137 }
138
139 CHKERR validateMaterialParameters(params[0], params[1], block_name.c_str());
140
141 A::paramVecByRange.push_back({block_entities, params});
142
143 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "MatBlock for Neohookean")
144 << block_name << " C10 = " << params[0] << " K = " << params[1]
145 << " mu = " << getShearModulus(params[0])
146 << " Abaqus D1 = " << getAbaqusD1(params[1]);
147
149 }
#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()
#define CHKERR
Inline error check.
static double getShearModulus(const double c10)
static MoFEMErrorCode validateMaterialParameters(const double c10, const double K, const char *source)
static double getAbaqusD1(const double K)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ getAbaqusD1()

template<typename M >
static double MatOps::MatNeohookeanGeneric< M >::getAbaqusD1 ( const double  K)
inlinestatic

Definition at line 31 of file MatNeohookean.cpp.

31{ return 2. / K; }

◆ getOptions()

template<typename M >
MoFEMErrorCode MatOps::MatNeohookeanGeneric< M >::getOptions ( MoFEM::Interface *  m_field_ptr = nullptr)
inlineoverride

Definition at line 50 of file MatNeohookean.cpp.

50 {
52
53 MOFEM_LOG_CHANNEL("WORLD");
54
55 if (!A::paramVecByRange.empty()) {
56 for (const auto &[range, parameters] : A::paramVecByRange) {
57 (void)range;
58 if (parameters.size() != 2) {
59 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
60 "Neohookean material range needs exactly C10 and K");
61 }
62 CHKERR validateMaterialParameters(parameters[0], parameters[1],
63 "preconfigured material range");
64 }
66 }
67
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);
71 PetscOptionsEnd();
72 CHKERR validateMaterialParameters(C10, K, "command-line parameters");
74
75 std::string block_name = "MAT_NEOHOOKEAN";
76
77 for (auto &m :
78
79 m_field_ptr->getInterface<MeshsetsManager>()->
80
81 getCubitMeshsetPtr(
82 std::regex((boost::format("%s(.*)") % block_name).str()))
83
84 ) {
85
86 std::vector<double> block_data;
87 CHKERR m->getAttributes(block_data);
88 auto get_block_ents = [&]() {
89 Range ents;
90 CHK_MOAB_THROW(m_field_ptr->get_moab().get_entities_by_handle(
91 m->meshset, ents, true),
92 "can not get block entities");
93 return ents;
94 };
95
96 CHKERR addBlockParameters(*m_field_ptr, m->getName(), m->getMeshsetId(),
97 get_block_ents(), block_data);
98 }
99
100 if (A::paramVecByRange.empty()) {
102 MOFEM_TAG_AND_LOG("WORLD", Sev::inform,
103 "Command line Neohookean parameters")
104 << "C10 = " << C10 << " K = " << K << " mu = " << getShearModulus(C10)
105 << " Abaqus D1 = " << getAbaqusD1(K);
106 }
107
109 }
#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 MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'm', 3 > m
std::vector< double > commandLineParameters
std::vector< double > defaultMaterialParameters
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
virtual moab::Interface & get_moab()=0

◆ getShearModulus()

template<typename M >
static double MatOps::MatNeohookeanGeneric< M >::getShearModulus ( const double  c10)
inlinestatic

Definition at line 29 of file MatNeohookean.cpp.

29{ return 2. * c10; }

◆ validateMaterialParameters()

template<typename M >
static MoFEMErrorCode MatOps::MatNeohookeanGeneric< M >::validateMaterialParameters ( const double  c10,
const double  K,
const char *  source 
)
inlinestatic

Definition at line 33 of file MatNeohookean.cpp.

35 {
37 if (!std::isfinite(c10) || c10 <= 0.) {
38 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
39 "Neohookean C10 must be finite and positive in %s", source);
40 }
41 if (!std::isfinite(K) || K <= 0.) {
42 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
43 "Neohookean bulk modulus K must be finite and positive in %s "
44 "(received C10=%.16g, K=%.16g)",
45 source, c10, K);
46 }
48 }
@ MOFEM_INVALID_DATA
Definition definitions.h:36

Member Data Documentation

◆ C10

template<typename M >
double MatOps::MatNeohookeanGeneric< M >::C10 = 1
protected

Definition at line 152 of file MatNeohookean.cpp.

◆ commandLineParameters

template<typename M >
std::vector<double> MatOps::MatNeohookeanGeneric< M >::commandLineParameters
protected

Definition at line 155 of file MatNeohookean.cpp.

◆ defaultMaterialParameters

template<typename M >
std::vector<double> MatOps::MatNeohookeanGeneric< M >::defaultMaterialParameters = {C10, K}
protected

Definition at line 154 of file MatNeohookean.cpp.

154{C10, K};

◆ K

template<typename M >
double MatOps::MatNeohookeanGeneric< M >::K = 2
protected

Definition at line 153 of file MatNeohookean.cpp.


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