6#include <amdis/GridFunctionOperatorTransposed.hpp>
7#include <amdis/Output.hpp>
8#include <amdis/common/Order.hpp>
9#include <amdis/common/TypeTraits.hpp>
10#include <amdis/utility/QuadratureFactory.hpp>
19 template <
class LF,
class Imp>
20 class GridFunctionLocalOperator;
37 template <
class GF,
class Imp>
41 using GridFunction = GF;
42 using Implementation = Imp;
49 template <
class Gr
idFct,
class Impl>
51 int derivDeg,
int gridFctOrder)
52 : gridFct_(FWD(gridFct))
55 , gridFctOrder_(gridFctOrder)
58 template <
class Gr
idView>
59 void update(GridView
const&) { }
63 return GridFunctionLocalOperator{localFunction(op.gridFct_), op.impl_,
64 op.derivDeg_, op.gridFctOrder_};
69 GridFunction gridFct_;
81 template <
class Gr
idFct,
class Impl>
82 GridFunctionOperator(GridFct
const& gridFct,
Impl const& impl,
int,
int)
83 -> GridFunctionOperator<GridFct, Impl>;
100 template <
class LF,
class Imp>
105 using LocalFunction = LF;
108 using Implementation = Imp;
117 template <
class LocalFct,
class Impl>
119 int derivDeg,
int localFctOrder)
120 : localFct_(FWD(localFct))
122 , derivDeg_(derivDeg)
123 , localFctOrder_(localFctOrder)
130 template <
class Element>
131 void bind(Element
const& element)
133 localFct_.bind(element);
147 template <
class CG,
class RN,
class CN,
class Mat>
148 void assemble(CG
const& contextGeo, RN
const& rowNode, CN
const& colNode,
149 Mat& elementMatrix)
const
151 auto const& quad = getQuadratureRule(contextGeo.geometry(),
152 derivDeg_, localFctOrder(), rowNode, colNode);
153 impl().assemble(contextGeo, rowNode, colNode, quad, localFct_, elementMatrix);
161 template <
class CG,
class Node,
class Vec>
162 void assemble(CG
const& contextGeo, Node
const& node,
163 Vec& elementVector)
const
165 auto const& quad = getQuadratureRule(contextGeo.geometry(),
166 derivDeg_, localFctOrder(), node);
167 impl().assemble(contextGeo, node, quad, localFct_, elementVector);
170 Implementation & impl() {
return impl_; }
171 Implementation
const& impl()
const {
return impl_; }
176 int localFctOrder()
const
178 if (localFctOrder_ >= 0)
179 return localFctOrder_;
183 if constexpr (Concepts::Polynomial<LF>)
184 coeffOrder = order(localFct_);
186 test_exit(coeffOrder >= 0,
187 "Polynomial degree of coefficients cannot be determined. "
188 "Please provide a quadrature order manually.");
196 LocalFunction localFct_;
199 Implementation impl_;
209 template <
class LocalFct,
class Impl>
210 GridFunctionLocalOperator(LocalFct
const& localFct,
Impl const& impl,
int,
int)
211 -> GridFunctionLocalOperator<LocalFct, Impl>;
215 template <
class Tag,
class LocalContext>
218 template <
class Tag,
class Expr>
225 OperatorTerm(Tag tag, Expr
const& expr,
int gridFctDeg = -1)
228 , gridFctDeg(gridFctDeg)
234 template <
class Tag,
class Expr>
240 template <
class Tag,
class Expr>
241 auto operatorTerm(Tag
const& tag, Expr&& expr,
int gridFctDeg = -1)
243 return OperatorTerm{tag, FWD(expr), gridFctDeg};
250 template <
class R,
class Tag>
251 using IsTransposed =
decltype(R::transposedTag(std::declval<Tag>()));
255 template <
class Context,
class Tag,
class Expr,
class Gr
idView>
256 auto makeOperator(OperatorTerm<Tag,Expr>
const& op, GridView
const& gridView)
260 using Registry = GridFunctionOperatorRegistry<Tag,Context>;
261 if constexpr (Dune::Std::is_detected_v<IsTransposed,Registry,Tag>) {
262 auto impl =
typename Registry::type{Registry::transposedTag(op.tag)};
263 return GridFunctionOperatorTransposed{
264 GridFunctionOperator{std::move(gf), std::move(impl), Registry::degree, op.gridFctDeg}
267 auto impl =
typename Registry::type{op.tag};
268 return GridFunctionOperator{std::move(gf), std::move(impl), Registry::degree, op.gridFctDeg};
The main implementation of a local-operator depending on a local-function.
Definition: GridFunctionOperator.hpp:102
GridFunctionLocalOperator(LocalFct &&localFct, Impl &&impl, int derivDeg, int localFctOrder)
Constructor. Stores a copy of localFct and impl.
Definition: GridFunctionOperator.hpp:118
void bind(Element const &element)
Binds operator to element.
Definition: GridFunctionOperator.hpp:131
void assemble(CG const &contextGeo, Node const &node, Vec &elementVector) const
Assemble a local element vector on the element that is bound.
Definition: GridFunctionOperator.hpp:162
void assemble(CG const &contextGeo, RN const &rowNode, CN const &colNode, Mat &elementMatrix) const
Assemble a local element matrix on the element that is bound.
Definition: GridFunctionOperator.hpp:148
void unbind()
Unbinds operator from element.
Definition: GridFunctionOperator.hpp:137
The main implementation of an operator depending on a grid-function.
Definition: GridFunctionOperator.hpp:39
GridFunctionOperator(GridFct &&gridFct, Impl &&impl, int derivDeg, int gridFctOrder)
Constructor. Stores a copy of gridFct and impl.
Definition: GridFunctionOperator.hpp:50
decltype(auto) makeGridFunction(PreGridFct const &preGridFct, GridView const &gridView)
Generator for Gridfunctions from Expressions (PreGridfunctions)
Definition: GridFunction.hpp:168
auto makeOperator(Tag const &tag, Expr &&expr, int gridFctDeg=-1)
Definition: GridFunctionOperator.hpp:235
Registry to specify a tag for each implementation type.
Definition: GridFunctionOperator.hpp:216
Definition: GridFunctionOperator.hpp:220