solverbase.h 3.45 KB
Newer Older
Jonas Kusch's avatar
Jonas Kusch committed
1
2
3
4
#ifndef SOLVER_H
#define SOLVER_H

// include Matrix, Vector definitions
5
6
#include "common/globalconstants.h"
#include "common/typedef.h"
7

steffen.schotthoefer's avatar
steffen.schotthoefer committed
8
// Forward Declarations
9
10
11
12
13
class NumericalFlux;
class Mesh;
class Config;
class ProblemBase;
class QuadratureBase;
steffen.schotthoefer's avatar
steffen.schotthoefer committed
14

Jonas Kusch's avatar
Jonas Kusch committed
15
16
class Solver
{
17
  protected:
18
19
20
21
    Mesh* _mesh;           /*! @brief mesh object for writing out information */
    NumericalFlux* _g;     /*! @brief class for numerical flux */
    Config* _settings;     /*! @brief config class for global information */
    ProblemBase* _problem; /*! @brief problem class for initial conditions */
steffen.schotthoefer's avatar
steffen.schotthoefer committed
22

23
24
    // --------- Often used variables of member classes for faster access ----

jannick.wolters's avatar
jannick.wolters committed
25
26
27
28
29
30
    unsigned _nEnergies;             /*! @brief number of energy/time steps, number of nodal energy values for CSD */
    double _dE;                      /*! @brief energy/time step size */
    Vector _energies;                // energy groups used in the simulation [keV]
    std::vector<double> _density;    // patient density, dim(_density) = _nCells
    Vector _s;                       // stopping power, dim(_s) = _nTimeSteps
    std::vector<VectorVector> _Q;    /*!  @brief  external source term */
31
32
33
34
35

    VectorVector _sigmaS; /*!  @brief scattering cross section for all energies */
    VectorVector _sigmaT; /*!  @brief total cross section for all energies */

    // quadrature related numbers
36
37
38
39
40
    QuadratureBase* _quadrature; /*! @brief quadrature to create members below */
    unsigned _nq;                /*! @brief number of quadrature points */

    // VectorVector _quadPoints;    /*!  @brief quadrature points, dim(_quadPoints) = (_nSystem,spatialDim) */
    // Vector _weights;             /*!  @brief quadrature weights, dim(_weights) = (_NCells) */
Jonas Kusch's avatar
Jonas Kusch committed
41

42
43
44
45
46
47
48
49
50
51
52
    // Mesh related members
    unsigned _nCells;                          /*! @brief number of spatial cells */
    std::vector<BOUNDARY_TYPE> _boundaryCells; /*! boundary type for all cells, dim(_boundary) = (_NCells) */
    std::vector<double> _areas;                /*! @brief surface area of all spatial cells, dim(_areas) = _NCells */
    /*! @brief edge normals multiplied by edge length, dim(_normals) = (_NCells,nEdgesPerCell,spatialDim) */
    std::vector<std::vector<Vector>> _normals;
    /*! @brief edge neighbor cell ids, dim(_neighbors) = (_NCells,nEdgesPerCell) */
    std::vector<std::vector<unsigned>> _neighbors;

    // Solution related members
    VectorVector _sol;                 /*! @brief solution of the PDE, e.g. angular flux or moments */
53
    std::vector<double> _solverOutput; /*! @brief LEGACY: Outputfield for solver ==> Will be replaced by _outputFields in the near future */
54
55

    // we will have to add a further dimension for quadPoints and weights once we start with multilevel SN
56

57
58
59
60
61
62
    /**
     * @brief ComputeTimeStep calculates the maximal stable time step
     * @param cfl is cfl number
     */
    double ComputeTimeStep( double cfl ) const;

63
  public:
Jonas Kusch's avatar
Jonas Kusch committed
64
65
66
67
    /**
     * @brief Solver constructor
     * @param settings stores all needed information
     */
68
    Solver( Config* settings );
Jonas Kusch's avatar
Jonas Kusch committed
69

70
71
    ~Solver();

Jonas Kusch's avatar
Jonas Kusch committed
72
73
74
75
76
    /**
     * @brief Create constructor
     * @param settings stores all needed information
     * @return pointer to Solver
     */
77
    static Solver* Create( Config* settings );
Jonas Kusch's avatar
Jonas Kusch committed
78
79
80
81

    /**
     * @brief Solve functions runs main time loop
     */
82
    virtual void Solve() = 0;
83
84
85
86
87

    /**
     * @brief Output solution to VTK file
     */
    virtual void Save() const = 0;
steffen.schotthoefer's avatar
steffen.schotthoefer committed
88
89

    virtual void Save( int currEnergy ) const = 0;
Jonas Kusch's avatar
Jonas Kusch committed
90
91
};

92
#endif    // SOLVER_H