IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Quadrature.hpp
Go to the documentation of this file.
1
2namespace ippl {
3 template <typename T, unsigned NumNodes1D, typename ElementType>
5 : ref_element_m(ref_element) {}
6
7 template <typename T, unsigned NumNodes1D, typename ElementType>
9 return this->degree_m + 1;
10 }
11
12 template <typename T, unsigned NumNodes1D, typename ElementType>
14 return this->degree_m;
15 }
16
17 template <typename T, unsigned NumNodes1D, typename ElementType>
20 Vector<T, NumNodes1D> w = this->getWeights1D(0.0, 1.0);
21
22 Vector<T, std::remove_reference_t<decltype(*this)>::numElementNodes> tensor_prod_w;
23
25 for (unsigned i = 0; i < std::remove_reference_t<decltype(*this)>::numElementNodes; ++i) {
26 tensor_prod_w[i] = 1.0;
27 for (unsigned d = 0; d < ElementType::dim; ++d) {
28 tensor_prod_w[i] *= w[nd_index[d]];
29 }
30
31 // Update nd_index for next iteration
32 // Increment the nd_index variable in the first dimension, or if it
33 // is already at the maximum value reset it and, go to the higher dimension
34 for (unsigned d = 0; d < ElementType::dim; ++d) {
35 if (++nd_index[d] < NumNodes1D)
36 break;
37 nd_index[d] = 0;
38 }
39 }
40
41 return tensor_prod_w;
42 }
43
44 template <typename T, unsigned NumNodes1D, typename ElementType>
49
50 Vector<Vector<T, ElementType::dim>, std::remove_reference_t<decltype(*this)>::numElementNodes> tensor_prod_q;
51
53 for (unsigned i = 0; i < std::remove_reference_t<decltype(*this)>::numElementNodes; ++i) {
54 for (unsigned d = 0; d < ElementType::dim; ++d) {
55 tensor_prod_q[i][d] = q[nd_index[d]];
56 }
57
58 // Update nd_index for next iteration
59 // Increment the nd_index variable in the first dimension, or if it
60 // is already at the maximum value reset it and, go to the higher dimension
61 for (unsigned d = 0; d < ElementType::dim; ++d) {
62 if (++nd_index[d] < NumNodes1D)
63 break;
64 nd_index[d] = 0;
65 }
66 }
67
68 return tensor_prod_q;
69 }
70
71 template <typename T, unsigned NumNodes1D, typename ElementType>
73 const T& a, const T& b) const {
74 assert(b > a);
75 // scale the integration nodes from the local domain [a_m, b_m] to the given one [a, b]
76
77 return (this->integration_nodes_m - this->a_m) / (this->b_m - this->a_m) * (b - a) + a;
78 }
79
80 template <typename T, unsigned NumNodes1D, typename ElementType>
82 const T& b) const {
83 assert(b > a);
84 return this->weights_m * (b - a) / (this->b_m - this->a_m);
85 }
86
87} // namespace ippl
Definition Archive.h:20
const ElementType & ref_element_m
Definition Quadrature.h:112
Vector< T, NumNodes1D > weights_m
Definition Quadrature.h:114
static constexpr unsigned numElementNodes
Definition Quadrature.h:44
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