Skip to content

Commit c884fa2

Browse files
committed
docu: improve quadrature stuff
also: fix typo on interface implementation file name. also: move Polynomial into namespace quadrature
1 parent 3891c16 commit c884fa2

File tree

12 files changed

+486
-166
lines changed

12 files changed

+486
-166
lines changed

include/pfasst/quadrature.hpp

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
/**
2+
* @file pfasst/quadrature.hpp
3+
* @since v0.1.0
4+
*/
15
#ifndef _PFASST__QUADRATURE_HPP_
26
#define _PFASST__QUADRATURE_HPP_
37

48
#include <cmath>
59
#include <exception>
6-
#include <type_traits>
710
#include <vector>
11+
using namespace std;
812

913
#include <Eigen/Dense>
14+
template<typename scalar>
15+
using Matrix = Eigen::Matrix<scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
16+
1017
#include <boost/math/constants/constants.hpp>
1118

1219
#include "pfasst/config.hpp"
@@ -19,19 +26,29 @@
1926
#include "pfasst/quadrature/clenshaw_curtis.hpp"
2027
#include "pfasst/quadrature/uniform.hpp"
2128

22-
template<typename scalar>
23-
using Matrix = Eigen::Matrix<scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
24-
25-
using namespace std;
2629

2730
namespace pfasst
2831
{
29-
32+
/**
33+
* functionality related to computing quadrature nodes and weights.
34+
*
35+
* @note Please note, that all quadrature nodes are in the range \\( [0, 1] \\).
36+
*/
3037
namespace quadrature
3138
{
32-
39+
/**
40+
* instantiates quadrature handler for given number of nodes and type descriptor.
41+
*
42+
* @tparam precision numerical type of the nodes (e.g. `double`)
43+
* @param[in] nnodes number of quadrature nodes
44+
* @param[in] qtype type descriptor of the quadrature
45+
* @returns instance of pfasst::quadrature::IQuadrature of specified type with desired number
46+
* of nodes
47+
* @throws pfasst::ValueError if @p qtype is not a valid quadrature type descriptor
48+
*/
3349
template<typename precision = pfasst::time_precision>
34-
shared_ptr<IQuadrature<precision>> quadrature_factory(const size_t nnodes, const QuadratureType qtype)
50+
shared_ptr<IQuadrature<precision>> quadrature_factory(const size_t nnodes,
51+
const QuadratureType qtype)
3552
{
3653
if (qtype == QuadratureType::GaussLegendre) {
3754
return make_shared<GaussLegendre<precision>>(nnodes);
@@ -49,12 +66,28 @@ namespace pfasst
4966
}
5067
}
5168

69+
/**
70+
* compute quadrature nodes for given quadrature type descriptor.
71+
*
72+
* @tparam precision numerical type of the nodes (e.g. `double`)
73+
* @param[in] nnodes number of quadrature nodes to compute
74+
* @param[in] qtype type descriptor of the quadrature nodes
75+
* @returns std::vector of quadrature nodes of given type
76+
*
77+
* @see pfasst::quadrature::QuadratureType for valid types
78+
* @see pfasst::quadrature::quadrature_factory for further details
79+
*/
5280
template<typename precision = pfasst::time_precision>
5381
vector<precision> compute_nodes(size_t nnodes, QuadratureType qtype)
5482
{
5583
return quadrature_factory<precision>(nnodes, qtype)->get_nodes();
5684
}
5785

86+
/**
87+
* @todo write documentation
88+
*
89+
* @tparam precision numerical type of the interpolation (e.g. `double`)
90+
*/
5891
template<typename precision = time_precision>
5992
Matrix<precision> compute_interp(vector<precision> dst, vector<precision> src)
6093
{
@@ -84,13 +117,12 @@ namespace pfasst
84117

85118
return mat;
86119
}
87-
88120
} // ::pfasst::quadrature
89121

122+
90123
namespace config
91124
{
92-
// note: GCC fails with "error: explicit template specialization cannot have a storage class"
93-
// if this template specialization is also declared 'static'; Clang does not care.
125+
//! @overload
94126
template<>
95127
inline quadrature::QuadratureType get_value(const string& name)
96128
{
@@ -110,21 +142,18 @@ namespace pfasst
110142
}
111143
}
112144

113-
// note: GCC fails with "error: explicit template specialization cannot have a storage class"
114-
// if this template specialization is also declared 'static'; Clang does not care.
145+
//! @overload
115146
template<>
116147
inline quadrature::QuadratureType get_value(const string& name,
117-
const quadrature::QuadratureType& default_value)
148+
const quadrature::QuadratureType& default_value)
118149
{
119150
if (options::get_instance().get_variables_map().count(name) == 1) {
120151
return get_value<quadrature::QuadratureType>(name);
121152
} else {
122153
return default_value;
123154
}
124155
}
125-
126156
} // ::pfasst::config
127-
128157
} // ::pfasst
129158

130159
#endif // _PFASST__QUADRATURE_HPP_

include/pfasst/quadrature/clenshaw_curtis.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1+
/**
2+
* @file pfasst/quadrature/clenshaw_curtis.hpp
3+
* @since v0.3.0
4+
*/
15
#ifndef _PFASST__QUADRATURE__CLENSHAW_CURTIS_HPP_
26
#define _PFASST__QUADRATURE__CLENSHAW_CURTIS_HPP_
37

48
#include <cassert>
59
#include <vector>
6-
7-
#include <boost/math/constants/constants.hpp>
10+
using namespace std;
811

912
#include "pfasst/interfaces.hpp"
10-
#include "pfasst/quadrature/polynomial.hpp"
1113
#include "pfasst/quadrature/interface.hpp"
1214

13-
using namespace std;
14-
using namespace boost::math::constants;
15-
1615

1716
namespace pfasst
1817
{
1918
namespace quadrature
2019
{
20+
/**
21+
* quadrature handler for Clenshaw-Curtis quadrature
22+
*
23+
* @tparam scalar precision of quadrature (i.e. `double`)
24+
*
25+
* @since v0.3.0
26+
*/
2127
template<typename precision = pfasst::time_precision>
2228
class ClenshawCurtis
2329
: public IQuadrature<precision>
@@ -30,6 +36,9 @@ namespace pfasst
3036

3137
public:
3238
//! @{
39+
/**
40+
* @throws invalid_argument if less than two nodes are requested
41+
*/
3342
explicit ClenshawCurtis(const size_t num_nodes);
3443
ClenshawCurtis() = default;
3544
virtual ~ClenshawCurtis() = default;

include/pfasst/quadrature/gauss_legendre.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @file pfasst/quadrature/gauss_legendre.hpp
3+
* @since v0.3.0
4+
*/
15
#ifndef _PFASST__QUADRATURE__GAUSS_LEGENDRE_HPP_
26
#define _PFASST__QUADRATURE__GAUSS_LEGENDRE_HPP_
37

@@ -8,6 +12,13 @@ namespace pfasst
812
{
913
namespace quadrature
1014
{
15+
/**
16+
* quadrature handler for Gauss-Legendre quadrature
17+
*
18+
* @tparam scalar precision of quadrature (i.e. `double`)
19+
*
20+
* @since v0.3.0
21+
*/
1122
template<typename precision = pfasst::time_precision>
1223
class GaussLegendre
1324
: public IQuadrature<precision>

include/pfasst/quadrature/gauss_lobatto.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @file pfasst/quadrature/gauss_lobatto.hpp
3+
* @since v0.3.0
4+
*/
15
#ifndef _PFASST__QUADRATURE__GAUSS_LOBATTO_HPP_
26
#define _PFASST__QUADRATURE__GAUSS_LOBATTO_HPP_
37

@@ -8,6 +12,13 @@ namespace pfasst
812
{
913
namespace quadrature
1014
{
15+
/**
16+
* quadrature handler for Gauss-Lobatto quadrature
17+
*
18+
* @tparam scalar precision of quadrature (i.e. `double`)
19+
*
20+
* @since v0.3.0
21+
*/
1122
template<typename precision = pfasst::time_precision>
1223
class GaussLobatto
1324
: public IQuadrature<precision>
@@ -20,6 +31,9 @@ namespace pfasst
2031

2132
public:
2233
//! @{
34+
/**
35+
* @throws invalid_argument if less than two nodes are requested
36+
*/
2337
explicit GaussLobatto(const size_t num_nodes);
2438
GaussLobatto() = default;
2539
virtual ~GaussLobatto() = default;

include/pfasst/quadrature/gauss_radau.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @file pfasst/quadrature/gauss_radau.hpp
3+
* @since v0.3.0
4+
*/
15
#ifndef _PFASST__QUADRATURE__GAUSS_RADAU_HPP_
26
#define _PFASST__QUADRATURE__GAUSS_RADAU_HPP_
37

@@ -8,6 +12,13 @@ namespace pfasst
812
{
913
namespace quadrature
1014
{
15+
/**
16+
* quadrature handler for Gauss-Radau quadrature
17+
*
18+
* @tparam scalar precision of quadrature (i.e. `double`)
19+
*
20+
* @since v0.3.0
21+
*/
1122
template<typename precision = pfasst::time_precision>
1223
class GaussRadau
1324
: public IQuadrature<precision>
@@ -20,6 +31,9 @@ namespace pfasst
2031

2132
public:
2233
//! @{
34+
/**
35+
* @throws invalid_argument if less than two nodes are requested
36+
*/
2337
explicit GaussRadau(const size_t num_nodes);
2438
GaussRadau() = default;
2539
virtual ~GaussRadau() = default;

0 commit comments

Comments
 (0)