diff --git a/examples/navier_stokes.cc b/examples/navier_stokes.cc index b12b46c03f6c6f3876414303a4a4f4a9baada820..4fcf941ba26aa0d16f10dc0ef26832dc01a881d7 100644 --- a/examples/navier_stokes.cc +++ b/examples/navier_stokes.cc @@ -38,7 +38,7 @@ int main(int argc, char** argv) Parameters::get("stokes->density", density); Parameters::get("stokes->boundary velocity", vel); - AdaptInfo adaptInfo("adapt", prob.getNumComponents()); + AdaptInfo adaptInfo("adapt"); // tree-paths for components auto _v = 0_c; diff --git a/examples/stokes0.cc b/examples/stokes0.cc index fac4ec6dac9731d418c1d83367ed9942d473c01b..fbcc5fb80bd5d7bb703046cd30a48bbc8c933d34 100644 --- a/examples/stokes0.cc +++ b/examples/stokes0.cc @@ -71,7 +71,7 @@ int main(int argc, char** argv) prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0); - AdaptInfo adaptInfo("adapt", prob.getNumComponents()); + AdaptInfo adaptInfo("adapt"); // assemble and solve system prob.buildAfterCoarsen(adaptInfo, Flag(0)); diff --git a/examples/stokes1.cc b/examples/stokes1.cc index c8d92b6dd87e354ef349a2e3fb9e7607039d7e19..cd62b4cdb60d9c1598bfd74c2ba8484f630a1cb7 100644 --- a/examples/stokes1.cc +++ b/examples/stokes1.cc @@ -72,7 +72,7 @@ int main(int argc, char** argv) prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0); - AdaptInfo adaptInfo("adapt", prob.getNumComponents()); + AdaptInfo adaptInfo("adapt"); // assemble and solve system prob.buildAfterCoarsen(adaptInfo, Flag(0)); diff --git a/examples/stokes3.cc b/examples/stokes3.cc index 76db5c2d9feda07418ab1a7854465245d2db04da..7c4e3a6cd488fbcc1051e4cd3aea3fe601a95e69 100644 --- a/examples/stokes3.cc +++ b/examples/stokes3.cc @@ -55,7 +55,7 @@ int main(int argc, char** argv) // set point constraint for pressure prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, _p, _p, 0.0); - AdaptInfo adaptInfo("adapt", prob.getNumComponents()); + AdaptInfo adaptInfo("adapt"); // assemble and solve system prob.buildAfterCoarsen(adaptInfo, Flag(0)); diff --git a/src/amdis/ProblemInstat.hpp b/src/amdis/ProblemInstat.hpp index 1a5fe0289a4d2898df5ea67efd5240c39619f9d0..2a67680284ac7f7943224caaec4a2c9b13a12aae 100644 --- a/src/amdis/ProblemInstat.hpp +++ b/src/amdis/ProblemInstat.hpp @@ -58,15 +58,26 @@ namespace AMDiS } /// Returns \ref oldSolution. - decltype(auto) getOldSolution() { return *oldSolution; } - decltype(auto) getOldSolution() const { return *oldSolution; } + std::unique_ptr<SystemVector> getOldSolutionVector() const + { + return *oldSolution; + } + + /// Return a mutable view to a oldSolution component + template <class TreePath = RootTreePath> + auto getOldSolution(TreePath const& path = {}) + { + auto&& tp = makeTreePath(path); + return makeDOFVectorView(*oldSolution, tp); + } - /// Returns the I'th component of \ref oldSolution. - // template <std::size_t I = 0> - // decltype(auto) getOldSolution(const index_t<I> _i = {}) - // { - // return (*oldSolution)[_i]; - // } + /// Return a const view to a oldSolution component + template <class TreePath = RootTreePath> + auto getOldSolution(TreePath const& path = {}) const + { + auto&& tp = makeTreePath(path); + return makeDOFVectorView(*oldSolution, tp); + } /// Implementation of \ref ProblemTimeInterface::transferInitialSolution(). virtual void transferInitialSolution(AdaptInfo& adaptInfo) override; @@ -80,7 +91,6 @@ namespace AMDiS }; - #if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION // Deduction rule template <class Traits> @@ -90,8 +100,7 @@ namespace AMDiS // Generator for ProblemInstat with given ProblemStat template <class Traits> - ProblemInstat<Traits> - makeProblemInstat(std::string name, ProblemStat<Traits>& prob) + ProblemInstat<Traits> makeProblemInstat(std::string name, ProblemStat<Traits>& prob) { return {std::move(name), prob}; } diff --git a/src/amdis/ProblemInstat.inc.hpp b/src/amdis/ProblemInstat.inc.hpp index 78c31ed1b31769edbccd439013df34a6163c706f..4c268f5a52181be316539b4959d25ced87acd3c5 100644 --- a/src/amdis/ProblemInstat.inc.hpp +++ b/src/amdis/ProblemInstat.inc.hpp @@ -42,16 +42,10 @@ void ProblemInstat<Traits>::createUhOld() { AMDIS_FUNCNAME("ProblemInstat::createUhOld()"); - if (oldSolution) { + if (oldSolution) warning("oldSolution already created\n"); - } - else { - const int size = problemStat.getNumComponents(); - - // create oldSolution - std::vector<std::string> componentNames(size, name + "_uOld"); + else // create oldSolution oldSolution.reset(new SystemVector(*problemStat.getGlobalBasis(), name + "_uOld")); - } }