From b7561b93e0e317dd155c0d68ecdc0bda8897ded4 Mon Sep 17 00:00:00 2001 From: philippun Date: Thu, 20 Jul 2023 14:59:31 +0200 Subject: [PATCH] changed type auto to specific type --- include/tug/Grid.hpp | 3 ++- include/tug/Simulation.hpp | 19 ++++++++++++------- src/Simulation.cpp | 17 +++++++++++------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/tug/Grid.hpp b/include/tug/Grid.hpp index 012e05d..2188f62 100644 --- a/include/tug/Grid.hpp +++ b/include/tug/Grid.hpp @@ -20,7 +20,8 @@ class Grid { */ Grid(int row, int col); - Grid(MatrixXd concentrations); + // TODO + // Grid(MatrixXd concentrations); /** * @brief Set the Concentrations object diff --git a/include/tug/Simulation.hpp b/include/tug/Simulation.hpp index f0a9ebf..f568ec8 100644 --- a/include/tug/Simulation.hpp +++ b/include/tug/Simulation.hpp @@ -43,7 +43,7 @@ class Simulation { * @brief Get the Timestep object * */ - auto getTimestep(); + double getTimestep(); /** * @brief Set the Iterations object @@ -57,14 +57,19 @@ class Simulation { * * @return auto */ - auto getIterations(); - - void printConcentrationsConsole(); - - void printConcentrationsCSV(string ident); + int getIterations(); /** - * @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 */ diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 53ce95b..a078f47 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -31,7 +31,7 @@ void Simulation::setTimestep(double timestep) { this->timestep = timestep; } -auto Simulation::getTimestep() { +double Simulation::getTimestep() { return this->timestep; } @@ -39,7 +39,7 @@ void Simulation::setIterations(int iterations) { this->iterations = iterations; } -auto Simulation::getIterations() { +int Simulation::getIterations() { return this->iterations; } @@ -49,12 +49,17 @@ void Simulation::printConcentrationsConsole() { cout << endl; } -void Simulation::printConcentrationsCSV(string ident) { +void Simulation::printConcentrationsCSV(string ident, bool appendMode) { ofstream file; string filename = "output-" + ident + ".csv"; // 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) { exit(1); } @@ -70,7 +75,7 @@ void Simulation::run() { printConcentrationsConsole(); for (int i = 0; i < iterations; i++) { if (csv_output == CSV_OUTPUT_VERBOSE) { - printConcentrationsCSV("test"); + printConcentrationsCSV("test", true); } grid.setConcentrations(FTCS(grid, bc, timestep)); // if (i != 0 && i % 200 == 0) { @@ -79,7 +84,7 @@ void Simulation::run() { } printConcentrationsConsole(); if (csv_output >= CSV_OUTPUT_ON) { - printConcentrationsCSV("test"); + printConcentrationsCSV("test", true); } } else if (approach == BTCS_APPROACH) { for (int i = 0; i < iterations; i++) {