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

added option to control output write frequency


Former-commit-id: 379ab8f9
parent 178e4838
...@@ -93,6 +93,7 @@ class Config ...@@ -93,6 +93,7 @@ class Config
// Output Options // Output Options
unsigned short _nVolumeOutput; /*!< @brief Number of volume outputs */ unsigned short _nVolumeOutput; /*!< @brief Number of volume outputs */
std::vector<VOLUME_OUTPUT> _volumeOutput; /*!< @brief Output groups for volume output*/ std::vector<VOLUME_OUTPUT> _volumeOutput; /*!< @brief Output groups for volume output*/
unsigned short _outputFrequency; /*!< @brief Frequency of vtk write of volume output*/
// --- Parsing Functionality and Initializing of Options --- // --- Parsing Functionality and Initializing of Options ---
/*! /*!
...@@ -244,6 +245,7 @@ class Config ...@@ -244,6 +245,7 @@ class Config
// Linesource // Linesource
double inline GetSigmaS() const { return _sigmaS; } double inline GetSigmaS() const { return _sigmaS; }
// Optimizer // Optimizer
double inline GetNewtonOptimizerEpsilon() const { return _optimizerEpsilon; } double inline GetNewtonOptimizerEpsilon() const { return _optimizerEpsilon; }
unsigned inline GetNewtonIter() const { return _newtonIter; } unsigned inline GetNewtonIter() const { return _newtonIter; }
...@@ -261,6 +263,7 @@ class Config ...@@ -261,6 +263,7 @@ class Config
// Output Structure // Output Structure
std::vector<VOLUME_OUTPUT> inline GetVolumeOutput() { return _volumeOutput; } std::vector<VOLUME_OUTPUT> inline GetVolumeOutput() { return _volumeOutput; }
unsigned short inline GetNVolumeOutput() { return _nVolumeOutput; } unsigned short inline GetNVolumeOutput() { return _nVolumeOutput; }
unsigned short inline GetOutputFrequency() { return _outputFrequency; }
// ---- Setters for option structure // ---- Setters for option structure
......
...@@ -56,7 +56,7 @@ class PNSolver : public Solver ...@@ -56,7 +56,7 @@ class PNSolver : public Solver
/*! @brief Function that prepares VTK export and csv export of the current solver iteration /*! @brief Function that prepares VTK export and csv export of the current solver iteration
@returns: Mass of current iteration @returns: Mass of current iteration
*/ */
double WriteOutputFields(); double WriteOutputFields( unsigned idx_pseudoTime );
// Solver // Solver
/*! @brief: parameter functions for setting up system matrix /*! @brief: parameter functions for setting up system matrix
......
...@@ -29,7 +29,7 @@ CFL_NUMBER = 0.7 ...@@ -29,7 +29,7 @@ CFL_NUMBER = 0.7
% Final time for simulation % Final time for simulation
TIME_FINAL = 0.3 TIME_FINAL = 0.3
% Maximal Moment degree % Maximal Moment degree
MAX_MOMENT_SOLVER = 1 MAX_MOMENT_SOLVER = 2
% %
%% Entropy settings %% Entropy settings
ENTROPY_FUNCTIONAL = MAXWELL_BOLZMANN ENTROPY_FUNCTIONAL = MAXWELL_BOLZMANN
......
...@@ -31,7 +31,7 @@ CFL_NUMBER = 0.7 ...@@ -31,7 +31,7 @@ CFL_NUMBER = 0.7
% Final time for simulation % Final time for simulation
TIME_FINAL = 0.3 TIME_FINAL = 0.3
% Maximal Moment degree % Maximal Moment degree
MAX_MOMENT_SOLVER = 3 MAX_MOMENT_SOLVER = 2
% ---- Boundary Conditions ---- % ---- Boundary Conditions ----
% Example: BC_DIRICLET = (dummyMarker1, dummyMarker2) % Example: BC_DIRICLET = (dummyMarker1, dummyMarker2)
......
...@@ -273,10 +273,14 @@ void Config::SetConfigOptions() { ...@@ -273,10 +273,14 @@ void Config::SetConfigOptions() {
AddStringListOption( "BC_DIRICHLET", _nMarkerDirichlet, _MarkerDirichlet ); AddStringListOption( "BC_DIRICHLET", _nMarkerDirichlet, _MarkerDirichlet );
AddStringListOption( "BC_NEUMANN", _nMarkerNeumann, _MarkerNeumann ); AddStringListOption( "BC_NEUMANN", _nMarkerNeumann, _MarkerNeumann );
/*! @brief Scattering kernel \n DESCRIPTION: Describes used scattering kernel \n DEFAULT KERNEL_Isotropic \ingroup Config */
AddEnumOption( "KERNEL", _kernelName, Kernel_Map, KERNEL_Isotropic ); AddEnumOption( "KERNEL", _kernelName, Kernel_Map, KERNEL_Isotropic );
// Output related options // Output related options
/*! @brief Volume output \n DESCRIPTION: Describes output groups to write to vtk \ingroup Config */
AddEnumListOption( "VOLUME_OUTPUT", _nVolumeOutput, _volumeOutput, VolOutput_Map ); AddEnumListOption( "VOLUME_OUTPUT", _nVolumeOutput, _volumeOutput, VolOutput_Map );
/*! @brief Output Frequency \n DESCRIPTION: Describes output write frequency \n DEFAULT 0 ,i.e. only last value \ingroup Config */
AddUnsignedShortOption( "OUTPUT_FREQUENCY", _outputFrequency, 0 );
} }
void Config::SetConfigParsing( string case_filename ) { void Config::SetConfigParsing( string case_filename ) {
......
...@@ -183,7 +183,7 @@ void MNSolver::Solve() { ...@@ -183,7 +183,7 @@ void MNSolver::Solve() {
// --- VTK and CSV Output --- // --- VTK and CSV Output ---
mass = WriteOutputFields( idx_energy ); mass = WriteOutputFields( idx_energy );
Save( idx_energy ); Save( idx_energy );
WriteNNTrainingData( idx_energy ); // WriteNNTrainingData( idx_energy );
// --- Screen Output --- // --- Screen Output ---
if( rank == 0 ) log->info( "{:03.8f} {:01.5e}", _energies[idx_energy], mass ); if( rank == 0 ) log->info( "{:03.8f} {:01.5e}", _energies[idx_energy], mass );
...@@ -264,41 +264,44 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) { ...@@ -264,41 +264,44 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing
} }
for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) { if( _settings->GetOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetOutputFrequency() == 0 ) {
switch( _settings->GetVolumeOutput()[idx_group] ) {
case MINIMAL: for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { switch( _settings->GetVolumeOutput()[idx_group] ) {
_outputFields[idx_group][0][idx_cell] = firstMomentScaleFactor * _sol[idx_cell][0]; case MINIMAL:
}
break;
case MOMENTS:
for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
_outputFields[idx_group][idx_sys][idx_cell] = _sol[idx_cell][idx_sys]; _outputFields[idx_group][0][idx_cell] = firstMomentScaleFactor * _sol[idx_cell][0];
} }
} break;
break; case MOMENTS:
case DUAL_MOMENTS: for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) { for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { _outputFields[idx_group][idx_sys][idx_cell] = _sol[idx_cell][idx_sys];
_outputFields[idx_group][idx_sys][idx_cell] = _alpha[idx_cell][idx_sys]; }
} }
} break;
break; case DUAL_MOMENTS:
case ANALYTIC: for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
// Compute total "mass" of the system ==> to check conservation properties for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { _outputFields[idx_group][idx_sys][idx_cell] = _alpha[idx_cell][idx_sys];
}
}
break;
case ANALYTIC:
// Compute total "mass" of the system ==> to check conservation properties
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
double time = idx_pseudoTime * _dE; double time = idx_pseudoTime * _dE;
double sigma = 0; double sigma = 0;
_outputFields[idx_group][0][idx_cell] = _outputFields[idx_group][0][idx_cell] =
( 4 * M_PI ) * _problem->GetAnalyticalSolution( ( 4 * M_PI ) * _problem->GetAnalyticalSolution(
_mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, sigma ); _mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, sigma );
} }
break; break;
default: ErrorMessages::Error( "Volume Output Group not defined for MN Solver!", CURRENT_FUNCTION ); break; default: ErrorMessages::Error( "Volume Output Group not defined for MN Solver!", CURRENT_FUNCTION ); break;
}
} }
} }
return mass; return mass;
...@@ -307,7 +310,9 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) { ...@@ -307,7 +310,9 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void MNSolver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); } void MNSolver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); }
void MNSolver::Save( int currEnergy ) const { void MNSolver::Save( int currEnergy ) const {
ExportVTK( _settings->GetOutputFile() + "_" + std::to_string( currEnergy ), _outputFields, _outputFieldNames, _mesh ); if( _settings->GetOutputFrequency() != 0 && currEnergy % (unsigned)_settings->GetOutputFrequency() == 0 ) {
ExportVTK( _settings->GetOutputFile() + "_" + std::to_string( currEnergy ), _outputFields, _outputFieldNames, _mesh );
}
} }
void MNSolver::WriteNNTrainingData( unsigned idx_pseudoTime ) { void MNSolver::WriteNNTrainingData( unsigned idx_pseudoTime ) {
......
...@@ -69,7 +69,7 @@ void PNSolver::Solve() { ...@@ -69,7 +69,7 @@ void PNSolver::Solve() {
if( rank == 0 ) log->info( "{:10} {:10}", "t", "mass" ); if( rank == 0 ) log->info( "{:10} {:10}", "t", "mass" );
// Remove // Remove
mass = WriteOutputFields(); mass = WriteOutputFields( 0 );
if( rank == 0 ) log->info( " {:01.5e} {:01.5e}", 0.0, mass ); if( rank == 0 ) log->info( " {:01.5e} {:01.5e}", 0.0, mass );
// Loop over energies (pseudo-time of continuous slowing down approach) // Loop over energies (pseudo-time of continuous slowing down approach)
...@@ -123,7 +123,7 @@ void PNSolver::Solve() { ...@@ -123,7 +123,7 @@ void PNSolver::Solve() {
_sol = psiNew; _sol = psiNew;
// --- VTK and CSV Output --- // --- VTK and CSV Output ---
mass = WriteOutputFields(); mass = WriteOutputFields( idx_energy );
Save( idx_energy ); Save( idx_energy );
// --- Screen Output --- // --- Screen Output ---
...@@ -371,7 +371,7 @@ void PNSolver::PrepareOutputFields() { ...@@ -371,7 +371,7 @@ void PNSolver::PrepareOutputFields() {
} }
} }
double PNSolver::WriteOutputFields() { double PNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
double mass = 0.0; double mass = 0.0;
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput(); unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
double firstMomentScaleFactor = sqrt( 4 * M_PI ); double firstMomentScaleFactor = sqrt( 4 * M_PI );
...@@ -381,21 +381,24 @@ double PNSolver::WriteOutputFields() { ...@@ -381,21 +381,24 @@ double PNSolver::WriteOutputFields() {
mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing
} }
for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) { if( _settings->GetOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetOutputFrequency() == 0 ) {
switch( _settings->GetVolumeOutput()[idx_group] ) {
case MINIMAL: for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { switch( _settings->GetVolumeOutput()[idx_group] ) {
_outputFields[idx_group][0][idx_cell] = _sol[idx_cell][0]; case MINIMAL:
}
break;
case MOMENTS:
for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) { for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
_outputFields[idx_group][idx_sys][idx_cell] = firstMomentScaleFactor * _sol[idx_cell][idx_sys]; _outputFields[idx_group][0][idx_cell] = _sol[idx_cell][0];
} }
} break;
break; case MOMENTS:
default: ErrorMessages::Error( "Volume Output Group not defined for PN Solver!", CURRENT_FUNCTION ); break; for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
_outputFields[idx_group][idx_sys][idx_cell] = firstMomentScaleFactor * _sol[idx_cell][idx_sys];
}
}
break;
default: ErrorMessages::Error( "Volume Output Group not defined for PN Solver!", CURRENT_FUNCTION ); break;
}
} }
} }
return mass; return mass;
...@@ -404,7 +407,9 @@ double PNSolver::WriteOutputFields() { ...@@ -404,7 +407,9 @@ double PNSolver::WriteOutputFields() {
void PNSolver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); } void PNSolver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); }
void PNSolver::Save( int currEnergy ) const { void PNSolver::Save( int currEnergy ) const {
ExportVTK( _settings->GetOutputFile() + "_" + std::to_string( currEnergy ), _outputFields, _outputFieldNames, _mesh ); if( _settings->GetOutputFrequency() != 0 && currEnergy % (unsigned)_settings->GetOutputFrequency() == 0 ) {
ExportVTK( _settings->GetOutputFile() + "_" + std::to_string( currEnergy ), _outputFields, _outputFieldNames, _mesh );
}
} }
void PNSolver::CleanFluxMatrices() { void PNSolver::CleanFluxMatrices() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment