CalibrationTest.cpp File Reference
#include <Logger.h>
#include <Math/Helpers.h>

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
29 {
30  //read in params
31  // material type
32  std::string type = helpers::readFromCommandLine(argc,argv,"-speciesType",std::string("X"));
33  // type of fit function from in- to output
34  std::string fit = helpers::readFromCommandLine(argc,argv,"-fit",std::string("X"));
35  // the string that is written into the output file
36  std::string out;
37  // the name of the output file
38  std::string outFile = "CalibrationTest_" + type;
39 
40  // case specific translation from in- to output
41  if (fit == "identity1") {
42  // 1D input, 1D output: f(x)=x
43  // read param0
44  std::string string0 = helpers::readFromCommandLine(argc, argv, "-param0", std::string("0"));
45  double param0 = std::stof(string0);
46  // prepare output
47  out = std::to_string(param0);
48  outFile += "_" + string0 ;
49  } else if (fit == "identity2") {
50  // 2D input, 2D output: f(x)=x
51  // read param0
52  std::string string0 = helpers::readFromCommandLine(argc, argv, "-param0", std::string("0"));
53  double param0 = std::stof(string0);
54  std::string string1 = helpers::readFromCommandLine(argc, argv, "-param1", std::string("0"));
55  double param1 = std::stof(string1);
56  // prepare output
57  out = std::to_string(param0) + ' ' + std::to_string(param1);
58  outFile += "_" + string0 + "_" + string1;
59  } else if (fit == "calibration43") {
60  // 4D input, 3D output
61  // read param0
62  std::string string0 = helpers::readFromCommandLine(argc, argv, "-restitutionCoefficient", std::string("0"));
63  double restitutionCoefficient = std::stof(string0);
64  std::string string1 = helpers::readFromCommandLine(argc, argv, "-slidingFriction", std::string("0"));
65  double slidingFriction = std::stof(string1);
66  std::string string2 = helpers::readFromCommandLine(argc, argv, "-rollingFriction", std::string("0"));
67  double rollingFriction = std::stof(string2);
68  std::string string3 = helpers::readFromCommandLine(argc, argv, "-bondNumber", std::string("0"));
69  double bondNumber = std::stof(string3);
70  // fit
71  //double angleOfRepose = slidingFriction;
72  //double drum = slidingFriction + rollingFriction;
73  //double ffc = 1.0/(slidingFriction+rollingFriction+bondNumber);
74  double ffc = 1.0/bondNumber;
75  double angleOfRepose = slidingFriction;
76  double drum = rollingFriction;
77  // prepare output
78  out = std::to_string(ffc) + ' ' + std::to_string(angleOfRepose) + ' ' + std::to_string(drum);
79  outFile += "_" + string0 + "_" + string1 + "_" + string2 + "_" + string3;
80  } else if (fit == "calibration44") {
81  // 4D input, 4D output
82  // read param0
83  std::string string0 = helpers::readFromCommandLine(argc, argv, "-restitutionCoefficient", std::string("0"));
84  double restitutionCoefficient = std::stof(string0);
85  std::string string1 = helpers::readFromCommandLine(argc, argv, "-slidingFriction", std::string("0"));
86  double slidingFriction = std::stof(string1);
87  std::string string2 = helpers::readFromCommandLine(argc, argv, "-rollingFriction", std::string("0"));
88  double rollingFriction = std::stof(string2);
89  std::string string3 = helpers::readFromCommandLine(argc, argv, "-bondNumber", std::string("0"));
90  double bondNumber = std::stof(string3);
91  // fit
92  double dummy = restitutionCoefficient;
93  double ffc = 1.0/bondNumber;
94  double angleOfRepose = slidingFriction;
95  double drum = rollingFriction;
96  // prepare output
97  out = std::to_string(dummy) + ' ' + std::to_string(ffc) + ' ' + std::to_string(angleOfRepose) + ' ' + std::to_string(drum);
98  outFile += "_" + string0 + "_" + string1 + "_" + string2 + "_" + string3;
99  } else {
100  logger(ERROR,"fit function % unknown", fit);
101  }
102 
103  //write output
104 
105  helpers::writeToFile(outFile + ".txt", out);
106  logger(INFO,"Output to %: %",outFile, out);
107  return 0;
108 }
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
bool readFromCommandLine(int argc, char *argv[], std::string varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:103
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References ERROR, INFO, logger, helpers::readFromCommandLine(), and helpers::writeToFile().