v0.16.0
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< doubledefaultMaterialParameters = {C10, K}
 
std::vector< doublecommandLineParameters
 

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 119 of file MatNeohookean.cpp.

121 {
123
124 const auto json_params =
125 m_field.getInterface<JsonConfigManager>()->getParamsFromBlockset(
126 "MAT_NEOHOOKEAN", block_id);
127 std::vector<double> params;
128 if (!json_params.empty()) {
129 if (json_params.size() != 2 ||
130 json_params.find("c10") == json_params.end() ||
131 json_params.find("k") == json_params.end()) {
132 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
133 "Neohookean JSON block %s needs exactly C10 and K attributes",
134 block_name.c_str());
135 }
136 params = {json_params.at("c10"), json_params.at("k")};
137 } else {
138 if (block_data.size() < 2) {
139 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
140 "Neohookean block %s has %d attributes; expected C10 and K",
141 block_name.c_str(), static_cast<int>(block_data.size()));
142 }
143 params = {block_data[0], block_data[1]};
144 }
145
146 CHKERR validateMaterialParameters(params[0], params[1],
147 block_name.c_str());
148
149 A::paramVecByRange.push_back({block_entities, params});
150
151 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "MatBlock for Neohookean")
152 << block_name << " C10 = " << params[0] << " K = " << params[1]
153 << " mu = " << getShearModulus(params[0])
154 << " Abaqus D1 = " << getAbaqusD1(params[1]);
155
157 }
#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 33 of file MatNeohookean.cpp.

33 {
34 return 2. / K;
35 }

◆ getOptions()

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

Definition at line 54 of file MatNeohookean.cpp.

54 {
56
57 MOFEM_LOG_CHANNEL("WORLD");
58
59 if (!A::paramVecByRange.empty()) {
60 for (const auto &[range, parameters] : A::paramVecByRange) {
61 (void)range;
62 if (parameters.size() != 2) {
63 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
64 "Neohookean material range needs exactly C10 and K");
65 }
66 CHKERR validateMaterialParameters(parameters[0], parameters[1],
67 "preconfigured material range");
68 }
70 }
71
72 PetscOptionsBegin(PETSC_COMM_WORLD, "neo_hookean_", "", "none");
73 CHKERR PetscOptionsScalar("-c10", "C10", "", C10, &C10, PETSC_NULLPTR);
74 CHKERR PetscOptionsScalar("-K", "Bulk modulus K", "", K, &K,
75 PETSC_NULLPTR);
76 PetscOptionsEnd();
77 CHKERR validateMaterialParameters(C10, K, "command-line parameters");
79
80 std::string block_name = "MAT_NEOHOOKEAN";
81
82 for (auto &m :
83
84 m_field_ptr->getInterface<MeshsetsManager>()->
85
86 getCubitMeshsetPtr(
87 std::regex((boost::format("%s(.*)") % block_name).str()))
88
89 ) {
90
91 std::vector<double> block_data;
92 CHKERR m->getAttributes(block_data);
93 auto get_block_ents = [&]() {
94 Range ents;
95 CHK_MOAB_THROW(m_field_ptr->get_moab().get_entities_by_handle(
96 m->meshset, ents, true),
97 "can not get block entities");
98 return ents;
99 };
100
101 CHKERR addBlockParameters(*m_field_ptr, m->getName(),
102 m->getMeshsetId(), get_block_ents(),
103 block_data);
104 }
105
106 if (A::paramVecByRange.empty()) {
108 MOFEM_TAG_AND_LOG("WORLD", Sev::inform,
109 "Command line Neohookean parameters")
110 << "C10 = " << C10 << " K = " << K
111 << " mu = " << getShearModulus(C10)
112 << " Abaqus D1 = " << getAbaqusD1(K);
113 }
114
116 }
#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 {
30 return 2. * c10;
31 }

◆ validateMaterialParameters()

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

Definition at line 37 of file MatNeohookean.cpp.

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

Member Data Documentation

◆ C10

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

Definition at line 160 of file MatNeohookean.cpp.

◆ commandLineParameters

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

Definition at line 163 of file MatNeohookean.cpp.

◆ defaultMaterialParameters

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

Definition at line 162 of file MatNeohookean.cpp.

162{C10, K};

◆ K

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

Definition at line 161 of file MatNeohookean.cpp.


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