57 PGenDeck(std::string genMethod,
json pGenJson =
json({}),
bool genWithRandomRotation =
true)
67 auto j =
json({{
"Method",
"From_File"}, {
"Random_Rotation",
true}});
78 d_genMethod = j.value(
"Method", std::string(
"Use_Particle_Geometry"));
82 if (j.find(
"Data") == j.end())
83 throw std::runtime_error(
"Need information inside key Data.");
96 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
99 std::ostringstream oss;
100 oss << tabS <<
"------- PGenDeck --------" << std::endl << std::endl;
101 oss << tabS <<
"Method = " <<
d_genMethod << std::endl;
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;
113 oss << tabS << std::endl;
124 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
nlohmann::ordered_json json
Collection of methods and database related to input.
std::string getTabS(int nt)
Returns tab spaces of a given size.
Structure to read and store particle generation data, such as particle locations and group file.
PGenDeck(std::string genMethod, json pGenJson=json({}), bool genWithRandomRotation=true)
Constructor.
static json getExampleJson(std::string genMethod="From_File")
Returns example JSON object for ModelDeck configuration.
json d_pGenJson
Json object loaded from the input json file or jason file for particle generation.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
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.
bool d_genWithRandomRotation
Random rotation of particles if orientation is not provided.
PGenDeck(const json &j=json({}))
Constructor.
std::string d_genMethod
Particle generation method.