11#ifndef INP_MATERIALDECK_H
12#define INP_MATERIALDECK_H
92 static const std::vector<Field<MatData>> &
fields() {
93 static const std::vector<Field<MatData>> f = {
119 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
122 std::ostringstream oss;
123 oss << tabS <<
"------- MatData --------" << std::endl << std::endl;
124 oss << tabS <<
"Young's modulus = " <<
d_E << std::endl;
125 oss << tabS <<
"Shear modulus = " <<
d_G << std::endl;
126 oss << tabS <<
"Bulk modulus = " <<
d_K << std::endl;
127 oss << tabS <<
"Poisson ratio = " <<
d_nu << std::endl;
128 oss << tabS <<
"Lame parameter Lambda = " <<
d_lambda << std::endl;
129 oss << tabS <<
"Lame parameter Mu = " <<
d_mu << std::endl;
130 oss << tabS <<
"Critical stress intensity factor = " <<
d_KIc << std::endl;
131 oss << tabS <<
"Critical energy release rate = " <<
d_Gc << std::endl;
132 oss << tabS << std::endl;
143 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
156 double toNu(
double lambda,
double mu) {
return lambda * 0.5 / (lambda + mu); }
164 double toNuEG(
double E,
double G) {
return E * 0.5 / G - 1.; }
172 double toE(
double K,
double nu) {
return K * (3. * (1. - 2. * nu)); }
180 double toK(
double E,
double nu) {
return E / (3. * (1. - 2. * nu)); }
190 return E * nu / ((1. + nu) * (1. - 2. * nu));
200 double toLambdaK(
double K,
double nu) {
return 3. * K * nu / (1. + nu); }
208 double toGE(
double E,
double nu) {
return E / (2. * (1. + nu)); }
216 double toGK(
double K,
double nu) {
217 return 3. * K * (1. - 2. * nu) / (2. * (1. + nu));
228 return lambda * (1. + nu) * (1. - 2. * nu) / nu;
244 double toGc(
double KIc,
double nu,
double E) {
return KIc * KIc / E; }
259 double toKIc(
double Gc,
double nu,
double E) {
return std::sqrt(Gc * E); }
344 double horizon = -1.,
double horizonMeshRatio = -1.,
double density = 1.,
345 double K = 0.,
double G = 0.,
double Gc = 0.,
bool computeParamsFromElastic =
true,
346 size_t influenceFnType = 0)
388 static const std::vector<Field<MaterialDeck>> &
fields() {
389 static const std::vector<Field<MaterialDeck>> f = {
391 "Peridynamic material model"),
394 "Compute_From_Classical",
true,
395 "Derive the bond parameters from the elastic constants"),
397 "Is_Plane_Strain",
false,
398 "Plane strain rather than plane stress", {},
399 [](
const bool &v) {
return v; }),
401 "Peridynamic horizon", {},
402 [](
const double &v) {
return v > 0.; }),
404 "Horizon_Mesh_Ratio", -1.,
405 "Horizon as a multiple of the mesh size",
407 [](
const double &v) {
return v > 0.; }),
410 "Bond parameters given directly rather than derived", {},
411 [](
const std::vector<double> &v) {
return !v.empty(); }),
414 {},
"State parameters given directly rather than derived", {},
415 [](
const std::vector<double> &v) {
return !v.empty(); }),
425 static const std::vector<Field<MaterialDeck>> f = {
427 "Influence function used in the bond force"),
428 field<MaterialDeck, std::vector<double>>(
430 "Parameters of the influence function", {},
431 [](
const std::vector<double> &v) {
return !v.empty(); }),
440 static const std::vector<OneOf> &
groups() {
441 static const std::vector<OneOf> g = {
442 {
"the horizon", {
"Horizon",
"Horizon_Mesh_Ratio"}},
464 const std::vector<std::string> extra = {
"E",
"K",
"G",
"Gc",
465 "Influence_Function"};
495 if (j.find(
"Is_Plane_Strain") == j.end() &&
496 j.find(
"Is_Plain_Strain") != j.end())
501 if (j.find(
"Influence_Function") != j.end())
504 throw std::runtime_error(
505 "Compute_From_Classical is false but Bond_Potential_Params is missing.");
515 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
518 std::ostringstream oss;
519 oss << tabS <<
"------- MaterialDeck --------" << std::endl << std::endl;
523 oss << tabS <<
"Bond potential params = ["
528 oss << tabS <<
"State potential params = ["
533 oss << tabS <<
"Influence function params = ["
539 oss << tabS <<
"State contribution from broken bond enabled = "
542 oss << tabS <<
"Compute parameters from elastic properties = "
545 oss << tabS <<
"Density = " <<
d_density << std::endl;
546 oss << tabS <<
"Horizon = " <<
d_horizon << std::endl;
549 oss << tabS << std::endl;
560 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
nlohmann::ordered_json json
Collection of methods and database related to input.
Field< Deck > field(T Deck::*m, std::string key, T def, std::string doc, Accepts< T > accepts={}, std::function< bool(const T &)> emitIf=[](const T &) { return true;})
Declares a field that maps one key to one member.
void readFields(Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
Reads every field of the table from the block.
json applyGiven(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
The default block with the given keys replaced.
void checkGroups(const json &block, const std::vector< OneOf > &groups)
Checks that each group has exactly one of its keys.
std::string getTabS(int nt)
Returns tab spaces of a given size.
Structure for elastic properties and fracture properties.
double toGc(double KIc, double nu, double E)
Compute critical energy release rate Gc from critical stress-intensity factor KIc,...
double toLambdaE(double E, double nu)
Compute Lame first parameter lambda from Young's modulus E and Poisson's ratio nu.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
double d_mu
Lame second parameter.
double toGK(double K, double nu)
Compute shear modulus from Bulk modulus K and Poisson's ratio nu.
double toKIc(double Gc, double nu, double E)
Compute critical stress-intensity factor KIc from critical energy release rate Gc,...
void readFromJson(const json &j)
double d_KIc
Critical stress intensity factor.
MatData(const MatData &md)
Copy constructor.
double toK(double E, double nu)
Compute Bulk modulus K from Young's modulus K and Poisson's ratio nu.
double d_lambda
Lame first parameter.
double toNu(double lambda, double mu)
Compute Poisson's ratio from Lame parameters.
double toGE(double E, double nu)
Compute shear modulus from Young's modulus E and Poisson's ratio nu.
double d_nu
Poisson's ratio.
double d_G
Shear modulus or Lame second parameter.
static const std::vector< Field< MatData > > & fields()
Reads from json object.
double toELambda(double lambda, double nu)
Compute Young's modulus E from Lame first parameter lambda and Poisson's ratio nu.
double toLambdaK(double K, double nu)
Compute Lame first parameter lambda from Bulk modulus K and Poisson's ratio nu.
double toNuEG(double E, double G)
Compute Poisson's ratio from Young's and Shear modulus.
double d_E
Young's elastic modulus.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
double d_Gc
Critical energy release rate.
double toE(double K, double nu)
Compute Young's modulus E from Bulk modulus K and Poisson's ratio nu.
Structure to read and store material related data.
MaterialDeck(const json &j=json({}))
Constructor.
bool d_isPlaneStrain
Indicates if the 2-d simulation is of plane-strain type (thick material) or plane-stress type (thin m...
static json getExampleJson(const json &given=json::object())
Returns example JSON object for ModelDeck configuration.
double d_density
Density of material.
static const std::vector< OneOf > & groups()
Quantities this deck accepts in more than one form.
MaterialDeck(std::string materialType, bool isPlainStrain=false, double horizon=-1., double horizonMeshRatio=-1., double density=1., double K=0., double G=0., double Gc=0., bool computeParamsFromElastic=true, size_t influenceFnType=0)
Constructor.
size_t d_bondPotentialType
Type of pairwise (bond-based) potential.
double d_horizonMeshRatio
Horizon to mesh ratio.
size_t d_influenceFnType
Type of influence function.
std::vector< double > d_bondPotentialParams
List of parameters for pairwise potential.
void readFromJson(const json &j)
Reads from json object.
static json getExampleJson(const std::string &)=delete
Rejects a value given where a set of named values is expected.
std::string d_materialType
Material type.
double d_horizon
Horizon for peridynamic interaction.
bool d_stateContributionFromBrokenBond
Flag for contribution to hydrostatic force from the broken bond.
static const std::vector< Field< MaterialDeck > > & fields()
The fields of the block itself.
bool d_computeParamsFromElastic
Compute Peridynamic material properties from elastic properties.
inp::MatData d_matData
List of elastic and fracture properties.
std::vector< double > d_influenceFnParams
List of parameters for influence function.
size_t d_statePotentialType
Type of hydrostatic (state-based) potential.
std::vector< double > d_statePotentialParams
List of parameters for hydrostatic potential.
bool d_irreversibleBondBreak
Flag for irreversible breaking of bonds.
static json getExampleJson(const char *)=delete
Rejects a value given where a set of named values is expected.
double d_checkScFactor
Factor to check if bond is broken.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
static const std::vector< Field< MaterialDeck > > & influenceFields()
The fields of the Influence_Function sub-block.
MaterialDeck(const MaterialDeck &md)
Copy constructor.