AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
FirstOrderGradTest.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <amdis/GridFunctionOperator.hpp>
6#include <amdis/common/StaticSize.hpp>
7
8namespace AMDiS
9{
15 namespace tag
16 {
17 struct gradtest {};
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, "Expression must be of vector type.");
32 static_assert(Node::isLeaf, "Node must be Leaf-Node.");
33
34 std::size_t feSize = node.size();
35
36 using RangeFieldType = typename Node::LocalBasis::Traits::RangeFieldType;
37 using WorldVector = FieldVector<RangeFieldType,CG::dow>;
38 std::vector<WorldVector> gradients;
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 transposed inverse Jacobian of the map from the reference element to the element
45 const auto jacobian = contextGeo.elementGeometry().jacobianInverseTransposed(local);
46
47 // The multiplicative factor in the integral transformation formula
48 const auto factor = localFct(local);
49 const auto dx = contextGeo.integrationElement(qp.position()) * qp.weight();
50
51 // The gradients of the shape functions on the reference element
52 auto const& shapeGradients = node.localBasisJacobiansAt(local);
53
54 // Compute the shape function gradients on the real element
55 gradients.resize(shapeGradients.size());
56
57 for (std::size_t i = 0; i < gradients.size(); ++i)
58 jacobian.mv(shapeGradients[i][0], gradients[i]);
59
60 for (std::size_t i = 0; i < feSize; ++i) {
61 const auto local_i = node.localIndex(i);
62 elementVector[local_i] += dx * (factor * gradients[i]);
63 }
64 }
65 }
66 };
67
68
69 template <class LC>
70 struct GridFunctionOperatorRegistry<tag::gradtest, LC>
71 {
72 static constexpr int degree = 1;
74 };
75
78} // end namespace AMDiS
first-order operator
Definition: FirstOrderGradTest.hpp:23
Registry to specify a tag for each implementation type.
Definition: GridFunctionOperator.hpp:216
Definition: FirstOrderGradTest.hpp:17