From c52b3a19873e0c394ad706480916be2203485cfc Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sun, 8 Dec 2019 13:34:52 +0100 Subject: [PATCH] renamed requires_ to require to conform to other dune concept defintions --- src/amdis/AdaptionInterface.hpp | 11 +++- src/amdis/common/Access.hpp | 12 ++--- src/amdis/common/Concepts.hpp | 54 +++++++++++-------- src/amdis/common/ConceptsBase.hpp | 17 ++---- src/amdis/common/Resize.hpp | 14 ++--- .../gridfunctions/AnalyticGridFunction.hpp | 3 ++ src/amdis/gridfunctions/Derivative.hpp | 17 ++++-- .../gridfunctions/FunctorGridFunction.hpp | 4 -- src/amdis/gridfunctions/GridFunction.hpp | 22 ++++++-- src/amdis/gridfunctions/Order.hpp | 15 +++++- src/amdis/operations/Basic.hpp | 5 +- src/amdis/typetree/TreePath.hpp | 5 ++ 12 files changed, 114 insertions(+), 65 deletions(-) diff --git a/src/amdis/AdaptionInterface.hpp b/src/amdis/AdaptionInterface.hpp index 66a0baf6..ff999f1d 100644 --- a/src/amdis/AdaptionInterface.hpp +++ b/src/amdis/AdaptionInterface.hpp @@ -16,7 +16,7 @@ namespace AMDiS struct InterpolateData { template - auto requires_(Data const& data) -> decltype( + auto require(Data const& data) -> decltype( const_cast(data).preAdapt(true), const_cast(data).postAdapt(true) ); @@ -25,7 +25,7 @@ namespace AMDiS struct UpdateData { template - auto requires_(Basis const& basis) -> decltype( + auto require(Basis const& basis) -> decltype( const_cast(basis).update(basis.gridView()) ); }; @@ -35,9 +35,16 @@ namespace AMDiS template constexpr bool InterpolateData = models; + template + using InterpolateData_t = models_t; + + template constexpr bool UpdateData = models; + template + using UpdateData_t = models_t; + } // end namespace Concepts /// @} diff --git a/src/amdis/common/Access.hpp b/src/amdis/common/Access.hpp index 202deada..a99de107 100644 --- a/src/amdis/common/Access.hpp +++ b/src/amdis/common/Access.hpp @@ -15,30 +15,30 @@ namespace AMDiS struct HasVectorAccess { template - auto requires_(V&& v, I&& i, Dune::PriorityTag<2>) -> decltype( v[i] ); + auto require(V&& v, I&& i, Dune::PriorityTag<2>) -> decltype( v[i] ); template - auto requires_(V&& v, I&& i, Dune::PriorityTag<1>) -> decltype( v(i) ); + auto require(V&& v, I&& i, Dune::PriorityTag<1>) -> decltype( v(i) ); }; struct HasMatrixAccess { template - auto requires_(M&& m, I&& i, J&& j, Dune::PriorityTag<2>) -> decltype( m[i][j] ); + auto require(M&& m, I&& i, J&& j, Dune::PriorityTag<2>) -> decltype( m[i][j] ); template - auto requires_(M&& m, I&& i, J&& j, Dune::PriorityTag<1>) -> decltype( m(i,j) ); + auto require(M&& m, I&& i, J&& j, Dune::PriorityTag<1>) -> decltype( m(i,j) ); }; } // end namespace Definition /// Vector component can be accessed either with [.] or (.) template - using VectorAccessible_t = bool_t)>>; + using VectorAccessible_t = models_t)>; /// Matrix component can be accessed either with [.][.] or (.,.) template - using MatrixAccessible_t = bool_t)>>; + using MatrixAccessible_t = models_t)>; } // end namespace Concepts diff --git a/src/amdis/common/Concepts.hpp b/src/amdis/common/Concepts.hpp index 3a43c784..41d2ee08 100644 --- a/src/amdis/common/Concepts.hpp +++ b/src/amdis/common/Concepts.hpp @@ -53,19 +53,9 @@ namespace AMDiS struct IsReferenceWrapper> : std::true_type {}; - - template - struct IsDefined - : std::false_type {}; - - template - struct IsDefined::value && - !std::is_pointer::value && - (sizeof(T) > 0)> > - : std::true_type {}; - } // end namespace Traits + namespace Concepts { #ifndef DOXYGEN @@ -75,33 +65,42 @@ namespace AMDiS struct Callable { template - auto requires_(F&& f, Args&&... args) -> decltype(f(FWD(args)...)); + auto require(F&& f, Args&&... args) -> decltype( + f(FWD(args)...) + ); }; // idx[0] struct MultiIndex { template - auto requires_(MI&& idx) -> decltype( - Concepts::valid_expr( - idx[0], - idx.size(), - idx.max_size() - /* ,idx.resize() */ - )); + auto require(MI&& idx) -> decltype( + idx[0], + idx.size(), + idx.max_size() + ); }; } // end namespace Definition #endif // DOXYGEN + /// Types are the same template constexpr bool Same = Traits::IsSame::value; + template + using Same_t = Traits::IsSame; + + /// Types are the same, up to decay of qualifiers template constexpr bool Similar = Traits::IsSimilar::value; + template + using Similar_t = Traits::IsSimilar; + + /// \brief A Collable is a function `F` that can be called with arguments of type `Args...`. /** * To be used as follows: `Concepts::Collable`. Returns true, if @@ -111,6 +110,9 @@ namespace AMDiS template constexpr bool Callable = models; + template + using Callable_t = models_t; + /// \brief A Functor is a function `F` with signature `Signature`. /** @@ -121,18 +123,26 @@ namespace AMDiS template // F, Signature=Return(Arg) constexpr bool Functor = Dune::Functions::Concept::isFunction(); + template // F, Signature=Return(Arg) + using Functor_t = bool_t>; + + /// A predicate is a function that returns a boolean. template constexpr bool Predicate = Functor; + template + using Predicate_t = Functor_t; + + + /// A multi-index type template constexpr bool MultiIndex = models; - template - constexpr bool Defined = Traits::IsDefined::value; + template + using MultiIndex_t = models_t; /** @} **/ } // end namespace Concepts - } // end namespace AMDiS diff --git a/src/amdis/common/ConceptsBase.hpp b/src/amdis/common/ConceptsBase.hpp index 67b1d6b4..1925ebe0 100644 --- a/src/amdis/common/ConceptsBase.hpp +++ b/src/amdis/common/ConceptsBase.hpp @@ -32,21 +32,10 @@ namespace AMDiS {}; template - struct models().requires_(std::declval()...)) >> + struct models().require(std::declval()...)) >> : std::true_type {}; - struct valid_expr - { - template - void operator()(Ts&&...) const; - -#if defined(__GNUC__) && !defined(__clang__) - template - void operator()(Ts const&...) const; -#endif - }; - } // end namespace Impl_ @@ -54,9 +43,9 @@ namespace AMDiS template constexpr bool models = Impl_::models::value; - constexpr Impl_::valid_expr valid_expr = {}; + template + using models_t = Impl_::models; #endif // DOXYGEN } // end namespace Concepts - } // end namespace AMDiS diff --git a/src/amdis/common/Resize.hpp b/src/amdis/common/Resize.hpp index a94b71c9..a894792c 100644 --- a/src/amdis/common/Resize.hpp +++ b/src/amdis/common/Resize.hpp @@ -14,32 +14,32 @@ namespace AMDiS struct VectorResizable { template - auto requires_(V const& vec, Dune::PriorityTag<2>) -> decltype( const_cast(vec).resize(0u), 0); + auto require(V const& vec, Dune::PriorityTag<2>) -> decltype( const_cast(vec).resize(0u), 0); template - auto requires_(V const& vec, Dune::PriorityTag<1>) -> decltype( const_cast(vec).change_dim(0u), 0); + auto require(V const& vec, Dune::PriorityTag<1>) -> decltype( const_cast(vec).change_dim(0u), 0); }; struct MatrixResizable { template - auto requires_(M const& mat, Dune::PriorityTag<3>) -> decltype( const_cast(mat).resize(0u,0u), 0); + auto require(M const& mat, Dune::PriorityTag<3>) -> decltype( const_cast(mat).resize(0u,0u), 0); template - auto requires_(M const& mat, Dune::PriorityTag<2>) -> decltype( const_cast(mat).change_dim(0u,0u), 0); + auto require(M const& mat, Dune::PriorityTag<2>) -> decltype( const_cast(mat).change_dim(0u,0u), 0); template - auto requires_(M const& mat, Dune::PriorityTag<1>) -> decltype( const_cast(mat).setSize(0u,0u), 0); + auto require(M const& mat, Dune::PriorityTag<1>) -> decltype( const_cast(mat).setSize(0u,0u), 0); }; } /// Checks whether a vector can be resized by various resize methods template - using VectorResizable_t = bool_t)> >; + using VectorResizable_t = models_t)>; /// Checks whether a matrix can be resized by various resize methods template - using MatrixResizable_t = bool_t)> >; + using MatrixResizable_t = models_t)>; } // end namespace Concepts diff --git a/src/amdis/gridfunctions/AnalyticGridFunction.hpp b/src/amdis/gridfunctions/AnalyticGridFunction.hpp index 4e683653..eac7c2ae 100644 --- a/src/amdis/gridfunctions/AnalyticGridFunction.hpp +++ b/src/amdis/gridfunctions/AnalyticGridFunction.hpp @@ -193,6 +193,9 @@ namespace AMDiS Definition::CallableDow; #endif + template + using CallableDomain_t = bool_t>; + } // end namespace Concepts diff --git a/src/amdis/gridfunctions/Derivative.hpp b/src/amdis/gridfunctions/Derivative.hpp index 6516cd6b..d1723100 100644 --- a/src/amdis/gridfunctions/Derivative.hpp +++ b/src/amdis/gridfunctions/Derivative.hpp @@ -28,19 +28,19 @@ namespace AMDiS struct HasDerivative { template - auto requires_(F&& f, T&& t) -> decltype( derivative(f,t) ); + auto require(F&& f, T&& t) -> decltype( derivative(f,t) ); }; struct HasLocalFunctionDerivative { template - auto requires_(F&& f, T&& t) -> decltype( derivative(localFunction(f),t) ); + auto require(F&& f, T&& t) -> decltype( derivative(localFunction(f),t) ); }; struct HasPartial { template - auto requires_(F&& f, I&& i) -> decltype( partial(f, i) ); + auto require(F&& f, I&& i) -> decltype( partial(f, i) ); }; } // end namespace Definition @@ -50,14 +50,25 @@ namespace AMDiS template constexpr bool HasDerivative = models; + template + using HasDerivative_t = models_t; + + /// \brief GridFunction GF has free function `derivative(localFunction(F))` template constexpr bool HasLocalFunctionDerivative = models; + template + using HasLocalFunctionDerivative_t = models_t; + + /// \brief Functor F has free function `partial(F,_0)` template constexpr bool HasPartial = models)>; + template + using HasPartial_t = models_t)>; + /** @} **/ } // end namespace Concepts diff --git a/src/amdis/gridfunctions/FunctorGridFunction.hpp b/src/amdis/gridfunctions/FunctorGridFunction.hpp index 3c6fe3c4..2b7746d2 100644 --- a/src/amdis/gridfunctions/FunctorGridFunction.hpp +++ b/src/amdis/gridfunctions/FunctorGridFunction.hpp @@ -20,16 +20,12 @@ namespace AMDiS struct DomainType { using type = typename T0::Domain; - // static_assert( all_of_v< std::is_same::type>::value... >, - // "All GridFunctions must have the same Domain." ); }; template struct EntitySetType { using type = typename T0::EntitySet; - // static_assert( all_of_v< std::is_same::type>::value... >, - // "All GridFunctions must have the same EntitySet." ); }; } // end namespace Impl diff --git a/src/amdis/gridfunctions/GridFunction.hpp b/src/amdis/gridfunctions/GridFunction.hpp index 434ec4c6..6e643795 100644 --- a/src/amdis/gridfunctions/GridFunction.hpp +++ b/src/amdis/gridfunctions/GridFunction.hpp @@ -38,16 +38,19 @@ namespace AMDiS struct HasLocalFunction { template - auto requires_(F&& f) -> decltype( localFunction(f) ); + auto require(F&& f) -> decltype( + localFunction(f) + ); }; struct HasGridFunctionTypes { template - auto requires_(GF const& /*gf*/) -> void_t< + auto require(GF const& /*gf*/) -> void_t< typename GF::Range, typename GF::Domain, - typename GF::EntitySet >; + typename GF::EntitySet + >; }; } // end namespace Definition @@ -57,12 +60,20 @@ namespace AMDiS template constexpr bool HasLocalFunction = models; + template + using HasLocalFunction_t = models_t; + + /// \brief GridFunction GF is a Type that has LocalFunction and provides some /// typedefs for `Domain`, `Range`, and `EntitySet`. template constexpr bool GridFunction = HasLocalFunction && models; + template + using GridFunction_t = bool_t>; + + /// \brief Concept is fulfilled, if at least one of the massed Expressions /// can be converted to a GridFunction, or is already a GridFunction. template @@ -70,6 +81,9 @@ namespace AMDiS any_of_v>...> || any_of_v>::value...>; + template + using AnyGridFunction_t = bool_t>; + /** @} **/ } // end namespace Concepts @@ -137,7 +151,7 @@ namespace AMDiS template decltype(auto) makeGridFunction(PreGridFct const& preGridFct, GridView const& gridView) { - using isGridFct = bool_t>; + using isGridFct = Concepts::GridFunction_t; return Impl::makeGridFunctionImpl(preGridFct, gridView, isGridFct{}); } diff --git a/src/amdis/gridfunctions/Order.hpp b/src/amdis/gridfunctions/Order.hpp index ff2cef28..8a2ffeb4 100644 --- a/src/amdis/gridfunctions/Order.hpp +++ b/src/amdis/gridfunctions/Order.hpp @@ -24,13 +24,17 @@ namespace AMDiS struct HasLocalFunctionOrder { template - auto requires_(F&& f) -> decltype( order(localFunction(f)) ); + auto require(F&& f) -> decltype( + order(localFunction(f)) + ); }; struct HasOrder { template - auto requires_(F&& f) -> decltype( order(f) ); + auto require(F&& f) -> decltype( + order(f) + ); }; } // end namespace Definition @@ -40,10 +44,17 @@ namespace AMDiS template constexpr bool HasLocalFunctionOrder = models; + template + using HasLocalFunctionOrder_t = models_t; + + /// \brief LocalFuncion LF has free function `order(F)` template constexpr bool HasOrder = models; + template + using HasOrder_t = models_t; + /** @} **/ } // end namespace Concepts diff --git a/src/amdis/operations/Basic.hpp b/src/amdis/operations/Basic.hpp index 18670dde..36f29607 100644 --- a/src/amdis/operations/Basic.hpp +++ b/src/amdis/operations/Basic.hpp @@ -15,12 +15,15 @@ namespace AMDiS struct HasFunctorOrder { template - auto requires_(F&& f, std::integer_sequence) -> decltype( order(f, I...) ); + auto require(F&& f, std::integer_sequence) -> decltype( order(f, I...) ); }; } template constexpr bool HasFunctorOrder = models)>; + + template + using HasFunctorOrder_t = bool_t>; } namespace Operation diff --git a/src/amdis/typetree/TreePath.hpp b/src/amdis/typetree/TreePath.hpp index 6a1b695d..a136ce0b 100644 --- a/src/amdis/typetree/TreePath.hpp +++ b/src/amdis/typetree/TreePath.hpp @@ -8,6 +8,8 @@ #include #include +#include + namespace AMDiS { struct RootTreePath {}; @@ -55,6 +57,9 @@ namespace AMDiS template constexpr bool PreTreePath = Dune::TypeTree::IsTreePath::value || Definition::IsPreTreePath::value; + template + using PreTreePath_t = bool_t>; + /** @} **/ } // end namespace Concepts -- GitLab