CppNoddy  0.92
Loading...
Searching...
No Matches
FnQuadrature.h
Go to the documentation of this file.
1/// \file FnQuadrature.h
2/// A specification for quadrature classes. This
3/// class is only useful for explicitly known functions
4/// and is instantiated with a function pointer.
5
6#ifndef FNQUADRATURE_H
7#define FNQUADRATURE_H
8
9#include <Uncopyable.h>
10#include <DenseVector.h>
11
12namespace CppNoddy {
13
14 /// A quadrature class that takes a function pointer.
15 class FnQuadrature : private Uncopyable {
16
17 public:
18
19 /// The function pointer associated with this instance.
20 typedef void (*fn_ptr)(const double&, double&);
21
22 /// Constructor.
23 /// \param ptr_to_fn the function that defines the integrand.
24 /// \param x1 left hand boundary of the domain.
25 /// \param x2 right hand boundary of the domain.
26 /// \param num_of_regions initial number of sub-regions to divide the domain into.
27 FnQuadrature(fn_ptr ptr_to_fn,
28 const double& x1, const double& x2,
29 const unsigned& num_of_regions);
30
31 /// Constructor.
32 /// \param ptr_to_fn the function that defines the integrand.
33 /// \param x1 left hand boundary of the domain.
34 /// \param x2 right hand boundary of the domain.
35 /// \param nodes A vector of nodal positions.
36 FnQuadrature(fn_ptr ptr_to_fn,
37 const double& x1, const double& x2,
38 const DenseVector<double>& nodes);
39
40 /// A set method to define a UNIFORM number of sub intervals.
41 /// \param n Number of sub intervals
42 void set_subintervals(const unsigned& n);
43
44 /// n-point Gauss rule inefficiently written!
45 /// \param n The number of points.
46 /// \return Approximation to the integral
47 double Gauss(const int& n);
48
49 /// Evaluate the integral by applying an
50 /// n-point Gauss rule on each of N sub-intervals.
51 /// <b> This is inefficient in terms of class instantiation
52 /// for each sub-interval, but not currently an issue. </b>
53 /// \param n The order of the Gauss rule.
54 /// \return Approximation to the integral.
55 double sub_Gauss(const int& n);
56
57 /// Quick trapezium summation again for sanity checking.
58 /// Should be essentially equivalent to the 1-point
59 /// Gauss rule.
60 /// \return An approximation to the integral.
61 double trapezium();
62
63 private:
64 double A, B;
65 fn_ptr p_FN;
67
68 };
69
70
71}
72
73#endif // FNQUADRATURE_H
74
Specification for a templated DenseVector class – a dense, dynamic, vector object.
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A quadrature class that takes a function pointer.
Definition: FnQuadrature.h:15
double sub_Gauss(const int &n)
Evaluate the integral by applying an n-point Gauss rule on each of N sub-intervals.
void set_subintervals(const unsigned &n)
A set method to define a UNIFORM number of sub intervals.
double Gauss(const int &n)
n-point Gauss rule inefficiently written!
void(* fn_ptr)(const double &, double &)
The function pointer associated with this instance.
Definition: FnQuadrature.h:20
double trapezium()
Quick trapezium summation again for sanity checking.
An object to block copying.
Definition: Uncopyable.h:8
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt