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

discretefunction with child function

parent bab05940
No related branches found
No related tags found
No related merge requests found
......@@ -151,6 +151,13 @@ namespace AMDiS
return *dofVector_;
}
template <class TreePath = RootTreePath>
auto child(TreePath const& path = {}) const
{
auto&& tp = makeTreePath(path);
return makeDiscreteFunction(*dofVector_, cat(this->treePath_,tp));
}
protected:
DOFVector<GB,VT> const* dofVector_;
TreePath treePath_;
......@@ -234,6 +241,15 @@ namespace AMDiS
/// Return the const DOFVector
using Super::coefficients;
template <class TreePath = RootTreePath>
auto child(TreePath const& path = {})
{
auto&& tp = makeTreePath(path);
return makeDiscreteFunction(*mutableDofVector_, cat(this->treePath_,tp));
}
using Super::child;
protected:
DOFVector<GB,VT>* mutableDofVector_;
};
......
......@@ -28,14 +28,14 @@ public:
LocalFunction(DiscreteFunction const& globalFunction)
: globalFunction_(globalFunction)
, localView_(globalFunction_.basis()->localView())
, subTree_(&child(localView_.tree(), globalFunction_.treePath()))
, subTree_(&Dune::TypeTree::child(localView_.tree(), globalFunction_.treePath()))
{}
/// Copy constructor.
LocalFunction(LocalFunction const& other)
: globalFunction_(other.globalFunction_)
, localView_(globalFunction_.basis()->localView())
, subTree_(&child(localView_.tree(), globalFunction_.treePath()))
, subTree_(&Dune::TypeTree::child(localView_.tree(), globalFunction_.treePath()))
{}
/// \brief Bind the LocalView to the element
......@@ -157,7 +157,7 @@ public:
: globalFunction_(globalFunction)
, type_(type)
, localView_(globalFunction_.basis()->localView())
, subTree_(&child(localView_.tree(), globalFunction_.treePath()))
, subTree_(&Dune::TypeTree::child(localView_.tree(), globalFunction_.treePath()))
{}
/// Copy constructor.
......@@ -165,7 +165,7 @@ public:
: globalFunction_(other.globalFunction_)
, type_(other.type_)
, localView_(globalFunction_.basis()->localView())
, subTree_(&child(localView_.tree(), globalFunction_.treePath()))
, subTree_(&Dune::TypeTree::child(localView_.tree(), globalFunction_.treePath()))
{}
void bind(Element const& element)
......
......@@ -22,10 +22,11 @@ namespace AMDiS
using GridView = typename GB::GridView;
using Writer = Dune::VtkWriter<GridView>;
using SeqWriter = Dune::PvdWriter<Writer>;
using Function = DiscreteFunction<GB,VT,TP,true>;
public:
/// Constructor.
DuneVtkWriter(std::string const& name, DiscreteFunction<GB,VT,TP> const& discreteFct)
DuneVtkWriter(std::string const& name, Function const& discreteFct)
: FileWriterBase(name)
, discreteFct_(discreteFct)
{
......@@ -75,7 +76,7 @@ namespace AMDiS
}
private:
DiscreteFunction<GB,VT,TP> discreteFct_;
Function discreteFct_;
std::shared_ptr<Writer> vtkWriter_;
std::shared_ptr<SeqWriter> vtkSeqWriter_;
......
......@@ -69,6 +69,13 @@ int main(int argc, char** argv)
auto u1_c = makeDiscreteFunction(U_c);
auto u1_m = makeDiscreteFunction(U_m);
// sub-range view on DiscreteFunction
auto su1_c = u1_c.child();
auto su1_c0 = u1_c.child(0);
auto su1_m = u1_m.child();
auto su1_m0 = u1_m.child(0);
using Range = typename decltype(u0)::Range;
auto expr1 = [](auto const& x) {
......
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