AMDiS  2.10
The Adaptive Multi-Dimensional Simulation Toolbox
ZeroOrderTest.hpp
1 #pragma once
2 
3 #include <type_traits>
4 
5 #include <amdis/GridFunctionOperator.hpp>
6 #include <amdis/common/StaticSize.hpp>
7 
8 namespace AMDiS
9 {
15  namespace tag
16  {
17  struct test {};
18  }
19 
22  {
23  public:
25 
26  template <class CG, class Node, class Quad, class LocalFct, class Vec>
27  void assemble(CG const& contextGeo, Node const& node, Quad const& quad,
28  LocalFct const& localFct, Vec& elementVector) const
29  {
30  static_assert(static_size_v<typename LocalFct::Range> == 1,
31  "Expression must be of scalar type." );
32  static_assert(Node::isLeaf,
33  "Operator can be applied to Leaf-Nodes only");
34 
35  std::size_t size = node.size();
36 
37  for (auto const& qp : quad) {
38  // Position of the current quadrature point in the reference element
39  auto&& local = contextGeo.coordinateInElement(qp.position());
40 
41  // The multiplicative factor in the integral transformation formula
42  auto factor = contextGeo.integrationElement(qp.position()) * qp.weight();
43  factor *= localFct(local);
44 
45  auto const& shapeValues = node.localBasisValuesAt(local);
46  for (std::size_t i = 0; i < size; ++i) {
47  const auto local_i = node.localIndex(i);
48  elementVector[local_i] += factor * shapeValues[i];
49  }
50  }
51  }
52  };
53 
54  template <class LC>
55  struct GridFunctionOperatorRegistry<tag::test, LC>
56  {
57  static constexpr int degree = 0;
58  using type = ZeroOrderTest;
59  };
60 
63 } // end namespace AMDiS
Definition: AdaptBase.hpp:6
zero-order vector-operator
Definition: ZeroOrderTest.hpp:21
Definition: ZeroOrderTest.hpp:17
Registry to specify a tag for each implementation type.
Definition: GridFunctionOperator.hpp:216