AMDiS  2.10
The Adaptive Multi-Dimensional Simulation Toolbox
ZeroOrderTestvec.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 testvec {};
18  }
19 
20 
23  {
24  public:
26 
27  template <class CG, class Node, class Quad, class LocalFct, class Vec>
28  void assemble(CG const& contextGeo, Node const& node, Quad const& quad,
29  LocalFct const& localFct, Vec& elementVector) const
30  {
31  static_assert(static_size_v<typename LocalFct::Range> == CG::dow,
32  "Expression must be of vector type." );
33  static_assert(Node::isPower,
34  "Operator can be applied to Power-Nodes only.");
35 
36  assert(node.degree() == CG::dow);
37 
38  std::size_t size = node.child(0).size();
39 
40  for (auto const& qp : quad) {
41  // Position of the current quadrature point in the reference element
42  auto&& local = contextGeo.coordinateInElement(qp.position());
43 
44  // The multiplicative factor in the integral transformation formula
45  const auto factor = contextGeo.integrationElement(qp.position()) * qp.weight();
46  const auto exprValue = localFct(local);
47 
48  auto const& shapeValues = node.child(0).localBasisValuesAt(local);
49 
50  for (std::size_t i = 0; i < size; ++i) {
51  const auto value = exprValue * (factor * shapeValues[i]);
52  for (std::size_t k = 0; k < node.degree(); ++k) {
53  const auto local_ki = node.child(k).localIndex(i);
54  elementVector[local_ki] += at(value,k);
55  }
56  }
57  }
58  }
59  };
60 
61  template <class LC>
62  struct GridFunctionOperatorRegistry<tag::testvec, LC>
63  {
64  static constexpr int degree = 0;
65  using type = ZeroOrderTestVec;
66  };
67 
70 } // end namespace AMDiS
Definition: AdaptBase.hpp:6
zero-order vector-operator
Definition: ZeroOrderTestvec.hpp:22
Definition: ZeroOrderTestvec.hpp:17
Registry to specify a tag for each implementation type.
Definition: GridFunctionOperator.hpp:216