Microflow 3D  v1.0
CmdLineArgsParser.cpp
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 25.03.19.
4 // Copyright (c) 2019 Wroclaw University of Science and Technology.
5 // Distributed under the Apache License, Version 2.0. You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0 or see accompanying file license.txt.
7 // Redistributions of source code must retain the above copyright and license notice.
8 // ==============================================================================================
9 
10 #include "CmdLineArgsParser.h"
11 
12 void MF::Parser::CmdLineArgsParser::parseCmdLineArgs(int argc, char** argv, const char* &pathToProgramConfigFile, const char* &pathToCaseFolder,
13  const char* &scope, bool &verbose, bool &geometryOnly, int &CPU_ThreadsNr)
14 {
15 
16  for (int i = 1; i < argc; i++)
17  {
18  if (strcmp(argv[i], "-h") == 0)
19  usageInfo();
20  else if (strcmp(argv[i], "-f") == 0)
21  {
22  if (i == argc-1)
23  usageInfo();
24  pathToProgramConfigFile = argv[i+1];
25  i++;
26  }
27  else if (strcmp(argv[i], "-cf") == 0)
28  {
29  if (i == argc-1)
30  usageInfo();
31  pathToCaseFolder = argv[i+1];
32  i++;
33  }
34  else if (strcmp(argv[i], "-g") == 0)
35  {
36  geometryOnly = true;
37  }
38  else if (strcmp(argv[i], "-j") == 0)
39  {
40  if (i == argc-1)
41  usageInfo();
42  CPU_ThreadsNr = std::stoul(argv[i+1]);
43  i++;
44  }
45  else if (strcmp(argv[i], "-s") == 0)
46  {
47  if (i == argc-1)
48  usageInfo();
49  scope = argv[i+1];
50  i++;
51  }
52  else if (strcmp(argv[i], "-v") == 0)
53  {
54  verbose = true;
55  }
56  else
57  {
58  std::cout << "Unrecognised option \n\n" << argv[i] << std::endl;
59  usageInfo();
60  }
61  }
62 }
63 
64 void MF::Parser::CmdLineArgsParser::usageInfo()
65 {
66  std::cout
67  << std::endl
68  << "usage: Microflow <options>\n"
69  << std::endl
70  << "The <options> can be:\n"
71  << " -cf <path> Path to case folder\n"
72  << " -f <path> Path to Microflow configuration file \n"
73  << " -h Print this usage statement\n"
74  << " -g Only geometry build and voxelize it \n"
75  << " -j <nr> Number of CPU threads to be allocated \n"
76  << " -s <scope> Scope in config file to be used\n"
77  << " -v Verbose\n"
78  << std::endl;
79  exit(1);
80 }
81 
void parseCmdLineArgs(int argc, char **argv, const char *&pathToProgramConfigFile, const char *&pathToCaseFolder, const char *&scope, bool &verbose, bool &geometryOnly, int &CPU_ThreadsNr)