Gobelijn API documentation
- generated for commit a0cbea7
|
The AdaptiveQuadrature is a host class with policy classes QuadRule1, QuadRule2, ErrorPolicy and ConvergencePolicy. More...
#include <AdaptiveQuadrature.h>
Public Types | |
using | first_rule = AQRule1< QuadRule1 > |
using | second_rule = AQRule2< QuadRule2 > |
Public Member Functions | |
AdaptiveQuadrature (double convergenceTolerance, unsigned int initialCellCount, unsigned int cellCountLimit) | |
Constructor initializes everything. More... | |
AQRule1< QuadRule1 > & | rule1 () |
Return a reference to the first sum rule subobject. More... | |
AQRule2< QuadRule2 > & | rule2 () |
Return a reference to the second sum rule subobject. More... | |
template<typename Integrand > | |
std::tuple< bool, typename Integrand::result_type, typename Integrand::result_type, unsigned int > | evaluate (typename Integrand::argument_type l, typename Integrand::argument_type r, Integrand ftor) const |
Evaluates the quadrature for a functor based on comparing two sum rules. More... | |
template<typename Integrand > | |
Integrand::result_type | operator() (typename Integrand::argument_type l, typename Integrand::argument_type r, Integrand ftor) const |
Simplified version of the evaluate member function, returns only second sum value. More... | |
double | getConvergenceTolerance () const |
Return the convergence tolerance. More... | |
unsigned int | getInitialCellCount () const |
Return the initial cell count. More... | |
unsigned int | getCellCountLimit () const |
Return the cell count limit. More... | |
void | setConvergenceTolerance (double x) |
Set the convergence tolerance. More... | |
void | setInitialCellCount (unsigned int i) |
Set initial cell count. More... | |
void | setCellCountLimit (unsigned int i) |
Set cell count limit. More... | |
Private Attributes | |
double | fConvergenceTolerance |
unsigned int | fInitialCellCount |
unsigned int | fCellCountLimit |
The AdaptiveQuadrature is a host class with policy classes QuadRule1, QuadRule2, ErrorPolicy and ConvergencePolicy.
All of their interfaces are exposed through public inheritance. The host class also has a template member function with the integrand as template parameter. It evaluates the integral by dividing the integration domain into cells and applying two quadrature rules (QuadRule1 and QuadRule2) on each cell. If both sums agree according to the approximation expressed in ConvergencePolicy, they are accepted as contribution to the integral. If not the cell is bisected and the same procedure is applied to the smaller cells. Thus the cellsize adapts locally to the rate of change of the integrand. Re CellCount: The cellCount is monitored and the ''cellCount <= cellCountLimit'' is an invariant. If the algorithm threatens to break it then, depending on the policy an exception is thrown, or the program exits or the quadrature proceeds with the current pattern of cells without further subdivision. All of this can be achieved with reasonably generic assertion like policy class that is used to test the invariant and reacts if the condition is violated. It has to implement a member bool check(bool b) that returns the value of b, but may be throwing, exiting etc as side effect. An alternative would have been an OnCellCountViolation class with a member function bool check(unsigned int cellCount) However I do not really anticipate any real use for the additional flexibility this provides. I mean, what can you do but check cellCount <= cellCountLimit ? Re ConvergencePolicy: Now this is a different kettle of fish: there are probably many ways you could evaluate a convergence criterion. Absolute difference and Combo difference seem good candidates, but there's also Relative difference, Relative and Absolute difference at the same time ... I want to preserve flexibility here, so the policy class needs to have a constructor storing all those numbers related to the criterion. Hence the policy simply has to have a member function bool check(double sum1, double sum2) instead of a static member. It can have as many data members and getter/setters as it wants but must also provide a default constructor.
Definition at line 125 of file AdaptiveQuadrature.h.
using UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::first_rule = AQRule1<QuadRule1> |
Definition at line 131 of file AdaptiveQuadrature.h.
using UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::second_rule = AQRule2<QuadRule2> |
Definition at line 132 of file AdaptiveQuadrature.h.
|
inline |
Constructor initializes everything.
Definition at line 137 of file AdaptiveQuadrature.h.
|
inline |
Return a reference to the first sum rule subobject.
None. |
Definition at line 150 of file AdaptiveQuadrature.h.
|
inline |
Return a reference to the second sum rule subobject.
None. |
Definition at line 157 of file AdaptiveQuadrature.h.
std::tuple< bool, typename Integrand::result_type, typename Integrand::result_type, unsigned int > UA_CoMP::Num::AdaptiveQuadrature< QuadRule1, QuadRule2, ConvergencePolicy, CellCountPolicy >::evaluate | ( | typename Integrand::argument_type | l, |
typename Integrand::argument_type | r, | ||
Integrand | ftor | ||
) | const |
Evaluates the quadrature for a functor based on comparing two sum rules.
l | Left boundary of integration interval. |
r | Right boundary of integration interval. |
ftor | Integrand. |
Depends | on policies used. |
Definition at line 205 of file AdaptiveQuadrature.h.
References sum().
|
inline |
Simplified version of the evaluate member function, returns only second sum value.
l | Left boundary of integration interval. |
r | Right boundary of integration interval. |
ftor | Integrand. |
Definition at line 287 of file AdaptiveQuadrature.h.
|
inline |
Return the convergence tolerance.
Definition at line 170 of file AdaptiveQuadrature.h.
|
inline |
Return the initial cell count.
Definition at line 173 of file AdaptiveQuadrature.h.
|
inline |
Return the cell count limit.
Definition at line 176 of file AdaptiveQuadrature.h.
|
inline |
Set the convergence tolerance.
Definition at line 179 of file AdaptiveQuadrature.h.
Referenced by main().
|
inline |
Set initial cell count.
Definition at line 182 of file AdaptiveQuadrature.h.
Referenced by main().
|
inline |
Set cell count limit.
Definition at line 185 of file AdaptiveQuadrature.h.
|
private |
Definition at line 188 of file AdaptiveQuadrature.h.
Referenced by UA_CoMP::Num::AdaptiveQuadrature< GaussLegendreSelect< N1 >::Rule, GaussLegendreSelect< N2 >::Rule, ConvergencePolicy, CellCountPolicy >::getConvergenceTolerance(), and UA_CoMP::Num::AdaptiveQuadrature< GaussLegendreSelect< N1 >::Rule, GaussLegendreSelect< N2 >::Rule, ConvergencePolicy, CellCountPolicy >::setConvergenceTolerance().
|
private |
Definition at line 189 of file AdaptiveQuadrature.h.
Referenced by UA_CoMP::Num::AdaptiveQuadrature< GaussLegendreSelect< N1 >::Rule, GaussLegendreSelect< N2 >::Rule, ConvergencePolicy, CellCountPolicy >::getInitialCellCount(), and UA_CoMP::Num::AdaptiveQuadrature< GaussLegendreSelect< N1 >::Rule, GaussLegendreSelect< N2 >::Rule, ConvergencePolicy, CellCountPolicy >::setInitialCellCount().
|
private |
Definition at line 190 of file AdaptiveQuadrature.h.
Referenced by UA_CoMP::Num::AdaptiveQuadrature< GaussLegendreSelect< N1 >::Rule, GaussLegendreSelect< N2 >::Rule, ConvergencePolicy, CellCountPolicy >::getCellCountLimit(), and UA_CoMP::Num::AdaptiveQuadrature< GaussLegendreSelect< N1 >::Rule, GaussLegendreSelect< N2 >::Rule, ConvergencePolicy, CellCountPolicy >::setCellCountLimit().