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[] 
)
9 {
10  //read in params
11  // material type
12  std::string type = helpers::readFromCommandLine(argc,argv,"-speciesType",std::string("X"));
13  // type of fit function from in- to output
14  std::string fit = helpers::readFromCommandLine(argc,argv,"-fit",std::string("X"));
15  // the string that is written into the output file
17  // the name of the output file
18  std::string outFile = "CalibrationTest_" + type;
19 
20  // case specific translation from in- to output
21  if (fit == "identity1") {
22  // 1D input, 1D output: f(x)=x
23  // read param0
24  std::string string0 = helpers::readFromCommandLine(argc, argv, "-param0", std::string("0"));
25  double param0 = std::stof(string0);
26  // prepare output
27  out = std::to_string(param0);
28  outFile += "_" + string0 ;
29  } else if (fit == "identity2") {
30  // 2D input, 2D output: f(x)=x
31  // read param0
32  std::string string0 = helpers::readFromCommandLine(argc, argv, "-param0", std::string("0"));
33  double param0 = std::stof(string0);
34  std::string string1 = helpers::readFromCommandLine(argc, argv, "-param1", std::string("0"));
35  double param1 = std::stof(string1);
36  // prepare output
37  out = std::to_string(param0) + ' ' + std::to_string(param1);
38  outFile += "_" + string0 + "_" + string1;
39  } else if (fit == "calibration43") {
40  // 4D input, 3D output
41  // read param0
42  std::string string0 = helpers::readFromCommandLine(argc, argv, "-restitutionCoefficient", std::string("0"));
43  double restitutionCoefficient = std::stof(string0);
44  std::string string1 = helpers::readFromCommandLine(argc, argv, "-slidingFriction", std::string("0"));
45  double slidingFriction = std::stof(string1);
46  std::string string2 = helpers::readFromCommandLine(argc, argv, "-rollingFriction", std::string("0"));
47  double rollingFriction = std::stof(string2);
48  std::string string3 = helpers::readFromCommandLine(argc, argv, "-bondNumber", std::string("0"));
49  double bondNumber = std::stof(string3);
50  // fit
51  //double angleOfRepose = slidingFriction;
52  //double drum = slidingFriction + rollingFriction;
53  //double ffc = 1.0/(slidingFriction+rollingFriction+bondNumber);
54  double ffc = 1.0/bondNumber;
55  double angleOfRepose = slidingFriction;
56  double drum = rollingFriction;
57  // prepare output
58  out = std::to_string(ffc) + ' ' + std::to_string(angleOfRepose) + ' ' + std::to_string(drum);
59  outFile += "_" + string0 + "_" + string1 + "_" + string2 + "_" + string3;
60  } else if (fit == "calibration44") {
61  // 4D input, 4D output
62  // read param0
63  std::string string0 = helpers::readFromCommandLine(argc, argv, "-restitutionCoefficient", std::string("0"));
64  double restitutionCoefficient = std::stof(string0);
65  std::string string1 = helpers::readFromCommandLine(argc, argv, "-slidingFriction", std::string("0"));
66  double slidingFriction = std::stof(string1);
67  std::string string2 = helpers::readFromCommandLine(argc, argv, "-rollingFriction", std::string("0"));
68  double rollingFriction = std::stof(string2);
69  std::string string3 = helpers::readFromCommandLine(argc, argv, "-bondNumber", std::string("0"));
70  double bondNumber = std::stof(string3);
71  // fit
72  double dummy = restitutionCoefficient;
73  double ffc = 1.0/bondNumber;
74  double angleOfRepose = slidingFriction;
75  double drum = rollingFriction;
76  // prepare output
77  out = std::to_string(dummy) + ' ' + std::to_string(ffc) + ' ' + std::to_string(angleOfRepose) + ' ' + std::to_string(drum);
78  outFile += "_" + string0 + "_" + string1 + "_" + string2 + "_" + string3;
79  } else {
80  logger(ERROR,"fit function % unknown", fit);
81  }
82 
83  //write output
84 
85  helpers::writeToFile(outFile + ".txt", out);
86  logger(INFO,"Output to %: %",outFile, out);
87  return 0;
88 }
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:32
#define INFO(i)
Definition: mumps_solver.h:54
type
Definition: compute_granudrum_aor.py:141
bool readFromCommandLine(int argc, char *argv[], const std::string &varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:99
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
std::ofstream out("Result.txt")

References ERROR, INFO, logger, out(), helpers::readFromCommandLine(), oomph::Global_string_for_annotation::string(), oomph::StringConversion::to_string(), compute_granudrum_aor::type, and helpers::writeToFile().