AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
ZeroOrderTestTrialvec.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_trialvec {};
18  }
19 
20 
23  {
24  public:
26 
27  template <class CG, class RN, class CN, class Quad, class LocalFct, class Mat>
28  void assemble(CG const& contextGeo, RN const& rowNode, CN const& colNode,
29  Quad const& quad, LocalFct const& localFct, Mat& elementMatrix) const
30  {
31  static_assert(static_size_v<typename LocalFct::Range> == CG::dow,
32  "Expression must be of vector type." );
33  static_assert(RN::isLeaf && CN::isPower,
34  "RN must be Leaf-Node and CN must be a Power-Node.");
35 
36  static const std::size_t CHILDREN = CN::CHILDREN;
37  static_assert(CHILDREN == CG::dow);
38 
39  std::size_t rowSize = rowNode.size();
40  std::size_t colSize = colNode.child(0).size();
41 
42  for (auto const& qp : quad) {
43  // Position of the current quadrature point in the reference element
44  auto&& local = contextGeo.local(qp.position());
45 
46  // The multiplicative factor in the integral transformation formula
47  const auto factor = contextGeo.integrationElement(qp.position()) * qp.weight();
48  const auto b = localFct(local);
49 
50  auto const& rowShapeValues = rowNode.localBasisValuesAt(local);
51  auto const& colShapeValues = colNode.child(0).localBasisValuesAt(local);
52 
53  for (std::size_t i = 0; i < rowSize; ++i) {
54  const auto local_i = rowNode.localIndex(i);
55 
56  for (std::size_t j = 0; j < colSize; ++j) {
57  const auto value = b * (factor * rowShapeValues[i] * colShapeValues[j]);
58 
59  for (std::size_t k = 0; k < CHILDREN; ++k) {
60  const auto local_kj = colNode.child(k).localIndex(j);
61  elementMatrix[local_i][local_kj] += at(value,k);
62  }
63  }
64  }
65  }
66  }
67  };
68 
69  template <class LC>
70  struct GridFunctionOperatorRegistry<tag::test_trialvec, LC>
71  {
72  static constexpr int degree = 0;
74  };
75 
78 } // end namespace AMDiS
zero-order operator
Definition: ZeroOrderTestTrialvec.hpp:22
Definition: AdaptBase.hpp:6
Definition: ZeroOrderTestTrialvec.hpp:17
Registry to specify a tag for each implementation type.
Definition: GridFunctionOperator.hpp:204