Commit bc96d1dc by Praetorius, Simon

### Cleanup DiscreteFunctions

parent b749d3f8
 ... @@ -11,6 +11,11 @@ namespace AMDiS ... @@ -11,6 +11,11 @@ namespace AMDiS struct matrix {}; struct matrix {}; struct unknown {}; struct unknown {}; // tags representing interpolation strategies struct average {}; struct assign {}; struct defaulted {}; } // end namespace tag } // end namespace tag } // end namespace AMDiS } // end namespace AMDiS
 ... @@ -12,6 +12,7 @@ ... @@ -12,6 +12,7 @@ #include #include #include #include #include #include #include #include #include #include #include #include #include ... @@ -22,14 +23,6 @@ ... @@ -22,14 +23,6 @@ namespace AMDiS namespace AMDiS { { namespace tag { struct average {}; struct assign {}; struct defaulted {}; } // end namespace tag namespace Impl namespace Impl { { template template ... ...
 ... @@ -9,7 +9,7 @@ ... @@ -9,7 +9,7 @@ #include #include #include #include #include #include #include #include #include #include #include #include ... @@ -32,18 +32,17 @@ namespace AMDiS ... @@ -32,18 +32,17 @@ namespace AMDiS class DiscreteFunction; class DiscreteFunction; #if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION #if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION template > template DiscreteFunction(Coeff&, GB const&, TreePath = {}) DiscreteFunction(Coeff&, GB const&, TreePath = {}) -> DiscreteFunction; -> DiscreteFunction>; #endif #endif /// A Generator for a mutable \ref DiscreteFunction /// A Generator for a mutable \ref DiscreteFunction template ().localView())> > class = void_t().localView())> > auto makeDiscreteFunction(Coeff& coefficients, GB const& basis, Path const& path) auto makeDiscreteFunction(Coeff& coefficients, GB const& basis, Path const& path = {}) { { auto treePath = makeTreePath(path); return DiscreteFunction>{coefficients, basis, path}; return DiscreteFunction{coefficients, basis, treePath}; } } ... @@ -61,8 +60,9 @@ namespace AMDiS ... @@ -61,8 +60,9 @@ namespace AMDiS public: public: /// Constructor. Stores a pointer to the mutable dofvector. /// Constructor. Stores a pointer to the mutable dofvector. DiscreteFunction(Coefficients& dofVector, GlobalBasis const& basis, TreePath const& treePath = {}) template : Super(dofVector, basis, treePath) DiscreteFunction(Coefficients& dofVector, GlobalBasis const& basis, Path const& path = {}) : Super(dofVector, basis, path) , mutableCoeff_(&dofVector) , mutableCoeff_(&dofVector) {} {} ... @@ -117,7 +117,10 @@ namespace AMDiS ... @@ -117,7 +117,10 @@ namespace AMDiS } } /// Return the mutable DOFVector /// Return the mutable DOFVector Coefficients& coefficients() { return *mutableCoeff_; } Coefficients& coefficients() { return *mutableCoeff_; } /// Return the const DOFVector /// Return the const DOFVector using Super::coefficients; using Super::coefficients; ... @@ -125,8 +128,8 @@ namespace AMDiS ... @@ -125,8 +128,8 @@ namespace AMDiS template template auto child(Path const& path = {}) auto child(Path const& path = {}) { { auto&& tp = makeTreePath(path); auto tp = cat(this->treePath_, makeTreePath(path)); return makeDiscreteFunction(*mutableCoeff_, this->basis(), cat(this->treePath_,tp)); return makeDiscreteFunction(*mutableCoeff_, this->basis(), tp); } } using Super::child; using Super::child; ... @@ -142,7 +145,7 @@ namespace AMDiS ... @@ -142,7 +145,7 @@ namespace AMDiS private: private: using Coefficients = std::remove_const_t; using Coefficients = std::remove_const_t; using GlobalBasis = GB; using GlobalBasis = GB; using ValueType = typename Coeff::value_type; using ValueType = typename Coefficients::value_type; using Tree = typename GlobalBasis::LocalView::Tree; using Tree = typename GlobalBasis::LocalView::Tree; using SubTree = typename Dune::TypeTree::ChildForTreePath; using SubTree = typename Dune::TypeTree::ChildForTreePath; ... @@ -177,12 +180,13 @@ namespace AMDiS ... @@ -177,12 +180,13 @@ namespace AMDiS public: public: /// Constructor. Stores a pointer to the dofVector and a copy of the treePath. /// Constructor. Stores a pointer to the dofVector and a copy of the treePath. DiscreteFunction(Coefficients const& coefficients, GlobalBasis const& basis, TreePath const& treePath = {}) template DiscreteFunction(Coefficients const& coefficients, GlobalBasis const& basis, Path const& path = {}) : coefficients_(&coefficients) : coefficients_(&coefficients) , basis_(&basis) , basis_(&basis) , treePath_(treePath) , treePath_(makeTreePath(path)) , entitySet_(basis_->gridView()) , entitySet_(basis_->gridView()) , nodeToRangeEntry_(Dune::Functions::makeDefaultNodeToRangeMap(*basis_, treePath)) , nodeToRangeEntry_(Dune::Functions::makeDefaultNodeToRangeMap(*basis_, treePath_)) {} {} /// \brief Evaluate DiscreteFunction in global coordinates. NOTE: expensive /// \brief Evaluate DiscreteFunction in global coordinates. NOTE: expensive ... @@ -221,8 +225,8 @@ namespace AMDiS ... @@ -221,8 +225,8 @@ namespace AMDiS template template auto child(Path const& path = {}) const auto child(Path const& path = {}) const { { auto&& tp = makeTreePath(path); auto tp = cat(this->treePath_, makeTreePath(path)); return makeDiscreteFunction(*coefficients_, *basis_, cat(this->treePath_,tp)); return makeDiscreteFunction(*coefficients_, *basis_, tp); } } protected: protected: ... ...
 ... @@ -6,6 +6,7 @@ ... @@ -6,6 +6,7 @@ #include #include #include #include #include namespace AMDiS { namespace AMDiS { ... ...
 #pragma once #pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace AMDiS { namespace AMDiS { namespace Impl { // specialization of Coeff has gather method template ().gather(std::declval(), std::declval()))> void gather(Coeff const& coeff, LocalView const& localView, LocalCoeff& localCoeff, Dune::PriorityTag<2>) { coeff.gather(localView, localCoeff); } // fallback implementation template void gather(Coeff const& coeff, LocalView const& localView, LocalCoeff& localCoeff, Dune::PriorityTag<1>) { localCoeff.resize(localView.size()); auto it = localCoeff.begin(); for (auto const& idx : nodeIndices(localView)) *it++ = coeff[idx]; } } // end namespace Impl template template class DiscreteFunction::LocalFunction class DiscreteFunction::LocalFunction ... @@ -42,8 +66,7 @@ public: ... @@ -42,8 +66,7 @@ public: void bind(Element const& element) void bind(Element const& element) { { localView_.bind(element); localView_.bind(element); Impl::gather(globalFunction_.coefficients(), localView_, localCoefficients_, Dune::PriorityTag<4>{}); globalFunction_.coefficients().gather(localView_, localCoefficients_); bound_ = true; bound_ = true; } } ... @@ -173,7 +196,7 @@ public: ... @@ -173,7 +196,7 @@ public: localView_.bind(element); localView_.bind(element); geometry_.emplace(element.geometry()); geometry_.emplace(element.geometry()); globalFunction_.coefficients().gather(localView_, localCoefficients_); Impl::gather(globalFunction_.coefficients(), localView_, localCoefficients_, Dune::PriorityTag<4>{}); bound_ = true; bound_ = true; } } ... ...
 ... @@ -139,6 +139,10 @@ namespace AMDiS ... @@ -139,6 +139,10 @@ namespace AMDiS return Dune::TypeTree::hybridTreePath(); return Dune::TypeTree::hybridTreePath(); } } /// Type of the generated treepath template using TreePath_t = TYPEOF(makeTreePath(std::declval())); #endif // DOXYGEN #endif // DOXYGEN ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!