IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
Quadrature.h
1// Class Quadrature
2// This is the base class for all quadrature rules.
3
4#ifndef IPPL_QUADRATURE_H
5#define IPPL_QUADRATURE_H
6
7#include <cmath>
8
9#include "Types/Vector.h"
10
11#include "Utility/IpplException.h"
12
13#include "FEM/Elements/Element.h"
14
15// own power function since Kokkos::pow is not constexpr
16template <typename T>
17constexpr T power(T base, unsigned exponent) {
18 return exponent == 0 ? 1 : base * power(base, exponent - 1);
19}
20
21inline constexpr unsigned getNumElementNodes(unsigned NumNodes1D, unsigned Dim) {
22 return static_cast<unsigned>(power(static_cast<int>(NumNodes1D), static_cast<int>(Dim)));
23}
24
25namespace ippl {
26
34 template <typename T, unsigned NumNodes1D, typename ElementType>
35 class Quadrature {
36 public:
37 // the number of quadrature nodes for one dimension
38 static constexpr unsigned numNodes1D = NumNodes1D;
39
40 // the dimension of the reference element to compute the quadrature nodes for
41 static constexpr unsigned dim = ElementType::dim;
42
43 // the number of quadrature nodes for the reference element
44 static constexpr unsigned numElementNodes =
45 getNumElementNodes(NumNodes1D, ElementType::dim);
46
52 Quadrature(const ElementType& ref_element);
53
59 size_t getOrder() const;
60
66 size_t getDegree() const;
67
74
81
91 Vector<T, NumNodes1D> getIntegrationNodes1D(const T& a, const T& b) const;
92
102 Vector<T, NumNodes1D> getWeights1D(const T& a, const T& b) const;
103
108 virtual void computeNodesAndWeights() = 0;
109
110 protected:
111 unsigned degree_m;
112 const ElementType& ref_element_m;
113 Vector<T, NumNodes1D> integration_nodes_m;
114 Vector<T, NumNodes1D> weights_m;
115
116 // local domain start
117 T a_m;
118 // local domain end
119 T b_m;
120 };
121
122} // namespace ippl
123
124#include "FEM/Quadrature/Quadrature.hpp"
125
126#endif
This is the base class for all quadrature rules.
Definition Quadrature.h:35
virtual void computeNodesAndWeights()=0
Pure virtual function that computes the local quadrature nodes and weights. (Needs to be implemented ...
Vector< T, NumNodes1D > getWeights1D(const T &a, const T &b) const
Get the quadrature weights for one dimension. (With respect to the given domain [a,...
Definition Quadrature.hpp:81
Vector< Vector< T, dim >, numElementNodes > getIntegrationNodesForRefElement() const
Get the integration (quadrature) nodes for the reference element.
Definition Quadrature.hpp:47
size_t getDegree() const
Returns the degree of exactness of the quadrature rule.
Definition Quadrature.hpp:13
Vector< T, NumNodes1D > getIntegrationNodes1D(const T &a, const T &b) const
Get the quadrature nodes for one dimension. (With respect to the given domain [a, b])
Definition Quadrature.hpp:72
size_t getOrder() const
Returns the order of the quadrature rule. (order = degree + 1)
Definition Quadrature.hpp:8
Vector< T, numElementNodes > getWeightsForRefElement() const
Get the quadrature weights for the reference element.
Definition Quadrature.hpp:19
Definition Vector.h:23
Definition Archive.h:20