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

tidy up core solver headers

parent c8ec6724
Pipeline #117480 canceled with stage
......@@ -29,7 +29,7 @@ class CSDSNSolver : public SNSolver
private:
void PrepareOutputFields() override;
double WriteOutputFields( unsigned idx_pseudoTime ) override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
};
#endif // CSDSNSOLVER_H
......@@ -20,6 +20,7 @@ class MNSolver : public Solver
~MNSolver();
private:
// --- Private member variables ---
unsigned _nTotalEntries; /*! @brief: Total number of equations in the system */
unsigned short _LMaxDegree; /*! @brief: Max Order of Moments */
......@@ -27,11 +28,10 @@ class MNSolver : public Solver
SphericalHarmonics* _basis; /*! @brief: Class to compute and store current spherical harmonics basis */
VectorVector _moments; /*! @brief: Moment Vector pre-computed at each quadrature point: dim= _nq x _nTotalEntries */
// Right hand side members
// Scattering
Vector _scatterMatDiag; /*! @brief: Diagonal of the scattering matrix (its a diagonal matrix by construction) */
// TODO: Source
// quadrature related members
// Quadrature related members
VectorVector _quadPoints; /*! @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */
Vector _weights; /*! @brief quadrature weights, dim(_weights) = (_nq) */
VectorVector _quadPointsSphere; /*! @brief (my,phi), dim(_quadPoints) = (_nq,2) */
......@@ -42,49 +42,41 @@ class MNSolver : public Solver
Layout: _nCells x _nTotalEntries*/
OptimizerBase* _optimizer; /*! @brief: Class to solve minimal entropy problem */
// ---- Member functions ---
// ---- Private Member functions ---
// IO
/*! @brief Initializes the output groups and fields of this solver and names the fields */
void PrepareOutputFields() override;
/*! @brief Function that writes NN Training Data in a .csv file */
void WriteNNTrainingData( unsigned idx_pseudoTime );
/*! @brief Function that prepares VTK export and csv export of the current solver iteration
@returns: Mass of current iteration
*/
double WriteOutputFields( unsigned idx_pseudoTime ) override;
/*! @brief : computes the global index of the moment corresponding to basis function (l,k)
* @param : degree l, it must hold: 0 <= l <=_nq
* @param : order k, it must hold: -l <=k <= l
* @returns : global index
*/
int GlobalIndex( int l, int k ) const;
void PrepareOutputFields() override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
// Solver
void FVMUpdate( VectorVector& psiNew, unsigned idx_energy ) override;
void FluxUpdate( VectorVector& psiNew ) override;
void IterPreprocessing() override;
void IterPostprocessing();
/*! @brief : Construct flux by computing the Moment of the sum of FVM discretization at the interface of cell
* @param : idx_cell = current cell id
* @returns : sum over all neighbors of flux for all moments at interface of idx_cell, idx_neighbor */
Vector ConstructFlux( unsigned idx_cell );
/*! @brief Corrects the solution _sol[idx_cell] to be realizable w.r.t. the reconstructed entropy (eta'(alpha*m))
@param idx_cell = cell where the correction happens*/
void ComputeRealizableSolution( unsigned idx_cell );
// Initialization of the solver
/*! @brief : Pre-Compute Moments at all quadrature points. */
void ComputeMoments();
/*! @brief: fucntion for computing and setting up EV matrix for scattering kernel */
void ComputeScatterMatrix();
/*! @brief Corrects the solution _sol[idx_cell] to be realizable w.r.t. the reconstructed entropy (eta'(alpha*m))
@param idx_cell = cell where the correction happens*/
void ComputeRealizableSolution( unsigned idx_cell );
// Solver
void FVMUpdate( VectorVector& psiNew, unsigned idx_energy ) override;
void FluxUpdate( VectorVector& psiNew ) override;
void IterPreprocessing() override;
void IterPostprocessing();
// Helper
void ComputeRadFlux();
/*! @brief : computes the global index of the moment corresponding to basis function (l,k)
* @param : degree l, it must hold: 0 <= l <=_nq
* @param : order k, it must hold: -l <=k <= l
* @returns : global index
*/
int GlobalIndex( int l, int k ) const;
};
#endif // MNSOLVER_H
......@@ -11,11 +11,13 @@ class PNSolver : public Solver
*/
PNSolver( Config* settings );
protected:
/*! @brief PNSolver destructor */
~PNSolver();
private:
unsigned _nTotalEntries; /*! @brief: total number of equations in the system */
unsigned _LMaxDegree; /*! @brief: maximal degree of the spherical harmonics basis*/
// VectorVector _sigmaA; /*! @brief: Absorption coefficient for all energies*/
// System Matrix for x, y and z flux
// ==> not needed after computation of A+ and A- ==> maybe safe only temporarly and remove as member?
SymMatrix _Ax; /*! @brief: Flux Jacbioan in x direction */
......@@ -33,8 +35,6 @@ class PNSolver : public Solver
Matrix _AzMinus; /*! @brief: Flux Jacbioan in z direction, negative part */
Matrix _AzAbs; /*! @brief: Flux Jacbioan in z direction, absolute part */
// double _combinedSpectralRadius; /*! @brief: Combined spectral radius of sum of flux jacobians*/
Vector _scatterMatDiag; /*! @brief: diagonal of the scattering matrix (its a diagonal matrix by construction). Contains eigenvalues of the
scattering kernel. */
......@@ -43,10 +43,9 @@ class PNSolver : public Solver
// IO
/*! @brief Initializes the output groups and fields of this solver and names the fields */
void PrepareOutputFields() override;
/*! @brief Function that prepares VTK export and csv export of the current solver iteration
@returns: Mass of current iteration */
double WriteOutputFields( unsigned idx_pseudoTime ) override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
// Solver
void FVMUpdate( VectorVector& psiNew, unsigned idx_energy ) override;
......@@ -57,7 +56,7 @@ class PNSolver : public Solver
// Helper
void ComputeRadFlux();
// Initialization
// Initialization of the Solver
/*! @brief: parameter functions for setting up system matrix
* @param: degree l, it must hold: 0 <= l <=_nq
* @param : order k, it must hold: -l <=k <= l
......
......@@ -20,8 +20,9 @@ class SNSolver : public Solver
SNSolver( Config* settings );
private:
// IO
void PrepareOutputFields() override;
double WriteOutputFields( unsigned idx_pseudoTime ) override;
void WriteOutputFields( unsigned idx_pseudoTime ) override;
// Solver
void FVMUpdate( VectorVector& psiNew, unsigned idx_energy ) override;
......
......@@ -74,17 +74,12 @@ class Solver
// 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
@returns: Mass of current iteration */
virtual double WriteOutputFields( unsigned idx_pseudoTime ) = 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 );
......
......@@ -187,7 +187,7 @@ void CSDSNSolver::PrepareOutputFields() {
}
}
double CSDSNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
void CSDSNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
double mass = 0.0;
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
......@@ -219,5 +219,4 @@ double CSDSNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
}
}
}
return mass;
}
......@@ -244,16 +244,8 @@ void MNSolver::PrepareOutputFields() {
}
}
double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
double mass = 0.0;
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
double firstMomentScaleFactor = sqrt( 4 * M_PI );
// Compute total "mass" of the system ==> to check conservation properties
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing
}
mass *= firstMomentScaleFactor;
void MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) ||
( idx_pseudoTime == _nEnergies - 1 ) /* need sol at last iteration */ ) {
......@@ -294,7 +286,6 @@ double MNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
}
}
}
return mass;
}
void MNSolver::WriteNNTrainingData( unsigned idx_pseudoTime ) {
......
......@@ -359,16 +359,8 @@ void PNSolver::PrepareOutputFields() {
}
}
double PNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
double mass = 0.0;
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
double firstMomentScaleFactor = sqrt( 4 * M_PI );
// Compute total "mass" of the system ==> to check conservation properties
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
mass += _sol[idx_cell][0] * _areas[idx_cell]; // Should probably go to postprocessing
}
mass *= firstMomentScaleFactor;
void PNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) ||
( idx_pseudoTime == _nEnergies - 1 ) /* need sol at last iteration */ ) {
......@@ -390,7 +382,6 @@ double PNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
}
}
}
return mass;
}
void PNSolver::CleanFluxMatrices() {
......
......@@ -220,17 +220,9 @@ void SNSolver::PrepareOutputFields() {
}
}
double SNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
double mass = 0.0;
void SNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
unsigned nGroups = (unsigned)_settings->GetNVolumeOutput();
// Compute total "mass" of the system ==> to check conservation properties
std::vector<double> flux( _nCells, 0.0 );
for( unsigned idx_cell = 0; idx_cell < _nCells; ++idx_cell ) {
flux[idx_cell] = dot( _sol[idx_cell], _weights );
mass += flux[idx_cell] * _areas[idx_cell];
}
if( ( _settings->GetVolumeOutputFrequency() != 0 && idx_pseudoTime % (unsigned)_settings->GetVolumeOutputFrequency() == 0 ) ||
( idx_pseudoTime == _nEnergies - 1 ) /* need sol at last iteration */ ) {
......@@ -243,11 +235,8 @@ double SNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
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;
_outputFields[idx_group][0][idx_cell] = _problem->GetAnalyticalSolution(
_mesh->GetCellMidPoints()[idx_cell][0], _mesh->GetCellMidPoints()[idx_cell][1], time, _sigmaS[idx_pseudoTime][idx_cell] );
}
......@@ -257,5 +246,4 @@ double SNSolver::WriteOutputFields( unsigned idx_pseudoTime ) {
}
}
}
return mass;
}
......@@ -155,8 +155,6 @@ void Solver::Solve() {
auto log = spdlog::get( "event" );
double mass = 0;
if( rank == 0 ) log->info( "{:10} {:10}", "t", "mass" );
// Loop over energies (pseudo-time of continuous slowing down approach)
......@@ -175,7 +173,7 @@ void Solver::Solve() {
IterPostprocessing();
// --- VTK and CSV Output ---
mass = WriteOutputFields( idx_energy );
WriteOutputFields( idx_energy );
Save( idx_energy );
// --- Screen Output ---
......
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