mnsolver.h 3.89 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();

22
    void Solve() override;                      /*! @brief Solve functions runs main time loop */
23
24
    void Save() const override;                 /*! @brief Save Output solution to VTK file */
    void Save( int currEnergy ) const override; /*! @brief Save Output solution at given energy (pseudo time) to VTK file */
steffen.schotthoefer's avatar
steffen.schotthoefer committed
25
26

  private:
27
28
    unsigned _nTotalEntries;    /*! @brief: Total number of equations in the system */
    unsigned short _LMaxDegree; /*! @brief: Max Order of Moments */
29

30
31
32
33
    // Solver specific physics
    VectorVector _sigmaA; /*!  @brief: Absorption coefficient for all energies*/

    // Moment basis
34
35
    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 */
36

37
    // Right hand side members
38
    Vector _scatterMatDiag; /*! @brief: Diagonal of the scattering matrix (its a diagonal matrix by construction) */
39
    // TODO: Source
40

41
    // quadrature related members
42
43
44
    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
45

46
47
48
49
    // 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*/
50
    OptimizerBase* _optimizer; /*! @brief: Class to solve minimal entropy problem */
51
52

    // Output related members
53
54
55
56
57
58
59
60
    std::vector<std::vector<std::vector<double>>> _outputFields; /*! @brief: Solver Output: dimensions (GroupID,FieldID,CellID). !Protoype output for
                                                                    multiple output fields. Will replace _solverOutput */
    std::vector<std::vector<std::string>> _outputFieldNames;     /*! @brief: Names of the outputFields: dimensions (GroupID,FieldID) */

    // ---- Member functions ---

    /*! @brief Initializes the output groups and fields of this solver and names the fields */
    void PrepareOutputFields();
61
62
63
64

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

65
66
67
68
69
    /*! @brief Function that prepares VTK export and csv export of the current solver iteration
        @returns: Mass of current iteration
    */
    double WriteOutputFields();

steffen.schotthoefer's avatar
steffen.schotthoefer committed
70
71
72
73
74
75
76
    /*! @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;

77
    /*! @brief : Construct flux by computing the Moment of the  sum of FVM discretization at the interface of cell
78
     *  @param : idx_cell = current cell id
79
80
     *  @returns : sum over all neighbors of flux for all moments at interface of idx_cell, idx_neighbor */
    Vector ConstructFlux( unsigned idx_cell );
81
82
83

    /*! @brief : Pre-Compute Moments at all quadrature points. */
    void ComputeMoments();
84
85
86
87

    /*! @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 );
steffen.schotthoefer's avatar
steffen.schotthoefer committed
88
};
steffen.schotthoefer's avatar
steffen.schotthoefer committed
89
#endif    // MNSOLVER_H