AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
FirstOrderPartialTest.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <amdis/GridFunctionOperator.hpp>
6#include <amdis/common/StaticSize.hpp>
7#include <amdis/utility/LocalToGlobalAdapter.hpp>
8
9namespace AMDiS
10{
16 namespace tag
17 {
19 {
20 std::size_t comp;
21 };
22 }
23
24
27 {
28 int comp_;
29
30 public:
32 : comp_(tag.comp)
33 {}
34
35 template <class CG, class Node, class Quad, class LocalFct, class Vec>
36 void assemble(CG const& contextGeo, Node const& node, Quad const& quad,
37 LocalFct const& localFct, Vec& elementVector) const
38 {
39 static_assert(static_size_v<typename LocalFct::Range> == 1, "Expression must be of scalar type." );
40 static_assert(Node::isLeaf, "Operator can be applied to Leaf-Nodes only.");
41
42 LocalToGlobalBasisAdapter localBasis(node, contextGeo.elementGeometry());
43
44 for (auto const& qp : quad) {
45 // Position of the current quadrature point in the reference element
46 decltype(auto) local = contextGeo.coordinateInElement(qp.position());
47
48 // The multiplicative factor in the integral transformation formula
49 auto dx = contextGeo.integrationElement(qp.position()) * qp.weight();
50 dx *= localFct(local);
51
52 // Compute the shape function gradients on the real element
53 auto const& partial = localBasis.partialsAt(local, comp_);
54
55 for (std::size_t j = 0; j < localBasis.size(); ++j) {
56 const auto local_j = node.localIndex(j);
57 elementVector[local_j] += dx * partial[j];
58 }
59 }
60 }
61 };
62
63 template <class LC>
64 struct GridFunctionOperatorRegistry<tag::partialtest, LC>
65 {
66 static constexpr int degree = 1;
68 };
69
72} // end namespace AMDiS
first-order operator
Definition: FirstOrderPartialTest.hpp:27
Convert a simple (scalar) local basis into a global basis.
Definition: LocalToGlobalAdapter.hpp:65
auto const & partialsAt(typename Traits::DomainLocal const &x, std::size_t comp) const
Definition: LocalToGlobalAdapter.hpp:175
std::size_t size() const
Return the number of local basis functions.
Definition: LocalToGlobalAdapter.hpp:96
Registry to specify a tag for each implementation type.
Definition: GridFunctionOperator.hpp:216
Definition: FirstOrderPartialTest.hpp:19