16 vector <string>
flags = {} ;
32 std::map <std::string, bool>
requiredfieldset = {{
"dimension",
false}, {
"window size",
false}, {
"fields",
false}, {
"max time",
false}, {
"boundaries",
false}, {
"boxes",
false}} ;
38 std::map <std::string, std::string>
mapping ;
77 for (
auto v : j.items())
80 else if (v.key() ==
"savefile")
save = v.value().get<
string>() ;
81 else if (v.key() ==
"saveformat")
83 try {
saveformat = v.value().get<vector<string>>();}
84 catch(...) {
string a = v.value().get<
string>();
saveformat.push_back(
a) ; }
86 else if (v.key() ==
"window size")
88 else if (v.key() ==
"skip")
skipT = v.value().get<
int>() ;
89 else if (v.key() ==
"max time") {
maxT = v.value().get<
int>() ;
requiredfieldset[v.key()] = true ;}
90 else if (v.key() ==
"fields") {
flags = v.value().get<vector<string>>();
requiredfieldset[v.key()] = true ; }
93 else if (v.key() ==
"time average")
98 else if (v.value().get<
string>() ==
"Intermediate and Final" || v.value().get<
string>() ==
"Final and Intermediate")
timeaverage =
AverageType::Both ;
102 printf(
"WARN: unknown average type (allowed: 'None', 'Final', 'Intermediate', 'Intermediate and Final', 'Pre pass 5', 'Intermediate and pre pass 5'). Case sensitive\n") ;
106 else if (v.key() ==
"density") {
default_density=v.value().get<
double>() ; }
107 else if (v.key() ==
"radius") {
default_radius=v.value().get<
double>() ; }
108 else if (v.key() ==
"diameter") {
default_radius=v.value().get<
double>()/2. ; }
109 else if (v.key() ==
"superquadric") {
114 else if (v.key() ==
"dimension") {
dim = v.value().get<
int>() ;
requiredfieldset[v.key()] = true ; }
115 else printf(
"Unknown json key: %s.\n", v.key().c_str()) ;
127 printf(
"%d ", ts) ;fflush(stdout) ;
128 for (
auto & v:
files)
130 v.reader->read_timestep(ts) ;
137 if (
files.size() ==0) { printf(
"ERR: a file should be defined.\n"); return ; }
139 if (!
requiredfieldset[
"window size"]) { printf(
"ERR: 'window size' is required and cannot be built. \n") ; return ; }
140 if (!
requiredfieldset[
"fields"]) { printf(
"ERR: 'fields' is required and cannot be built. \n") ; return ; }
141 if (!
requiredfieldset[
"boxes"]) { printf(
"ERR: the number of boxes in each dimension is required and cannot be built.\n") ; return ; }
148 printf(
"ERR: Cannot find the total number of timestep from the file.\n") ;
152 printf(
"//%d//",
maxT) ;
158 printf(
"ERR: dimension of the boundaries is not consistent (should be '2 x dimension' or '3 x dimension' if including delta)\n") ;
159 if (
boxes.size() !=
static_cast<unsigned int>(
dim))
160 printf(
"ERR: dimension of the boxes is not consistent (should be 'dimension')\n") ;
174 for(
int i=0 ; i<
dim ; i++)
179 printf(
"WARN: using more than 1 box in the periodic dimension does not make much sense\n");
200 v.reader->post_init() ;
205 printf(
"THIS FUNCTION HAS BEEN REMOVED (identify_max_level)\n") ;
223 else {printf(
"Unknown windowing function.\n") ;
return Windows::Lucy3D ; }
234 else printf(
"ERR: unknown extrafields type\n") ;
235 extrafields.push_back({.name=v[
"name"].get<
string>(), .order=
static_cast<TensorOrder>(v[
"tensor order"].get<int>()), .type=typ}) ;
236 if (v.exist(
"mapping")) {
extrafields.back().mapping=v[
"mapping"].get<
string>();}
242 for (
size_t f=0 ; f<j2.size() ; f++)
247 if (j.exist(
"action"))
249 auto v = j[
"action"] ;
250 if ( v.get<
string>() ==
"remove")
255 else if (v.get<
string>() ==
"edit")
257 else if (v.get<
string>() ==
"donothing")
259 else if (v.get<
string>() ==
"create")
262 printf(
"WARN: Unknown action command on process_file\n") ;
266 if (j.exist(
"content"))
270 else if ( j[
"content"].get<string>() ==
"both") content =
FileType::both ;
271 else printf(
"WARN: unknown file content.\n") ;
273 else {printf(
"WARN: the key 'content' is recommended when defining a file. Set to 'particles' by default.\n") ;}
276 if (j.exist(
"format"))
284 else {printf(
"ERR: unknown file format.\n") ; return ;}
286 else { printf(
"ERR: the key 'format' is required when defining a file. \n") ; return ; }
289 std::map <std::string, std::string> mapping ;
290 if ( j.exist(
"mapping") ) mapping= j[
"mapping"].
get<std::map <std::string, std::string>>();
292 files.insert(
files.begin()+f, {.fileformat=format, .filetype=content, .mapping=mapping, .reader =
nullptr,}) ;
298 #ifndef NOTALLFORMATS
307 std::vector<File>::iterator it ;
308 for (it =
files.begin() ; it<
files.end() ; it++)
311 if (it ==
files.end())
313 printf(
"ERR: a dump particles needs to be defined before defining a dump contacts\n") ;
327 printf(
"ERR: no Mercury file format support FileType::both.\n") ;
336 printf(
"ERR: no Mercury VTU file format support FileType::contacts and FileType::both.\n") ;
345 printf(
"Coarse graining has not been compiled with the requested file format") ;
348 bool multifile = false ;
349 files[f].reader->path = j[
"filename"].
get<
string>() ;
350 if (j.exist(
"initial")) {multifile = true ;
files[f].reader->filenumbering.initial = j[
"initial"].
get<
double>() ; }
351 if (j.exist(
"delta")) {multifile = true ;
files[f].reader->filenumbering.delta = j[
"delta"].
get<
double>() ; }
353 if (multifile &&
files[f].reader->path.find(
'%') == std::string::npos)
354 printf(
"WARN: you have provided file initial or delta numbering, but there is no pattern in your filename, which is surprising\n") ;
355 if (
files[f].reader->path.find(
'%') != std::string::npos)
files[f].reader->filenumbering.ismultifile =
true ;
375 for (
int dd=0 ; dd<
dim ; dd++)
383 for (
int dd=0 ; dd<
dim*(
dim-1)/2 ; dd++)
391 for (
int dd=0 ; dd<4 ; dd++)
395 for (
int dd=0 ; dd<6 ; dd++)
400 for (
int dd=0 ; dd<std::get<1>(v) ; dd++)
409 if (v.reader->get_num_particles() != -1)
410 return v.reader->get_num_particles() ;
416 if (v.reader->get_num_contacts() != -1)
417 return v.reader->get_num_contacts() ;
422 auto bnds =
files[0].reader->get_bounds() ;
424 for (
size_t i=0; i<bnds[0].size() ; i++)
425 volume *= bnds[1][i]-bnds[0][i] ;
433 res = v.reader->get_data(datavalue, dd, name) ;
FileType
Definition: Parameters.h:8
@ particles
Definition: Parameters.h:8
@ both
Definition: Parameters.h:8
@ contacts
Definition: Parameters.h:8
FileFormat
Definition: Parameters.h:7
@ Interactive
Definition: Parameters.h:7
@ Yade
Definition: Parameters.h:7
@ MercuryVTU
Definition: Parameters.h:7
@ NDDEM
Definition: Parameters.h:7
@ Liggghts
Definition: Parameters.h:7
@ MercuryData
Definition: Parameters.h:7
Windows
Definition: WindowLibrary.h:2
@ Sphere3DIntersect_MonteCarlo
Definition: Reader-interactive.h:7
Definition: Reader-Liggghts.h:73
Definition: Reader-Liggghts.h:18
Definition: Reader-Mercury.h:56
Definition: Reader-Mercury.h:28
Definition: Reader-NDDEM.h:5
Definition: Reader-Yade.h:11
namespace for Niels Lohmann
Definition: json.hpp:20203
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:21875
vector< double * > superquadric
Superquadrics information.
Definition: Coarsing.h:112
vector< double * > omega
Particle angular velocity.
Definition: Coarsing.h:108
AverageType
Definition: Coarsing.h:65
vector< double * > mpq
Moment of particle 1 on 2.
Definition: Coarsing.h:123
double * radius
Particle radius.
Definition: Coarsing.h:103
int N
Number of particles.
Definition: Coarsing.h:102
vector< double * > pospq
Location of contact point.
Definition: Coarsing.h:120
double * id2
Index of the second particle in contact.
Definition: Coarsing.h:119
vector< double * > fpq
Force at contact.
Definition: Coarsing.h:122
double * mass
Particle masses.
Definition: Coarsing.h:104
vector< double * > pos
Particle positions.
Definition: Coarsing.h:106
TensorOrder
Definition: Coarsing.h:63
int Ncf
Number of contacts.
Definition: Coarsing.h:117
vector< double * > orient
Particle orientation (quaternions)
Definition: Coarsing.h:109
vector< double * > extra
Definition: Coarsing.h:127
double * id1
Index of first particle in contact.
Definition: Coarsing.h:118
vector< std::tuple< std::string, int, int > > extrafields
Definition: Coarsing.h:128
FieldType
Definition: Coarsing.h:64
double * Imom
Particle moment of inertia.
Definition: Coarsing.h:105
vector< double * > lpq
Branch vector of the contact, use compute_lpq() to populate this.
Definition: Coarsing.h:121
vector< double * > mqp
Moment of particle 2 on 1.
Definition: Coarsing.h:124
vector< double * > vel
Particle velocity.
Definition: Coarsing.h:107
@ Pre5
Definition: Coarsing.h:65
@ Final
Definition: Coarsing.h:65
@ None
Definition: Coarsing.h:65
@ IntermediateAndPre5
Definition: Coarsing.h:65
@ Both
Definition: Coarsing.h:65
@ Intermediate
Definition: Coarsing.h:65
@ Particle
Definition: Coarsing.h:64
@ Fluctuation
Definition: Coarsing.h:64
@ Contact
Definition: Coarsing.h:64
DataValue
Definition: Typedefs.h:19
@ superquadric
Definition: Typedefs.h:19
@ fpq
Definition: Typedefs.h:19
@ Imom
Definition: Typedefs.h:19
@ pospq
Definition: Typedefs.h:19
@ id2
Definition: Typedefs.h:19
@ lpq
Definition: Typedefs.h:19
@ pos
Definition: Typedefs.h:19
@ vel
Definition: Typedefs.h:19
@ orient
Definition: Typedefs.h:19
@ mqp
Definition: Typedefs.h:19
@ mpq
Definition: Typedefs.h:19
@ id1
Definition: Typedefs.h:19
@ extra_named
Definition: Typedefs.h:19
@ omega
Definition: Typedefs.h:19
@ radius
Definition: Typedefs.h:19
@ mass
Definition: Typedefs.h:19
struct JsonValue json
Definition: json_parser.h:15
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181
Data structure handling point data and contact data.
Definition: Coarsing.h:99
Definition: IOLiggghts.h:92
TensorOrder order
Definition: IOLiggghts.h:94
string name
Definition: IOLiggghts.h:93
std::optional< std::string > mapping
Definition: Parameters.h:49
int datalocation
Definition: Parameters.h:50
FieldType type
Definition: IOLiggghts.h:95
Definition: Parameters.h:35
FileFormat fileformat
Definition: Parameters.h:36
Reader * reader
Definition: Parameters.h:39
std::map< std::string, std::string > mapping
Definition: Parameters.h:38
FileType filetype
Definition: Parameters.h:37
Contains the parameters of the simulation & CG.
Definition: IOLiggghts.h:67
string windowstr
Definition: IOLiggghts.h:86
int set_data(Data &cgdata)
Definition: Parameters.h:360
int read_timestep(int ts, bool particleonly=false)
Definition: Parameters.h:124
vector< int > boxes
Definition: IOLiggghts.h:75
std::vector< double > default_sqaxes
Definition: Parameters.h:23
std::vector< File > files
Definition: Parameters.h:42
vector< vector< double > > boundaries
Definition: IOLiggghts.h:76
double default_density
Definition: Parameters.h:22
double windowsize
Definition: IOLiggghts.h:88
bool tsread
Definition: Parameters.h:55
Windows identify_window(std::string windowname)
Definition: Parameters.h:209
vector< ExtaField > extrafields
Definition: IOLiggghts.h:97
AverageType timeaverage
Definition: Parameters.h:25
vector< bool > periodicity
Definition: IOLiggghts.h:89
double get_volume()
Definition: Parameters.h:420
double * get_data(DataValue datavalue, int dd=0, std::string name="")
Definition: Parameters.h:428
vector< string > saveformat
Definition: IOLiggghts.h:78
string save
Definition: IOLiggghts.h:77
int maxT
Definition: IOLiggghts.h:72
void process_extrafields(json &j)
Definition: Parameters.h:226
vector< string > flags
Definition: IOLiggghts.h:73
Windows window
Definition: IOLiggghts.h:87
int get_num_particles()
Definition: Parameters.h:406
int get_num_contacts()
Definition: Parameters.h:413
std::vector< double > default_sqpower
Definition: Parameters.h:23
const int dim
Definition: IOLiggghts.h:74
vector< double > delta
Definition: IOLiggghts.h:90
int identify_max_level()
Definition: Parameters.h:203
std::map< std::string, bool > requiredfieldset
Definition: Parameters.h:32
int skipT
Definition: IOLiggghts.h:71
double default_radius
Definition: Parameters.h:22
int curts
Definition: Parameters.h:54
void process_file(json &j)
Definition: Parameters.h:240