16 vector <string>
flags = {} ;
31 std::map <std::string, bool>
requiredfieldset = {{
"dimension",
false}, {
"window size",
false}, {
"fields",
false}, {
"max time",
false}, {
"boundaries",
false}, {
"boxes",
false}} ;
37 std::map <std::string, std::string>
mapping ;
75 for (
auto v : j.items())
78 else if (v.key() ==
"savefile")
save = v.value().get<
string>() ;
79 else if (v.key() ==
"saveformat")
81 try {
saveformat = v.value().get<vector<string>>();}
82 catch(...) {
string a = v.value().get<
string>();
saveformat.push_back(
a) ; }
84 else if (v.key() ==
"window size")
86 else if (v.key() ==
"skip")
skipT = v.value().get<
int>() ;
87 else if (v.key() ==
"max time") {
maxT = v.value().get<
int>() ;
requiredfieldset[v.key()] = true ;}
88 else if (v.key() ==
"fields") {
flags = v.value().get<vector<string>>();
requiredfieldset[v.key()] = true ; }
91 else if (v.key() ==
"time average")
96 else if (v.value().get<
string>() ==
"Intermediate and Final" || v.value().get<
string>() ==
"Final and Intermediate")
timeaverage =
AverageType::Both ;
98 printf(
"WARN: unknown average type (allowed: 'None', 'Final', 'Intermediate', 'Intermediate and Final'). Case sensitive\n") ;
102 else if (v.key() ==
"density") {
default_density=v.value().get<
double>() ; }
103 else if (v.key() ==
"radius") {
default_radius=v.value().get<
double>() ; }
104 else if (v.key() ==
"diameter") {
default_radius=v.value().get<
double>()/2. ; }
106 else if (v.key() ==
"dimension") {
dim = v.value().get<
int>() ;
requiredfieldset[v.key()] = true ; }
107 else printf(
"Unknown json key: %s.\n", v.key().c_str()) ;
119 printf(
"%d ", ts) ;fflush(stdout) ;
120 for (
auto & v:
files)
122 v.reader->read_timestep(ts) ;
129 if (
files.size() ==0) { printf(
"ERR: a file should be defined.\n"); return ; }
131 if (!
requiredfieldset[
"window size"]) { printf(
"ERR: 'window size' is required and cannot be built. \n") ; return ; }
132 if (!
requiredfieldset[
"fields"]) { printf(
"ERR: 'fields' is required and cannot be built. \n") ; return ; }
133 if (!
requiredfieldset[
"boxes"]) { printf(
"ERR: the number of boxes in each dimension is required and cannot be built.\n") ; return ; }
140 printf(
"ERR: Cannot find the total number of timestep from the file.\n") ;
144 printf(
"//%d//",
maxT) ;
150 printf(
"ERR: dimension of the boundaries is not consistent (should be '2 x dimension')\n") ;
151 if (
boxes.size() !=
static_cast<unsigned int>(
dim))
152 printf(
"ERR: dimension of the boxes is not consistent (should be 'dimension')\n") ;
166 for(
int i=0 ; i<
dim ; i++)
171 printf(
"WARN: using more than 1 box in the periodic dimension does not make much sense\n");
188 v.reader->post_init() ;
193 printf(
"THIS FUNCTION HAS BEEN REMOVED (identify_max_level)\n") ;
209 else {printf(
"Unknown windowing function.\n") ;
return Windows::Lucy3D ; }
220 else printf(
"ERR: unknown extrafields type\n") ;
221 extrafields.push_back({.name=v[
"name"].get<
string>(), .order=
static_cast<TensorOrder>(v[
"tensor order"].get<int>()), .type=typ}) ;
222 if (v.exist(
"mapping")) {
extrafields.back().mapping=v[
"mapping"].get<
string>();}
228 for (
size_t f=0 ; f<j2.size() ; f++)
233 if (j.exist(
"action"))
235 auto v = j[
"action"] ;
236 if ( v.get<
string>() ==
"remove")
241 else if (v.get<
string>() ==
"edit")
243 else if (v.get<
string>() ==
"donothing")
245 else if (v.get<
string>() ==
"create")
248 printf(
"WARN: Unknown action command on process_file\n") ;
252 if (j.exist(
"content"))
256 else if ( j[
"content"].get<string>() ==
"both") content =
FileType::both ;
257 else printf(
"WARN: unknown file content.\n") ;
259 else {printf(
"WARN: the key 'content' is recommended when defining a file. Set to 'particles' by default.\n") ;}
262 if (j.exist(
"format"))
270 else {printf(
"ERR: unknown file format.\n") ; return ;}
272 else { printf(
"ERR: the key 'format' is required when defining a file. \n") ; return ; }
275 std::map <std::string, std::string> mapping ;
276 if ( j.exist(
"mapping") ) mapping= j[
"mapping"].
get<std::map <std::string, std::string>>();
278 files.insert(
files.begin()+f, {.fileformat=format, .filetype=content, .mapping=mapping, .reader =
nullptr,}) ;
284 #ifndef NOTALLFORMATS
293 std::vector<File>::iterator it ;
294 for (it =
files.begin() ; it<
files.end() ; it++)
297 if (it ==
files.end())
299 printf(
"ERR: a dump particles needs to be defined before defining a dump contacts\n") ;
313 printf(
"ERR: no Mercury file format support FileType::both.\n") ;
322 printf(
"ERR: no Mercury VTU file format support FileType::contacts and FileType::both.\n") ;
331 printf(
"Coarse graining has not been compiled with the requested file format") ;
334 bool multifile = false ;
335 files[f].reader->path = j[
"filename"].
get<
string>() ;
336 if (j.exist(
"initial")) {multifile = true ;
files[f].reader->filenumbering.initial = j[
"initial"].
get<
double>() ; }
337 if (j.exist(
"delta")) {multifile = true ;
files[f].reader->filenumbering.delta = j[
"delta"].
get<
double>() ; }
339 if (multifile &&
files[f].reader->path.find(
'%') == std::string::npos)
340 printf(
"WARN: you have provided file initial or delta numbering, but there is no pattern in your filename, which is surprising\n") ;
341 if (
files[f].reader->path.find(
'%') != std::string::npos)
files[f].reader->filenumbering.ismultifile =
true ;
361 for (
int dd=0 ; dd<
dim ; dd++)
369 for (
int dd=0 ; dd<
dim*(
dim-1)/2 ; dd++)
378 for (
int dd=0 ; dd<std::get<1>(v) ; dd++)
387 if (v.reader->get_num_particles() != -1)
388 return v.reader->get_num_particles() ;
394 if (v.reader->get_num_contacts() != -1)
395 return v.reader->get_num_contacts() ;
403 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
Definition: Reader-interactive.h:7
Definition: Reader-Liggghts.h:72
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 * > omega
Particle angular velocity.
Definition: Coarsing.h:102
AverageType
Definition: Coarsing.h:60
vector< double * > mpq
Moment of particle 1 on 2.
Definition: Coarsing.h:113
double * radius
Particle radius.
Definition: Coarsing.h:97
int N
Number of particles.
Definition: Coarsing.h:96
vector< double * > pospq
Location of contact point.
Definition: Coarsing.h:110
double * id2
Index of the second particle in contact.
Definition: Coarsing.h:109
vector< double * > fpq
Force at contact.
Definition: Coarsing.h:112
double * mass
Particle masses.
Definition: Coarsing.h:98
vector< double * > pos
Particle positions.
Definition: Coarsing.h:100
TensorOrder
Definition: Coarsing.h:58
int Ncf
Number of contacts.
Definition: Coarsing.h:107
vector< double * > extra
Definition: Coarsing.h:117
double * id1
Index of first particle in contact.
Definition: Coarsing.h:108
vector< std::tuple< std::string, int, int > > extrafields
Definition: Coarsing.h:118
FieldType
Definition: Coarsing.h:59
double * Imom
Particle moment of inertia.
Definition: Coarsing.h:99
vector< double * > lpq
Branch vector of the contact, use compute_lpq() to populate this.
Definition: Coarsing.h:111
vector< double * > mqp
Moment of particle 2 on 1.
Definition: Coarsing.h:114
vector< double * > vel
Particle velocity.
Definition: Coarsing.h:101
@ Final
Definition: Coarsing.h:60
@ None
Definition: Coarsing.h:60
@ Both
Definition: Coarsing.h:60
@ Intermediate
Definition: Coarsing.h:60
@ Particle
Definition: Coarsing.h:59
@ Fluctuation
Definition: Coarsing.h:59
@ Contact
Definition: Coarsing.h:59
DataValue
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
@ 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:93
Definition: IOLiggghts.h:92
TensorOrder order
Definition: IOLiggghts.h:94
string name
Definition: IOLiggghts.h:93
std::optional< std::string > mapping
Definition: Parameters.h:48
int datalocation
Definition: Parameters.h:49
FieldType type
Definition: IOLiggghts.h:95
Definition: Parameters.h:34
FileFormat fileformat
Definition: Parameters.h:35
Reader * reader
Definition: Parameters.h:38
std::map< std::string, std::string > mapping
Definition: Parameters.h:37
FileType filetype
Definition: Parameters.h:36
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:346
int read_timestep(int ts, bool particleonly=false)
Definition: Parameters.h:116
vector< int > boxes
Definition: IOLiggghts.h:75
std::vector< File > files
Definition: Parameters.h:41
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:54
Windows identify_window(std::string windowname)
Definition: Parameters.h:197
vector< ExtaField > extrafields
Definition: IOLiggghts.h:97
AverageType timeaverage
Definition: Parameters.h:24
vector< bool > periodicity
Definition: IOLiggghts.h:89
double * get_data(DataValue datavalue, int dd=0, std::string name="")
Definition: Parameters.h:398
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:212
vector< string > flags
Definition: IOLiggghts.h:73
Windows window
Definition: IOLiggghts.h:87
int get_num_particles()
Definition: Parameters.h:384
int get_num_contacts()
Definition: Parameters.h:391
const int dim
Definition: IOLiggghts.h:74
vector< double > delta
Definition: IOLiggghts.h:90
int identify_max_level()
Definition: Parameters.h:191
std::map< std::string, bool > requiredfieldset
Definition: Parameters.h:31
int skipT
Definition: IOLiggghts.h:71
double default_radius
Definition: Parameters.h:22
int curts
Definition: Parameters.h:53
void process_file(json &j)
Definition: Parameters.h:226