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

Member Typedef Documentation

◆ A

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

Definition at line 14 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 100 of file MatNeohookean.cpp.

102 {
104
105 const auto json_params =
106 m_field.getInterface<JsonConfigManager>()->getParamsFromBlockset(
107 "MAT_NEOHOOKEAN", block_id);
108 std::vector<double> params;
109 if (!json_params.empty()) {
110 if (json_params.size() != 2 ||
111 json_params.find("c10") == json_params.end() ||
112 json_params.find("k") == json_params.end()) {
113 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
114 "Neohookean JSON block %s needs exactly C10 and K attributes",
115 block_name.c_str());
116 }
117 params = {json_params.at("c10"), json_params.at("k")};
118 } else {
119 if (block_data.size() < 2) {
120 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
121 "Neohookean block %s has %d attributes; expected C10 and K",
122 block_name.c_str(), static_cast<int>(block_data.size()));
123 }
124 params = {block_data[0], block_data[1]};
125 }
126
127 CHKERR validateMaterialParameters(params[0], params[1], block_name.c_str());
128
129 A::paramVecByRange.push_back({block_entities, params});
130
131 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "MatBlock for Neohookean")
132 << block_name << " C10 = " << params[0] << " K = " << params[1]
133 << " mu = " << getShearModulus(params[0])
134 << " Abaqus D1 = " << getAbaqusD1(params[1]);
135
137 }
#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 19 of file MatNeohookean.cpp.

19{ return 2. / K; }

◆ getOptions()

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

Definition at line 38 of file MatNeohookean.cpp.

38 {
40
41 MOFEM_LOG_CHANNEL("WORLD");
42
43 if (!A::paramVecByRange.empty()) {
44 for (const auto &[range, parameters] : A::paramVecByRange) {
45 (void)range;
46 if (parameters.size() != 2) {
47 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
48 "Neohookean material range needs exactly C10 and K");
49 }
50 CHKERR validateMaterialParameters(parameters[0], parameters[1],
51 "preconfigured material range");
52 }
54 }
55
56 PetscOptionsBegin(PETSC_COMM_WORLD, "neo_hookean_", "", "none");
57 CHKERR PetscOptionsScalar("-c10", "C10", "", C10, &C10, PETSC_NULLPTR);
58 CHKERR PetscOptionsScalar("-K", "Bulk modulus K", "", K, &K, PETSC_NULLPTR);
59 PetscOptionsEnd();
60 CHKERR validateMaterialParameters(C10, K, "command-line parameters");
62
63 std::string block_name = "MAT_NEOHOOKEAN";
64
65 for (auto &m :
66
67 m_field_ptr->getInterface<MeshsetsManager>()->
68
69 getCubitMeshsetPtr(
70 std::regex((boost::format("%s(.*)") % block_name).str()))
71
72 ) {
73
74 std::vector<double> block_data;
75 CHKERR m->getAttributes(block_data);
76 auto get_block_ents = [&]() {
77 Range ents;
78 CHK_MOAB_THROW(m_field_ptr->get_moab().get_entities_by_handle(
79 m->meshset, ents, true),
80 "can not get block entities");
81 return ents;
82 };
83
84 CHKERR addBlockParameters(*m_field_ptr, m->getName(), m->getMeshsetId(),
85 get_block_ents(), block_data);
86 }
87
88 if (A::paramVecByRange.empty()) {
90 MOFEM_TAG_AND_LOG("WORLD", Sev::inform,
91 "Command line Neohookean parameters")
92 << "C10 = " << C10 << " K = " << K << " mu = " << getShearModulus(C10)
93 << " Abaqus D1 = " << getAbaqusD1(K);
94 }
95
97 }
std::vector< double > empty
One value per component.
#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 17 of file MatNeohookean.cpp.

17{ 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 21 of file MatNeohookean.cpp.

23 {
25 if (!std::isfinite(c10) || c10 <= 0.) {
26 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
27 "Neohookean C10 must be finite and positive in %s", source);
28 }
29 if (!std::isfinite(K) || K <= 0.) {
30 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
31 "Neohookean bulk modulus K must be finite and positive in %s "
32 "(received C10=%.16g, K=%.16g)",
33 source, c10, K);
34 }
36 }
std::vector< int > source
@ MOFEM_INVALID_DATA
Definition definitions.h:36

Member Data Documentation

◆ C10

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

Definition at line 140 of file MatNeohookean.cpp.

◆ commandLineParameters

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

Definition at line 143 of file MatNeohookean.cpp.

◆ defaultMaterialParameters

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

Definition at line 142 of file MatNeohookean.cpp.

142{C10, K};

◆ K

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

Definition at line 141 of file MatNeohookean.cpp.


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