mnsolver.h 3.22 KB
Newer Older
steffen.schotthoefer's avatar
steffen.schotthoefer committed
1
2
3
#ifndef MNSOLVER_H
#define MNSOLVER_H

4
#include "solverbase.h"
5
6
7
8

class EntropyBase;
class SphericalHarmonics;
class OptimizerBase;
steffen.schotthoefer's avatar
steffen.schotthoefer committed
9

10
class MNSolver : public Solver
steffen.schotthoefer's avatar
steffen.schotthoefer committed
11
{
steffen.schotthoefer's avatar
steffen.schotthoefer committed
12
13
14
15
  public:
    /**
     * @brief MNSolver constructor
     * @param settings stores all needed information
steffen.schotthoefer's avatar
steffen.schotthoefer committed
16
     */
steffen.schotthoefer's avatar
steffen.schotthoefer committed
17
18
    MNSolver( Config* settings );

19
20
21
    /*! @brief MNSolver destructor */
    ~MNSolver();

steffen.schotthoefer's avatar
steffen.schotthoefer committed
22
  private:
23
    // --- Private member variables ---
24
25
    unsigned _nTotalEntries;    /*! @brief: Total number of equations in the system */
    unsigned short _LMaxDegree; /*! @brief: Max Order of Moments */
26

27
    // Moment basis
28
29
    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 */
30

31
    // Scattering
32
    Vector _scatterMatDiag; /*! @brief: Diagonal of the scattering matrix (its a diagonal matrix by construction) */
33

34
    // Quadrature related members
35
36
37
    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) */
steffen.schotthoefer's avatar
steffen.schotthoefer committed
38

39
40
41
42
    // Entropy Optimization related members
    EntropyBase* _entropy;     /*! @brief: Class to handle entropy functionals */
    VectorVector _alpha;       /*! @brief: Lagrange Multipliers for Minimal Entropy problem for each gridCell
                                           Layout: _nCells x _nTotalEntries*/
43
    OptimizerBase* _optimizer; /*! @brief: Class to solve minimal entropy problem */
44

45
    // ---- Private Member functions ---
46

47
    // IO
48
49
50
    /*! @brief Function that writes NN Training Data in a .csv file */
    void WriteNNTrainingData( unsigned idx_pseudoTime );

51
52
    void PrepareOutputFields() override;
    void WriteOutputFields( unsigned idx_pseudoTime ) override;
steffen.schotthoefer's avatar
steffen.schotthoefer committed
53

54
    // Solver
55
56
    void FVMUpdate( unsigned idx_energy ) override;
    void FluxUpdate() override;
57
58
    void IterPreprocessing() override;
    void IterPostprocessing();
59
    /*! @brief : Construct flux by computing the Moment of the  sum of FVM discretization at the interface of cell
60
     *  @param : idx_cell = current cell id
61
62
     *  @returns : sum over all neighbors of flux for all moments at interface of idx_cell, idx_neighbor */
    Vector ConstructFlux( unsigned idx_cell );
63
64
65
    /*! @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 );
66

67
    // Initialization of the solver
68
69
    /*! @brief : Pre-Compute Moments at all quadrature points. */
    void ComputeMoments();
70
71
72
    /*! @brief:  fucntion for computing and setting up EV matrix for scattering kernel */
    void ComputeScatterMatrix();

73
74
    // Helper
    void ComputeRadFlux();
75
76
77
78
79
80
    /*! @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;
steffen.schotthoefer's avatar
steffen.schotthoefer committed
81
};
steffen.schotthoefer's avatar
steffen.schotthoefer committed
82
#endif    // MNSOLVER_H