6#include <dune/common/ftraits.hh>
7#include <dune/common/typeutilities.hh>
8#include <dune/functions/common/defaultderivativetraits.hh>
9#include <dune/functions/functionspacebases/flatvectorview.hh>
10#include <dune/functions/gridfunctions/gridviewentityset.hh>
11#include <dune/typetree/childextraction.hh>
13#include <amdis/common/DerivativeTraits.hpp>
14#include <amdis/common/Tags.hpp>
15#include <amdis/functions/NodeCache.hpp>
16#include <amdis/interpolators/SimpleInterpolator.hpp>
17#include <amdis/linearalgebra/Access.hpp>
18#include <amdis/typetree/FiniteElementType.hpp>
19#include <amdis/typetree/RangeType.hpp>
20#include <amdis/typetree/TreePath.hpp>
37 template <
class Coeff,
class GB,
class TreePath,
class Range =
void>
38 class DiscreteFunction;
42 template <
class Coeff,
class GB,
class TreePath,
class R>
49 using Coefficients = std::remove_const_t<Coeff>;
50 using GlobalBasis = GB;
54 template <
class C,
class B,
class... Path,
59 , mutableCoeff_(wrap_or_share<Coefficients>(FWD(
coefficients)))
72 template <
class Expr,
class Tag = tag::assign>
85 template <
class Expr,
class Tag = tag::assign>
105 template <
class Expr>
115 return *mutableCoeff_;
121 template <
class Range = void,
class... Indices>
122 auto child(Indices... ii)
124 auto tp = cat(Super::treePath_, makeTreePath(ii...));
126 return Child{mutableCoeff_, Super::basis_, tp};
132 std::shared_ptr<Coefficients> mutableCoeff_;
136 template <
class Coeff,
class GB,
class TreePath,
class R>
140 using Coefficients = std::remove_const_t<Coeff>;
141 using GlobalBasis = GB;
145 using Coefficient = TYPEOF(std::declval<Traits::Access>()(std::declval<Coeff const>(), std::declval<typename GB::MultiIndex>()));
148 using SubTree =
typename Dune::TypeTree::ChildForTreePath<Tree, TreePath>;
152 using EntitySet = Dune::Functions::GridViewEntitySet<GridView, 0>;
155 using Domain =
typename EntitySet::GlobalCoordinate;
158 using Range = std::conditional_t<std::is_same_v<R,void>, RangeType_t<SubTree,Coefficient>, R>;
162 enum { hasDerivative =
false };
166 template <
class Type>
179 template <
class C,
class B,
class... Path,
184 , basis_{wrap_or_share(FWD(basis))}
185 , treePath_{makeTreePath(path...)}
186 , entitySet_{basis_->gridView()}
195 return {basis().localView(), treePath_, coefficients_,
tag::value{}};
219 return *coefficients_;
222 template <
class Range = void,
class... Indices>
223 auto child(Indices... ii)
const
225 auto tp = cat(this->treePath_, makeTreePath(ii...));
226 using Child =
DiscreteFunction<Coeff
const, GB, TYPEOF(makeTreePath(tp)), Range>;
227 return Child{coefficients_, basis_, tp};
231 std::shared_ptr<Coefficients const> coefficients_;
232 std::shared_ptr<GlobalBasis const> basis_;
234 EntitySet entitySet_;
240 template <
class Coefficients,
class Basis,
class... Indices,
241 class C = Underlying_t<Coefficients>,
242 class B = std::remove_const_t<Underlying_t<Basis>>,
243 class TP = TYPEOF(makeTreePath(std::declval<Indices>()...)),
244 REQUIRES(Concepts::GlobalBasis<B>)>
245 DiscreteFunction(Coefficients&&, Basis&&, Indices...)
246 -> DiscreteFunction<C,B,TP>;
253 template <
class Range = void,
class C,
class GB,
class TP,
class R,
class... Indices>
254 auto valueOf(DiscreteFunction<C,GB,TP,R>& df, Indices... ii)
256 return df.template child<Range>(ii...);
260 template <
class Range = void,
class C,
class GB,
class TP,
class R,
class... Indices>
261 auto valueOf(DiscreteFunction<C,GB,TP,R>
const& df, Indices... ii)
263 return df.template child<Range>(ii...);
268#include "DiscreteLocalFunction.inc.hpp"
269#include "DiscreteFunction.inc.hpp"
A Const DiscreteFunction.
Definition: DiscreteFunction.hpp:138
TreePath const & treePath() const
Return treePath associated with this discrete function.
Definition: DiscreteFunction.hpp:211
typename EntitySet::GlobalCoordinate Domain
Global coordinates of the EntitySet.
Definition: DiscreteFunction.hpp:155
Dune::Functions::GridViewEntitySet< GridView, 0 > EntitySet
Set of entities the DiscreteFunction is defined on.
Definition: DiscreteFunction.hpp:152
Range operator()(Domain const &x) const
Evaluate DiscreteFunction in global coordinates. NOTE: expensive.
DiscreteFunction(C &&coefficients, B &&basis, Path... path)
Definition: DiscreteFunction.hpp:182
std::conditional_t< std::is_same_v< R, void >, RangeType_t< SubTree, Coefficient >, R > Range
Range type of this DiscreteFunction. If R=void deduce the Range automatically, using RangeType_t.
Definition: DiscreteFunction.hpp:158
Coefficients const & coefficients() const
Return const coefficient vector.
Definition: DiscreteFunction.hpp:217
LocalFunction< tag::value > makeLocalFunction() const
Create a local function for this view on the DOFVector.
Definition: DiscreteFunction.hpp:193
EntitySet const & entitySet() const
Return a Dune::Functions::GridViewEntitySet.
Definition: DiscreteFunction.hpp:199
GlobalBasis const & basis() const
Return global basis bound to the DOFVector.
Definition: DiscreteFunction.hpp:205
A mutable view on the subspace of a DOFVector,.
Definition: DiscreteFunction.hpp:45
DiscreteFunction(C &&coefficients, B &&basis, Path... path)
Constructor. Stores a pointer to the mutable coefficients vector.
Definition: DiscreteFunction.hpp:57
Self & operator+=(Expr &&expr)
interpolate (*this) + expr to DOFVector
Definition: DiscreteFunction.hpp:98
Coefficients & coefficients()
Return the mutable DOFVector.
Definition: DiscreteFunction.hpp:113
Self & operator-=(Expr &&expr)
interpolate (*this) - expr to DOFVector
Definition: DiscreteFunction.hpp:106
void interpolate(Expr &&expr, Tag strategy={})
Interpolation of GridFunction to DOFVector.
Definition: DiscreteFunction.inc.hpp:52
Self & operator<<(Expr &&expr)
Interpolation of GridFunction to DOFVector, alias to interpolate()
Definition: DiscreteFunction.hpp:90
void interpolate_noalias(Expr &&expr, Tag strategy={})
Interpolation of GridFunction to DOFVector, assuming that there is no reference to this DOFVector in ...
Definition: DiscreteFunction.inc.hpp:36
Global basis defined on a pre-basis.
Definition: GlobalBasis.hpp:48
AMDiS::LocalView< Self > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: GlobalBasis.hpp:61
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: GlobalBasis.hpp:57
typename Super::Tree Tree
Tree of local finite elements / local shape function sets.
Definition: LocalView.hpp:24
constexpr bool Similar
Types are the same, up to decay of qualifiers.
Definition: Concepts.hpp:107
Definition: DerivativeTraits.hpp:18