QuadratureIntegrator1D.h 2.77 KB
Newer Older
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
1
2
3
4
5
6
7
8
9
10
#ifndef QUADRATURE_INTEGRATOR_1D_H_
#define QUADRATURE_INTEGRATOR_1D_H_

/**
 * @file QuadratureIntegrator1D.h
 * @author Bryan BERTHOU (SPhN / CEA Saclay)
 * @date 15 February 2016
 * @version 1.0
 */

11
#include <ElementaryUtils/parameters/Parameters.h>
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
12
#include <string>
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
13
14
#include <vector>

15
16
17
18
19
#include "Integrator1DModule.h"

namespace NumA {
class FunctionType1D;
} /* namespace NumA */
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
20
21
22
23
24

class FunctionType1D;

namespace NumA {

Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
25
26
27
28
/**
 * @class QuadratureIntegrator1D
 *
 * @brief Abstract quadrature class (for fixed quadrature rules).
29
30
31
32
33
34
 *
 * Child classes must define a way to compute the nodes \f$ x_i \f$ and weights \f$ w_i \f$.\n
 * The integration itself is done by this abstract class:
 * \f$ \displaystyle \int_a^b f\left(x\right) \mathrm{d}x = \sum_{i=0}^{N-1} w_i f\left(x_i\right) \f$, through the integrate() routine.
 *
 * See Integrator1D documentation for an example.
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
35
36
 */

37
class QuadratureIntegrator1D: public Integrator1DModule {
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
38
public:
39
    static const std::string PARAM_NAME_N; ///< Parameter used in the configure() to set the order of the quadrature.
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
40

41
42
    /**
     * Constructor.
43
44
45
     * See BaseObject::BaseObject and ModuleObject::ModuleObject for more details.
     *
     * @param className name of child class.
46
     */
47
48
49
50
51
52
53
54
    QuadratureIntegrator1D(const std::string &className);

//    /**
//     * Constructor.
//     * @param N Order of the quadrature (number of nodes).
//     */
//    QuadratureIntegrator1D(unsigned int N = 0);

55
56
57
    /**
     * Default destructor.
     */
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
58
59
    virtual ~QuadratureIntegrator1D();

Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
60
61
    virtual QuadratureIntegrator1D* clone() const = 0;

Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
62
63
64
65
66
    virtual double integrate(FunctionType1D* pFunction, double a, double b,
            std::vector<double> &parameters);

    virtual void configure(const ElemUtils::Parameters &parameters);

67
68
69
70
    /**
     *
     * @return Order of the quadrature (number of nodes).
     */
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
71
    unsigned int getN() const;
72
73
74
75
    /**
     *
     * @param n Order of the quadrature (number of nodes).
     */
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
76
    virtual void setN(unsigned int n) = 0;
77
78
79
80
    /**
     *
     * @return Nodes of the quadrature.
     */
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
81
    const std::vector<double>& getNodes() const;
82
83
84
85
    /**
     *
     * @return Weights of the quadrature.
     */
Nabil Chouika's avatar
refs#16    
Nabil Chouika committed
86
87
    const std::vector<double>& getWeights() const;

Bryan Berthou's avatar
refs#16    
Bryan Berthou committed
88
protected:
89
90
91
92
93
94
95
96
97
    unsigned int m_N; ///< Order of the quadrature (number of nodes).
    std::vector<double> m_nodes; ///< Nodes of the quadrature.
    std::vector<double> m_weights; ///< Weights of the quadrature.

    /**
     * Copy constructor.
     * Called by clone().
     * @param other QuadratureIntegrator1D object to copy.
     */
Bryan Berthou's avatar
refs#16    
Bryan Berthou committed
98
    QuadratureIntegrator1D(const QuadratureIntegrator1D &other);
99
100
101
102
103

    virtual void setNodesAndWeights() = 0;

    virtual void isModuleWellConfigured();
    virtual void initModule();
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
104
105
106
107
108
};

} // namespace NumA

#endif /* QUADRATURE_INTEGRATOR_1D_H_ */