9#include <kernel/cubature/scalar/driver_factory.hpp>
10#include <kernel/cubature/rule.hpp>
16 template<
typename Shape_>
23 static int count(
int num_points)
36 for(
int i(0); i < scalar_rule.get_num_points(); ++i)
38 rule.get_weight(i) = scalar_rule.get_weight(i);
39 rule.get_coord(i, 0) = scalar_rule.get_coord(i);
48 static int count(
int num_points)
50 return num_points * num_points;
61 int num_points = scalar_rule.get_num_points();
62 for(
int i(0); i < num_points; ++i)
64 for(
int j(0); j < num_points; ++j)
66 int l = i*num_points + j;
67 rule.get_weight(l) = scalar_rule.get_weight(i) * scalar_rule.get_weight(j);
68 rule.get_coord(l, 0) = scalar_rule.get_coord(i);
69 rule.get_coord(l, 1) = scalar_rule.get_coord(j);
79 static int count(
int num_points)
81 return num_points * num_points * num_points;
92 int num_points = scalar_rule.get_num_points();
93 for(
int i(0); i < num_points; ++i)
95 for(
int j(0); j < num_points; ++j)
97 for(
int k(0); k < num_points; ++k)
99 int l = (i*num_points + j)*num_points + k;
100 rule.get_weight(l) = scalar_rule.get_weight(i) * scalar_rule.get_weight(j) * scalar_rule.get_weight(k);
101 rule.get_coord(l, 0) = scalar_rule.get_coord(i);
102 rule.get_coord(l, 1) = scalar_rule.get_coord(j);
103 rule.get_coord(l, 2) = scalar_rule.get_coord(k);
111 typename ScalarDriver_,
129 int num_points = TensorProductDriverType::count(scalar_rule.get_num_points());
130#ifdef FEAT_CUBATURE_TENSOR_PREFIX
135 TensorProductDriverType::fill(rule, scalar_rule);
148#ifdef FEAT_CUBATURE_TENSOR_PREFIX
150 String::size_type k = name.find_first_of(
':');
155 String head(name.substr(0, k));
156 String tail(name.substr(k + 1));
163 ScalarRuleType scalar_rule;
164 if(!ScalarFactoryType::create(scalar_rule, tail.
trim()))
168 ScalarRuleType scalar_rule;
169 if(!ScalarFactoryType::create(scalar_rule, name))
174 create(rule, scalar_rule);
180#ifdef FEAT_CUBATURE_TENSOR_PREFIX
181 return "tensor:" + ScalarFactoryType::name();
183 return ScalarFactoryType::name();
187 template<
typename Functor_>
188 static void alias(Functor_& functor)
190#ifdef FEAT_CUBATURE_TENSOR_PREFIX
191 AliasTensorPrefixFunctor<Functor_> prefix_functor(functor);
192 ScalarFactoryType::alias(prefix_functor);
194 ScalarFactoryType::alias(functor);
200#ifdef FEAT_CUBATURE_TENSOR_PREFIX
201 template<
typename Functor_>
202 class AliasTensorPrefixFunctor
208 explicit AliasTensorPrefixFunctor(Functor_& functor) :
213 void alias(
const String& name)
215 _functor.alias(
"tensor:" + name);
218 void alias(
const String& name,
int num_points)
220 _functor.alias(
"tensor:" + name, num_points);
228 typename ScalarDriver_,
230 bool variadic_ = ScalarDriver_::variadic>
234 typename ScalarDriver_,
241 typedef Shape_ ShapeType;
243 static constexpr bool variadic =
false;
244 static constexpr int num_points = ScalarFactoryType::num_points;
251 using BaseClass::create;
253 template<
typename Weight_,
typename Coord_,
typename Po
int_>
258 ScalarFactoryType::create(scalar_rule);
261 create(rule, scalar_rule);
266 typename ScalarDriver_,
273 typedef Shape_ ShapeType;
275 static constexpr bool variadic =
true;
276 static constexpr int min_points = ScalarFactoryType::min_points;
277 static constexpr int max_points = ScalarFactoryType::max_points;
284 _num_points(num_points)
288 using BaseClass::create;
290 template<
typename Weight_,
typename Coord_,
typename Po
int_>
293 create(rule, _num_points);
296 template<
typename Weight_,
typename Coord_,
typename Po
int_>
301 ScalarFactoryType::create(scalar_rule, num_points);
304 create(rule, scalar_rule);
Cubature Rule class template.
Scalar Cubature Driver-Factory class template.
Scalar Cubature Rule class template.
String class implementation.
int compare_no_case(const String &other) const
Compares two strings without regard to case.
String trim(const String &charset) const
Trims the string.
Hypercube shape tag struct template.