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

Structure to read and store model related input data. More...

#include <modelDeck.h>

Collaboration diagram for inp::ModelDeck:

Public Member Functions

 ModelDeck (const json &j=json({}))
 Constructor.
 
 ModelDeck (size_t dim, double tFinal=1.0, size_t Nt=10, std::string spatialDiscretization="finite_difference", std::string timeDiscretization="central_difference", bool populateElementNodeConnectivity=true, size_t quadOrder=2, std::string particleSimType="Multi_Particle", int seed=0)
 
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< ModelDeck > > & fields ()
 Returns example JSON object for ModelDeck configuration.
 
static json getExampleJson (const json &given=json::object())
 Returns the block with the given fields set.
 

Data Fields

std::string d_simType
 Simulation type.
 
bool d_isRestartActive
 Flag indicating if this restart problem.
 
std::string d_spatialDiscretization
 Tag for spatial discretization.
 
std::string d_timeDiscretization
 Tag for time discretization.
 
bool d_populateElementNodeConnectivity
 Flag to indicate if we should populate element-node connectivity data in meshes.
 
size_t d_quadOrder
 Order of quadrature approximation for strain and stress computation (default is 1)
 
std::string d_particleSimType
 Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or 'Multi_Particle'.
 
std::string d_mpiStrategy
 MPI domain-decomposition strategy (independent of Particle_Sim_Type).
 
std::string d_bondBreak
 Bond failure criterion: tension (default) or absolute_stretch.
 
std::vector< std::pair< size_t, double > > d_rigidParticles
 Rigid translating particles: {"Id": <id>, "Mass": <mass>}. Nodal force densities are set to density * (net force / Mass).
 
std::string d_selfContact
 Intra-body self-contact law name (default broken_bond_kn).
 
std::string d_wallContact
 Wall contact representation: meshed (default) or analytical_plane.
 
size_t d_dim
 Dimension.
 
double d_tFinal
 Final simulation time.
 
double d_dt
 Size of time steps.
 
size_t d_Nt
 Number of time steps.
 
int d_seed
 Seed for random calculations (if any)
 

Detailed Description

Structure to read and store model related input data.

Definition at line 27 of file modelDeck.h.

Constructor & Destructor Documentation

◆ ModelDeck() [1/2]

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

Constructor.

Definition at line 125 of file modelDeck.h.

125 {}))
127 d_tFinal(0.), d_dt(0.), d_Nt(0),
128 d_particleSimType(""), d_mpiStrategy("auto"),
129 d_bondBreak("tension"), d_selfContact("broken_bond_kn"),
130 d_wallContact("meshed"), d_seed(0), d_quadOrder(1) {
131
132 readFromJson(j);
133 };
bool d_populateElementNodeConnectivity
Flag to indicate if we should populate element-node connectivity data in meshes.
Definition modelDeck.h:62
std::string d_mpiStrategy
MPI domain-decomposition strategy (independent of Particle_Sim_Type).
Definition modelDeck.h:84
void readFromJson(const json &j)
Reads from json object.
Definition modelDeck.h:229
size_t d_quadOrder
Order of quadrature approximation for strain and stress computation (default is 1)
Definition modelDeck.h:65
size_t d_Nt
Number of time steps.
Definition modelDeck.h:117
size_t d_dim
Dimension.
Definition modelDeck.h:108
std::string d_selfContact
Intra-body self-contact law name (default broken_bond_kn).
Definition modelDeck.h:100
double d_tFinal
Final simulation time.
Definition modelDeck.h:111
std::string d_particleSimType
Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or ...
Definition modelDeck.h:73
std::string d_bondBreak
Bond failure criterion: tension (default) or absolute_stretch.
Definition modelDeck.h:89
int d_seed
Seed for random calculations (if any)
Definition modelDeck.h:120
double d_dt
Size of time steps.
Definition modelDeck.h:114
std::string d_wallContact
Wall contact representation: meshed (default) or analytical_plane.
Definition modelDeck.h:105
bool d_isRestartActive
Flag indicating if this restart problem.
Definition modelDeck.h:38

◆ ModelDeck() [2/2]

inp::ModelDeck::ModelDeck ( size_t  dim,
double  tFinal = 1.0,
size_t  Nt = 10,
std::string  spatialDiscretization = "finite_difference",
std::string  timeDiscretization = "central_difference",
bool  populateElementNodeConnectivity = true,
size_t  quadOrder = 2,
std::string  particleSimType = "Multi_Particle",
int  seed = 0 
)
inline

Definition at line 135 of file modelDeck.h.

142 : d_dim(dim), d_isRestartActive(false),
143 d_spatialDiscretization(spatialDiscretization),
144 d_timeDiscretization(timeDiscretization),
145 d_populateElementNodeConnectivity(populateElementNodeConnectivity),
146 d_tFinal(tFinal), d_dt(0.), d_Nt(Nt),
147 d_particleSimType(particleSimType), d_mpiStrategy("auto"),
148 d_bondBreak("tension"), d_selfContact("broken_bond_kn"),
149 d_wallContact("meshed"), d_seed(seed), d_quadOrder(quadOrder) {
150
151 if (d_timeDiscretization == "central_difference" or d_timeDiscretization == "velocity_verlet")
152 d_simType = "explicit";
153
154 if (std::abs(d_tFinal) < 1.0E-10 or d_Nt <= 0) {
155 throw std::runtime_error(
157 << "Error: Check Final_Time and Time_Steps data.\n");
158 }
159
160 d_dt = d_tFinal / d_Nt;
161 };
Collects a message with stream syntax for use in an exception.
Definition io.h:52
std::string d_simType
Simulation type.
Definition modelDeck.h:35
std::string d_spatialDiscretization
Tag for spatial discretization.
Definition modelDeck.h:49
std::string d_timeDiscretization
Tag for time discretization.
Definition modelDeck.h:59

References d_dt, d_Nt, d_simType, d_tFinal, and d_timeDiscretization.

Member Function Documentation

◆ fields()

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

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

The fields of this deck, declared once

Reading, writing, printing and the schema are generated from this table. The discretization block, the simulation type it implies, the time step and the rigid particles are read in readDerived.

Returns
fields The field table

Definition at line 177 of file modelDeck.h.

177 {
178 static const std::vector<Field<ModelDeck>> f = {
179 field(&ModelDeck::d_dim, "Dimension", size_t(2),
180 "Spatial dimension", {{size_t(1), size_t(2), size_t(3)}, {}, {}}),
181 field(&ModelDeck::d_tFinal, "Final_Time", 1.0,
182 "End of the integration window"),
183 field(&ModelDeck::d_Nt, "Time_Steps", size_t(10),
184 "Number of time steps", {{}, size_t(1), {}}),
186 "Populate_ElementNodeConnectivity", true,
187 "Build the element to node map, which strain output needs"),
188 field(&ModelDeck::d_quadOrder, "Quad_Approximation_Order", size_t(2),
189 "Order of the quadrature rule"),
190 field(&ModelDeck::d_particleSimType, "Particle_Sim_Type",
191 std::string("Multi_Particle"), "One body or many",
192 {{"Multi_Particle", "Single_Particle"}, {}, {}}),
193 field(&ModelDeck::d_mpiStrategy, "MPI_Strategy", std::string("auto"),
194 "What is distributed across ranks",
195 {{"auto", "none", "particle", "dof"}, {}, {}}),
196 field(&ModelDeck::d_bondBreak, "Bond_Break", std::string("tension"),
197 "Criterion for breaking a bond",
198 {{"tension", "absolute_stretch"}, {}, {}}),
199 field(&ModelDeck::d_selfContact, "Self_Contact",
200 std::string("broken_bond_kn"),
201 "Contact across broken bonds inside one body",
202 {{"broken_bond_kn", "reference_gap", "none"}, {}, {}}),
203 field(&ModelDeck::d_wallContact, "Wall_Contact",
204 std::string("meshed"), "How a wall is represented for contact",
205 {{"meshed", "analytical_plane"}, {}, {}}),
206 field(&ModelDeck::d_seed, "Seed", 0,
207 "Seed of the random number generator"),
208 };
209 return f;
210 }
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_bondBreak, d_dim, d_mpiStrategy, d_Nt, d_particleSimType, d_populateElementNodeConnectivity, d_quadOrder, d_seed, d_selfContact, d_tFinal, d_wallContact, and inp::field().

Referenced by getExampleJson(), printStr(), and readFromJson().

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

◆ getExampleJson()

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

Returns the block with the given fields set.

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

Definition at line 217 of file modelDeck.h.

217 {
218 json j = applyGiven(given, fields(),
219 {"Discretization_Type", "Rigid_Particles"});
220 if (j.find("Discretization_Type") == j.end())
221 j["Discretization_Type"] = json{{"Spatial", "finite_difference"},
222 {"Time", "central_difference"}};
223 return j;
224 }
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
static const std::vector< Field< ModelDeck > > & fields()
Returns example JSON object for ModelDeck configuration.
Definition modelDeck.h:177

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

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(), anonymous_namespace{testMeshGen.cpp}::builtinMeshCheckForGeometry(), getInputJson(), anonymous_namespace{main.cpp}::makeDeck(), and anonymous_namespace{testDeckRoundTrip.cpp}::testModelDeck().

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

◆ print()

void inp::ModelDeck::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 293 of file modelDeck.h.

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

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::ModelDeck::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 270 of file modelDeck.h.

270 {
271 auto tabS = util::io::getTabS(nt);
272 std::ostringstream oss;
273 oss << tabS << "------- ModelDeck --------" << std::endl << std::endl;
274 printFields(*this, oss, fields(), tabS);
275 oss << tabS << "Discretization_Type.Spatial = " << d_spatialDiscretization
276 << std::endl;
277 oss << tabS << "Discretization_Type.Time = " << d_timeDiscretization
278 << std::endl;
279 oss << tabS << "Simulation type = " << d_simType << std::endl;
280 oss << tabS << "Time step size = " << d_dt << std::endl;
281 oss << tabS << "Restart active = " << d_isRestartActive << std::endl;
282 oss << tabS << std::endl;
283
284 return oss.str();
285 }
void printFields(const Deck &d, std::ostringstream &oss, const std::vector< Field< Deck > > &fs, const std::string &tab="")
Appends every field of the table to a stream.
Definition deckField.h:251
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82

References d_dt, d_isRestartActive, d_simType, d_spatialDiscretization, d_timeDiscretization, fields(), util::io::getTabS(), and inp::printFields().

Referenced by print().

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

◆ readFromJson()

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

Reads from json object.

Definition at line 229 of file modelDeck.h.

229 {
230 if (j.empty())
231 return;
232
233 readFields(*this, j, fields());
234
235 d_spatialDiscretization = j.at("Discretization_Type").at("Spatial");
236 d_timeDiscretization = j.at("Discretization_Type").at("Time");
237 if (d_timeDiscretization == "central_difference" or
238 d_timeDiscretization == "velocity_verlet")
239 d_simType = "explicit";
240
241 d_rigidParticles.clear();
242 if (j.find("Rigid_Particles") != j.end()) {
243 for (const auto &r : j.at("Rigid_Particles")) {
244 const double mass = r.value("Mass", -1.);
245 if (!(mass > 0.)) {
246 throw std::runtime_error(
248 << "Error: Model.Rigid_Particles entries need Mass > 0.\n");
249 }
250 d_rigidParticles.emplace_back(r.at("Id").get<size_t>(), mass);
251 }
252 }
253
254 if (std::abs(d_tFinal) < 1.0E-10 or d_Nt <= 0) {
255 throw std::runtime_error(
257 << "Error: Check Final_Time and Time_Steps data.\n");
258 }
259
260 d_dt = d_tFinal / d_Nt;
261 }
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
std::vector< std::pair< size_t, double > > d_rigidParticles
Rigid translating particles: {"Id": <id>, "Mass": <mass>}. Nodal force densities are set to density *...
Definition modelDeck.h:95

References d_dt, d_Nt, d_rigidParticles, d_simType, d_spatialDiscretization, d_tFinal, d_timeDiscretization, fields(), and inp::readFields().

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

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

Field Documentation

◆ d_bondBreak

std::string inp::ModelDeck::d_bondBreak

Bond failure criterion: tension (default) or absolute_stretch.

Definition at line 89 of file modelDeck.h.

Referenced by fields().

◆ d_dim

◆ d_dt

double inp::ModelDeck::d_dt

Size of time steps.

Definition at line 114 of file modelDeck.h.

Referenced by ModelDeck(), printStr(), and readFromJson().

◆ d_isRestartActive

bool inp::ModelDeck::d_isRestartActive

Flag indicating if this restart problem.

Definition at line 38 of file modelDeck.h.

Referenced by printStr().

◆ d_mpiStrategy

std::string inp::ModelDeck::d_mpiStrategy

MPI domain-decomposition strategy (independent of Particle_Sim_Type).

Allowed: auto (default), none, particle, dof.

  • auto: Multi_Particle → particle; Single_Particle → dof
  • none: no domain split (use one MPI rank)
  • particle: distribute whole particles across ranks (Particle-MPI)
  • dof: distribute nodes/DOFs across ranks (DOF-MPI)

Definition at line 84 of file modelDeck.h.

Referenced by fields().

◆ d_Nt

size_t inp::ModelDeck::d_Nt

Number of time steps.

Definition at line 117 of file modelDeck.h.

Referenced by fields(), ModelDeck(), and readFromJson().

◆ d_particleSimType

std::string inp::ModelDeck::d_particleSimType

Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or 'Multi_Particle'.

This flag is used to populate input deck data. For the case when we consider single particle and its deformation, one do not have to specify data such as zones and contact.

Definition at line 73 of file modelDeck.h.

Referenced by fields().

◆ d_populateElementNodeConnectivity

bool inp::ModelDeck::d_populateElementNodeConnectivity

Flag to indicate if we should populate element-node connectivity data in meshes.

Definition at line 62 of file modelDeck.h.

Referenced by fields(), mesh::Mesh::loadFromTetraElements3D(), and mesh::Mesh::loadFromTriangleElements2D().

◆ d_quadOrder

size_t inp::ModelDeck::d_quadOrder

Order of quadrature approximation for strain and stress computation (default is 1)

Definition at line 65 of file modelDeck.h.

Referenced by fields().

◆ d_rigidParticles

std::vector<std::pair<size_t, double> > inp::ModelDeck::d_rigidParticles

Rigid translating particles: {"Id": <id>, "Mass": <mass>}. Nodal force densities are set to density * (net force / Mass).

Definition at line 95 of file modelDeck.h.

Referenced by readFromJson().

◆ d_seed

int inp::ModelDeck::d_seed

Seed for random calculations (if any)

Definition at line 120 of file modelDeck.h.

Referenced by fields().

◆ d_selfContact

std::string inp::ModelDeck::d_selfContact

Intra-body self-contact law name (default broken_bond_kn).

Definition at line 100 of file modelDeck.h.

Referenced by fields().

◆ d_simType

std::string inp::ModelDeck::d_simType

Simulation type.

List of allowed values are:

  • explicit
  • implicit

Definition at line 35 of file modelDeck.h.

Referenced by ModelDeck(), printStr(), and readFromJson().

◆ d_spatialDiscretization

std::string inp::ModelDeck::d_spatialDiscretization

Tag for spatial discretization.

List of allowed values are:

  • **finite_difference**
  • **weak_finite_element**
  • **nodal_finite_element**
  • **truss_finite_element**

Definition at line 49 of file modelDeck.h.

Referenced by mesh::Mesh::loadFromTetraElements3D(), mesh::Mesh::loadFromTriangleElements2D(), printStr(), and readFromJson().

◆ d_tFinal

double inp::ModelDeck::d_tFinal

Final simulation time.

Definition at line 111 of file modelDeck.h.

Referenced by fields(), ModelDeck(), and readFromJson().

◆ d_timeDiscretization

std::string inp::ModelDeck::d_timeDiscretization

Tag for time discretization.

List of allowed values are:

  • empty string
  • **central_difference**
  • **velocity_verlet**

Definition at line 59 of file modelDeck.h.

Referenced by ModelDeck(), printStr(), and readFromJson().

◆ d_wallContact

std::string inp::ModelDeck::d_wallContact

Wall contact representation: meshed (default) or analytical_plane.

Definition at line 105 of file modelDeck.h.

Referenced by fields().


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