11#ifndef INP_MODELDECK_H
12#define INP_MODELDECK_H
135 ModelDeck(
size_t dim,
double tFinal = 1.0,
size_t Nt = 10,
136 std::string spatialDiscretization =
"finite_difference",
137 std::string timeDiscretization =
"central_difference",
138 bool populateElementNodeConnectivity =
true,
139 size_t quadOrder = 2,
140 std::string particleSimType =
"Multi_Particle",
155 throw std::runtime_error(
157 <<
"Error: Check Final_Time and Time_Steps data.\n");
177 static const std::vector<Field<ModelDeck>> &
fields() {
178 static const std::vector<Field<ModelDeck>> f = {
180 "Spatial dimension", {{size_t(1), size_t(2), size_t(3)}, {}, {}}),
182 "End of the integration window"),
184 "Number of time steps", {{}, size_t(1), {}}),
186 "Populate_ElementNodeConnectivity",
true,
187 "Build the element to node map, which strain output needs"),
189 "Order of the quadrature rule"),
191 std::string(
"Multi_Particle"),
"One body or many",
192 {{
"Multi_Particle",
"Single_Particle"}, {}, {}}),
194 "What is distributed across ranks",
195 {{
"auto",
"none",
"particle",
"dof"}, {}, {}}),
197 "Criterion for breaking a bond",
198 {{
"tension",
"absolute_stretch"}, {}, {}}),
200 std::string(
"broken_bond_kn"),
201 "Contact across broken bonds inside one body",
202 {{
"broken_bond_kn",
"reference_gap",
"none"}, {}, {}}),
204 std::string(
"meshed"),
"How a wall is represented for contact",
205 {{
"meshed",
"analytical_plane"}, {}, {}}),
207 "Seed of the random number generator"),
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"}};
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.);
246 throw std::runtime_error(
248 <<
"Error: Model.Rigid_Particles entries need Mass > 0.\n");
255 throw std::runtime_error(
257 <<
"Error: Check Final_Time and Time_Steps data.\n");
270 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
272 std::ostringstream oss;
273 oss << tabS <<
"------- ModelDeck --------" << std::endl << std::endl;
279 oss << tabS <<
"Simulation type = " <<
d_simType << std::endl;
280 oss << tabS <<
"Time step size = " <<
d_dt << std::endl;
282 oss << tabS << std::endl;
293 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
Collects a message with stream syntax for use in an exception.
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.
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.
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.
std::string getTabS(int nt)
Returns tab spaces of a given size.
Structure to read and store model related input data.
bool d_populateElementNodeConnectivity
Flag to indicate if we should populate element-node connectivity data in meshes.
std::string d_mpiStrategy
MPI domain-decomposition strategy (independent of Particle_Sim_Type).
void readFromJson(const json &j)
Reads from json object.
size_t d_quadOrder
Order of quadrature approximation for strain and stress computation (default is 1)
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)
size_t d_Nt
Number of time steps.
static const std::vector< Field< ModelDeck > > & fields()
Returns example JSON object for ModelDeck configuration.
std::string d_selfContact
Intra-body self-contact law name (default broken_bond_kn).
double d_tFinal
Final simulation time.
std::string d_particleSimType
Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or ...
ModelDeck(const json &j=json({}))
Constructor.
std::string d_bondBreak
Bond failure criterion: tension (default) or absolute_stretch.
std::string d_simType
Simulation type.
std::vector< std::pair< size_t, double > > d_rigidParticles
Rigid translating particles: {"Id": <id>, "Mass": <mass>}. Nodal force densities are set to density *...
int d_seed
Seed for random calculations (if any)
std::string d_spatialDiscretization
Tag for spatial discretization.
double d_dt
Size of time steps.
std::string d_wallContact
Wall contact representation: meshed (default) or analytical_plane.
bool d_isRestartActive
Flag indicating if this restart problem.
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.
std::string d_timeDiscretization
Tag for time discretization.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.