AMDiS  2.10
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  assert(colNode.degree() == CG::dow);
37 
38  std::size_t rowSize = rowNode.size();
39  std::size_t colSize = colNode.child(0).size();
40 
41  for (auto const& qp : quad) {
42  // Position of the current quadrature point in the reference element
43  auto&& local = contextGeo.coordinateInElement(qp.position());
44 
45  // The multiplicative factor in the integral transformation formula
46  const auto factor = contextGeo.integrationElement(qp.position()) * qp.weight();
47  const auto b = localFct(local);
48 
49  auto const& rowShapeValues = rowNode.localBasisValuesAt(local);
50  auto const& colShapeValues = colNode.child(0).localBasisValuesAt(local);
51 
52  for (std::size_t i = 0; i < rowSize; ++i) {
53  const auto local_i = rowNode.localIndex(i);
54 
55  for (std::size_t j = 0; j < colSize; ++j) {
56  const auto value = b * (factor * rowShapeValues[i] * colShapeValues[j]);
57 
58  for (std::size_t k = 0; k < colNode.degree(); ++k) {
59  const auto local_kj = colNode.child(k).localIndex(j);
60  elementMatrix[local_i][local_kj] += at(value,k);
61  }
62  }
63  }
64  }
65  }
66  };
67 
68  template <class LC>
69  struct GridFunctionOperatorRegistry<tag::test_trialvec, LC>
70  {
71  static constexpr int degree = 0;
73  };
74 
77 } // 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:216