Loading...
Searching...
No Matches
gridfunction.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
#ifndef DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
#define DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
#include <type_traits>
#include <dune/common/typeutilities.hh>
#include <dune/functions/common/typeerasure.hh>
#include <dune/functions/common/defaultderivativetraits.hh>
#include <dune/functions/common/differentiablefunction.hh>
#include <dune/functions/common/localfunction.hh>
#include <dune/functions/common/functionconcepts.hh>
#include <dune/functions/gridfunctions/localderivativetraits.hh>
#include <dune/functions/gridfunctions/gridfunction_imp.hh>
namespace Dune {
namespace Functions {
/*
* Default implementation is empty
* The actual implementation is only given if Signature is an type
* describing a function signature as Range(Domain).
*/
template<class Signature, class EntitySet, template<class> class DerivativeTraits=DefaultDerivativeTraits, size_t bufferSize=56>
class GridFunction
{};
namespace Imp
{
template<class S, class ES, template<class> class DerivativeTraits, size_t bufferSize>
struct GridFunctionTraits :
DifferentiableFunctionTraits<S, DerivativeTraits, bufferSize>
{
protected:
using Base=DifferentiableFunctionTraits<S, DerivativeTraits, bufferSize>;
public:
using EntitySet = ES;
using Element = typename EntitySet::Element;
using DerivativeSignature = typename Base::DerivativeSignature;
using DerivativeInterface = GridFunction<DerivativeSignature, ES, DerivativeTraits, bufferSize>;
using LocalSignature = typename Base::Range(typename EntitySet::LocalCoordinate);
template<class R>
using LocalDerivativeTraits = typename Dune::Functions::LocalDerivativeTraits<EntitySet, DerivativeTraits>::template Traits<R>;
using LocalFunctionTraits = typename Dune::Functions::Imp::LocalFunctionTraits<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
using LocalFunctionInterface = LocalFunction<LocalSignature, Element, LocalDerivativeTraits, bufferSize>;
using Concept = GridFunctionWrapperInterface<S, DerivativeInterface, LocalFunctionInterface, ES>;
template<class B>
using Model = GridFunctionWrapperImplementation<S, DerivativeInterface, LocalFunctionInterface, ES, B>;
};
}
template<class Range, class Domain, class ES, template<class> class DerivativeTraits, size_t bufferSize>
class GridFunction<Range(Domain), ES, DerivativeTraits, bufferSize> :
public TypeErasureBase<
typename Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::Concept,
Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>::template Model>
{
using Traits = Imp::GridFunctionTraits<Range(Domain), ES, DerivativeTraits, bufferSize>;
using Base = TypeErasureBase<typename Traits::Concept, Traits::template Model>;
using DerivativeInterface = typename Traits::DerivativeInterface;
using LocalFunctionInterface = typename Traits::LocalFunctionInterface;
using EntitySet = typename Traits::EntitySet;
public:
template<class F, disableCopyMove<GridFunction, F> = 0 >
GridFunction(F&& f) :
Base(std::forward<F>(f))
{
static_assert(Dune::Functions::Concept::isGridFunction<F, Range(Domain), EntitySet>(), "Trying to construct a GridFunction from type that does not model the GridFunction concept");
}
GridFunction() = default;
Range operator() (const Domain& x) const
{
return this->asInterface().operator()(x);
}
friend DerivativeInterface derivative(const GridFunction& t)
{
return t.asInterface().derivative();
}
friend LocalFunctionInterface localFunction(const GridFunction& t)
{
return t.asInterface().wrappedLocalFunction();
}
const EntitySet& entitySet() const
{
return this->asInterface().wrappedEntitySet();
}
};
}} // namespace Dune::Functions
#endif // DUNE_FUNCTIONS_GRIDFUNCTIONS_GRID_FUNCTION_HH
localderivativetraits.hh
gridfunction_imp.hh
localfunction.hh
differentiablefunction.hh
defaultderivativetraits.hh
functionconcepts.hh
typeerasure.hh
Dune::Functions::Concept::isGridFunction
static constexpr bool isGridFunction()
Check if F models the GridFunction concept with given signature and entity set.
Definition functionconcepts.hh:273
Dune
Definition monomialset.hh:19
Dune::Functions
Definition monomialset.hh:19
Dune::Functions::Concept
Definition backends/concepts.hh:17
Dune::Functions::DefaultDerivativeTraits
Default implementation for derivative traits.
Definition defaultderivativetraits.hh:41
Dune::Functions::LocalFunction
Definition localfunction.hh:34
Dune::Functions::TypeErasureBase< Imp::GridFunctionTraits< Range(Domain), ES, DerivativeTraits, bufferSize >::Concept, Imp::GridFunctionTraits< Range(Domain), ES, DerivativeTraits, bufferSize >::template Model >::TypeErasureBase
TypeErasureBase(T &&t)
Definition typeerasure.hh:174
Dune::Functions::TypeErasureBase< Imp::GridFunctionTraits< Range(Domain), ES, DerivativeTraits, bufferSize >::Concept, Imp::GridFunctionTraits< Range(Domain), ES, DerivativeTraits, bufferSize >::template Model >::asInterface
Imp::GridFunctionTraits< Range(Domain), ES, DerivativeTraits, bufferSize >::Concept & asInterface()
Definition typeerasure.hh:182
Dune::Functions::GridFunction
Definition gridfunction.hh:36
Dune::Functions::GridFunction< Range(Domain), ES, DerivativeTraits, bufferSize >::derivative
friend DerivativeInterface derivative(const GridFunction &t)
Get derivative of wrapped function.
Definition gridfunction.hh:155
Dune::Functions::GridFunction< Range(Domain), ES, DerivativeTraits, bufferSize >::GridFunction
GridFunction()=default
Dune::Functions::GridFunction< Range(Domain), ES, DerivativeTraits, bufferSize >::entitySet
const EntitySet & entitySet() const
Get associated EntitySet.
Definition gridfunction.hh:180
Dune::Functions::GridFunction< Range(Domain), ES, DerivativeTraits, bufferSize >::GridFunction
GridFunction(F &&f)
Construct from function.
Definition gridfunction.hh:129
Dune::Functions::GridFunction< Range(Domain), ES, DerivativeTraits, bufferSize >::localFunction
friend LocalFunctionInterface localFunction(const GridFunction &t)
Get local function of wrapped function.
Definition gridfunction.hh:169
Dune::Functions::LocalDerivativeTraits
Derivative traits for local functions.
Definition localderivativetraits.hh:32