9#include <kernel/shape.hpp>
10#include <kernel/util/tiny_algebra.hpp>
34 typename Weight_ =
Real,
35 typename Coord_ =
Real,
36 typename Point_ = Tiny::Vector<Coord_, Shape_::dimension>>
40 typedef Shape_ ShapeType;
41 typedef Weight_ WeightType;
42 typedef Coord_ CoordType;
43 typedef Point_ PointType;
44 static constexpr int dimension = ShapeType::dimension;
49 std::vector<WeightType> _weights;
50 std::vector<PointType> _points;
59 explicit Rule(
int num_points,
const String& name) :
61 _num_points(num_points)
65 _weights.resize(std::size_t(num_points));
66 _points.resize(std::size_t(num_points));
70 template<
typename Factory_>
71 Rule(CtorFactory,
const Factory_& factory) :
75 factory.create_throw(*
this);
81 _num_points(other._num_points),
82 _weights(std::forward<std::vector<WeightType>>(other._weights)),
83 _points(std::forward<std::vector<PointType>>(other._points))
86 other._num_points = 0;
97 _num_points = other._num_points;
98 _weights = std::forward<std::vector<WeightType>>(other._weights);
99 _points = std::forward<std::vector<PointType>>(other._points);
102 other._num_points = 0;
113 Rule rule(_num_points, _name);
114 rule._weights = this->_weights;
115 rule._points = this->_points;
119 const String& get_name()
const
124 int get_num_points()
const
129 WeightType& get_weight(
int i)
132 return _weights[std::size_t(i)];
135 WeightType* get_weights()
137 return _weights.data();
140 const WeightType& get_weight(
int i)
const
143 return _weights[std::size_t(i)];
146 const WeightType* get_weights()
const
148 return _weights.data();
151 PointType& get_point(
int i)
154 return _points[std::size_t(i)];
157 PointType* get_points()
159 return _points.data();
162 const PointType& get_point(
int i)
const
165 return _points[std::size_t(i)];
168 const PointType* get_points()
const
173 CoordType& get_coord(
int i,
int j)
175 ASSERTM((i >= 0) && (i < _num_points),
"point index i out-of-range");
176 ASSERTM((j >= 0) && (j < dimension),
"coord index j out-of-range");
177 return _points[std::size_t(i)][j];
180 const CoordType& get_coord(
int i,
int j)
const
182 ASSERTM((i >= 0) && (i < _num_points),
"point index i out-of-range");
183 ASSERTM((j >= 0) && (j < dimension),
"coord index j out-of-range");
184 return _points[std::size_t(i)][j];
#define ASSERT(expr)
Debug-Assertion macro definition.
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
Cubature Rule class template.
Rule(Rule &&other)
move ctor
Rule & operator=(Rule &&other)
move-assign operator
String class implementation.
double Real
Real data type.