Creates an object in the cgHandler of the dpm class that satisfies the options specified by the command line arguments.
First, it checks if -help was specified. In this case, the help file is displayed, and the program exits.
Second, the correct type of CG object is determined, based on the following command line arguments: name, -coordinate, -function, -fields, -timeaverage, -timesmooth
Third, all other command line arguments are read and passed into the CG object.
115 for (
unsigned i = 2;
i < argc;
i++) {
116 if (argv[
i][0] ==
'-')
117 for (
unsigned j = 1;
j < strlen(argv[
i]); ++
j) {
118 argv[
i][
j] = tolower(argv[
i][
j]);
123 for (
unsigned i = 1;
i < argc;
i++)
124 if (!strcmp(argv[
i],
"-help")) {
134 for (
unsigned i = 1;
i < argc;
i++)
135 if (!strcmp(argv[
i],
"-coordinates") || !strcmp(argv[
i],
"-stattype")) {
136 coordinate = argv[
i + 1];
137 logger(
INFO,
"Set CGCoordinates to %", coordinate);
145 for (
unsigned i = 1;
i < argc;
i++)
146 if (!strcmp(argv[
i],
"-function") || !strcmp(argv[
i],
"-cgtype")) {
147 function = argv[
i + 1];
148 logger(
INFO,
"Set CGFunction to %",
function);
156 for (
unsigned i = 1;
i < argc;
i++)
157 if (!strcmp(argv[
i],
"-fields")) {
158 fields = argv[
i + 1];
168 if (coordinate[0] ==
'T') {
169 type =
"TimeSmoothedCG";
170 coordinate = coordinate.substr(1);
172 for (
unsigned i = 1;
i < argc;
i++)
173 if (!strcmp(argv[
i],
"-timeaverage")) {
174 type =
"TimeAveragedCG";
176 }
else if (!strcmp(argv[
i],
"-timeaveraging")) {
177 logger(
ERROR,
"% is not a valid argument; use -timeaverage instead",argv[
i]);
179 for (
unsigned i = 1;
i < argc;
i++)
180 if (!strcmp(argv[
i],
"-timesmooth")) {
181 type =
"TimeSmoothedCG";
192 if (argc > 1 && argv[1][0] !=
'-') {
197 logger(
ERROR,
"Please enter a base name base name of the files to be analysed.\n"
198 "For more information, enter './MercuryCG -help'");
218 while (
i < argc && argv[
i][0] !=
'-')
i++;
221 for (;
i < argc;
i += 2) {
222 if (!strcmp(argv[
i],
"-w") || !strcmp(argv[
i],
"-width")) {
223 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
226 }
else if (!strcmp(argv[
i],
"-wt") || !strcmp(argv[
i],
"-widthTime")) {
227 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
230 }
else if (!strcmp(argv[
i],
"-dt") || !strcmp(argv[
i],
"-timeStep")) {
231 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
234 }
else if (!strcmp(argv[
i],
"-std")) {
235 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
238 }
else if (!strcmp(argv[
i],
"-eps")) {
239 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
242 }
else if (!strcmp(argv[
i],
"-verbose")) {
246 }
else if (!strcmp(argv[
i],
"-averagebeyonddomain")) {
247 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
249 logger(
INFO,
"Set averageBeyondDomain to %", argv[
i + 1]);
250 }
else if (!strcmp(argv[
i],
"-n")) {
251 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
252 cg->
setN(atoi(argv[
i + 1]));
254 }
else if (!strcmp(argv[
i],
"-nx")) {
255 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
256 cg->
setNX(atoi(argv[
i + 1]));
258 }
else if (!strcmp(argv[
i],
"-ny")) {
259 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
260 cg->
setNY(atoi(argv[
i + 1]));
262 }
else if (!strcmp(argv[
i],
"-nz")) {
263 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
264 cg->
setNZ(atoi(argv[
i + 1]));
266 }
else if (!strcmp(argv[
i],
"-h")) {
267 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
268 cg->
setH(atof(argv[
i + 1]));
270 }
else if (!strcmp(argv[
i],
"-hx")) {
271 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
272 cg->
setHX(atof(argv[
i + 1]));
274 }
else if (!strcmp(argv[
i],
"-hy")) {
275 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
276 cg->
setHY(atof(argv[
i + 1]));
278 }
else if (!strcmp(argv[
i],
"-hz")) {
279 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
280 cg->
setHZ(atof(argv[
i + 1]));
282 }
else if (!strcmp(argv[
i],
"-x")) {
283 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
284 cg->
setX(atof(argv[
i + 1]), atof(argv[
i + 2]));
285 logger(
INFO,
"Set x to (%,%)", argv[
i + 1], argv[
i + 2]);
287 }
else if (!strcmp(argv[
i],
"-y")) {
288 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
289 cg->
setY(atof(argv[
i + 1]), atof(argv[
i + 2]));
290 logger(
INFO,
"Set y to (%,%)", argv[
i + 1], argv[
i + 2]);
292 }
else if (!strcmp(argv[
i],
"-z")) {
293 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
294 cg->
setZ(atof(argv[
i + 1]), atof(argv[
i + 2]));
295 logger(
INFO,
"Set z to (%,%)", argv[
i + 1], argv[
i + 2]);
297 }
else if (!strcmp(argv[
i],
"-t")) {
298 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
301 logger(
INFO,
"Set t to (%,%)", argv[
i + 1], argv[
i + 2]);
303 }
else if (!strcmp(argv[
i],
"-savecount")) {
304 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
307 }
else if (!strcmp(argv[
i],
"-writedata")) {
309 logger(
INFO,
"Turn on data file output. Execute %.xballs to visualise output", dpm.
getName());
311 }
else if (!strcmp(argv[
i],
"-tmin")) {
312 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
315 }
else if (!strcmp(argv[
i],
"-timemin")) {
316 logger(
ERROR,
"% is not a valid argument; use -tMin instead",argv[
i]);
317 }
else if (!strcmp(argv[
i],
"-tmax")) {
318 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
321 }
else if (!strcmp(argv[
i],
"-dt")) {
322 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
324 logger(
INFO,
"Set evaluation time interval to %", argv[
i + 1]);
325 }
else if (!strcmp(argv[
i],
"-initialfilecounter")) {
326 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
328 logger(
INFO,
"Initial file counter set to %", argv[
i + 1]);
329 }
else if (!strcmp(argv[
i],
"-timemax")) {
330 logger(
ERROR,
"% is not a valid argument; use -tMax instead",argv[
i]);
331 }
else if (!strcmp(argv[
i],
"-species")) {
332 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
334 logger(
INFO,
"Evaluating species #%", atoi(argv[
i + 1]));
335 }
else if (!strcmp(argv[
i],
"-o")) {
336 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
338 logger(
INFO,
"Set output file name to %", argv[
i + 1]);
339 }
else if (!strcmp(argv[
i],
"-coordinates") || !strcmp(argv[
i],
"-stattype") || !strcmp(argv[
i],
"-cgtype") || !strcmp(argv[
i],
"-function") || !strcmp(argv[
i],
"-fields") || !strcmp(argv[
i],
"-restartandanalyse")) {
341 }
else if (!strcmp(argv[
i],
"-help") || !strcmp(argv[
i],
"-readfromrestart") || !strcmp(argv[
i],
"-timeaverage") || !strcmp(argv[
i],
"-timesmooth")) {
344 }
else if (!strcmp(argv[
i],
"-timeaveragereset")) {
346 logger(
WARN,
"This fstatistics command has no equivalent yet in MercuryCG and will be ignored: %", argv[
i]);
352 if (!std::isnormal(cg->
getEps()))
364 enum class DataSource {
368 } dataSource = DataSource::readFromData;
370 for (
unsigned i = 1;
i < argc;
i++) {
371 if (!strcmp(argv[
i],
"-readfromrestart")) {
372 dataSource = DataSource::readFromRestart;
373 }
else if (!strcmp(argv[
i],
"-restartandanalyse")) {
374 dataSource = DataSource::restartAndAnalyse;
379 if (dataSource == DataSource::readFromData) {
382 logger(
ERROR,
"Evaluation of data files has failed. Check input files.");
384 }
else if (dataSource == DataSource::readFromRestart){
388 logger(
ERROR,
"Evaluation of restart files requires multiple restart files. Check input.");
392 logger(
INFO,
"Restarting simulation for live analysis");
398 "MercuryCG has finished.\n"
399 "Coarse-grained output is written to %\n"
400 "To load output into Matlab, use data=readMercuryCG('%')",
int i
Definition: BiCGSTAB_step_by_step.cpp:9
@ MULTIPLE_FILES
each time-step will be written into/read from separate files numbered consecutively: name_....
@ MULTIPLE_FILES_PADDED
each time-step will be written into/read from separate files numbered consecutively,...
@ ONE_FILE
all data will be written into/ read from a single file called name_
LL< Log::VERBOSE > VERBOSE
Verbose information.
Definition: Logger.cc:36
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:33
void addObject(CGHandler &cg, std::string coordinate)
Definition: MercuryCG.cpp:22
Base class of all CG objects, needed to store the various CG objects in the CGHandler.
Definition: BaseCG.h:36
virtual Mdouble getWidth() const =0
Returns width_, the coarse-graining width.
void setHX(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:229
void setNY(std::size_t nY)
Sets nY_, the number of spatial mesh points in the y-direction.
Definition: BaseCG.cc:91
void setMax(Vec3D max)
Sets max_, the upper limit of the spatial domain.
Definition: BaseCG.cc:150
void setVerbose(const bool verbose)
Definition: BaseCG.h:258
void setZ(Mdouble min, Mdouble max)
Sets min_.Z, max_.Z, the limits of the spatial domain in Z.
Definition: BaseCG.cc:177
File statFile
File class to handle the output into a .stat file.
Definition: BaseCG.h:363
void setNX(std::size_t nX)
Sets nX_, the number of spatial mesh points in the x-direction.
Definition: BaseCG.cc:101
std::size_t getNY() const
Returns nY_, the number of spatial mesh points in the y-direction.
Definition: BaseCG.cc:96
Mdouble getEps() const
Definition: BaseCG.cc:76
void setHY(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:238
virtual void setWidth(Mdouble width)=0
Sets width_, the coarse-graining width.
virtual Mdouble getTimeStep() const
Definition: BaseCG.cc:272
virtual void setWidthTime(Mdouble widthTime)
Definition: BaseCG.cc:256
void setTimeMin(Mdouble timeMin)
Sets timeMin_, the lower limit of the temporal domain.
Definition: BaseCG.cc:125
void setX(Mdouble min, Mdouble max)
Sets min_.X, max_.X, the limits of the spatial domain in X.
Definition: BaseCG.cc:165
void setH(Mdouble h)
Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction....
Definition: BaseCG.cc:221
void setAverageBeyondDomain(const bool val)
Definition: BaseCG.h:254
void setEps(Mdouble eps)
Definition: BaseCG.cc:71
void setMin(Vec3D min)
Sets max_, the lower limit of the spatial domain.
Definition: BaseCG.cc:145
void selectSpecies(unsigned speciesIndex)
Definition: BaseCG.cc:208
void setNZ(std::size_t nZ)
Sets nZ_, the number of spatial mesh points in the z-direction.
Definition: BaseCG.cc:81
std::size_t getNZ() const
Returns nZ_, the number of spatial mesh points in the z-direction.
Definition: BaseCG.cc:86
void setTimeMax(Mdouble timeMax)
Sets timeMax_, the upper limit of the temporal domain.
Definition: BaseCG.cc:130
void setN(std::size_t n)
Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction.
Definition: BaseCG.cc:111
std::size_t getNX() const
Returns nX_, the number of spatial mesh points in the x-direction.
Definition: BaseCG.cc:106
void setHZ(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:247
virtual Mdouble getWidthTime() const
Definition: BaseCG.cc:266
virtual void setStandardDeviation(Mdouble std)=0
virtual void setTimeStep(Mdouble timeStep)
Definition: BaseCG.cc:261
void setY(Mdouble min, Mdouble max)
Sets min_.Y, max_.Y, the limits of the spatial domain in Y.
Definition: BaseCG.cc:171
virtual std::string getName() const =0
A purely virtual function.
bool evaluateDataFiles(bool evaluateFStatFiles=true)
does the same as StatisticsVector::statistics_from_fstat_and_data: loads a restart file (if existing)...
Definition: CGHandler.cc:307
bool evaluateRestartFiles()
Definition: CGHandler.cc:232
void setInitialFileCounter(unsigned initialFileCounter)
Definition: CGHandler.h:121
void restart(std::string name)
loads restart file, before evaluateDataFiles is run
Definition: CGHandler.cc:110
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:377
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1484
Vec3D getMax() const
Returns the maximum coordinates of the problem domain.
Definition: DPMBase.h:659
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1479
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1499
Vec3D getMin() const
Returns the minimum coordinates of the problem domain.
Definition: DPMBase.h:653
void readSpeciesFromDataFile(bool read=true)
Definition: DPMBase.h:331
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:864
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1513
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:143
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:176
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
Definition: File.cc:251
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:193
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:185
#define INFO(i)
Definition: mumps_solver.h:54
void more(const std::string &filename, unsigned nLines=constants::unsignedMax)
Definition: FileIOHelpers.cc:151
string name
Definition: plotDoE.py:33
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2