58 PGenDeck(std::string genMethod,
json pGenJson =
json({}),
bool genWithRandomRotation =
true)
66 static const std::vector<Field<PGenDeck>> &
fields() {
67 static const std::vector<Field<PGenDeck>> f = {
69 "Where the particle positions come from",
70 {{
"From_File",
"Use_Particle_Geometry"}, {}, {}}),
72 "Give each particle a random orientation when none is given"),
109 if (j.find(
"Data") == j.end())
110 throw std::runtime_error(
"Need information inside key Data.");
121 json j = json::object();
135 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
138 std::ostringstream oss;
139 oss << tabS <<
"------- PGenDeck --------" << std::endl << std::endl;
142 oss << tabS <<
"Number of particles in json object = " << nParticles << std::endl;
143 oss << tabS <<
"Data for first five particles: " << std::endl;
144 if (nParticles > 0) {
145 nParticles = nParticles > 5 ? 5 : nParticles;
146 for (
size_t i=0; i< nParticles; i++) {
147 oss << tabS <<
"Particle number = " << i << std::endl;
148 oss << tabS <<
d_pGenJson.at(std::to_string(i)) << std::endl;
151 oss << tabS << std::endl;
162 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.
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 writeFields(const Deck &d, json &j, const std::vector< Field< Deck > > &fs)
Writes every field of the table into 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 particle generation data, such as particle locations and group file.
PGenDeck(std::string genMethod, json pGenJson=json({}), bool genWithRandomRotation=true)
Constructor.
json d_pGenJson
Json object loaded from the input json file or jason file for particle generation.
json writeToJson() const
Returns this deck as a JSON object.
static const std::vector< Field< PGenDeck > > & fields()
Returns example JSON object for ModelDeck configuration.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
static json getExampleJson(const char *)=delete
Rejects a value given where a set of named values is expected.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
static json getExampleJson(const std::string &)=delete
Rejects a value given where a set of named values is expected.
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.