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
// Output Options
unsigned short _nVolumeOutput; /*!< @brief Number of volume outputs */
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 ---
/*!
......@@ -244,6 +245,7 @@ class Config
// Linesource
double inline GetSigmaS() const { return _sigmaS; }
// Optimizer
double inline GetNewtonOptimizerEpsilon() const { return _optimizerEpsilon; }
unsigned inline GetNewtonIter() const { return _newtonIter; }
......@@ -261,6 +263,7 @@ class Config
// Output Structure
std::vector<VOLUME_OUTPUT> inline GetVolumeOutput() { return _volumeOutput; }
unsigned short inline GetNVolumeOutput() { return _nVolumeOutput; }
unsigned short inline GetOutputFrequency() { return _outputFrequency; }
// ---- Setters for option structure
......
......@@ -56,7 +56,7 @@ class PNSolver : public Solver
/*! @brief Function that prepares VTK export and csv export of the current solver iteration
@returns: Mass of current iteration
*/
double WriteOutputFields();
double WriteOutputFields( unsigned idx_pseudoTime );
// Solver
/*! @brief: parameter functions for setting up system matrix
......
......@@ -29,7 +29,7 @@ CFL_NUMBER = 0.7
% Final time for simulation
TIME_FINAL = 0.3
% Maximal Moment degree
MAX_MOMENT_SOLVER = 1
MAX_MOMENT_SOLVER = 2
%
%% Entropy settings
ENTROPY_FUNCTIONAL = MAXWELL_BOLZMANN
......
......@@ -31,7 +31,7 @@ CFL_NUMBER = 0.7
% Final time for simulation
TIME_FINAL = 0.3
% Maximal Moment degree
MAX_MOMENT_SOLVER = 3
MAX_MOMENT_SOLVER = 2
% ---- Boundary Conditions ----
% Example: BC_DIRICLET = (dummyMarker1, dummyMarker2)
......
......@@ -273,10 +273,14 @@ void Config::SetConfigOptions() {
AddStringListOption( "BC_DIRICHLET", _nMarkerDirichlet, _MarkerDirichlet );
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 );
// 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 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 ) {
......
......@@ -183,7 +183,7 @@ void MNSolver::Solve() {
// --- VTK and CSV Output ---
mass = WriteOutputFields( idx_energy );
Save( idx_energy );
WriteNNTrainingData( idx_energy );
// WriteNNTrainingData( idx_energy );
// --- Screen Output ---
if( rank == 0 ) log->info( "{:03.8f} {:01.5e}", _energies[idx_energy], mass );
......@@ -264,41 +264,44 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing
}
for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) {
switch( _settings->GetVolumeOutput()[idx_group] ) {
case MINIMAL:
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
_outputFields[idx_group][0][idx_cell] = firstMomentScaleFactor * _sol[idx_cell][0];
}
break;
case MOMENTS:
for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
if( _settings->GetOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetOutputFrequency() == 0 ) {
for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) {
switch( _settings->GetVolumeOutput()[idx_group] ) {
case MINIMAL:
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;
case DUAL_MOMENTS:
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] = _alpha[idx_cell][idx_sys];
break;
case MOMENTS:
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] = _sol[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 ) {
break;
case DUAL_MOMENTS:
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] = _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 sigma = 0;
double time = idx_pseudoTime * _dE;
double sigma = 0;
_outputFields[idx_group][0][idx_cell] =
( 4 * M_PI ) * _problem->GetAnalyticalSolution(
_mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, sigma );
}
break;
_outputFields[idx_group][0][idx_cell] =
( 4 * M_PI ) * _problem->GetAnalyticalSolution(
_mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, sigma );
}
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;
......@@ -307,7 +310,9 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void MNSolver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); }
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 ) {
......
......@@ -69,7 +69,7 @@ void PNSolver::Solve() {
if( rank == 0 ) log->info( "{:10} {:10}", "t", "mass" );
// Remove
mass = WriteOutputFields();
mass = WriteOutputFields( 0 );
if( rank == 0 ) log->info( " {:01.5e} {:01.5e}", 0.0, mass );
// Loop over energies (pseudo-time of continuous slowing down approach)
......@@ -123,7 +123,7 @@ void PNSolver::Solve() {
_sol = psiNew;
// --- VTK and CSV Output ---
mass = WriteOutputFields();
mass = WriteOutputFields( idx_energy );
Save( idx_energy );
// --- Screen Output ---
......@@ -371,7 +371,7 @@ void PNSolver::PrepareOutputFields() {
}
}
double PNSolver::WriteOutputFields() {
double PNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
double mass = 0.0;
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
double firstMomentScaleFactor = sqrt( 4 * M_PI );
......@@ -381,21 +381,24 @@ double PNSolver::WriteOutputFields() {
mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing
}
for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) {
switch( _settings->GetVolumeOutput()[idx_group] ) {
case MINIMAL:
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
_outputFields[idx_group][0][idx_cell] = _sol[idx_cell][0];
}
break;
case MOMENTS:
for( unsigned idx_sys = 0; idx_sys < _nTotalEntries; idx_sys++ ) {
if( _settings->GetOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetOutputFrequency() == 0 ) {
for( unsigned idx_group = 0; idx_group < nGroups; idx_group++ ) {
switch( _settings->GetVolumeOutput()[idx_group] ) {
case MINIMAL:
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;
default: ErrorMessages::Error( "Volume Output Group not defined for PN Solver!", CURRENT_FUNCTION ); break;
break;
case MOMENTS:
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;
......@@ -404,7 +407,9 @@ double PNSolver::WriteOutputFields() {
void PNSolver::Save() const { ExportVTK( _settings->GetOutputFile(), _outputFields, _outputFieldNames, _mesh ); }
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() {
......
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