Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KiT-RT
KiT-RT
Commits
988ea7e5
Commit
988ea7e5
authored
Nov 18, 2020
by
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
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
code/include/common/config.h
View file @
988ea7e5
...
...
@@ -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
<
SC
REEN
_OUTPUT
>
_screenOutput
;
/*!< @brief Output groups for screen output*/
std
::
vector
<
SC
ALAR
_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
<
SC
REEN
_OUTPUT
>
inline
GetScreenOutput
()
{
return
_screenOutput
;
}
std
::
vector
<
SC
ALAR
_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
...
...
code/include/common/globalconstants.h
View file @
988ea7e5
...
...
@@ -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
}
};
// Sc
reen
output
enum
SC
REEN
_OUTPUT
{
ITER
,
MASS
,
RMS_FLUX
};
// Sc
alar
output
enum
SC
ALAR
_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
code/include/solvers/csdsnsolver.h
View file @
988ea7e5
...
...
@@ -28,8 +28,8 @@ class CSDSNSolver : public SNSolver
void
Solve
()
override
;
private:
void
PrepareOutput
Fields
()
override
;
void
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
override
;
void
Prepare
Volume
Output
()
override
;
void
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
override
;
};
#endif // CSDSNSOLVER_H
code/include/solvers/mnsolver.h
View file @
988ea7e5
...
...
@@ -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
PrepareOutput
Fields
()
override
;
void
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
override
;
void
Prepare
Volume
Output
()
override
;
void
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
override
;
// Solver
void
FVMUpdate
(
unsigned
idx_energy
)
override
;
...
...
code/include/solvers/pnsolver.h
View file @
988ea7e5
...
...
@@ -42,10 +42,10 @@ class PNSolver : public Solver
// IO
/*! @brief Initializes the output groups and fields of this solver and names the fields */
void
PrepareOutput
Fields
()
override
;
void
Prepare
Volume
Output
()
override
;
/*! @brief Function that prepares VTK export and csv export of the current solver iteration
@returns: Mass of current iteration */
void
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
override
;
void
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
override
;
// Solver
void
FVMUpdate
(
unsigned
idx_energy
)
override
;
...
...
code/include/solvers/snsolver.h
View file @
988ea7e5
...
...
@@ -21,8 +21,8 @@ class SNSolver : public Solver
private:
// IO
void
PrepareOutput
Fields
()
override
;
void
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
override
;
void
Prepare
Volume
Output
()
override
;
void
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
override
;
// Solver
void
FVMUpdate
(
unsigned
idx_energy
)
override
;
...
...
code/include/solvers/solverbase.h
View file @
988ea7e5
...
...
@@ -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
code/input/exampleMN.cfg
View file @
988ea7e5
...
...
@@ -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
code/src/common/config.cpp
View file @
988ea7e5
...
...
@@ -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
<
SC
REEN
_OUTPUT
,
int
>
dublicate_map
;
// Check for doublicates in
SCALAR
OUTPUT
std
::
map
<
SC
ALAR
_OUTPUT
,
int
>
dublicate_map
;
for
(
unsigned
short
idx_screenOutput
=
0
;
idx_screenOutput
<
_nScreenOutput
;
idx_screenOutput
++
)
{
std
::
map
<
SC
REEN
_OUTPUT
,
int
>::
iterator
it
=
dublicate_map
.
find
(
_screenOutput
[
idx_screenOutput
]
);
std
::
map
<
SC
ALAR
_OUTPUT
,
int
>::
iterator
it
=
dublicate_map
.
find
(
_screenOutput
[
idx_screenOutput
]
);
if
(
it
==
dublicate_map
.
end
()
)
{
dublicate_map
.
insert
(
std
::
pair
<
SC
REEN
_OUTPUT
,
int
>
(
_screenOutput
[
idx_screenOutput
],
0
)
);
dublicate_map
.
insert
(
std
::
pair
<
SC
ALAR
_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.
\n
Please 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
);
}
}
}
...
...
code/src/common/io.cpp
View file @
988ea7e5
...
...
@@ -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
);
...
...
code/src/solvers/csdsnsolver.cpp
View file @
988ea7e5
...
...
@@ -41,7 +41,7 @@ CSDSNSolver::CSDSNSolver( Config* settings ) : SNSolver( settings ) {
_density
=
Vector
(
_nCells
,
1.0
);
// Solver output
PrepareOutput
Fields
();
Prepare
Volume
Output
();
}
void
CSDSNSolver
::
Solve
()
{
...
...
@@ -143,7 +143,7 @@ void CSDSNSolver::Solve() {
}
// --- VTK and CSV Output ---
WriteOutput
Fields
(
n
);
Write
Volume
Output
(
n
);
Save
(
n
);
// --- Screen Output ---
...
...
@@ -154,7 +154,7 @@ void CSDSNSolver::Solve() {
}
}
void
CSDSNSolver
::
PrepareOutput
Fields
()
{
void
CSDSNSolver
::
Prepare
Volume
Output
()
{
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
_outputFieldNames
.
resize
(
nGroups
);
...
...
@@ -187,7 +187,7 @@ void CSDSNSolver::PrepareOutputFields() {
}
}
void
CSDSNSolver
::
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
{
void
CSDSNSolver
::
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
{
double
mass
=
0.0
;
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
...
...
code/src/solvers/mnsolver.cpp
View file @
988ea7e5
...
...
@@ -51,7 +51,7 @@ MNSolver::MNSolver( Config* settings ) : Solver( settings ) {
ComputeMoments
();
// Solver output
PrepareOutput
Fields
();
Prepare
Volume
Output
();
}
MNSolver
::~
MNSolver
()
{
...
...
@@ -180,7 +180,7 @@ void MNSolver::FVMUpdate( unsigned idx_energy ) {
}
}
void
MNSolver
::
PrepareOutput
Fields
()
{
void
MNSolver
::
Prepare
Volume
Output
()
{
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
_outputFieldNames
.
resize
(
nGroups
);
...
...
@@ -244,9 +244,10 @@ void MNSolver::PrepareOutputFields() {
}
}
void
MNSolver
::
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
{
void
MNSolver
::
Write
Volume
Output
(
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 */
)
{
...
...
code/src/solvers/pnsolver.cpp
View file @
988ea7e5
...
...
@@ -48,7 +48,7 @@ PNSolver::PNSolver( Config* settings ) : Solver( settings ) {
// TODO
// Solver output
PrepareOutput
Fields
();
Prepare
Volume
Output
();
}
void
PNSolver
::
IterPreprocessing
()
{
...
...
@@ -320,7 +320,7 @@ double PNSolver::LegendrePoly( double x, int l ) { // Legacy. TO BE DELETED
}
}
void
PNSolver
::
PrepareOutput
Fields
()
{
void
PNSolver
::
Prepare
Volume
Output
()
{
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
_outputFieldNames
.
resize
(
nGroups
);
...
...
@@ -360,7 +360,7 @@ void PNSolver::PrepareOutputFields() {
}
}
void
PNSolver
::
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
{
void
PNSolver
::
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
{
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
if
(
(
_settings
->
GetVolumeOutputFrequency
()
!=
0
&&
idx_pseudoTime
%
(
unsigned
)
_settings
->
GetVolumeOutputFrequency
()
==
0
)
||
...
...
code/src/solvers/snsolver.cpp
View file @
988ea7e5
...
...
@@ -21,7 +21,7 @@ SNSolver::SNSolver( Config* settings ) : Solver( settings ) {
delete
k
;
// Solver output
PrepareOutput
Fields
();
Prepare
Volume
Output
();
}
void
SNSolver
::
IterPreprocessing
()
{
...
...
@@ -186,7 +186,7 @@ void SNSolver::FVMUpdate( unsigned idx_energy ) {
}
}
void
SNSolver
::
PrepareOutput
Fields
()
{
void
SNSolver
::
Prepare
Volume
Output
()
{
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
_outputFieldNames
.
resize
(
nGroups
);
...
...
@@ -220,7 +220,7 @@ void SNSolver::PrepareOutputFields() {
}
}
void
SNSolver
::
WriteOutput
Fields
(
unsigned
idx_pseudoTime
)
{
void
SNSolver
::
Write
Volume
Output
(
unsigned
idx_pseudoTime
)
{
unsigned
nGroups
=
(
unsigned
)
_settings
->
GetNVolumeOutput
();
if
(
(
_settings
->
GetVolumeOutputFrequency
()
!=
0
&&
idx_pseudoTime
%
(
unsigned
)
_settings
->
GetVolumeOutputFrequency
()
==
0
)
||
...
...
code/src/solvers/solverbase.cpp
View file @
988ea7e5
...
...
@@ -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
]
=
"
m
ass"
;
break
;
case
MASS
:
_screenOutputFieldNames
[
idx_field
]
=
"
M
ass"
;
break
;
case
ITER
:
_screenOutputFieldNames
[
idx_field
]
=
"
i
ter"
;
break
;
case
ITER
:
_screenOutputFieldNames
[
idx_field
]
=
"
I
ter"
;
break
;
case
RMS_FLUX
:
_screenOutputFieldNames
[
idx_field
]
=
"RMS
_
flux"
;
break
;
case
RMS_FLUX
:
_screenOutputFieldNames
[
idx_field
]
=
"RMS
flux"
;
break
;
default:
ErrorMessages
::
<