mnsolver.h 3.4 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
    unsigned _nTotalEntries;    /*! @brief: Total number of equations in the system */
25
    unsigned short _LMaxDegree; /*! @brief: Max Order of Spherical Harmonics  */
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

Tianbai Xiao's avatar
Tianbai Xiao committed
45
46
47
    VectorVector _solDx; /*! @brief:  temporary storage of x-derivatives of alpha */
    VectorVector _solDy; /*! @brief:  temporary storage of y-derivatives of alpha */

48
    // ---- Private Member functions ---
49

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

54
55
    void PrepareVolumeOutput() override;
    void WriteVolumeOutput( unsigned idx_pseudoTime ) override;
steffen.schotthoefer's avatar
steffen.schotthoefer committed
56

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

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

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