diff --git a/src/amdis/AdaptInfo.hpp b/src/amdis/AdaptInfo.hpp index 3e12a88666788916f82f1b5d15c727f5fdf5fe40..9107d556b2b024a1aadc1124510e0974ada15ca7 100644 --- a/src/amdis/AdaptInfo.hpp +++ b/src/amdis/AdaptInfo.hpp @@ -11,7 +11,9 @@ // AMDiS includes #include <amdis/Output.hpp> +#include <amdis/common/ConceptsBase.hpp> #include <amdis/common/Math.hpp> +#include <amdis/utility/TreePath.hpp> namespace AMDiS { @@ -101,6 +103,12 @@ namespace AMDiS return true; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + bool spaceToleranceReached(TP& tp) const + { + return spaceToleranceReached(to_string(tp)); + } + /// Returns whether time tolerance is reached. virtual bool timeToleranceReached() const { @@ -120,6 +128,12 @@ namespace AMDiS return true; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + bool timeToleranceReached(TP& tp) const + { + return timeToleranceReached(to_string(tp)); + } + /// Returns whether time error is under its lower bound. virtual bool timeErrorLow() const { @@ -129,6 +143,7 @@ namespace AMDiS return true; } + /// Returns the time estimation as a combination /// of maximal and integral time error double getTimeEstCombined(std::string key) const @@ -138,6 +153,11 @@ namespace AMDiS scalContents.at(key)->est_t_sum * scalContents.at(key)->fac_sum; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getTimeEstCombined(TP& tp) const + { + return getTimeEstCombined(to_string(tp)); + } /// Print debug information about time error and its bound. void printTimeErrorLowInfo() const; @@ -268,24 +288,48 @@ namespace AMDiS scalContents.at(key)->est_sum = e; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void setEstSum(double e, TP& tp) + { + setEstSum(e, to_string(tp)); + } + /// Sets \ref est_max. void setEstMax(double e, std::string key) { scalContents.at(key)->est_max = e; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void setEstMax(double e, TP& tp) + { + setEstMax(e, to_string(tp)); + } + /// Sets \ref est_max. void setTimeEstMax(double e, std::string key) { scalContents.at(key)->est_t_max = e; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void setTimeEstMax(double e, TP& tp) + { + setTimeEstMax(e, to_string(tp)); + } + /// Sets \ref est_t_sum. void setTimeEstSum(double e, std::string key) { scalContents.at(key)->est_t_sum = e; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void setTimeEstSum(double e, TP& tp) + { + setTimeEstSum(e, to_string(tp)); + } + /// Returns \ref est_sum. double getEstSum(std::string key) const { @@ -295,12 +339,24 @@ namespace AMDiS return scalContents.at(key)->est_sum; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getEstSum(TP& tp) + { + return getEstSum(to_string(tp)); + } + /// Returns \ref est_t_sum. double getEstTSum(std::string key) const { return scalContents.at(key)->est_t_sum; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getEstTSum(TP& tp) + { + return getEstTSum(to_string(tp)); + } + /// Returns \ref est_max. double getEstMax(std::string key) const { @@ -310,18 +366,36 @@ namespace AMDiS return scalContents.at(key)->est_max; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getEstMax(TP& tp) + { + return getEstMax(to_string(tp)); + } + /// Returns \ref est_max. double getTimeEstMax(std::string key) const { return scalContents.at(key)->est_t_max; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getTimeEstmax(TP& tp) + { + return getTimeEstMax(to_string(tp)); + } + /// Returns \ref est_t_sum. double getTimeEstSum(std::string key) const { return scalContents.at(key)->est_t_sum; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getTimeEstSum(TP& tp) + { + return getTimeEstSum(to_string(tp)); + } + /// Returns \ref est_t the estimated overall time error double getTimeEst() const { @@ -339,24 +413,48 @@ namespace AMDiS return scalContents.at(key)->spaceTolerance; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getSpaceTolerance(TP& tp) + { + return getSpaceTolerance(to_string(tp)); + } + /// Sets \ref spaceTolerance. void setSpaceTolerance(std::string key, double tol) { scalContents.at(key)->spaceTolerance = tol; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void setSpaceTolerance(TP& tp, double tol) + { + return setSpaceTolerance(to_string(tp), tol); + } + /// Returns \ref timeTolerance. double getTimeTolerance(std::string key) const { return scalContents.at(key)->timeTolerance; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getTimeTolerance(TP& tp) + { + return getTimeTolerance(to_string(tp)); + } + /// Returns \ref timeRelativeTolerance. double getTimeRelativeTolerance(std::string key) const { return scalContents.at(key)->timeRelativeTolerance; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getTimeRelativeTolerance(TP& tp) + { + return getTimeRelativeTolerance(to_string(tp)); + } + /// Sets \ref time double setTime(double t) { @@ -481,30 +579,60 @@ namespace AMDiS return scalContents.at(key)->timeErrLow; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + double getTimeErrLow(TP& tp) + { + return getTimeErrLow(to_string(tp)); + } + /// Returns whether coarsening is allowed or not. bool isCoarseningAllowed(std::string key) const { return (scalContents.at(key)->coarsenAllowed == 1); } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + bool isCoarseningAllowed(TP& tp) + { + return isCoarseningAllowed(to_string(tp)); + } + /// Returns whether coarsening is allowed or not. bool isRefinementAllowed(std::string key) const { return (scalContents.at(key)->refinementAllowed == 1); } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + bool isRefinementAllowed(TP& tp) + { + return isRefinementAllowed(to_string(tp)); + } + /// void allowRefinement(bool allow, std::string key) { scalContents.at(key)->refinementAllowed = allow; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void allowRefinement(bool allow, TP& tp) + { + return allowRefinement(allow, to_string(tp)); + } + /// void allowCoarsening(bool allow, std::string key) { scalContents.at(key)->coarsenAllowed = allow; } + template <class TP, REQUIRES( Concepts::PreTreePath<TP> )> + void allowCoarsening(bool allow, TP& tp) + { + return allowCoarsening(allow, to_string(tp)); + } + int getSize() const { return int(scalContents.size()); diff --git a/src/amdis/utility/TreePath.hpp b/src/amdis/utility/TreePath.hpp index d8e8dcd593d8d673ba0a97ba686aaab6552c31d7..24fadd2189f7789dbcfad7d68fb9ec0ee96efd1f 100644 --- a/src/amdis/utility/TreePath.hpp +++ b/src/amdis/utility/TreePath.hpp @@ -2,11 +2,14 @@ #include <sstream> #include <string> +#include <type_traits> #include <dune/common/std/apply.hh> #include <dune/typetree/treepath.hh> #include <dune/typetree/typetraits.hh> +#include <amdis/common/Mpl.hpp> + namespace AMDiS { @@ -79,9 +82,9 @@ namespace AMDiS #else // DOXYGEN - auto makeTreePath(int i) { return Dune::TypeTree::hybridTreePath(std::size_t(i)); } - auto makeTreePath(std::size_t i) { return Dune::TypeTree::hybridTreePath(i); } - auto makeTreePath(RootTreePath) { return Dune::TypeTree::hybridTreePath(); } + inline auto makeTreePath(int i) { return Dune::TypeTree::hybridTreePath(std::size_t(i)); } + inline auto makeTreePath(std::size_t i) { return Dune::TypeTree::hybridTreePath(i); } + inline auto makeTreePath(RootTreePath) { return Dune::TypeTree::hybridTreePath(); } template <int I> @@ -140,7 +143,7 @@ namespace AMDiS return ss.str(); } - std::string to_string(Dune::TypeTree::HybridTreePath<> const& tp) + inline std::string to_string(Dune::TypeTree::HybridTreePath<> const& tp) { return ""; }