/usr/include/dune/functions/common/functionconcepts.hh is in libdune-functions-dev 2.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_FUNCTIONS_COMMON_FUNCTIONCONCEPT_HH
#define DUNE_FUNCTIONS_COMMON_FUNCTIONCONCEPT_HH
#include <dune/common/typelist.hh>
#include <dune/common/concept.hh>
#include <dune/functions/common/signature.hh>
#include <dune/functions/gridfunctions/localderivativetraits.hh>
#include <dune/functions/gridfunctions/gridviewentityset.hh>
namespace Dune {
namespace Functions {
namespace Concept {
using namespace Dune::Concept;
// Callable concept ############################################################
/**
* \brief Concept objects that can be called with given argument list
*
* \ingroup FunctionConcepts
*
* \tparam Args Argument list for function call
*/
template<class... Args>
struct Callable
{
template<class F>
auto require(F&& f) -> decltype(
f(std::declval<Args>()...)
);
};
/// Check if F models the Function concept with given signature \ingroup FunctionConcepts
template<class F, class... Args>
static constexpr bool isCallable()
{ return models<Concept::Callable<Args...>, F>(); }
/// Check if f models the Function concept with given signature \ingroup FunctionConcepts
template<class F, class... Args>
static constexpr bool isCallable(F&& f, TypeList<Args...>)
{ return models<Concept::Callable<Args...>, F>(); }
// Function concept ############################################################
template<class Signature>
struct Function;
/**
* \brief Concept for a function mapping \p Domain to \p Range
*
* \ingroup FunctionConcepts
*
* \tparam Domain Domain type
* \tparam Range Range type
*/
template<class Range, class Domain>
struct Function<Range(Domain)> : Refines<Callable<Domain> >
{
template<class F>
auto require(F&& f) -> decltype(
// F models Function<Range(Domain)> if the result of F(Domain) is implicitly convertible to Range
requireConvertible<Range>(f(std::declval<Domain>()))
);
};
/// Check if F models the Function concept with given signature \ingroup FunctionConcepts
template<class F, class Signature>
static constexpr bool isFunction()
{ return models<Concept::Function<Signature>, F>(); }
/// Check if f models the Function concept with given signature \ingroup FunctionConcepts
template<class F, class Signature, template<class> class DerivativeTraits>
static constexpr bool isFunction(F&& f, SignatureTag<Signature, DerivativeTraits>)
{ return models<Concept::Function<Signature>, F>(); }
// DifferentiableFunction concept ##############################################
template<class Signature, template<class> class DerivativeTraits = DefaultDerivativeTraits>
struct DifferentiableFunction;
/**
* \brief Concept for a differentiable function mapping \p Domain to \p Range
*
* \ingroup FunctionConcepts
*
* The derivative range is derived from the provided \p DerivativeTraits
*
* \tparam Domain Domain type
* \tparam Range Range type
* \tparam DerivativeTraits Traits class for computation of derivative range
*/
template<class Range, class Domain, template<class> class DerivativeTraits>
struct DifferentiableFunction<Range(Domain), DerivativeTraits> : Refines<Dune::Functions::Concept::Function<Range(Domain)> >
{
using DerivativeSignature = typename SignatureTraits<Range(Domain)>::template DerivativeSignature<DerivativeTraits>;
template<class F>
auto require(F&& f) -> decltype(
derivative(f),
requireConcept<Function<DerivativeSignature>>(derivative(f))
);
};
/// Check if F models the DifferentiableFunction concept with given signature \ingroup FunctionConcepts
template<class F, class Signature, template<class> class DerivativeTraits = DefaultDerivativeTraits>
static constexpr bool isDifferentiableFunction()
{ return models<Concept::DifferentiableFunction<Signature, DerivativeTraits>, F>(); }
/// Check if f models the DifferentiableFunction concept with given signature \ingroup FunctionConcepts
template<class F, class Signature, template<class> class DerivativeTraits>
static constexpr bool isDifferentiableFunction(F&& f, SignatureTag<Signature, DerivativeTraits>)
{ return models<Concept::DifferentiableFunction<Signature, DerivativeTraits>, F>(); }
// LocalFunction concept ##############################################
template<class Signature, class LocalContext, template<class> class DerivativeTraits = DefaultDerivativeTraits>
struct LocalFunction;
/**
* \brief Concept for a local function mapping \p Domain to \p Range
*
* \ingroup FunctionConcepts
*
* The derivative range is derived from the provided \p DerivativeTraits
*
* \tparam Domain Domain type
* \tparam Range Range type
* \tparam LocalContext The local context this function is defined on
* \tparam DerivativeTraits Traits class for computation of derivative range
*/
template<class Range, class Domain, class LocalContext, template<class> class DerivativeTraits>
struct LocalFunction<Range(Domain), LocalContext, DerivativeTraits> :
Refines<Dune::Functions::Concept::DifferentiableFunction<Range(Domain), DerivativeTraits> >
{
template<class F>
auto require(F&& f) -> decltype(
f.bind(std::declval<LocalContext>()),
f.unbind(),
f.localContext(),
requireConvertible<LocalContext>(f.localContext())
);
};
/// Check if F models the LocalFunction concept with given signature and local context \ingroup FunctionConcepts
template<class F, class Signature, class LocalContext, template<class> class DerivativeTraits = DefaultDerivativeTraits>
static constexpr bool isLocalFunction()
{ return models<Concept::LocalFunction<Signature, LocalContext, DerivativeTraits>, F>(); }
// EntitySet concept ##############################################
/**
* \brief Concept for an entity set for a \ref Concept::GridFunction<Range(Domain), EntitySet, DerivativeTraits>
*
* \ingroup FunctionConcepts
*
* This describes the set of entities on which a grid function
* can be localized.
*
*/
struct EntitySet
{
template<class E>
auto require(E&& f) -> decltype(
requireType<typename E::Element>(),
requireType<typename E::LocalCoordinate>(),
requireType<typename E::GlobalCoordinate>()
);
};
/// Check if F models the GridFunction concept with given signature and entity set \ingroup FunctionConcepts
template<class E>
static constexpr bool isEntitySet()
{ return models<Concept::EntitySet, E>(); }
// GridFunction concept ##############################################
template<class Signature, class EntitySet, template<class> class DerivativeTraits = DefaultDerivativeTraits>
struct GridFunction;
/**
* \brief Concept for a grid function mapping \p Domain to \p Range
*
* \ingroup FunctionConcepts
*
* The derivative range is derived from the provided \p DerivativeTraits.
*
* \tparam Domain Domain type
* \tparam Range Range type
* \tparam EntitySet Set of entities on which the function can be localized
* \tparam DerivativeTraits Traits class for computation of derivative range
*/
template<class Range, class Domain, class EntitySet, template<class> class DerivativeTraits>
struct GridFunction<Range(Domain), EntitySet, DerivativeTraits> :
Refines<Dune::Functions::Concept::DifferentiableFunction<Range(Domain), DerivativeTraits> >
{
using LocalSignature = Range(typename EntitySet::LocalCoordinate);
using LocalContext = typename EntitySet::Element;
template<class R>
using LocalDerivativeTraits = typename Dune::Functions::LocalDerivativeTraits<EntitySet, DerivativeTraits>::template Traits<R>;
template<class F>
auto require(F&& f) -> decltype(
localFunction(f),
f.entitySet(),
requireConcept<LocalFunction<LocalSignature, LocalContext, LocalDerivativeTraits>>(localFunction(f)),
requireConcept<Concept::EntitySet, EntitySet>(),
requireConvertible<EntitySet>(f.entitySet()),
requireConvertible<typename EntitySet::GlobalCoordinate, Domain>()
);
};
/// Check if F models the GridFunction concept with given signature and entity set \ingroup FunctionConcepts
template<class F, class Signature, class EntitySet, template<class> class DerivativeTraits = DefaultDerivativeTraits>
static constexpr bool isGridFunction()
{ return models<Concept::GridFunction<Signature, EntitySet, DerivativeTraits>, F>(); }
// GridViewFunction concept ##############################################
template<class Signature, class GridView, template<class> class DerivativeTraits = DefaultDerivativeTraits>
struct GridViewFunction;
/**
* \brief Concept for a grid view function mapping \p Domain to \p Range
*
* \ingroup FunctionConcepts
*
* This exactly the \ref Concept::GridFunction<Range(Domain), EntitySet, DerivativeTraits>
* concept with a \ref GridViewEntitySet as \p EntitySet.
*
* \tparam Domain Domain type
* \tparam Range Range type
* \tparam GridView GridView on which the function can be localized
* \tparam DerivativeTraits Traits class for computation of derivative range
*/
template<class Range, class Domain, class GridView, template<class> class DerivativeTraits>
struct GridViewFunction<Range(Domain), GridView, DerivativeTraits> :
Refines<Dune::Functions::Concept::GridFunction<Range(Domain), GridViewEntitySet<GridView,0>, DerivativeTraits>>
{
template<class F>
auto require(F&& f) -> decltype(
0 // We don't need to check any further expressions, because a GridViewFunction is just a GridFunction with a special EntitySet
);
};
/// Check if F models the GridViewFunction concept with given signature \ingroup FunctionConcepts
template<class F, class Signature, class GridView, template<class> class DerivativeTraits = DefaultDerivativeTraits>
static constexpr bool isGridViewFunction()
{ return models<Concept::GridViewFunction<Signature, GridView, DerivativeTraits>, F>(); }
}}} // namespace Dune::Functions::Concept
#endif // DUNE_FUNCTIONS_COMMON_FUNCTIONCONCEPT_HH
|