Skip to content
Snippets Groups Projects
Commit 71d185e6 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/hierarchic_node_to_range_map' into 'master'

Move transformTreePath helper function to HierarchicNodeToRangeMap

See merge request !101
parents e0d8ecb9 95ed026e
No related branches found
No related tags found
1 merge request!101Move transformTreePath helper function to HierarchicNodeToRangeMap
......@@ -15,7 +15,7 @@ namespace AMDiS
/**
* \brief A simple node to range map using the nested tree indices
*
* This map directly usses the tree path entries of the given
* This map directly uses the tree path entries of the given
* node to access the nested container.
*
* If the container does not provide any operator[] access,
......@@ -23,19 +23,38 @@ namespace AMDiS
*/
struct HierarchicNodeToRangeMap
{
// Specialization for ranges with operator[] access
template <class Node, class TreePath, class Range,
REQUIRES(Dune::models<Dune::Functions::Concept::HasIndexAccess, Range, Dune::index_constant<0>>())>
decltype(auto) operator()(const Node& node, const TreePath& treePath, Range&& y) const
{
return Dune::Functions::resolveStaticMultiIndex(y, treePath);
return Dune::Functions::resolveStaticMultiIndex(y, transformTreePath(treePath));
}
// Specialization for non-container ranges
template <class Node, class TreePath, class Range,
REQUIRES(not Dune::models<Dune::Functions::Concept::HasIndexAccess, Range, Dune::index_constant<0>>())>
decltype(auto) operator()(const Node& node, const TreePath& treePath, Range&& y) const
{
return std::forward<Range>(y);
}
private:
#if DUNE_VERSION_GT(DUNE_FUNCTIONS,2,6)
template <class TreePath>
static TreePath const& transformTreePath(TreePath const& treePath)
{
return treePath;
}
#else
// NOTE: due to a bug in dune-functions <= 2.6, a hybrid-treepath can not be passed to a HierarchicNodeToRangeMap,
// i.e. the HybridTreePath missed a size() function
template <class TreePath>
static auto transformTreePath(TreePath const& treePath)
{
return Tools::apply([](auto... i) { return Dune::makeTupleVector(i...); }, treePath._data);
}
#endif
};
} // end namespace AMDiS
......@@ -85,7 +85,7 @@ namespace Impl {
{
const auto& tmp = localF_(x);
const auto& tmp_vec = Dune::MatVec::as_vector(tmp);
y = Dune::Functions::flatVectorView(nodeToRangeEntry_(node_, transformTreePath(treePath_), tmp_vec))[comp_];
y = Dune::Functions::flatVectorView(nodeToRangeEntry_(node_, treePath_, tmp_vec))[comp_];
}
void setComponent(std::size_t comp)
......@@ -93,20 +93,6 @@ namespace Impl {
comp_ = comp;
}
#if DUNE_VERSION_GT(DUNE_FUNCTIONS,2,6)
static TreePath const& transformTreePath(TreePath const& treePath)
{
return treePath;
}
#else
// NOTE: due to a bug in dune-functions <= 2.6, a hybrid-treepath can not be passed to a HierarchicNodeToRangeMap,
// i.e. the HybridTreePath missed a size() function
static auto transformTreePath(TreePath const& treePath)
{
return Tools::apply([](auto... i) { return Dune::makeTupleVector(i...); }, treePath._data);
}
#endif
private:
Node const& node_;
TreePath const& treePath_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment