diff --git a/amdis/DOFVector.hpp b/amdis/DOFVector.hpp index db0934887005c111e3268737190f1a7a8df9c228..ebd5e2c75bd833e35b4ed91f30190725b83188e8 100644 --- a/amdis/DOFVector.hpp +++ b/amdis/DOFVector.hpp @@ -38,11 +38,14 @@ namespace AMDiS , private Observer { using Self = DOFVector; - using Coefficients = VectorFacade; public: + /// A global basis associated to the coefficients using GlobalBasis = GB; + /// The internal coefficient vector storage + using Coefficients = VectorFacade; + /// The index/size - type using size_type = typename GlobalBasis::size_type; diff --git a/amdis/gridfunctions/DiscreteFunction.hpp b/amdis/gridfunctions/DiscreteFunction.hpp index ada77d7c6091cabd588d237e67f09682c597466a..08581abc332b034420f26cdc6dc8c5a9b4c6a922 100644 --- a/amdis/gridfunctions/DiscreteFunction.hpp +++ b/amdis/gridfunctions/DiscreteFunction.hpp @@ -52,12 +52,20 @@ namespace AMDiS public: /// Constructor. Stores a pointer to the mutable `dofvector`. - template - DiscreteFunction(Coefficients& dofVector, GlobalBasis const& basis, Path const& path) - : Super(dofVector, basis, path) + template + DiscreteFunction(Coefficients& dofVector, GlobalBasis const& basis, Path... path) + : Super(dofVector, basis, path...) , mutableCoeff_(&dofVector) {} + /// Construct a DiscreteFunction directly from a DOFVector + template ().coefficients()), + class GB_ = TYPEOF(*std::declval().basis())> + DiscreteFunction(DV&& dofVector, Path... path) + : DiscreteFunction(dofVector.coefficients(), *dofVector.basis(), path...) + {} + public: /// \brief Interpolation of GridFunction to DOFVector, assuming that there is no /// reference to this DOFVector in the expression. @@ -172,15 +180,24 @@ namespace AMDiS public: /// Constructor. Stores a pointer to the dofVector and a copy of the treePath. - template - DiscreteFunction(Coefficients const& coefficients, GlobalBasis const& basis, Path const& path) + template + DiscreteFunction(Coefficients const& coefficients, GlobalBasis const& basis, Path... path) : coefficients_(&coefficients) , basis_(&basis) - , treePath_(makeTreePath(path)) + , treePath_(makeTreePath(path...)) , entitySet_(basis_->gridView()) , nodeToRangeEntry_(Dune::Functions::makeDefaultNodeToRangeMap(*basis_, treePath_)) {} + /// Construct a DiscreteFunction directly from a DOFVector + template ().coefficients()), + class GB_ = TYPEOF(*std::declval().basis())> + DiscreteFunction(DV const& dofVector, Path... path) + : DiscreteFunction(dofVector.coefficients(), *dofVector.basis(), path...) + {} + + /// \brief Evaluate DiscreteFunction in global coordinates. NOTE: expensive Range operator()(Domain const& x) const; @@ -229,6 +246,21 @@ namespace AMDiS NodeToRangeEntry nodeToRangeEntry_; }; + // deduction guides + + template ()...)), + REQUIRES(Concepts::GlobalBasis)> + DiscreteFunction(Coeff&, GB const&, Path...) + -> DiscreteFunction; + + template ().coefficients()), + class GB = decltype(*std::declval().basis()), + class TP = TYPEOF(makeTreePath(std::declval()...))> + DiscreteFunction(DV&, Path...) + -> DiscreteFunction,std::decay_t,TP>; + } // end namespace AMDiS #include "DiscreteLocalFunction.inc.hpp"