changed type auto to specific type

This commit is contained in:
philippun 2023-07-20 14:59:31 +02:00
parent d88d7956a5
commit b7561b93e0
3 changed files with 25 additions and 14 deletions

View File

@ -20,7 +20,8 @@ class Grid {
*/ */
Grid(int row, int col); Grid(int row, int col);
Grid(MatrixXd concentrations); // TODO
// Grid(MatrixXd concentrations);
/** /**
* @brief Set the Concentrations object * @brief Set the Concentrations object

View File

@ -43,7 +43,7 @@ class Simulation {
* @brief Get the Timestep object * @brief Get the Timestep object
* *
*/ */
auto getTimestep(); double getTimestep();
/** /**
* @brief Set the Iterations object * @brief Set the Iterations object
@ -57,14 +57,19 @@ class Simulation {
* *
* @return auto * @return auto
*/ */
auto getIterations(); int getIterations();
void printConcentrationsConsole();
void printConcentrationsCSV(string ident);
/** /**
* @brief * @brief Print the current concentrations of the grid to standard out.
*
*/
void printConcentrationsConsole();
void printConcentrationsCSV(string ident, bool appendMode = false);
/**
* @brief Start the simulation with all of the previously set parameters.
* *
* @return auto * @return auto
*/ */

View File

@ -31,7 +31,7 @@ void Simulation::setTimestep(double timestep) {
this->timestep = timestep; this->timestep = timestep;
} }
auto Simulation::getTimestep() { double Simulation::getTimestep() {
return this->timestep; return this->timestep;
} }
@ -39,7 +39,7 @@ void Simulation::setIterations(int iterations) {
this->iterations = iterations; this->iterations = iterations;
} }
auto Simulation::getIterations() { int Simulation::getIterations() {
return this->iterations; return this->iterations;
} }
@ -49,12 +49,17 @@ void Simulation::printConcentrationsConsole() {
cout << endl; cout << endl;
} }
void Simulation::printConcentrationsCSV(string ident) { void Simulation::printConcentrationsCSV(string ident, bool appendMode) {
ofstream file; ofstream file;
string filename = "output-" + ident + ".csv"; string filename = "output-" + ident + ".csv";
// string directory = "output/"; // string directory = "output/";
file.open(filename, std::ios_base::app);
if (appendMode) {
file.open(filename, std::ios_base::app);
} else {
file.open(filename);
}
if (!file) { if (!file) {
exit(1); exit(1);
} }
@ -70,7 +75,7 @@ void Simulation::run() {
printConcentrationsConsole(); printConcentrationsConsole();
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
if (csv_output == CSV_OUTPUT_VERBOSE) { if (csv_output == CSV_OUTPUT_VERBOSE) {
printConcentrationsCSV("test"); printConcentrationsCSV("test", true);
} }
grid.setConcentrations(FTCS(grid, bc, timestep)); grid.setConcentrations(FTCS(grid, bc, timestep));
// if (i != 0 && i % 200 == 0) { // if (i != 0 && i % 200 == 0) {
@ -79,7 +84,7 @@ void Simulation::run() {
} }
printConcentrationsConsole(); printConcentrationsConsole();
if (csv_output >= CSV_OUTPUT_ON) { if (csv_output >= CSV_OUTPUT_ON) {
printConcentrationsCSV("test"); printConcentrationsCSV("test", true);
} }
} else if (approach == BTCS_APPROACH) { } else if (approach == BTCS_APPROACH) {
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {