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.
127 for (
unsigned i = 2;
i < argc;
i++) {
128 if (argv[
i][0] ==
'-')
129 for (
unsigned j = 1; j < strlen(argv[
i]); ++j) {
130 argv[
i][j] = tolower(argv[
i][j]);
135 for (
unsigned i = 1;
i < argc;
i++)
136 if (!strcmp(argv[
i],
"-help")) {
145 std::string coordinate =
"O";
146 for (
unsigned i = 1;
i < argc;
i++)
147 if (!strcmp(argv[
i],
"-coordinates") || !strcmp(argv[
i],
"-stattype")) {
148 coordinate = argv[
i + 1];
149 logger(
INFO,
"Set CGCoordinates to %", coordinate);
156 std::string
function =
"Lucy";
157 for (
unsigned i = 1;
i < argc;
i++)
158 if (!strcmp(argv[
i],
"-function") || !strcmp(argv[
i],
"-cgtype")) {
159 function = argv[
i + 1];
160 logger(
INFO,
"Set CGFunction to %",
function);
167 std::string fields =
"StandardFields";
168 for (
unsigned i = 1;
i < argc;
i++)
169 if (!strcmp(argv[
i],
"-fields")) {
170 fields = argv[
i + 1];
179 std::string type =
"CG";
180 if (coordinate[0] ==
'T') {
181 type =
"TimeSmoothedCG";
182 coordinate = coordinate.substr(1);
184 for (
unsigned i = 1;
i < argc;
i++)
185 if (!strcmp(argv[
i],
"-timeaverage")) {
186 type =
"TimeAveragedCG";
188 }
else if (!strcmp(argv[
i],
"-timeaveraging")) {
189 logger(
ERROR,
"% is not a valid argument; use -timeaverage instead",argv[
i]);
191 for (
unsigned i = 1;
i < argc;
i++)
192 if (!strcmp(argv[
i],
"-timesmooth")) {
193 type =
"TimeSmoothedCG";
204 if (argc > 1 && argv[1][0] !=
'-') {
209 logger(
ERROR,
"Please enter a base name base name of the files to be analysed.\n"
210 "For more information, enter './MercuryCG -help'");
230 while (
i < argc && argv[
i][0] !=
'-')
i++;
233 for (;
i < argc;
i += 2) {
234 if (!strcmp(argv[
i],
"-w") || !strcmp(argv[
i],
"-width")) {
235 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
243 }
else if (!strcmp(argv[
i],
"-std")) {
244 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
247 }
else if (!strcmp(argv[
i],
"-verbose")) {
251 }
else if (!strcmp(argv[
i],
"-averagebeyonddomain")) {
252 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
254 logger(
INFO,
"Set averageBeyondDomain to %", argv[
i + 1]);
255 }
else if (!strcmp(argv[
i],
"-n")) {
256 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
257 cg->
setN(atoi(argv[
i + 1]));
259 }
else if (!strcmp(argv[
i],
"-nx")) {
260 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
261 cg->
setNX(atoi(argv[
i + 1]));
263 }
else if (!strcmp(argv[
i],
"-ny")) {
264 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
265 cg->
setNY(atoi(argv[
i + 1]));
267 }
else if (!strcmp(argv[
i],
"-nz")) {
268 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
269 cg->
setNZ(atoi(argv[
i + 1]));
271 }
else if (!strcmp(argv[
i],
"-h")) {
272 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
273 cg->
setH(atof(argv[
i + 1]));
275 }
else if (!strcmp(argv[
i],
"-hx")) {
276 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
277 cg->
setHX(atof(argv[
i + 1]));
279 }
else if (!strcmp(argv[
i],
"-hy")) {
280 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
281 cg->
setHY(atof(argv[
i + 1]));
283 }
else if (!strcmp(argv[
i],
"-hz")) {
284 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
285 cg->
setHZ(atof(argv[
i + 1]));
287 }
else if (!strcmp(argv[
i],
"-x")) {
288 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
289 cg->
setX(atof(argv[
i + 1]), atof(argv[
i + 2]));
290 logger(
INFO,
"Set x to (%,%)", argv[
i + 1], argv[
i + 2]);
292 }
else if (!strcmp(argv[
i],
"-y")) {
293 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
294 cg->
setY(atof(argv[
i + 1]), atof(argv[
i + 2]));
295 logger(
INFO,
"Set y to (%,%)", argv[
i + 1], argv[
i + 2]);
297 }
else if (!strcmp(argv[
i],
"-z")) {
298 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
299 cg->
setZ(atof(argv[
i + 1]), atof(argv[
i + 2]));
300 logger(
INFO,
"Set z to (%,%)", argv[
i + 1], argv[
i + 2]);
302 }
else if (!strcmp(argv[
i],
"-t")) {
303 logger.assert_debug(
i+2<argc,
"% requires two arguments",argv[
i]);
306 logger(
INFO,
"Set t to (%,%)", argv[
i + 1], argv[
i + 2]);
308 }
else if (!strcmp(argv[
i],
"-savecount")) {
309 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
312 }
else if (!strcmp(argv[
i],
"-writedata")) {
314 logger(
INFO,
"Turn on data file output. Execute %.xballs to visualise output", dpm.
getName());
316 }
else if (!strcmp(argv[
i],
"-tmin")) {
317 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
320 }
else if (!strcmp(argv[
i],
"-timemin")) {
321 logger(
ERROR,
"% is not a valid argument; use -tMin instead",argv[
i]);
322 }
else if (!strcmp(argv[
i],
"-tmax")) {
323 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
326 }
else if (!strcmp(argv[
i],
"-dt")) {
327 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
329 logger(
INFO,
"Set evaluation time interval to %", argv[
i + 1]);
330 }
else if (!strcmp(argv[
i],
"-initialfilecounter")) {
331 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
333 logger(
INFO,
"Initial file counter set to %", argv[
i + 1]);
334 }
else if (!strcmp(argv[
i],
"-timemax")) {
335 logger(
ERROR,
"% is not a valid argument; use -tMax instead",argv[
i]);
336 }
else if (!strcmp(argv[
i],
"-species")) {
337 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
339 logger(
INFO,
"Evaluating species #%", atoi(argv[
i + 1]));
340 }
else if (!strcmp(argv[
i],
"-o")) {
341 logger.assert_always(
i+1<argc,
"% requires argument",argv[
i]);
343 logger(
INFO,
"Set output file name to %", argv[
i + 1]);
344 }
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")) {
346 }
else if (!strcmp(argv[
i],
"-help") || !strcmp(argv[
i],
"-readfromrestart") || !strcmp(argv[
i],
"-timeaverage") || !strcmp(argv[
i],
"-timesmooth")) {
349 }
else if (!strcmp(argv[
i],
"-timeaveragereset")) {
351 logger(
WARN,
"This fstatistics command has no equivalent yet in MercuryCG and will be ignored: %", argv[
i]);
363 enum class DataSource {
367 } dataSource = DataSource::readFromData;
369 for (
unsigned i = 1;
i < argc;
i++) {
370 if (!strcmp(argv[
i],
"-readfromrestart")) {
371 dataSource = DataSource::readFromRestart;
372 }
else if (!strcmp(argv[
i],
"-restartandanalyse")) {
373 dataSource = DataSource::restartAndAnalyse;
378 if (dataSource == DataSource::readFromData) {
381 logger(
ERROR,
"Evaluation of data files has failed. Check input files.");
383 }
else if (dataSource == DataSource::readFromRestart){
387 logger(
ERROR,
"Evaluation of restart files requires multiple restart files. Check input.");
391 logger(
INFO,
"Restarting simulation for live analysis");
397 "MercuryCG has finished.\n"
398 "Coarse-grained output is written to %\n"
399 "To load output into Matlab, use data=readMercuryCG('%')",
@ 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::INFO > INFO
Info log level.
Definition: Logger.cc:55
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
void addObject(CGHandler &cg, std::string coordinate)
Definition: MercuryCG.cpp:40
Base class of all CG objects, needed to store the various CG objects in the CGHandler.
Definition: BaseCG.h:57
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:250
void setNY(std::size_t nY)
Sets nY_, the number of spatial mesh points in the y-direction.
Definition: BaseCG.cc:112
void setMax(Vec3D max)
Sets max_, the upper limit of the spatial domain.
Definition: BaseCG.cc:171
void setVerbose(const bool verbose)
Definition: BaseCG.h:279
void setZ(Mdouble min, Mdouble max)
Sets min_.Z, max_.Z, the limits of the spatial domain in Z.
Definition: BaseCG.cc:198
File statFile
File class to handle the output into a .stat file.
Definition: BaseCG.h:376
void setNX(std::size_t nX)
Sets nX_, the number of spatial mesh points in the x-direction.
Definition: BaseCG.cc:122
std::size_t getNY() const
Returns nY_, the number of spatial mesh points in the y-direction.
Definition: BaseCG.cc:117
void setHY(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:259
virtual void setWidth(Mdouble width)=0
Sets width_, the coarse-graining width.
void setTimeMin(Mdouble timeMin)
Sets timeMin_, the lower limit of the temporal domain.
Definition: BaseCG.cc:146
void setX(Mdouble min, Mdouble max)
Sets min_.X, max_.X, the limits of the spatial domain in X.
Definition: BaseCG.cc:186
void setH(Mdouble h)
Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction....
Definition: BaseCG.cc:242
void setAverageBeyondDomain(const bool val)
Definition: BaseCG.h:275
void setMin(Vec3D min)
Sets max_, the lower limit of the spatial domain.
Definition: BaseCG.cc:166
void selectSpecies(unsigned speciesIndex)
Definition: BaseCG.cc:229
void setNZ(std::size_t nZ)
Sets nZ_, the number of spatial mesh points in the z-direction.
Definition: BaseCG.cc:102
std::size_t getNZ() const
Returns nZ_, the number of spatial mesh points in the z-direction.
Definition: BaseCG.cc:107
void setTimeMax(Mdouble timeMax)
Sets timeMax_, the upper limit of the temporal domain.
Definition: BaseCG.cc:151
void setN(std::size_t n)
Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction.
Definition: BaseCG.cc:132
std::size_t getNX() const
Returns nX_, the number of spatial mesh points in the x-direction.
Definition: BaseCG.cc:127
void setHZ(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:268
virtual void setStandardDeviation(Mdouble std)=0
void setY(Mdouble min, Mdouble max)
Sets min_.Y, max_.Y, the limits of the spatial domain in Y.
Definition: BaseCG.cc:192
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:315
bool evaluateRestartFiles()
Definition: CGHandler.cc:247
void setInitialFileCounter(unsigned initialFileCounter)
Definition: CGHandler.h:141
void restart(std::string name)
loads restart file, before evaluateDataFiles is run
Definition: CGHandler.cc:127
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
Vec3D getMax() const
Definition: DPMBase.h:670
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1473
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1493
Vec3D getMin() const
Definition: DPMBase.h:664
void readSpeciesFromDataFile(bool read=true)
Definition: DPMBase.h:352
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1522
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:165
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:198
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
Definition: File.cc:273
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:207
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
void more(std::string filename, unsigned nLines=constants::unsignedMax)
Definition: FileIOHelpers.cc:181
std::string name
Definition: MercuryProb.h:48