11#ifndef INP_PARTICLEDECK_H
12#define INP_PARTICLEDECK_H
69 if (j.find(
"Particle") != j.end())
72 if (j.find(
"Mesh") != j.end())
75 if (j.find(
"Material") != j.end())
78 if (j.find(
"Contact") != j.end())
81 if (j.find(
"Neighbor") != j.end())
84 if (j.find(
"Particle_Generation") != j.end())
88 throw std::runtime_error(
"Number of particle geometry groups must be equal to number of particle mesh groups");
97 auto nSets = pGeomVec.size();
102 auto j =
json({{
"Sets", nSets}});
104 for (
size_t i = 0; i < nSets; i++) {
107 std::string set_name =
"Set_" + std::to_string(i+1);
123 auto nSets = j.value(
"Sets",
size_t(0));
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");
132 auto js = j.at(set_name);
141 auto js = j.find(
"Set_1") == j.end()? j : j.at(
"Set_1");
142 if (js.find(
"Type") != js.end()) {
154 std::vector<double> meshSizesVec = std::vector<double>()) {
156 auto nSets = filenameVec.size();
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}});
167 std::string set_name =
"Set_" + std::to_string(i+1);
179 auto nSets = j.value(
"Sets",
size_t(0));
182 for (
size_t i = 0; i < nSets; i++) {
183 auto set_name =
"Set_" + std::to_string(i + 1);
185 if (j.find(set_name) == j.end())
186 throw std::runtime_error(
"Set " + set_name +
" not found in particle mesh");
188 auto js = j.at(set_name);
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);
201 auto js = j.find(
"Set_1") == j.end()? j : j.at(
"Set_1");
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);
229 auto nSets = j.value(
"Sets",
size_t(0));
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");
237 auto js = j.at(set_name);
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);
251 auto js = j.find(
"Set_1") == j.end()? j : j.at(
"Set_1");
274 const json &given = json::object()) {
302 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
305 std::ostringstream oss;
306 oss << tabS <<
"------- ParticleDeck --------" << std::endl << std::endl;
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;
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;
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;
325 oss << tabS <<
"Particle material data:" << std::endl;
327 oss << tabS <<
"Particle material data for group = " << i << std::endl;
331 oss << tabS <<
"Contact data:" << std::endl;
334 oss << tabS <<
"Neighbor data:" << std::endl;
337 oss << tabS <<
"Particle generation data:" << std::endl;
340 oss << tabS << std::endl;
351 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
nlohmann::ordered_json json
void createGeomObject(const std::string &geom_type, const std::vector< double > ¶ms, 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)
void writeGeometry(json &j, const geom::GeomData &geomData)
Collection of methods and database related to input.
std::string getTabS(int nt)
Returns tab spaces of a given size.
static json getExampleJson(const json &given=json::object())
Returns example JSON object for ModelDeck configuration.
Structure to read and store particle generation data, such as particle locations and group file.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
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.
User-input data for particle neighbor search.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
void readFromJson(const json &j)
Reads from json object.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
Structure to read and store particle related input data.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
static json getParticleContactExampleJson(size_t nSets=0)
Returns example JSON object for ModelDeck configuration.
inp::ContactDeck d_contactDeck
Particle contact data.
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.
std::vector< geom::GeomData > d_pGeomVec
Particle geometry data.
ParticleDeck(const json &j=json({}), std::string particleSimType="Multi_Particle")
Constructor.
std::string d_particleSimType
Specify if this is single or multi particle simulation Expected value is either 'Single_Particle' or ...
void readParticleGenFromJson(const json &j)
void readParticleMeshFromJson(const json &j)
inp::PGenDeck d_pGenDeck
Particle generation data.
std::vector< inp::MaterialDeck > d_pMaterialVec
Particle material data.
void readParticleGeomFromJson(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 readParticleNeighborFromJson(const json &j)
inp::PNeighborDeck d_pNeighDeck
Neighbor search data.
static json getParticleNeighborExampleJson(const json &given=json::object())
Returns the neighbor block with the given fields set.
static json getParticleMaterialExampleJson(size_t nSets=0)
Returns example JSON object for ModelDeck configuration.
void readParticleContactFromJson(const json &j)
static json getParticleGenExampleJson(const json &given=json::object())
Returns the particle generation block with the given fields set.
void readParticleMaterialFromJson(const json &j)
void readFromJson(const json &j)
std::vector< inp::MeshDeck > d_pMeshVec
Particle mesh data.