quadraturebase.h 5.1 KB
Newer Older
1
2
3
4
5
/*! @file: quadraturebase.h
 *  @brief: Base class for all quadrature rules in KiT-RT
 *  @author: S. Schotthöfer
 */

6
7
8
#ifndef QUADRATURE_H
#define QUADRATURE_H

9
10
#include "common/globalconstants.h"
#include "common/typedef.h"
steffen.schotthoefer's avatar
steffen.schotthoefer committed
11

12
13
class Config;

14
class QuadratureBase
15
16
{
  public:
17
18
19
    /*! @brief: Constructor using settings class. This is the recommended constructor.
     *  @param: Config* settings: Settings class storing all important options.
     */
20
    QuadratureBase( Config* settings );
21
22
23
    /*! @brief: Constructor using directly the order of the quadrature. Not applicable for GaussLegendre, that need additional options.
                It sets member _settings = nulltpr.*/
    QuadratureBase( unsigned order );
24
    virtual ~QuadratureBase() {}
25
26

    // Aux functions
27
28
29
    void PrintWeights();          /*! @brief prints: Weight vector */
    void PrintPoints();           /*! @brief prints: Point vectorVector */
    void PrintPointsAndWeights(); /*! @brief prints: Point vectorVector with corresponding weight vector */
30

31
32
    /*! @brief sums up all entries of the weight vector.
     *  @returns sum of all weights */
33
    double SumUpWeights();
34

35
36
37
    /*! @brief Integrates f(x,y,z) with the quadrature.
     *  @param double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions.
     *  @returns double result: result of the quadrature rule */
38
    double Integrate( double( f )( double x0, double x1, double x2 ) );
39

40
41
42
43
44
45
    /*! @brief Integrates vector valued f(x,y,z) with the quadrature. Each dimension is integrated by itself.
     *  @param : double(f)( double x0, double x1, double x2 ) : density function that depends on a three spatial dimensions.
     *  @param :  len : lenght of vector
     *  @returns double result: result of the quadrature rule (vector valued) */
    std::vector<double> Integrate( std::vector<double>( f )( double x0, double x1, double x2 ), unsigned len );

46
    // Quadrature Hub
47
    /*! @brief Creates a quadrature rule with a given name and a given order.
48
     *  @param: Config* settings: Settings to handle quadrature options
49
     *  @returns Quadrature* quadrature: returns pointer to instance of the given derived quadrature class */
50
    static QuadratureBase* Create( Config* settings );
51

Steffen Schotthöfer's avatar
Steffen Schotthöfer committed
52
53
54
    /*! @brief Creates a quadrature rule with a given name and a given order.
     *  @param: name: name of quadrature as enum
     *  @param: quadOrder: order of quadrature
55
     *  @returns Quadrature* quadrature: returns pointer to instance of the given derived quadrature class */
56
    static QuadratureBase* Create( QUAD_NAME name, unsigned quadOrder );
57
58

    // Getter
steffen.schotthoefer's avatar
steffen.schotthoefer committed
59
60
61
62
    inline std::string GetName() const { return _name; }      /*! @returns std::string _name:  name of the quadrature */
    inline unsigned GetOrder() const { return _order; }       /*! @returns unsigned _order:  order of the quadrature */
    inline unsigned GetNq() const { return _nq; }             /*! @returns unsigned _nq:  number of gridpoints of the quadrature */
    inline VectorVector GetPoints() const { return _points; } /*! @returns VectorVector _points:  coordinates of gridpoints of the quadrature */
63
    virtual VectorVector GetPointsSphere() const;             /*! @returns VectorVector _pointsSphere:  "---- " in spherical coordinates (my, phi)*/
steffen.schotthoefer's avatar
steffen.schotthoefer committed
64
    inline Vector GetWeights() const { return _weights; }     /*! @returns Vector _weights:  weights of gridpoints of the quadrature */
65
66
67
    inline VectorVectorU GetConnectivity() const {
        return _connectivity;
    } /*! @returns VectorVectorU _connectivity:  connectivity of gridpoints of the quadrature */
68
69

  protected:
70
    // Setter
71
    inline void SetOrder( unsigned order ) { _order = order; } /*! @brief sets: order of the quadrature */
72
73
74
    virtual void SetName()         = 0;                        /*! @brief Sets: name of the quadrature */
    virtual void SetNq()           = 0;                        /*! @brief sets: number of gridpoints of the quadrature */
    virtual void SetConnectivity() = 0;                        /*! @brief sets: Connectivity Adjacency Matrix as VektorVektor*/
75
76
77
78

    /*! @brief Computes the a vector (length: nq) of (coordinates of) gridpoints used for the quadrature rule.
     *         Computes the a vector (length: nq) of weights for the gridpoints. The indices match the gridpoints VectorVector.
     *         Sets computed values for _points and _weights. */
79
    virtual void SetPointsAndWeights() = 0;
80
81

    // Member variables
82
    Config* _settings;           /*! @brief pointer to settings class that manages the solver */
83
84
85
86
87
88
    std::string _name;           /*! @brief name of the quadrature */
    unsigned _order;             /*! @brief order of the quadrature */
    unsigned _nq;                /*! @brief number of gridpoints of the quadrature */
    VectorVector _points;        /*! @brief gridpoints of the quadrature */
    Vector _weights;             /*! @brief weights of the gridpoints of the quadrature */
    VectorVectorU _connectivity; /*! @brief connectivity of the gripoints of the quadrature */
89

90
    VectorVector _pointsSphere; /*! @brief (my,phi)gridpoints of the quadrature in spherical cordinates */
91
92
93
};

#endif    // QUADRATURE_H