AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
QuadratureFactory.hpp
1#pragma once
2
3#include <dune/common/exceptions.hh>
4#include <dune/geometry/quadraturerules.hh>
5#include <dune/geometry/type.hh>
6
7#include <amdis/Output.hpp>
8#include <amdis/common/Order.hpp>
9#include <amdis/functions/Order.hpp>
10
11namespace AMDiS
12{
13 template <class Geometry, class RN, class CN>
14 int getQuadratureDegree(Geometry const& geometry, int derivOrder, int coeffDegree,
15 RN const& rowNode, CN const& colNode)
16 {
17 test_exit(coeffDegree >= 0,
18 "Polynomial degree of coefficients cannot be determined. "
19 "Please provide a quadrature order manually.");
20
21 int psiDegree = order(rowNode);
22 int phiDegree = order(colNode);
23
24 int degree = psiDegree + phiDegree + coeffDegree;
25 if (geometry.type().isSimplex())
26 degree -= derivOrder;
27 if (geometry.affine())
28 degree += 1;
29
30 return degree;
31 }
32
33 template <class Geometry, class Node>
34 int getQuadratureDegree(Geometry const& geometry, int derivOrder, int coeffDegree,
35 Node const& node)
36 {
37 test_exit(coeffDegree >= 0,
38 "Polynomial degree of coefficients cannot be determined. "
39 "Please provide a quadrature order manually.");
40
41 int psiDegree = order(node);
42 int degree = psiDegree + coeffDegree;
43
44 if (geometry.type().isSimplex())
45 degree -= derivOrder;
46 if (geometry.affine())
47 degree += 1;
48
49 return degree;
50 }
51
52 template <class Geometry, class... Nodes>
53 auto const& getQuadratureRule(Geometry const& geometry, int derivOrder,
54 int coeffDegree, Nodes const&... nodes)
55 {
56 int degree = getQuadratureDegree(geometry, derivOrder, coeffDegree, nodes...);
57 using QuadRules
58 = Dune::QuadratureRules<typename Geometry::ctype, Geometry::mydimension>;
59 return QuadRules::rule(geometry.type(), degree);
60 }
61
62} // end namespace AMDiS