IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Quadrature.h
Go to the documentation of this file.
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
12
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;
115
116 // local domain start
118 // local domain end
120 };
121
122} // namespace ippl
123
125
126#endif
constexpr unsigned Dim
constexpr unsigned getNumElementNodes(unsigned NumNodes1D, unsigned Dim)
Definition Quadrature.h:21
constexpr T power(T base, unsigned exponent)
Definition Quadrature.h:17
Definition Archive.h:20
const ElementType & ref_element_m
Definition Quadrature.h:112
Vector< T, NumNodes1D > integration_nodes_m
Definition Quadrature.h:113
static constexpr unsigned dim
Definition Quadrature.h:41
virtual void computeNodesAndWeights()=0
Pure virtual function that computes the local quadrature nodes and weights. (Needs to be implemented ...
Vector< T, NumNodes1D > weights_m
Definition Quadrature.h:114
static constexpr unsigned numElementNodes
Definition Quadrature.h:44
static constexpr unsigned numNodes1D
Definition Quadrature.h:38
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,...
Vector< Vector< T, dim >, numElementNodes > getIntegrationNodesForRefElement() const
Get the integration (quadrature) nodes for the reference element.
size_t getDegree() const
Returns the degree of exactness of the quadrature rule.
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]).
size_t getOrder() const
Returns the order of the quadrature rule. (order = degree + 1).
Definition Quadrature.hpp:8
Quadrature(const ElementType &ref_element)
Construct a new Quadrature object.
Definition Quadrature.hpp:4
Vector< T, numElementNodes > getWeightsForRefElement() const
Get the quadrature weights for the reference element.
unsigned degree_m
Definition Quadrature.h:111