quadraturebase.h 3.57 KB
Newer Older
1
2
3
#ifndef QUADRATURE_H
#define QUADRATURE_H

4
#include "settings/globalconstants.h"
steffen.schotthoefer's avatar
steffen.schotthoefer committed
5
#include "settings/typedef.h"
6
#include "toolboxes/errormessages.h"
7
8
#include <iostream>
#include <string>
steffen.schotthoefer's avatar
steffen.schotthoefer committed
9

10
class QuadratureBase
11
12
{
  public:
13
    QuadratureBase( unsigned order );
14
    virtual ~QuadratureBase() {}
15
16

    // Aux functions
17
18
19
    void PrintWeights();          /*! @brief prints: Weight vector */
    void PrintPoints();           /*! @brief prints: Point vectorVector */
    void PrintPointsAndWeights(); /*! @brief prints: Point vectorVector with corresponding weight vector */
20

21
22
    /*! @brief sums up all entries of the weight vector.
     *  @returns sum of all weights */
23
    double SumUpWeights();
24

25
26
27
    /*! @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 */
28
    double Integrate( double( f )( double x0, double x1, double x2 ) );
29

30
    // Quadrature Hub
31
32
33
34
    /*! @brief Creates a quadrature rule with a given name and a given order.
     *  @param: std::string name: Name of the quadrature rule
     *  @param: unsigned order: Order of the quadrature rule
     *  @returns Quadrature* quadrature: returns pointer to instance of the given derived quadrature class */
35
    static QuadratureBase* CreateQuadrature( QUAD_NAME name, unsigned order );
36
37

    // Getter
steffen.schotthoefer's avatar
steffen.schotthoefer committed
38
39
40
41
42
    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 */
    inline Vector GetWeights() const { return _weights; }     /*! @returns Vector _weights:  weights of gridpoints of the quadrature */
43
44
45
    inline VectorVectorU GetConnectivity() const {
        return _connectivity;
    } /*! @returns VectorVectorU _connectivity:  connectivity of gridpoints of the quadrature */
46
47

  protected:
48
    // Setter
49
    inline void SetOrder( unsigned order ) { _order = order; } /*! @brief sets: order of the quadrature */
50
51
52
    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*/
53
54
55
56

    /*! @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. */
57
    virtual void SetPointsAndWeights() = 0;
58
59

    // Member variables
60
61
62
63
64
65
    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 */
66
67
68
};

#endif    // QUADRATURE_H