Commit 988ea7e5 authored by Steffen Schotthöfer's avatar Steffen Schotthöfer
Browse files

added history output option, made screen output modular, changed screen output design

parent 2d478386
Pipeline #118488 passed with stage
in 13 minutes and 48 seconds
......@@ -96,9 +96,13 @@ class Config
unsigned short _volumeOutputFrequency; /*!< @brief Frequency of vtk write of volume output*/
unsigned short _nScreenOutput; /*!< @brief Number of screen outputs */
std::vector<SCREEN_OUTPUT> _screenOutput; /*!< @brief Output groups for screen output*/
std::vector<SCALAR_OUTPUT> _screenOutput; /*!< @brief Output groups for screen output*/
unsigned short _screenOutputFrequency; /*!< @brief Frequency of screen output*/
unsigned short _nHistoryOutput; /*!< @brief Number of screen outputs */
std::vector<SCALAR_OUTPUT> _historyOutput; /*!< @brief Output groups for screen output*/
unsigned short _historyOutputFrequency; /*!< @brief Frequency of screen output*/
// --- Parsing Functionality and Initializing of Options ---
/*!
* @brief Set default values for all options not yet set.
......@@ -269,9 +273,13 @@ class Config
unsigned short inline GetNVolumeOutput() { return _nVolumeOutput; }
unsigned short inline GetVolumeOutputFrequency() { return _volumeOutputFrequency; }
std::vector<SCREEN_OUTPUT> inline GetScreenOutput() { return _screenOutput; }
std::vector<SCALAR_OUTPUT> inline GetScreenOutput() { return _screenOutput; }
unsigned short inline GetNScreenOutput() { return _nScreenOutput; }
unsigned short inline GetScreenOutputFrequency() { return _screenOutputFrequency; }
std::vector<SCALAR_OUTPUT> inline GetHistoryOutput() { return _historyOutput; }
unsigned short inline GetNHistoryOutput() { return _nHistoryOutput; }
unsigned short inline GetHistoryOutputFrequency() { return _historyOutputFrequency; }
// ---- Setters for option structure
// Quadrature Structure
......
......@@ -81,9 +81,10 @@ enum VOLUME_OUTPUT { ANALYTIC, MINIMAL, MOMENTS, DUAL_MOMENTS, DOSE };
inline std::map<std::string, VOLUME_OUTPUT> VolOutput_Map{
{ "ANALYTIC", ANALYTIC }, { "MINIMAL", MINIMAL }, { "MOMENTS", MOMENTS }, { "DUAL_MOMENTS", DUAL_MOMENTS }, { "DOSE", DOSE } };
// Screen output
enum SCREEN_OUTPUT { ITER, MASS, RMS_FLUX };
// Scalar output
enum SCALAR_OUTPUT { ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT };
inline std::map<std::string, SCREEN_OUTPUT> ScreenOutput_Map{ { "ITER", ITER }, { "MASS", MASS }, { "RMS_FLUX", RMS_FLUX } };
inline std::map<std::string, SCALAR_OUTPUT> ScalarOutput_Map{
{ "ITER", ITER }, { "MASS", MASS }, { "RMS_FLUX", RMS_FLUX }, { "VTK_OUTPUT", VTK_OUTPUT }, { "CSV_OUTPUT", CSV_OUTPUT } };
#endif // GLOBAL_CONSTANTS_H
......@@ -28,8 +28,8 @@ class CSDSNSolver : public SNSolver
void Solve() override;
private:
void PrepareOutputFields() override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
void PrepareVolumeOutput() override;
void WriteVolumeOutput( unsigned idx_pseudoTime ) override;
};
#endif // CSDSNSOLVER_H
......@@ -48,8 +48,8 @@ class MNSolver : public Solver
/*! @brief Function that writes NN Training Data in a .csv file */
void WriteNNTrainingData( unsigned idx_pseudoTime );
void PrepareOutputFields() override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
void PrepareVolumeOutput() override;
void WriteVolumeOutput( unsigned idx_pseudoTime ) override;
// Solver
void FVMUpdate( unsigned idx_energy ) override;
......
......@@ -42,10 +42,10 @@ class PNSolver : public Solver
// IO
/*! @brief Initializes the output groups and fields of this solver and names the fields */
void PrepareOutputFields() override;
void PrepareVolumeOutput() override;
/*! @brief Function that prepares VTK export and csv export of the current solver iteration
@returns: Mass of current iteration */
void WriteOutputFields( unsigned idx_pseudoTime ) override;
void WriteVolumeOutput( unsigned idx_pseudoTime ) override;
// Solver
void FVMUpdate( unsigned idx_energy ) override;
......
......@@ -21,8 +21,8 @@ class SNSolver : public Solver
private:
// IO
void PrepareOutputFields() override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
void PrepareVolumeOutput() override;
void WriteVolumeOutput( unsigned idx_pseudoTime ) override;
// Solver
void FVMUpdate( unsigned idx_energy ) override;
......
......@@ -64,6 +64,10 @@ class Solver
std::vector<double> _screenOutputFields; /*! @brief: Solver Output: dimensions (FieldID). */
std::vector<std::string> _screenOutputFieldNames; /*! @brief: Names of the outputFields: dimensions (FieldID) */
// Output related members
std::vector<double> _historyOutputFields; /*! @brief: Solver Output: dimensions (FieldID). */
std::vector<std::string> _historyOutputFieldNames; /*! @brief: Names of the outputFields: dimensions (FieldID) */
// Internal Members
VectorVector _solNew; /*! @brief: VectorVector to store the new flux and later the new solution per iteration */ // REPLACES psiNEW
Vector _fluxNew; /*! @brief: Vector to store the new Flux */
......@@ -71,18 +75,6 @@ class Solver
// ---- Member functions ----
// IO
/*! @brief Initializes the output groups and fields of this solver and names the fields */
virtual void PrepareOutputFields() = 0;
/*! @brief Function that prepares VTK export and csv export of the current solver iteration */
virtual void WriteOutputFields( unsigned idx_pseudoTime ) = 0;
/*! @brief: Initialized the output fields and their Names for the Screenoutput */
void PrepareScreenOutputFields();
/*! @brief Function that Screen Output and prints to Screen/Logger */
void WriteScreenOutputFields( unsigned idx_pseudoTime );
/*! @brief Prints ScreenOutputFields to Screen and to logger */
void PrintScreen( std::shared_ptr<spdlog::logger> log );
// Solver
/*! @brief Performs preprocessing for the current solver iteration */
virtual void IterPreprocessing() = 0;
......@@ -94,38 +86,45 @@ class Solver
virtual void FVMUpdate( unsigned idx_energy ) = 0;
// Helper
/**
* @brief ComputeTimeStep calculates the maximal stable time step
* @param cfl is cfl number
*/
/*! @brief ComputeTimeStep calculates the maximal stable time step */
double ComputeTimeStep( double cfl ) const;
/*! @brief: Computes the flux of the solution to check conservation properties */
virtual void ComputeRadFlux() = 0;
// IO
/*! @brief Initializes the output groups and fields of this solver and names the fields */
virtual void PrepareVolumeOutput() = 0;
/*! @brief Function that prepares VTK export and csv export of the current solver iteration */
virtual void WriteVolumeOutput( unsigned iteration ) = 0;
/*! @brief Save Output solution at given energy (pseudo time) to VTK file */
void Save( int currEnergy ) const;
/*! @brief: Initialized the output fields and their Names for the Screenoutput */
void PrepareScreenOutput();
/*! @brief Function that Screen Output and prints to Screen/Logger */
void WriteScreenOutput( unsigned iteration );
/*! @brief Prints ScreenOutputFields to Screen and to logger */
void PrintScreen( unsigned iteration );
/*! @brief Function that writes scalar historyOutputFields to a .csv file */
void WriteHistoryOutput();
/*! @brief: Initialized the historyOutputFields and their Names for Historyoutput */
void PrepareHistoryOutput();
public:
/**
* @brief Solver constructor
* @param settings stores all needed information
*/
/*! @brief Solver constructor
* @param settings stores all needed information */
Solver( Config* settings );
~Solver();
/**
* @brief Create constructor
* @param settings stores all needed information
* @return pointer to Solver
*/
/*! @brief Create constructor
* @param settings stores all needed information
* @return pointer to Solver */
static Solver* Create( Config* settings );
/**
* @brief Solve functions runs main time loop
*/
/*! @brief Solve functions runs main time loop */
virtual void Solve();
void Save() const; /*! @brief Save Output solution to VTK file */
void Save( int currEnergy ) const; /*! @brief Save Output solution at given energy (pseudo time) to VTK file */
/*! @brief Save Output solution to VTK file */
void Save() const;
};
#endif // SOLVER_H
......@@ -60,4 +60,8 @@ QUAD_ORDER = 8
% ----- Output ----
%
VOLUME_OUTPUT = (ANALYTIC, MINIMAL, MOMENTS, DUAL_MOMENTS)
OUTPUT_FREQUENCY = 1
VOLUME_OUTPUT_FREQUENCY = 3
SCREEN_OUTPUT = (ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT)
SCREEN_OUTPUT_FREQUENCY = 1
HISTORY_OUTPUT = (ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT)
HISTORY_OUTPUT_FREQUENCY = 1
......@@ -279,12 +279,16 @@ void Config::SetConfigOptions() {
// Output related options
/*! @brief Volume output \n DESCRIPTION: Describes output groups to write to vtk \ingroup Config */
AddEnumListOption( "VOLUME_OUTPUT", _nVolumeOutput, _volumeOutput, VolOutput_Map );
/*! @brief Volume Output Frequency \n DESCRIPTION: Describes output write frequency \n DEFAULT 0 ,i.e. only last value \ingroup Config */
AddUnsignedShortOption( "OUTPUT_FREQUENCY", _volumeOutputFrequency, 0 );
/*! @brief Screen output \n DESCRIPTION: Describes scren output groups \ingroup Config */
AddEnumListOption( "SCREEN_OUTPUT", _nScreenOutput, _screenOutput, ScreenOutput_Map );
/*! @brief Screen Output Frequency \n DESCRIPTION: Describes screen output write frequency \n DEFAULT 0 ,i.e. only last value \ingroup Config */
AddUnsignedShortOption( "SCREEN_OUTPUT_FREQUENCY", _screenOutputFrequency, 0 );
/*! @brief Volume output Frequency \n DESCRIPTION: Describes output write frequency \n DEFAULT 0 ,i.e. only last value \ingroup Config */
AddUnsignedShortOption( "VOLUME_OUTPUT_FREQUENCY", _volumeOutputFrequency, 0 );
/*! @brief Screen output \n DESCRIPTION: Describes screen output fields \ingroup Config */
AddEnumListOption( "SCREEN_OUTPUT", _nScreenOutput, _screenOutput, ScalarOutput_Map );
/*! @brief Screen output Frequency \n DESCRIPTION: Describes screen output write frequency \n DEFAULT 1 \ingroup Config */
AddUnsignedShortOption( "SCREEN_OUTPUT_FREQUENCY", _screenOutputFrequency, 1 );
/*! @brief History output \n DESCRIPTION: Describes history output fields \ingroup Config */
AddEnumListOption( "HISTORY_OUTPUT", _nHistoryOutput, _historyOutput, ScalarOutput_Map );
/*! @brief History output Frequency \n DESCRIPTION: Describes history output write frequency \n DEFAULT 1 \ingroup Config */
AddUnsignedShortOption( "HISTORY_OUTPUT_FREQUENCY", _historyOutputFrequency, 1 );
}
void Config::SetConfigParsing( string case_filename ) {
......@@ -507,13 +511,13 @@ void Config::SetPostprocessing() {
// Screen Output Postprocessing
{
// Check for doublicates in VOLUME OUTPUT
std::map<SCREEN_OUTPUT, int> dublicate_map;
// Check for doublicates in SCALAR OUTPUT
std::map<SCALAR_OUTPUT, int> dublicate_map;
for( unsigned short idx_screenOutput = 0; idx_screenOutput < _nScreenOutput; idx_screenOutput++ ) {
std::map<SCREEN_OUTPUT, int>::iterator it = dublicate_map.find( _screenOutput[idx_screenOutput] );
std::map<SCALAR_OUTPUT, int>::iterator it = dublicate_map.find( _screenOutput[idx_screenOutput] );
if( it == dublicate_map.end() ) {
dublicate_map.insert( std::pair<SCREEN_OUTPUT, int>( _screenOutput[idx_screenOutput], 0 ) );
dublicate_map.insert( std::pair<SCALAR_OUTPUT, int>( _screenOutput[idx_screenOutput], 0 ) );
}
else {
it->second++;
......@@ -527,17 +531,57 @@ void Config::SetPostprocessing() {
}
// Set ITER always to index 0 . Assume only one instance of iter is chosen
std::vector<SCREEN_OUTPUT>::iterator it;
it = find( _screenOutput.begin(), _screenOutput.end(), ITER );
_screenOutput.erase( it );
_screenOutput.insert( _screenOutput.begin(), ITER );
if( _nScreenOutput > 0 ) {
std::vector<SCALAR_OUTPUT>::iterator it;
it = find( _screenOutput.begin(), _screenOutput.end(), ITER );
_screenOutput.erase( it );
_screenOutput.insert( _screenOutput.begin(), ITER );
}
// Set default screen output
if( _nScreenOutput == 0 ) {
_nScreenOutput = 3;
_nScreenOutput = 4;
_screenOutput.push_back( ITER );
_screenOutput.push_back( RMS_FLUX );
_screenOutput.push_back( MASS );
_screenOutput.push_back( VTK_OUTPUT );
}
}
// History Output Postprocessing
{
// Check for doublicates in VOLUME OUTPUT
std::map<SCALAR_OUTPUT, int> dublicate_map;
for( unsigned short idx_screenOutput = 0; idx_screenOutput < _nHistoryOutput; idx_screenOutput++ ) {
std::map<SCALAR_OUTPUT, int>::iterator it = dublicate_map.find( _historyOutput[idx_screenOutput] );
if( it == dublicate_map.end() ) {
dublicate_map.insert( std::pair<SCALAR_OUTPUT, int>( _historyOutput[idx_screenOutput], 0 ) );
}
else {
it->second++;
}
}
for( auto& e : dublicate_map ) {
if( e.second > 0 ) {
ErrorMessages::Error( "Each output field for option SCREEN_OUTPUT can only be set once.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
}
// Set ITER always to index 0 . Assume only one instance of iter is chosen
if( _nHistoryOutput > 0 ) {
std::vector<SCALAR_OUTPUT>::iterator it;
it = find( _historyOutput.begin(), _historyOutput.end(), ITER );
_historyOutput.erase( it );
_historyOutput.insert( _historyOutput.begin(), ITER );
}
// Set default screen output
if( _nHistoryOutput == 0 ) {
_nHistoryOutput = 4;
_historyOutput.push_back( ITER );
_historyOutput.push_back( RMS_FLUX );
_historyOutput.push_back( MASS );
_historyOutput.push_back( VTK_OUTPUT );
}
}
}
......
......@@ -133,8 +133,8 @@ void ExportVTK( const std::string fileName,
writer->Write();
auto log = spdlog::get( "event" );
log->info( "Result successfully exported to '{0}'!", fileNameWithExt );
// auto log = spdlog::get( "event" );
// log->info( "Result successfully exported to '{0}'!", fileNameWithExt );
}
MPI_Barrier( MPI_COMM_WORLD );
}
......@@ -335,12 +335,12 @@ void PrintLogHeader( std::string inputFile ) {
// New design
log->info( "------------------------------------------------------------------------" );
log->info( "| ____ __.______________ _____________________ |" );
log->info( "| | |/ _| \\__ ___/ \\______ \\__ ___/ |" );
log->info( "| | < | | | | ______ | _/ | | Version |" );
log->info( "| | | \\| | | | /_____/ | | \\ | | 0.0.2 |" );
log->info( "| |____|__ \\___| |____| |____|_ / |____| |" );
log->info( "| \\/ \\/ |" );
log->info( "| _ _____ _____ ____ _____ |" );
log->info( "| | |/ /_ _|_ _| | _ \\_ _| |" );
log->info( "| | ' / | | | |_____| |_) || | Version |" );
log->info( "| | . \\ | | | |_____| _ < | | 0.0.2 |" );
log->info( "| |_|\\_\\___| |_| |_| \\_\\|_| |" );
log->info( "| |" );
log->info( "------------------------------------------------------------------------" );
log->info( "| Copyright statement goes here |" );
log->info( "------------------------------------------------------------------------\n" );
......@@ -348,7 +348,8 @@ void PrintLogHeader( std::string inputFile ) {
log->info( "Config file:\t{0}", inputFile );
log->info( "MPI Threads:\t{0}", nprocs );
log->info( "OMP Threads:\t{0}", omp_get_max_threads() );
log->info( "\n-------------------------- Config File Info ----------------------------\n" );
log->info( "\n" );
log->info( "-------------------------- Config File Info ----------------------------\n" );
// print file content while omitting comments
std::ifstream ifs( inputFile );
......
......@@ -41,7 +41,7 @@ CSDSNSolver::CSDSNSolver( Config* settings ) : SNSolver( settings ) {
_density = Vector( _nCells, 1.0 );
// Solver output
PrepareOutputFields();
PrepareVolumeOutput();
}
void CSDSNSolver::Solve() {
......@@ -143,7 +143,7 @@ void CSDSNSolver::Solve() {
}
// --- VTK and CSV Output ---
WriteOutputFields( n );
WriteVolumeOutput( n );
Save( n );
// --- Screen Output ---
......@@ -154,7 +154,7 @@ void CSDSNSolver::Solve() {
}
}
void CSDSNSolver::PrepareOutputFields() {
void CSDSNSolver::PrepareVolumeOutput() {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
_outputFieldNames.resize( nGroups );
......@@ -187,7 +187,7 @@ void CSDSNSolver::PrepareOutputFields() {
}
}
void CSDSNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void CSDSNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) {
double mass = 0.0;
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
......
......@@ -51,7 +51,7 @@ MNSolver::MNSolver( Config* settings ) : Solver( settings ) {
ComputeMoments();
// Solver output
PrepareOutputFields();
PrepareVolumeOutput();
}
MNSolver::~MNSolver() {
......@@ -180,7 +180,7 @@ void MNSolver::FVMUpdate( unsigned idx_energy ) {
}
}
void MNSolver::PrepareOutputFields() {
void MNSolver::PrepareVolumeOutput() {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
_outputFieldNames.resize( nGroups );
......@@ -244,9 +244,10 @@ void MNSolver::PrepareOutputFields() {
}
}
void MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void MNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
// Check if volume output fields are written to file this iteration
if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) ||
( idx_pseudoTime == _nEnergies - 1 ) /* need sol at last iteration */ ) {
......
......@@ -48,7 +48,7 @@ PNSolver::PNSolver( Config* settings ) : Solver( settings ) {
// TODO
// Solver output
PrepareOutputFields();
PrepareVolumeOutput();
}
void PNSolver::IterPreprocessing() {
......@@ -320,7 +320,7 @@ double PNSolver::LegendrePoly( double x, int l ) { // Legacy. TO BE DELETED
}
}
void PNSolver::PrepareOutputFields() {
void PNSolver::PrepareVolumeOutput() {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
_outputFieldNames.resize( nGroups );
......@@ -360,7 +360,7 @@ void PNSolver::PrepareOutputFields() {
}
}
void PNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void PNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) ||
......
......@@ -21,7 +21,7 @@ SNSolver::SNSolver( Config* settings ) : Solver( settings ) {
delete k;
// Solver output
PrepareOutputFields();
PrepareVolumeOutput();
}
void SNSolver::IterPreprocessing() {
......@@ -186,7 +186,7 @@ void SNSolver::FVMUpdate( unsigned idx_energy ) {
}
}
void SNSolver::PrepareOutputFields() {
void SNSolver::PrepareVolumeOutput() {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
_outputFieldNames.resize( nGroups );
......@@ -220,7 +220,7 @@ void SNSolver::PrepareOutputFields() {
}
}
void SNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void SNSolver::WriteVolumeOutput( unsigned idx_pseudoTime ) {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) ||
......
......@@ -38,7 +38,6 @@ Solver::Solver( Config* settings ) : _settings( settings ) {
_sol = _problem->SetupIC();
_solNew = _sol; // setup temporary sol variable
//_s = _problem->GetStoppingPower( _energies );
_sigmaT = _problem->GetTotalXS( _energies );
_sigmaS = _problem->GetScatteringXS( _energies );
_Q = _problem->GetExternalSource( _energies );
......@@ -51,8 +50,9 @@ Solver::Solver( Config* settings ) : _settings( settings ) {
// Solver Output
_solverOutput.resize( _nCells ); // LEGACY! Only used for CSD SN
// Screen Output
PrepareScreenOutputFields();
PrepareScreenOutput(); // Screen Output
PrepareHistoryOutput(); // History Output
// initialize Helper Variables
_fluxNew = Vector( _nCells, 0 );
......@@ -65,17 +65,6 @@ Solver::~Solver() {
delete _problem;
}
double Solver::ComputeTimeStep( double cfl ) const {
double maxEdge = -1.0;
for( unsigned j = 0; j < _nCells; j++ ) {
for( unsigned l = 0; l < _normals[j].size(); l++ ) {
double currentEdge = _areas[j] / norm( _normals[j][l] );
if( currentEdge > maxEdge ) maxEdge = currentEdge;
}
}
return cfl * maxEdge;
}
Solver* Solver::Create( Config* settings ) {
switch( settings->GetSolverName() ) {
case SN_SOLVER: return new SNSolver( settings );
......@@ -86,6 +75,68 @@ Solver* Solver::Create( Config* settings ) {
}
}
void Solver::Solve() {
int rank;
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
auto log = spdlog::get( "event" );
std::string hLine = "--";
if( rank == 0 ) {
unsigned strLen = 10; // max width of one column
char paddingChar = ' ';
// Assemble Header for Screen Output
std::string lineToPrint = "| ";
std::string tmpLine = "------------";
for( unsigned idxFields = 0; idxFields < _settings->GetNScreenOutput(); idxFields++ ) {
std::string tmp = _screenOutputFieldNames[idxFields];
if( strLen > tmp.size() ) // Padding
tmp.insert( 0, strLen - tmp.size(), paddingChar );
else if( strLen < tmp.size() ) // Cutting
tmp.resize( strLen );
lineToPrint += tmp + " |";
hLine += tmpLine;
}
log->info( "------------------------------ Solver Starts ----------------------------" );
log->info( " The simulation will run for {} iterations.", _nEnergies );
log->info( hLine );
log->info( lineToPrint );
log->info( hLine );
}
// Loop over energies (pseudo-time of continuous slowing down approach)
for( unsigned iter = 0; iter < _nEnergies; iter++ ) {
// --- Prepare Boundaries and temp variables
IterPreprocessing();
// --- Compute Fluxes ---
FluxUpdate();
// --- Finite Volume Update ---
FVMUpdate( iter );
// --- Postprocessing ---
IterPostprocessing();
// --- VTK and CSV Output ---
WriteVolumeOutput( iter );
Save( iter );
// --- Screen Output ---
WriteScreenOutput( iter );
PrintScreen( iter );
}
if( rank == 0 ) {
log->info( hLine );
log->info( "\n" );
log->info( "------------------------------ Solver Finished ---------------------------" );
}
}
void Solver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); }
void Solver::Save( int currEnergy ) const {
......@@ -94,7 +145,20 @@ void Solver::Save( int currEnergy ) const {
}
}
void Solver::PrepareScreenOutputFields() {
// --- Helper ---
double Solver::ComputeTimeStep( double cfl ) const {
double maxEdge = -1.0;
for( unsigned j = 0; j < _nCells; j++ ) {
for( unsigned l = 0; l < _normals[j].size(); l++ ) {
double currentEdge = _areas[j] / norm( _normals[j][l] );
if( currentEdge > maxEdge ) maxEdge = currentEdge;
}
}
return cfl * maxEdge;
}
// --- IO ----
void Solver::PrepareScreenOutput() {
unsigned nFields = (unsigned)_settings->GetNScreenOutput();
_screenOutputFieldNames.resize( nFields );
......@@ -106,18 +170,22 @@ void Solver::PrepareScreenOutputFields() {
// Different procedure, depending on the Group...
switch( _settings->GetScreenOutput()[idx_field] ) {
case MASS: _screenOutputFieldNames[idx_field] = "mass"; break;
case MASS: _screenOutputFieldNames[idx_field] = "Mass"; break;
case ITER: _screenOutputFieldNames[idx_field] = "iter"; break;
case ITER: _screenOutputFieldNames[idx_field] = "Iter"; break;
case RMS_FLUX: _screenOutputFieldNames[idx_field] = "RMS_flux"; break;
case RMS_FLUX: _screenOutputFieldNames[idx_field] = "RMS flux"; break;
default: ErrorMessages::<