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

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

#include <particleDeck.h>

Collaboration diagram for inp::ParticleDeck:

Public Member Functions

 ParticleDeck (const json &j=json({}), std::string particleSimType="Multi_Particle")
 Constructor.
 
void readFromJson (const json &j)
 
void readParticleGeomFromJson (const json &j)
 Reads from json object.
 
void readParticleMeshFromJson (const json &j)
 
void readParticleMaterialFromJson (const json &j)
 
void readParticleContactFromJson (const json &j)
 
void readParticleNeighborFromJson (const json &j)
 
void readParticleGenFromJson (const json &j)
 
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 getParticleGeomExampleJson (std::vector< geom::GeomData > pGeomVec=std::vector< geom::GeomData >())
 Returns example JSON object for ModelDeck configuration.
 
static json getParticleMeshExampleJson (std::vector< std::string > filenameVec=std::vector< std::string >(), std::vector< double > meshSizesVec=std::vector< double >())
 Returns example JSON object for ModelDeck configuration.
 
static json getParticleMaterialExampleJson (size_t nSets=0)
 Returns example JSON object for ModelDeck configuration.
 
static json getParticleContactExampleJson (size_t nSets=0)
 Returns example JSON object for ModelDeck configuration.
 
static json getParticleNeighborExampleJson (const json &given=json::object())
 Returns the neighbor block with the given fields set.
 
static json getParticleGenExampleJson (const json &given=json::object())
 Returns the particle generation block with the given fields set.
 

Data Fields

std::string d_particleSimType
 Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or 'Multi_Particle'.
 
std::vector< geom::GeomData > d_pGeomVec
 Particle geometry data.
 
std::vector< inp::MeshDeck > d_pMeshVec
 Particle mesh data.
 
std::vector< inp::MaterialDeck > d_pMaterialVec
 Particle material data.
 
inp::ContactDeck d_contactDeck
 Particle contact data.
 
inp::PNeighborDeck d_pNeighDeck
 Neighbor search data.
 
inp::PGenDeck d_pGenDeck
 Particle generation data.
 

Detailed Description

Structure to read and store particle related input data.

Definition at line 31 of file particleDeck.h.

Constructor & Destructor Documentation

◆ ParticleDeck()

inp::ParticleDeck::ParticleDeck ( const json &  j = json({}),
std::string  particleSimType = "Multi_Particle" 
)
inline

Constructor.

Definition at line 62 of file particleDeck.h.

62 {}), std::string particleSimType = "Multi_Particle") {
63 d_particleSimType = particleSimType;
64 readFromJson(j);
65 };
std::string d_particleSimType
Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or ...
void readFromJson(const json &j)

Member Function Documentation

◆ getParticleContactExampleJson()

static json inp::ParticleDeck::getParticleContactExampleJson ( size_t  nSets = 0)
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 260 of file particleDeck.h.

260 {
261 return inp::ContactDeck::getExampleJson(json{{"Sets", nSets}});
262 }
nlohmann::ordered_json json
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.

References inp::ContactDeck::getExampleJson().

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

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

◆ getParticleGenExampleJson()

static json inp::ParticleDeck::getParticleGenExampleJson ( const json &  given = json::object())
inlinestatic

Returns the particle generation block with the given fields set.

Parameters
givenField names and values to set, checked against the table
Returns
JSON object for the particle generation block

Definition at line 287 of file particleDeck.h.

287 {
288 return inp::PGenDeck::getExampleJson(given);
289 }
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
Definition pGenDeck.h:82

References inp::PGenDeck::getExampleJson().

Here is the call graph for this function:

◆ getParticleGeomExampleJson()

static json inp::ParticleDeck::getParticleGeomExampleJson ( std::vector< geom::GeomData >  pGeomVec = std::vector<geom::GeomData>())
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 95 of file particleDeck.h.

95 {
96
97 auto nSets = pGeomVec.size();
98
99 if (nSets == 0)
100 return json({});
101
102 auto j = json({{"Sets", nSets}});
103
104 for (size_t i = 0; i < nSets; i++) {
105 auto js = json({});
106 geom::writeGeometry(js, pGeomVec[i]);
107 std::string set_name = "Set_" + std::to_string(i+1);
108 j[set_name] = js;
109 }
110
111 return j;
112 }
void writeGeometry(json &j, const geom::GeomData &geomData)

References geom::writeGeometry().

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(), and getInputJson().

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

◆ getParticleMaterialExampleJson()

static json inp::ParticleDeck::getParticleMaterialExampleJson ( size_t  nSets = 0)
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 210 of file particleDeck.h.

210 {
211
212 if (nSets == 0)
213 return json({});
214
215 auto j = json({{"Sets", nSets}});
216 for (size_t i = 0; i < nSets; i++) {
217 std::string set_name = "Set_" + std::to_string(i+1);
218 j[set_name] = {};
219 }
220
221 return j;
222 }

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

Here is the caller graph for this function:

◆ getParticleMeshExampleJson()

static json inp::ParticleDeck::getParticleMeshExampleJson ( std::vector< std::string >  filenameVec = std::vector<std::string>(),
std::vector< double >  meshSizesVec = std::vector<double>() 
)
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 153 of file particleDeck.h.

154 {
155
156 auto nSets = filenameVec.size();
157
158 if (nSets == 0)
159 return json({});
160
161 auto j = json({{"Sets", nSets}});
162 for (size_t i = 0; i < nSets; i++) {
163 double h = meshSizesVec.size() > i ? meshSizesVec[i] : -1.;
165 json{{"File", filenameVec[i]}, {"Mesh_Size", h}});
166
167 std::string set_name = "Set_" + std::to_string(i+1);
168 j[set_name] = js;
169 }
170
171 return j;
172 }
static json getExampleJson(const json &given=json::object())
Returns example JSON object for ModelDeck configuration.
Definition meshDeck.h:81

References inp::MeshDeck::getExampleJson().

Referenced by getInputJson().

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

◆ getParticleNeighborExampleJson()

static json inp::ParticleDeck::getParticleNeighborExampleJson ( const json &  given = json::object())
inlinestatic

Returns the neighbor block with the given fields set.

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

Definition at line 273 of file particleDeck.h.

274 {
276 }
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.

References inp::PNeighborDeck::getExampleJson().

Here is the call graph for this function:

◆ print()

void inp::ParticleDeck::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 351 of file particleDeck.h.

351{ 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::ParticleDeck::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 302 of file particleDeck.h.

302 {
303
304 auto tabS = util::io::getTabS(nt);
305 std::ostringstream oss;
306 oss << tabS << "------- ParticleDeck --------" << std::endl << std::endl;
307
308 oss << tabS << "Number of particle geometry groups = " << d_pGeomVec.size() << std::endl;
309 oss << tabS << "Number of particle mesh groups = " << d_pMeshVec.size() << std::endl;
310 oss << tabS << "Number of particle material groups = " << d_pMaterialVec.size() << std::endl;
311
312 oss << tabS << "Particle geometry data:" << std::endl;
313 for (size_t i = 0; i < d_pGeomVec.size(); i++) {
314 oss << tabS << "Particle geometry data for group = " << i << std::endl;
315 oss << d_pGeomVec[i].printStr(nt + 1, lvl);
316 }
317
318
319 oss << tabS << "Particle mesh data:" << std::endl;
320 for (size_t i = 0; i < d_pMeshVec.size(); i++) {
321 oss << tabS << "Particle mesh data for group = " << i << std::endl;
322 oss << d_pMeshVec[i].printStr(nt + 1, lvl);
323 }
324
325 oss << tabS << "Particle material data:" << std::endl;
326 for (size_t i = 0; i < d_pMaterialVec.size(); i++) {
327 oss << tabS << "Particle material data for group = " << i << std::endl;
328 oss << d_pMaterialVec[i].printStr(nt + 1, lvl);
329 }
330
331 oss << tabS << "Contact data:" << std::endl;
332 oss << d_contactDeck.printStr(nt + 1, lvl);
333
334 oss << tabS << "Neighbor data:" << std::endl;
335 oss << d_pNeighDeck.printStr(nt+1, lvl);
336
337 oss << tabS << "Particle generation data:" << std::endl;
338 oss << d_pGenDeck.printStr(nt+1, lvl);
339
340 oss << tabS << std::endl;
341
342 return oss.str();
343 }
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.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition pGenDeck.h:135
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
inp::ContactDeck d_contactDeck
Particle contact data.
std::vector< geom::GeomData > d_pGeomVec
Particle geometry data.
inp::PGenDeck d_pGenDeck
Particle generation data.
std::vector< inp::MaterialDeck > d_pMaterialVec
Particle material data.
inp::PNeighborDeck d_pNeighDeck
Neighbor search data.
std::vector< inp::MeshDeck > d_pMeshVec
Particle mesh data.

References d_contactDeck, d_pGenDeck, d_pGeomVec, d_pMaterialVec, d_pMeshVec, d_pNeighDeck, util::io::getTabS(), inp::ContactDeck::printStr(), inp::PGenDeck::printStr(), and inp::PNeighborDeck::printStr().

Referenced by print().

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

◆ readFromJson()

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

Definition at line 67 of file particleDeck.h.

67 {
68
69 if (j.find("Particle") != j.end())
70 readParticleGeomFromJson(j.at("Particle"));
71
72 if (j.find("Mesh") != j.end())
73 readParticleMeshFromJson(j.at("Mesh"));
74
75 if (j.find("Material") != j.end())
76 readParticleMaterialFromJson(j.at("Material"));
77
78 if (j.find("Contact") != j.end())
79 readParticleContactFromJson(j.at("Contact"));
80
81 if (j.find("Neighbor") != j.end())
82 readParticleNeighborFromJson(j.at("Neighbor"));
83
84 if (j.find("Particle_Generation") != j.end())
85 readParticleGenFromJson(j.at("Particle_Generation"));
86
87 if (d_pGeomVec.size() != d_pMeshVec.size())
88 throw std::runtime_error("Number of particle geometry groups must be equal to number of particle mesh groups");
89 }
void readParticleGenFromJson(const json &j)
void readParticleMeshFromJson(const json &j)
void readParticleGeomFromJson(const json &j)
Reads from json object.
void readParticleNeighborFromJson(const json &j)
void readParticleContactFromJson(const json &j)
void readParticleMaterialFromJson(const json &j)

References d_pGeomVec, d_pMeshVec, readParticleContactFromJson(), readParticleGenFromJson(), readParticleGeomFromJson(), readParticleMaterialFromJson(), readParticleMeshFromJson(), and readParticleNeighborFromJson().

Here is the call graph for this function:

◆ readParticleContactFromJson()

void inp::ParticleDeck::readParticleContactFromJson ( const json &  j)
inline

Definition at line 264 of file particleDeck.h.

264 {
266 }
void readFromJson(const json &j)
Reads from json object.

References d_contactDeck, and inp::ContactDeck::readFromJson().

Referenced by readFromJson().

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

◆ readParticleGenFromJson()

void inp::ParticleDeck::readParticleGenFromJson ( const json &  j)
inline

Definition at line 291 of file particleDeck.h.

291 {
293 }
void readFromJson(const json &j)
Reads from json object.
Definition pGenDeck.h:102

References d_pGenDeck, and inp::PGenDeck::readFromJson().

Referenced by readFromJson().

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

◆ readParticleGeomFromJson()

void inp::ParticleDeck::readParticleGeomFromJson ( const json &  j)
inline

Reads from json object.

Definition at line 117 of file particleDeck.h.

117 {
118
119 if (j.empty())
120 return;
121
122 if (d_particleSimType == "Multi_Particle") {
123 auto nSets = j.value("Sets", size_t(0));
124
125 d_pGeomVec.resize(nSets);
126
127 for (size_t i = 0; i < nSets; i++) {
128 auto set_name = "Set_" + std::to_string(i + 1);
129 if (j.find(set_name) == j.end())
130 throw std::runtime_error("Set " + set_name + " not found in particle geometry");
131
132 auto js = j.at(set_name);
133
134 // read
136 // create
138 }
139 } else if (d_particleSimType == "Single_Particle") {
140 d_pGeomVec.resize(1);
141 auto js = j.find("Set_1") == j.end()? j : j.at("Set_1");
142 if (js.find("Type") != js.end()) {
145 }
146 }
147 }
void createGeomObject(const std::string &geom_type, const std::vector< double > &params, const std::vector< std::string > &vec_type, const std::vector< std::string > &vec_flag, std::shared_ptr< geom::GeomObject > &obj, bool perform_check)
void readGeometry(const json &j, geom::GeomData &geomData)

References geom::createGeomObject(), d_particleSimType, d_pGeomVec, and geom::readGeometry().

Referenced by readFromJson().

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

◆ readParticleMaterialFromJson()

void inp::ParticleDeck::readParticleMaterialFromJson ( const json &  j)
inline

Definition at line 224 of file particleDeck.h.

224 {
225 if (j.empty())
226 return;
227
228 if (d_particleSimType == "Multi_Particle") {
229 auto nSets = j.value("Sets", size_t(0));
230 d_pMaterialVec.resize(nSets);
231
232 for (size_t i = 0; i < nSets; i++) {
233 auto set_name = "Set_" + std::to_string(i + 1);
234 if (j.find(set_name) == j.end())
235 throw std::runtime_error("Set " + set_name + " not found in particle mesh");
236
237 auto js = j.at(set_name);
238
239 // copy this set from previous set?
240 int copy_set = js.value("Copy_Data", int(-1));
241 if (copy_set != -1) {
242 std::string copy_set_tag = "Set_" + std::to_string(copy_set);
243 auto js_copy = j.at(copy_set_tag);
244 d_pMaterialVec[i].readFromJson(js_copy);
245 } else {
246 d_pMaterialVec[i].readFromJson(js);
247 }
248 } // loop over sets
249 } else if (d_particleSimType == "Single_Particle") {
250 d_pMaterialVec.resize(1);
251 auto js = j.find("Set_1") == j.end()? j : j.at("Set_1");
252 d_pMaterialVec[0].readFromJson(js);
253 }
254 }

References d_particleSimType, and d_pMaterialVec.

Referenced by readFromJson().

Here is the caller graph for this function:

◆ readParticleMeshFromJson()

void inp::ParticleDeck::readParticleMeshFromJson ( const json &  j)
inline

Definition at line 174 of file particleDeck.h.

174 {
175 if (j.empty())
176 return;
177
178 if (d_particleSimType == "Multi_Particle") {
179 auto nSets = j.value("Sets", size_t(0));
180 d_pMeshVec.resize(nSets);
181
182 for (size_t i = 0; i < nSets; i++) {
183 auto set_name = "Set_" + std::to_string(i + 1);
184
185 if (j.find(set_name) == j.end())
186 throw std::runtime_error("Set " + set_name + " not found in particle mesh");
187
188 auto js = j.at(set_name);
189
190 // copy this set from a previous set?
191 int copy_set = js.value("Copy_Data", int(-1));
192 if (copy_set != -1) {
193 std::string copy_set_tag = "Set_" + std::to_string(copy_set);
194 auto js_copy = j.at(copy_set_tag);
195 d_pMeshVec[i].readFromJson(js_copy);
196 } else
197 d_pMeshVec[i].readFromJson(js);
198 }
199 } else if (d_particleSimType == "Single_Particle") {
200 d_pMeshVec.resize(1);
201 auto js = j.find("Set_1") == j.end()? j : j.at("Set_1");
202 d_pMeshVec[0].readFromJson(js);
203 }
204 }

References d_particleSimType, and d_pMeshVec.

Referenced by readFromJson().

Here is the caller graph for this function:

◆ readParticleNeighborFromJson()

void inp::ParticleDeck::readParticleNeighborFromJson ( const json &  j)
inline

Definition at line 278 of file particleDeck.h.

278 {
280 }
void readFromJson(const json &j)
Reads from json object.

References d_pNeighDeck, and inp::PNeighborDeck::readFromJson().

Referenced by readFromJson().

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

Field Documentation

◆ d_contactDeck

inp::ContactDeck inp::ParticleDeck::d_contactDeck

Particle contact data.

Definition at line 51 of file particleDeck.h.

Referenced by printStr(), and readParticleContactFromJson().

◆ d_particleSimType

std::string inp::ParticleDeck::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 39 of file particleDeck.h.

Referenced by readParticleGeomFromJson(), readParticleMaterialFromJson(), and readParticleMeshFromJson().

◆ d_pGenDeck

inp::PGenDeck inp::ParticleDeck::d_pGenDeck

Particle generation data.

Definition at line 57 of file particleDeck.h.

Referenced by printStr(), and readParticleGenFromJson().

◆ d_pGeomVec

std::vector<geom::GeomData> inp::ParticleDeck::d_pGeomVec

Particle geometry data.

Definition at line 42 of file particleDeck.h.

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

◆ d_pMaterialVec

std::vector<inp::MaterialDeck> inp::ParticleDeck::d_pMaterialVec

Particle material data.

Definition at line 48 of file particleDeck.h.

Referenced by printStr(), and readParticleMaterialFromJson().

◆ d_pMeshVec

std::vector<inp::MeshDeck> inp::ParticleDeck::d_pMeshVec

Particle mesh data.

Definition at line 45 of file particleDeck.h.

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

◆ d_pNeighDeck

inp::PNeighborDeck inp::ParticleDeck::d_pNeighDeck

Neighbor search data.

Definition at line 54 of file particleDeck.h.

Referenced by printStr(), and readParticleNeighborFromJson().


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