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

Structure to read and store particle generation data, such as particle locations and group file. More...

#include <pGenDeck.h>

Collaboration diagram for inp::PGenDeck:

Public Member Functions

 PGenDeck (const json &j=json({}))
 Constructor.
 
 PGenDeck (std::string genMethod, json pGenJson=json({}), bool genWithRandomRotation=true)
 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 json getExampleJson (std::string genMethod="From_File")
 Returns example JSON object for ModelDeck configuration.
 

Data Fields

std::string d_genMethod
 Particle generation method.
 
json d_pGenJson
 Json object loaded from the input json file or jason file for particle generation.
 
bool d_genWithRandomRotation
 Random rotation of particles if orientation is not provided.
 

Detailed Description

Structure to read and store particle generation data, such as particle locations and group file.

Definition at line 27 of file pGenDeck.h.

Constructor & Destructor Documentation

◆ PGenDeck() [1/2]

inp::PGenDeck::PGenDeck ( const json j = json({}))
inline

Constructor.

Definition at line 48 of file pGenDeck.h.

48 {}))
49 : d_genMethod("Use_Particle_Geometry"),
51 readFromJson(j);
52 };
json d_pGenJson
Json object loaded from the input json file or jason file for particle generation.
Definition pGenDeck.h:40
void readFromJson(const json &j)
Reads from json object.
Definition pGenDeck.h:74
bool d_genWithRandomRotation
Random rotation of particles if orientation is not provided.
Definition pGenDeck.h:43
std::string d_genMethod
Particle generation method.
Definition pGenDeck.h:37

◆ PGenDeck() [2/2]

inp::PGenDeck::PGenDeck ( std::string  genMethod,
json  pGenJson = json({}),
bool  genWithRandomRotation = true 
)
inline

Constructor.

Definition at line 57 of file pGenDeck.h.

57 {}), bool genWithRandomRotation = true)
58 : d_genMethod(genMethod),
59 d_pGenJson(pGenJson), d_genWithRandomRotation(genWithRandomRotation) {};

Member Function Documentation

◆ getExampleJson()

static json inp::PGenDeck::getExampleJson ( std::string  genMethod = "From_File")
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 65 of file pGenDeck.h.

65 {
66
67 auto j = json({{"Method", "From_File"}, {"Random_Rotation", true}});
68 return j;
69 }
nlohmann::ordered_json json

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(), getInputJson(), and inp::ParticleDeck::getParticleGenExampleJson().

Here is the caller graph for this function:

◆ print()

void inp::PGenDeck::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 124 of file pGenDeck.h.

124{ 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 pGenDeck.h:96

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::PGenDeck::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 96 of file pGenDeck.h.

96 {
97
98 auto tabS = util::io::getTabS(nt);
99 std::ostringstream oss;
100 oss << tabS << "------- PGenDeck --------" << std::endl << std::endl;
101 oss << tabS << "Method = " << d_genMethod << std::endl;
102 oss << tabS << "Random rotation of particles = " << d_genWithRandomRotation << std::endl;
103 size_t nParticles = d_pGenJson.value("N", 0);
104 oss << tabS << "Number of particles in json object = " << nParticles << std::endl;
105 oss << tabS << "Data for first five particles: " << std::endl;
106 if (nParticles > 0) {
107 nParticles = nParticles > 5 ? 5 : nParticles;
108 for (size_t i=0; i< nParticles; i++) {
109 oss << tabS << "Particle number = " << i << std::endl;
110 oss << tabS << d_pGenJson.at(std::to_string(i)) << std::endl;
111 }
112 }
113 oss << tabS << std::endl;
114
115 return oss.str();
116 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39

References d_genMethod, d_genWithRandomRotation, d_pGenJson, and util::io::getTabS().

Referenced by print(), and inp::ParticleDeck::printStr().

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

◆ readFromJson()

void inp::PGenDeck::readFromJson ( const json j)
inline

Reads from json object.

Definition at line 74 of file pGenDeck.h.

74 {
75 if (j.empty())
76 return;
77
78 d_genMethod = j.value("Method", std::string("Use_Particle_Geometry"));
79 d_genWithRandomRotation = j.value("Random_Rotation", true);
80
81 if (d_genMethod == "From_File") {
82 if (j.find("Data") == j.end())
83 throw std::runtime_error("Need information inside key Data.");
84
85 d_pGenJson = j.at("Data");
86 }
87 }

References d_genMethod, d_genWithRandomRotation, and d_pGenJson.

Referenced by inp::ParticleDeck::readParticleGenFromJson().

Here is the caller graph for this function:

Field Documentation

◆ d_genMethod

std::string inp::PGenDeck::d_genMethod

Particle generation method.

"From_File" means particle location, radius and other details will be loaded from the input json file. Use key 'Particle_Generation' to provide the data.

"Use_Particle_Geometry" means particle geometry will be used to generate particles.

Definition at line 37 of file pGenDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_genWithRandomRotation

bool inp::PGenDeck::d_genWithRandomRotation

Random rotation of particles if orientation is not provided.

Definition at line 43 of file pGenDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_pGenJson

json inp::PGenDeck::d_pGenJson

Json object loaded from the input json file or jason file for particle generation.

Definition at line 40 of file pGenDeck.h.

Referenced by printStr(), and readFromJson().


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