Commit 81bcc9de authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/discretefunction_child' into 'master'

discretefunction with child function

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