5 #include <amdis/GridFunctionOperator.hpp> 6 #include <amdis/common/StaticSize.hpp> 22 template <
class LC,
class Gr
idFct>
29 static_assert( static_size_v<typename GridFct::Range> == 1,
"Expression must be of scalar type." );
36 template <
class CG,
class RN,
class CN,
class Mat>
37 void getElementMatrix(CG
const& contextGeo, RN
const& rowNode, CN
const& colNode, Mat& elementMatrix)
39 const bool sameFE = std::is_same_v<FiniteElementType_t<RN>, FiniteElementType_t<CN>>;
40 const bool sameNode = rowNode.treeIndex() == colNode.treeIndex();
42 auto const& quad = this->getQuadratureRule(contextGeo.type(), rowNode, colNode);
43 if (sameFE && sameNode)
44 getElementMatrixOptimized(contextGeo, quad, rowNode, colNode, elementMatrix);
46 getElementMatrixStandard(contextGeo, quad, rowNode, colNode, elementMatrix);
49 template <
class CG,
class Node,
class Vec>
50 void getElementVector(CG
const& contextGeo, Node
const& node, Vec& elementVector)
52 static_assert(Node::isLeaf,
"Operator can be applied to Leaf-Nodes only");
54 auto const& quad = this->getQuadratureRule(contextGeo.type(), node);
55 std::size_t size = node.size();
57 for (
auto const& qp : quad) {
59 auto&& local = contextGeo.local(qp.position());
62 const auto factor = Super::coefficient(local) * contextGeo.integrationElement(qp.position())
65 auto const& shapeValues = node.localBasisValuesAt(local);
66 for (std::size_t i = 0; i < size; ++i) {
67 const auto local_i = node.localIndex(i);
68 elementVector[local_i] += factor * shapeValues[i];
75 template <
class CG,
class QR,
class RN,
class CN,
class Mat>
76 void getElementMatrixStandard(CG
const& contextGeo, QR
const& quad,
77 RN
const& rowNode, CN
const& colNode,
80 static_assert(RN::isLeaf && CN::isLeaf,
81 "Operator can be applied to Leaf-Nodes only.");
83 std::size_t rowSize = rowNode.size();
84 std::size_t colSize = colNode.size();
86 for (
auto const& qp : quad) {
88 auto&& local = contextGeo.local(qp.position());
91 const auto factor = Super::coefficient(local) * contextGeo.integrationElement(qp.position()) * qp.weight();
93 auto const& rowShapeValues = rowNode.localBasisValuesAt(local);
94 auto const& colShapeValues = colNode.localBasisValuesAt(local);
96 for (std::size_t i = 0; i < rowSize; ++i) {
97 const auto local_i = rowNode.localIndex(i);
98 const auto value = factor * rowShapeValues[i];
100 for (std::size_t j = 0; j < colSize; ++j) {
101 const auto local_j = colNode.localIndex(j);
102 elementMatrix[local_i][local_j] += value * colShapeValues[j];
109 template <
class CG,
class QR,
class RN,
class CN,
class Mat>
110 void getElementMatrixOptimized(CG
const& contextGeo, QR
const& quad,
111 RN
const& node, CN
const& ,
114 static_assert(RN::isLeaf && CN::isLeaf,
115 "Operator can be applied to Leaf-Nodes only.");
117 std::size_t size = node.size();
119 for (
auto const& qp : quad) {
121 auto&& local = contextGeo.local(qp.position());
124 const auto factor = Super::coefficient(local) * contextGeo.integrationElement(qp.position()) * qp.weight();
126 auto const& shapeValues = node.localBasisValuesAt(local);
128 for (std::size_t i = 0; i < size; ++i) {
129 const auto local_i = node.localIndex(i);
131 const auto value = factor * shapeValues[i];
132 elementMatrix[local_i][local_i] += value * shapeValues[i];
134 for (std::size_t j = i+1; j < size; ++j) {
135 const auto local_j = node.localIndex(j);
137 elementMatrix[local_i][local_j] += value * shapeValues[j];
138 elementMatrix[local_j][local_i] += value * shapeValues[j];
147 template <
class Expr,
class... QuadratureArgs>
148 auto zot(Expr&& expr, QuadratureArgs&&... args)
auto makeOperator(Tag tag, Expr &&expr, QuadratureArgs &&... args)
Store tag and expression into a PreGridFunctionOperator to create a GridFunctionOperator.
Definition: GridFunctionOperator.hpp:220
The base-template for GridFunctionOperators.
Definition: GridFunctionOperator.hpp:242
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Definition: ZeroOrderTestTrial.hpp:17
auto zot(Expr &&expr, QuadratureArgs &&... args)
Create a zero-order term.
Definition: ZeroOrderTestTrial.hpp:148
The main implementation of an CRTP-base class for operators using a grid-function coefficient to be u...
Definition: GridFunctionOperator.hpp:39