22 #include <LbmLib/include/GlobalSimulationParameters.hpp>
23 #include <UtilLib/include/Exception.hpp>
35 const std::string& fileName) {
36 std::ifstream fileStream;
37 fileStream.open(fileName);
38 if (fileStream.is_open()) {
40 while (std::getline(fileStream, line)) {
41 std::stringstream lineStream(line);
42 if (line.at(0) !=
'#') {
43 std::string identifier;
44 lineStream >> identifier;
45 if (identifier ==
"CurrentIterations:") {
46 lineStream >> currentIteration_;
47 }
else if (identifier ==
"Iterations:") {
48 lineStream >> iterations_;
49 }
else if (identifier ==
"ReportStep:") {
50 lineStream >> reportSteps_;
51 }
else if (identifier ==
"SizeX:") {
53 }
else if (identifier ==
"SizeY:") {
55 }
else if (identifier ==
"tauFluid:") {
56 lineStream >> tauFluid_;
57 }
else if (identifier ==
"CDESolvers:") {
60 while (lineStream >> tempName >> tempTau) {
61 cdeSolvers_[tempName] = tempTau;
64 "An unknown parameter was passed in the global Parameter file");
69 lbm_fail(
"Cannot find the parameter file.");
75 const std::string& fileName)
const {
76 std::ofstream fileStream;
77 fileStream.open(fileName);
78 if (fileStream.is_open()) {
79 fileStream <<
"#Global Parameter file\n";
80 fileStream <<
"CurrentIterations:" <<
'\t' << currentIteration_ <<
"\n";
81 fileStream <<
"Iterations:" <<
'\t' << iterations_ <<
"\n";
82 fileStream <<
"ReportStep:" <<
'\t' << reportSteps_ <<
"\n";
83 fileStream <<
"SizeX:" <<
'\t' << sizeX_ <<
"\n";
84 fileStream <<
"SizeY:" <<
'\t' << sizeY_ <<
"\n";
85 fileStream <<
"tauFluid:" <<
'\t' << tauFluid_ <<
"\n";
86 fileStream <<
"CDESolvers:";
87 for (
const auto& solver : cdeSolvers_) {
88 fileStream <<
'\t' << solver.first <<
'\t' << solver.second;
93 "Problem to open the output file for the force solver");
100 const int num_threads(omp_get_max_threads());
101 omp_set_num_threads(num_threads);
102 std::cout << std::endl;
103 std::cout << std::left << std::setfill(
'*') << std::setw(51) <<
"*" <<
104 std::endl << std::setfill(
' ');
105 std::cout << std::setw(25) <<
"| PARAMETERS:" << std::setw(25) <<
107 std::cout << std::setw(25) <<
"| Threads:" << std::setw(25) <<
108 num_threads <<
"|\n";
109 std::cout << std::setw(25) <<
"| Size X:" << std::setw(25) <<
111 std::cout << std::setw(25) <<
"| Size Y:" << std::setw(25) <<
113 std::cout << std::setw(25) <<
"| Fluid Tau:" << std::setw(25) <<
115 std::cout << std::setw(25) <<
"| Iterations:" << std::setw(25) <<
116 iterations_ <<
"|\n";
117 std::cout << std::setw(25) <<
"| Current iterations:" << std::setw(25) <<
118 currentIteration_ <<
"|\n";
119 std::cout << std::setw(25) <<
"| Report Steps:" << std::setw(25) <<
120 reportSteps_ <<
"|\n";
121 for (
const auto& solver : cdeSolvers_) {
122 std::cout << std::setw(15) <<
"| CDESolver:" << std::setw(10) <<
123 "name:" << std::setw(25) << solver.first <<
"|\n";
124 std::cout << std::setw(15) <<
"| " << std::setw(10) <<
"tau: " <<
125 std::setw(25) << solver.second <<
"|\n";
127 std::cout << std::setfill(
'*') << std::setw(51) <<
"*" << std::endl;
128 std::cout << std::setfill(
' ');
void loadGlobalSimulationParameters(const std::string &fileName)
loads the parameters from the file
GlobalSimulationParameters_()
the class that stores all parameters related to the simulation
void printParameters() const
prints the parameters to the standard output
void writeGlobalSimulationParameters(const std::string &fileName) const
writes all parameters to the file