Commit 9277c585 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Fix definition of NodeCache in DiscreteFunction

parent d8ec05df
......@@ -53,6 +53,11 @@ namespace AMDiS
, mutableCoeff_(&dofVector)
{}
template <class... Path>
DiscreteFunction(Coefficients& dofVector, std::shared_ptr<GlobalBasis const> const& basis, Path... path)
: DiscreteFunction(dofVector, *basis, path...)
{}
/// Construct a DiscreteFunction directly from a DOFVector
template <class DV, class... Path,
class Coeff_ = TYPEOF(std::declval<DV>().coefficients()),
......@@ -146,7 +151,7 @@ namespace AMDiS
using Tree = typename GlobalBasis::LocalView::Tree;
using SubTree = typename Dune::TypeTree::ChildForTreePath<Tree, TreePath>;
using TreeCache = typename GlobalBasis::LocalView::TreeCache;
using TreeCache = NodeCache_t<Tree>;
using SubTreeCache = typename Dune::TypeTree::ChildForTreePath<TreeCache, TreePath>;
using NodeToRangeEntry = Dune::Functions::DefaultNodeToRangeMap<SubTree>;
......@@ -188,12 +193,17 @@ namespace AMDiS
, nodeToRangeEntry_(Dune::Functions::makeDefaultNodeToRangeMap(*basis_, treePath_))
{}
template <class... Path>
DiscreteFunction(Coefficients const& coefficients, std::shared_ptr<GlobalBasis const> const& basisPtr, Path... path)
: DiscreteFunction(coefficients, *basisPtr, path...)
{}
/// Construct a DiscreteFunction directly from a DOFVector
template <class DV, class... Path,
class Coeff_ = TYPEOF(std::declval<DV>().coefficients()),
class GB_ = TYPEOF(*std::declval<DV>().basis())>
class GB_ = TYPEOF(std::declval<DV>().basis())>
DiscreteFunction(DV const& dofVector, Path... path)
: DiscreteFunction(dofVector.coefficients(), *dofVector.basis(), path...)
: DiscreteFunction(dofVector.coefficients(), dofVector.basis(), path...)
{}
......@@ -247,18 +257,19 @@ namespace AMDiS
// deduction guides
template <class Coeff, class GB, class... Path,
template <class Coeff, class Basis, class... Path,
class TP = TYPEOF(makeTreePath(std::declval<Path>()...)),
class GB = Underlying_t<Basis>,
REQUIRES(Concepts::GlobalBasis<GB>)>
DiscreteFunction(Coeff&, GB const&, Path...)
DiscreteFunction(Coeff&, Basis const&, Path...)
-> DiscreteFunction<Coeff,GB,TP>;
template <class DV, class... Path,
class Coeff = decltype(std::declval<DV>().coefficients()),
class GB = decltype(*std::declval<DV>().basis()),
class GB = decltype(std::declval<DV>().basis()),
class TP = TYPEOF(makeTreePath(std::declval<Path>()...))>
DiscreteFunction(DV&, Path...)
-> DiscreteFunction<std::remove_reference_t<Coeff>,std::decay_t<GB>,TP>;
-> DiscreteFunction<std::remove_reference_t<Coeff>,Underlying_t<GB>,TP>;
// grid functions representing the DOFVector
......@@ -284,7 +295,7 @@ namespace AMDiS
class = decltype(std::declval<DV>().basis())>
auto valueOf(DV& dofVec, Indices... ii)
{
return DiscreteFunction{dofVec.coefficients(), *dofVec.basis(), makeTreePath(ii...)};
return DiscreteFunction{dofVec.coefficients(), dofVec.basis(), makeTreePath(ii...)};
}
} // end namespace AMDiS
......
......@@ -54,14 +54,16 @@ public:
LocalFunction(DiscreteFunction const& globalFunction)
: globalFunction_(globalFunction)
, localView_(globalFunction_.basis().localView())
, subTreeCache_(&Dune::TypeTree::child(localView_.treeCache(), globalFunction_.treePath()))
, treeCache_(makeNodeCache(localView_.tree()))
, subTreeCache_(&Dune::TypeTree::child(treeCache_, globalFunction_.treePath()))
{}
/// Copy constructor.
LocalFunction(LocalFunction const& other)
: globalFunction_(other.globalFunction_)
, localView_(globalFunction_.basis().localView())
, subTreeCache_(&Dune::TypeTree::child(localView_.treeCache(), globalFunction_.treePath()))
, treeCache_(makeNodeCache(localView_.tree()))
, subTreeCache_(&Dune::TypeTree::child(treeCache_, globalFunction_.treePath()))
{}
/// \brief Bind the LocalView to the element
......@@ -149,6 +151,7 @@ public:
private:
DiscreteFunction globalFunction_;
LocalView localView_;
TreeCache treeCache_;
SubTreeCache const* subTreeCache_;
std::vector<ValueType> localCoefficients_;
......@@ -182,7 +185,8 @@ public:
: globalFunction_(globalFunction)
, type_(type)
, localView_(globalFunction_.basis().localView())
, subTreeCache_(&Dune::TypeTree::child(localView_.treeCache(), globalFunction_.treePath()))
, treeCache_(makeNodeCache(localView_.tree()))
, subTreeCache_(&Dune::TypeTree::child(treeCache_, globalFunction_.treePath()))
{}
/// Copy constructor.
......@@ -190,7 +194,8 @@ public:
: globalFunction_(other.globalFunction_)
, type_(other.type_)
, localView_(globalFunction_.basis().localView())
, subTreeCache_(&Dune::TypeTree::child(localView_.treeCache(), globalFunction_.treePath()))
, treeCache_(makeNodeCache(localView_.tree()))
, subTreeCache_(&Dune::TypeTree::child(treeCache_, globalFunction_.treePath()))
{}
void bind(Element const& element)
......@@ -238,6 +243,7 @@ protected:
DiscreteFunction globalFunction_;
Type type_;
LocalView localView_;
TreeCache treeCache_;
SubTreeCache const* subTreeCache_;
std::optional<Geometry> geometry_;
std::vector<ValueType> localCoefficients_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment