PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
inp::MaterialDeck Struct Reference

Structure to read and store material related data. More...

#include <materialDeck.h>

Collaboration diagram for inp::MaterialDeck:

Public Member Functions

 MaterialDeck (const json &j=json({}))
 Constructor.
 
 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.
 
 MaterialDeck (const MaterialDeck &md)
 Copy constructor.
 
void readFromJson (const json &j)
 Reads from json object.
 
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 Public Member Functions

static const std::vector< Field< MaterialDeck > > & fields ()
 The fields of the block itself.
 
static const std::vector< Field< MaterialDeck > > & influenceFields ()
 The fields of the Influence_Function sub-block.
 
static const std::vector< OneOf > & groups ()
 Quantities this deck accepts in more than one form.
 
static json getExampleJson (const json &given=json::object())
 Returns example JSON object for ModelDeck configuration.
 
static json getExampleJson (const std::string &)=delete
 Rejects a value given where a set of named values is expected.
 
static json getExampleJson (const char *)=delete
 Rejects a value given where a set of named values is expected.
 

Data Fields

bool d_isPlaneStrain
 Indicates if the 2-d simulation is of plane-strain type (thick material) or plane-stress type (thin material)
 
std::string d_materialType
 Material type.
 
size_t d_bondPotentialType
 Type of pairwise (bond-based) potential.
 
size_t d_statePotentialType
 Type of hydrostatic (state-based) potential.
 
size_t d_influenceFnType
 Type of influence function.
 
std::vector< double > d_bondPotentialParams
 List of parameters for pairwise potential.
 
std::vector< double > d_statePotentialParams
 List of parameters for hydrostatic potential.
 
std::vector< double > d_influenceFnParams
 List of parameters for influence function.
 
bool d_irreversibleBondBreak
 Flag for irreversible breaking of bonds.
 
bool d_stateContributionFromBrokenBond
 Flag for contribution to hydrostatic force from the broken bond.
 
double d_checkScFactor
 Factor to check if bond is broken.
 
bool d_computeParamsFromElastic
 Compute Peridynamic material properties from elastic properties.
 
inp::MatData d_matData
 List of elastic and fracture properties.
 
double d_density
 Density of material.
 
double d_horizon
 Horizon for peridynamic interaction.
 
double d_horizonMeshRatio
 Horizon to mesh ratio.
 

Detailed Description

Structure to read and store material related data.

Definition at line 270 of file materialDeck.h.

Constructor & Destructor Documentation

◆ MaterialDeck() [1/3]

inp::MaterialDeck::MaterialDeck ( const json &  j = json({}))
inline

Constructor.

Definition at line 330 of file materialDeck.h.

330 {}))
331 : d_materialType(""),
336 d_density(1.), d_horizon(-1.), d_horizonMeshRatio(-1.) {
337 readFromJson(j);
338 };
Structure for elastic properties and fracture properties.
bool d_isPlaneStrain
Indicates if the 2-d simulation is of plane-strain type (thick material) or plane-stress type (thin m...
double d_density
Density of material.
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.
void readFromJson(const json &j)
Reads from json object.
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.
bool d_computeParamsFromElastic
Compute Peridynamic material properties from elastic properties.
inp::MatData d_matData
List of elastic and fracture properties.
size_t d_statePotentialType
Type of hydrostatic (state-based) potential.
bool d_irreversibleBondBreak
Flag for irreversible breaking of bonds.
double d_checkScFactor
Factor to check if bond is broken.

◆ MaterialDeck() [2/3]

inp::MaterialDeck::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 
)
inline

Constructor.

Definition at line 343 of file materialDeck.h.

347 : d_materialType(materialType),
349 d_influenceFnType(influenceFnType), d_irreversibleBondBreak(true),
351 d_computeParamsFromElastic(computeParamsFromElastic), d_matData(inp::MatData()),
352 d_density(density), d_horizon(horizon), d_horizonMeshRatio(horizonMeshRatio) {
353
354 d_matData.d_K = K;
355 d_matData.d_G = G;
356 d_matData.d_Gc = Gc;
357 };
float K
Definition problem.py:43
double d_K
Bulk modulus.
double d_G
Shear modulus or Lame second parameter.
double d_Gc
Critical energy release rate.

References inp::MatData::d_G, inp::MatData::d_Gc, inp::MatData::d_K, and d_matData.

◆ MaterialDeck() [3/3]

inp::MaterialDeck::MaterialDeck ( const MaterialDeck &  md)
inline

Copy constructor.

Parameters
mdAnother MaterialDeck object

Definition at line 364 of file materialDeck.h.

365 : d_materialType(md.d_materialType),
366 d_isPlaneStrain(md.d_isPlaneStrain),
367 d_bondPotentialType(md.d_bondPotentialType),
368 d_statePotentialType(md.d_statePotentialType),
369 d_influenceFnType(md.d_influenceFnType),
370 d_bondPotentialParams(md.d_bondPotentialParams),
371 d_statePotentialParams(md.d_statePotentialParams),
372 d_influenceFnParams(md.d_influenceFnParams),
373 d_irreversibleBondBreak(md.d_irreversibleBondBreak),
374 d_stateContributionFromBrokenBond(md.d_stateContributionFromBrokenBond),
375 d_checkScFactor(md.d_checkScFactor),
376 d_computeParamsFromElastic(md.d_computeParamsFromElastic),
377 d_matData(md.d_matData), d_density(md.d_density),
378 d_horizon(md.d_horizon), d_horizonMeshRatio(md.d_horizonMeshRatio){};
std::vector< double > d_bondPotentialParams
List of parameters for pairwise potential.
std::vector< double > d_influenceFnParams
List of parameters for influence function.
std::vector< double > d_statePotentialParams
List of parameters for hydrostatic potential.

Member Function Documentation

◆ fields()

static const std::vector< Field< MaterialDeck > > & inp::MaterialDeck::fields ( )
inlinestatic

The fields of the block itself.

A horizon or a ratio that is not given keeps -1 and is left out of the block, which is how the material classes read it as absent.

Returns
fields The field table

Definition at line 388 of file materialDeck.h.

388 {
389 static const std::vector<Field<MaterialDeck>> f = {
390 field(&MaterialDeck::d_materialType, "Type", std::string(),
391 "Peridynamic material model"),
392 field(&MaterialDeck::d_density, "Density", 1., "Mass density"),
394 "Compute_From_Classical", true,
395 "Derive the bond parameters from the elastic constants"),
396 field<MaterialDeck, bool>(&MaterialDeck::d_isPlaneStrain,
397 "Is_Plane_Strain", false,
398 "Plane strain rather than plane stress", {},
399 [](const bool &v) { return v; }),
400 field<MaterialDeck, double>(&MaterialDeck::d_horizon, "Horizon", -1.,
401 "Peridynamic horizon", {},
402 [](const double &v) { return v > 0.; }),
403 field<MaterialDeck, double>(&MaterialDeck::d_horizonMeshRatio,
404 "Horizon_Mesh_Ratio", -1.,
405 "Horizon as a multiple of the mesh size",
406 {},
407 [](const double &v) { return v > 0.; }),
408 field<MaterialDeck, std::vector<double>>(
409 &MaterialDeck::d_bondPotentialParams, "Bond_Potential_Params", {},
410 "Bond parameters given directly rather than derived", {},
411 [](const std::vector<double> &v) { return !v.empty(); }),
412 field<MaterialDeck, std::vector<double>>(
413 &MaterialDeck::d_statePotentialParams, "State_Potential_Params",
414 {}, "State parameters given directly rather than derived", {},
415 [](const std::vector<double> &v) { return !v.empty(); }),
416 };
417 return f;
418 }
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.
Definition deckField.h:144

References d_bondPotentialParams, d_computeParamsFromElastic, d_density, d_horizon, d_horizonMeshRatio, d_isPlaneStrain, d_materialType, d_statePotentialParams, and inp::field().

Referenced by getExampleJson(), and readFromJson().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExampleJson() [1/3]

static json inp::MaterialDeck::getExampleJson ( const char *  )
staticdelete

Rejects a value given where a set of named values is expected.

A material type passed on its own would convert to a JSON string and be read as a block with no keys, so such a call is rejected when compiling.

◆ getExampleJson() [2/3]

static json inp::MaterialDeck::getExampleJson ( const json &  given = json::object())
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Returns the block with the given fields set

The extent of a bond is given either as Horizon, a length, or as Horizon_Mesh_Ratio, a multiple of the mesh size; naming one of the two is what selects it. The elastic constants K, G and Gc are written as given, since a material that states none of them cannot be built, and E is derived from K when it is not named.

Parameters
givenField names and values to set, checked against the table
Returns
JSON object for this deck

Definition at line 463 of file materialDeck.h.

463 {
464 const std::vector<std::string> extra = {"E", "K", "G", "Gc",
465 "Influence_Function"};
466 json j = applyGiven(given, fields(), extra);
467 checkGroups(j, groups());
468 return j;
469 }
nlohmann::ordered_json json
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.
Definition deckField.h:443
void checkGroups(const json &block, const std::vector< OneOf > &groups)
Checks that each group has exactly one of its keys.
Definition deckField.h:317
static const std::vector< OneOf > & groups()
Quantities this deck accepts in more than one form.
static const std::vector< Field< MaterialDeck > > & fields()
The fields of the block itself.

References inp::applyGiven(), inp::checkGroups(), fields(), and groups().

Referenced by anonymous_namespace{main.cpp}::buildBhatInputJson(), anonymous_namespace{main.cpp}::buildImpactInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildTraskInputJson(), getInputJson(), anonymous_namespace{main.cpp}::makeDeck(), and anonymous_namespace{testDeckRoundTrip.cpp}::testMaterialDeck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExampleJson() [3/3]

static json inp::MaterialDeck::getExampleJson ( const std::string &  )
staticdelete

Rejects a value given where a set of named values is expected.

A material type passed on its own would convert to a JSON string and be read as a block with no keys, so such a call is rejected when compiling.

◆ groups()

static const std::vector< OneOf > & inp::MaterialDeck::groups ( )
inlinestatic

Quantities this deck accepts in more than one form.

Returns
groups The groups

Definition at line 440 of file materialDeck.h.

440 {
441 static const std::vector<OneOf> g = {
442 {"the horizon", {"Horizon", "Horizon_Mesh_Ratio"}},
443 };
444 return g;
445 }

Referenced by getExampleJson(), and readFromJson().

Here is the caller graph for this function:

◆ influenceFields()

static const std::vector< Field< MaterialDeck > > & inp::MaterialDeck::influenceFields ( )
inlinestatic

The fields of the Influence_Function sub-block.

Returns
fields The field table

Definition at line 424 of file materialDeck.h.

424 {
425 static const std::vector<Field<MaterialDeck>> f = {
426 field(&MaterialDeck::d_influenceFnType, "Type", size_t(0),
427 "Influence function used in the bond force"),
428 field<MaterialDeck, std::vector<double>>(
429 &MaterialDeck::d_influenceFnParams, "Parameters", {},
430 "Parameters of the influence function", {},
431 [](const std::vector<double> &v) { return !v.empty(); }),
432 };
433 return f;
434 }

References d_influenceFnParams, d_influenceFnType, and inp::field().

Referenced by readFromJson().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

void inp::MaterialDeck::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 560 of file materialDeck.h.

560{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::MaterialDeck::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 515 of file materialDeck.h.

515 {
516
517 auto tabS = util::io::getTabS(nt);
518 std::ostringstream oss;
519 oss << tabS << "------- MaterialDeck --------" << std::endl << std::endl;
520 oss << tabS << "Is plain strain = " << d_isPlaneStrain << std::endl;
521 oss << tabS << "Material type = " << d_materialType << std::endl;
522 oss << tabS << "Bond potential type = " << d_bondPotentialType << std::endl;
523 oss << tabS << "Bond potential params = ["
524 << util::io::printStr<double>(d_bondPotentialParams, 0) << "]"
525 << std::endl;
526 oss << tabS << "State potential type = " << d_statePotentialType
527 << std::endl;
528 oss << tabS << "State potential params = ["
529 << util::io::printStr<double>(d_statePotentialParams, 0) << "]"
530 << std::endl;
531 oss << tabS << "Influence function type = " << d_influenceFnType
532 << std::endl;
533 oss << tabS << "Influence function params = ["
534 << util::io::printStr<double>(d_influenceFnParams, 0) << "]"
535 << std::endl;
536 oss << tabS
537 << "Irreversible bond breaking enabled = " << d_irreversibleBondBreak
538 << std::endl;
539 oss << tabS << "State contribution from broken bond enabled = "
540 << d_stateContributionFromBrokenBond << std::endl;
541 oss << tabS << "Check Sc factor = " << d_checkScFactor << std::endl;
542 oss << tabS << "Compute parameters from elastic properties = "
543 << d_computeParamsFromElastic << std::endl;
544 oss << d_matData.printStr(nt + 1, lvl);
545 oss << tabS << "Density = " << d_density << std::endl;
546 oss << tabS << "Horizon = " << d_horizon << std::endl;
547 oss << tabS << "Horizon to mesh ratio = " << d_horizonMeshRatio
548 << std::endl;
549 oss << tabS << std::endl;
550
551 return oss.str();
552 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.

References d_bondPotentialParams, d_bondPotentialType, d_checkScFactor, d_computeParamsFromElastic, d_density, d_horizon, d_horizonMeshRatio, d_influenceFnParams, d_influenceFnType, d_irreversibleBondBreak, d_isPlaneStrain, d_matData, d_materialType, d_stateContributionFromBrokenBond, d_statePotentialParams, d_statePotentialType, util::io::getTabS(), and inp::MatData::printStr().

Referenced by material::PdState::computeParameters(), and print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFromJson()

void inp::MaterialDeck::readFromJson ( const json &  j)
inline

Reads from json object.

Definition at line 484 of file materialDeck.h.

484 {
485 if (j.empty())
486 return;
487
488 // read mat data
490
491 readFields(*this, j, fields());
492
493 // Older decks spell this Is_Plain_Strain. The table reads the current
494 // spelling, so the older one is applied when it alone is present.
495 if (j.find("Is_Plane_Strain") == j.end() &&
496 j.find("Is_Plain_Strain") != j.end())
497 d_isPlaneStrain = j.at("Is_Plain_Strain").get<bool>();
498
499 checkGroups(j, groups());
500
501 if (j.find("Influence_Function") != j.end())
502 readFields(*this, j.at("Influence_Function"), influenceFields());
504 throw std::runtime_error(
505 "Compute_From_Classical is false but Bond_Potential_Params is missing.");
506 }
void readFields(Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
Reads every field of the table from the block.
Definition deckField.h:230
void readFromJson(const json &j)
static const std::vector< Field< MaterialDeck > > & influenceFields()
The fields of the Influence_Function sub-block.

References inp::checkGroups(), d_bondPotentialParams, d_computeParamsFromElastic, d_isPlaneStrain, d_matData, fields(), groups(), influenceFields(), inp::readFields(), and inp::MatData::readFromJson().

Referenced by anonymous_namespace{testDeckRoundTrip.cpp}::testMaterialDeck().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ d_bondPotentialParams

std::vector<double> inp::MaterialDeck::d_bondPotentialParams

◆ d_bondPotentialType

size_t inp::MaterialDeck::d_bondPotentialType

Type of pairwise (bond-based) potential.

Definition at line 282 of file materialDeck.h.

Referenced by printStr().

◆ d_checkScFactor

double inp::MaterialDeck::d_checkScFactor

Factor to check if bond is broken.

Definition at line 310 of file materialDeck.h.

Referenced by printStr().

◆ d_computeParamsFromElastic

bool inp::MaterialDeck::d_computeParamsFromElastic

Compute Peridynamic material properties from elastic properties.

Definition at line 313 of file materialDeck.h.

Referenced by fields(), material::PdElastic::PdElastic(), material::PdState::PdState(), material::PmbMaterial::PmbMaterial(), printStr(), readFromJson(), and material::RnpMaterial::RnpMaterial().

◆ d_density

double inp::MaterialDeck::d_density

Density of material.

Definition at line 319 of file materialDeck.h.

Referenced by fields(), and printStr().

◆ d_horizon

double inp::MaterialDeck::d_horizon

Horizon for peridynamic interaction.

Definition at line 322 of file materialDeck.h.

Referenced by particle::BaseParticle::BaseParticle(), fields(), and printStr().

◆ d_horizonMeshRatio

double inp::MaterialDeck::d_horizonMeshRatio

Horizon to mesh ratio.

Definition at line 325 of file materialDeck.h.

Referenced by particle::BaseParticle::BaseParticle(), fields(), and printStr().

◆ d_influenceFnParams

◆ d_influenceFnType

◆ d_irreversibleBondBreak

bool inp::MaterialDeck::d_irreversibleBondBreak

Flag for irreversible breaking of bonds.

True means bond breaking is irreversible.

Definition at line 304 of file materialDeck.h.

Referenced by printStr().

◆ d_isPlaneStrain

bool inp::MaterialDeck::d_isPlaneStrain

Indicates if the 2-d simulation is of plane-strain type (thick material) or plane-stress type (thin material)

Definition at line 276 of file materialDeck.h.

Referenced by fields(), material::PdElastic::PdElastic(), material::PdState::PdState(), material::PmbMaterial::PmbMaterial(), printStr(), readFromJson(), and material::RnpMaterial::RnpMaterial().

◆ d_matData

◆ d_materialType

std::string inp::MaterialDeck::d_materialType

Material type.

Definition at line 279 of file materialDeck.h.

Referenced by particle::BaseParticle::BaseParticle(), fields(), and printStr().

◆ d_stateContributionFromBrokenBond

bool inp::MaterialDeck::d_stateContributionFromBrokenBond

Flag for contribution to hydrostatic force from the broken bond.

Definition at line 307 of file materialDeck.h.

Referenced by printStr().

◆ d_statePotentialParams

std::vector<double> inp::MaterialDeck::d_statePotentialParams

List of parameters for hydrostatic potential.

Definition at line 294 of file materialDeck.h.

Referenced by fields(), and printStr().

◆ d_statePotentialType

size_t inp::MaterialDeck::d_statePotentialType

Type of hydrostatic (state-based) potential.

Definition at line 285 of file materialDeck.h.

Referenced by printStr().


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