comments for Simulation files

This commit is contained in:
Hannes Signer 2023-08-05 21:28:44 +02:00
parent eb339667c6
commit aa4ce6a086
2 changed files with 109 additions and 68 deletions

View File

@ -1,3 +1,7 @@
/**
* @file Simulation.hpp
* @brief
*/
#include "Boundary.hpp"
#include <ios>
@ -27,87 +31,118 @@ enum TIME_MEASURE {
TIME_MEASURE_VERBOSE // print time measures after each iteration
};
/**
* @brief The class forms the interface for performing the diffusion simulations
* and contains all the methods for controlling the desired parameters, such as
* time step, number of simulations, etc.
*
*/
class Simulation {
public:
/**
* @brief Set up a runnable simulation environment with the largest stable
* time step and 1000 iterations by passing the required parameters.
*
* @param grid Valid grid object
* @param bc Valid boundary condition object
* @param approach Approach to solving the problem. Either FTCS or BTCS.
*/
Simulation(Grid &grid, Boundary &bc, APPROACH approach);
/**
* @brief Construct a new Simulation object
*
* @param grid
* @param bc
* @param aproach
*/
Simulation(Grid &grid, Boundary &bc, APPROACH approach);
/**
* @brief Set the option to output the results to a CSV file.
*
*
* @param csv_output Valid output option. The following options can be set
* here:
* - CSV_OUTPUT_OFF: do not produce csv output
* - CSV_OUTPUT_ON: produce csv output with last
* concentration matrix
* - CSV_OUTPUT_VERBOSE: produce csv output with all
* concentration matrices
* - CSV_OUTPUT_XTREME: produce csv output with all
* concentration matrices and simulation environment
*/
void setOutputCSV(CSV_OUTPUT csv_output);
/**
* @brief
*
* @param csv_output
*/
void setOutputCSV(CSV_OUTPUT csv_output);
/**
* @brief Set the options for outputting information to the console.
*
* @param console_output Valid output option. The following options can be set
* here:
* - CONSOLE_OUTPUT_OFF: do not print any output to console
* - CONSOLE_OUTPUT_ON: print before and after concentrations to console
* - CONSOLE_OUTPUT_VERBOSE: print all concentration matrices to console
*/
void setOutputConsole(CONSOLE_OUTPUT console_output);
/**
* @brief Set the Output Console object
*
* @param console_output
*/
void setOutputConsole(CONSOLE_OUTPUT console_output);
/**
* @brief Set the Time Measure object
*
* @param time_measure
*/
void setTimeMeasure(TIME_MEASURE time_measure);
/**
* @brief Set the Time Measure object
*
* @param time_measure
*/
void setTimeMeasure(TIME_MEASURE time_measure);
/**
* @brief Setting the time step for each iteration step. Time step must be
* greater than zero.
*
* @param timestep Valid timestep greater than zero.
*/
void setTimestep(double timestep);
/**
* @brief Set the Timestep object
*
* @param timetstep
*/
void setTimestep(double timetstep);
/**
* @brief Currently set time step is returned.
*
* @return double timestep
*/
double getTimestep();
/**
* @brief Get the Timestep object
*
*/
double getTimestep();
/**
* @brief Set the desired iterations to be calculated. A value greater
* than zero must be specified here.
*
* @param iterations Number of iterations to be simulated.
*/
void setIterations(int iterations);
/**
* @brief Set the Iterations object
*
* @param iterations
*/
void setIterations(int iterations);
/**
* @brief Return the currently set iterations to be calculated.
*
* @return int Number of iterations.
*/
int getIterations();
/**
* @brief Get the Iterations object
*
* @return auto
*/
int getIterations();
/**
* @brief Outputs the current concentrations of the grid on the console.
*
*/
void printConcentrationsConsole();
/**
* @brief Print the current concentrations of the grid to standard out.
*
*/
void printConcentrationsConsole();
/**
* @brief Creates a CSV file with a name containing the current simulation
* parameters. If the data name already exists, an additional counter is
* appended to the name. The name of the file is built up as follows:
* <approach> + <number rows> + <number columns> + <number of iterations>-<counter>.csv
*
* @return string Filename with given simulation parameter.
*/
string createCSVfile();
/**
* @brief
*
* @return string
*/
string createCSVfile();
/**
* @brief Writes the currently calculated concentration values of the grid
* into the CSV file with the passed filename.
*
* @param filename Name of the file to which the concentration values are
* to be written.
*/
void printConcentrationsCSV(string filename);
void printConcentrationsCSV(string filename);
/**
* @brief
*
* @return Grid
*/
void run();
/**
* @brief Method starts the simulation process with the previously set
* parameters.
*/
void run();
private:

View File

@ -65,6 +65,9 @@ void Simulation::setTimeMeasure(TIME_MEASURE time_measure) {
void Simulation::setTimestep(double timestep) {
//TODO check timestep in FTCS for max value
if(timestep <= 0){
throw_invalid_argument("Timestep has to be greater than zero.");
}
this->timestep = timestep;
}
@ -73,6 +76,9 @@ double Simulation::getTimestep() {
}
void Simulation::setIterations(int iterations) {
if(iterations <= 0){
throw_invalid_argument("Number of iterations must be greater than zero.");
}
this->iterations = iterations;
}