diff --git a/examples/ellipt.cc b/examples/ellipt.cc index 67b30e6f1d594455e1cdce1329d4ae9f1a95fbf7..396737c3643a17662486482fe66a5fc45f540577 100644 --- a/examples/ellipt.cc +++ b/examples/ellipt.cc @@ -55,7 +55,7 @@ int main(int argc, char** argv) std::vector<double> errH1; errH1.reserve(numLevels); std::vector<double> widths; widths.reserve(numLevels); for (int i = 0; i < numLevels; ++i) { - prob.getGrid()->globalRefine(1); + prob.grid().globalRefine(1); auto gridView = prob.gridView(); double h = 0; diff --git a/src/amdis/Assembler.inc.hpp b/src/amdis/Assembler.inc.hpp index 5ab4ed185154626e52901f22613b2e4409fa8144..f073f40c9c90ddb077b4ad20bc14ac223cc126c3 100644 --- a/src/amdis/Assembler.inc.hpp +++ b/src/amdis/Assembler.inc.hpp @@ -1,8 +1,8 @@ #pragma once #include <dune/functions/functionspacebases/subspacebasis.hh> -#include <dune/typetree/traversal.hh> #include <amdis/utility/TreePath.hpp> +#include <amdis/utility/Visitor.hpp> #include <amdis/common/Math.hpp> diff --git a/src/amdis/ProblemInstat.inc.hpp b/src/amdis/ProblemInstat.inc.hpp index 9005f11fb067bbb2c1c40a233f2adc47e99aab1e..47c2d4f9ee43229e323282ed6825b79b4f1a018c 100644 --- a/src/amdis/ProblemInstat.inc.hpp +++ b/src/amdis/ProblemInstat.inc.hpp @@ -45,7 +45,7 @@ void ProblemInstat<Traits>::createUhOld() if (oldSolution) warning("oldSolution already created\n"); else // create oldSolution - oldSolution.reset(new SystemVector(*problemStat.globalBasis(), name + "_uOld")); + oldSolution.reset(new SystemVector(problemStat.globalBasis(), name + "_uOld")); } diff --git a/src/amdis/ProblemStat.hpp b/src/amdis/ProblemStat.hpp index 033a6b65ade3f3186f3f24635f5871aad047f458..9e36f2ca8ddaa34689db11e5d47400ac691a8971 100644 --- a/src/amdis/ProblemStat.hpp +++ b/src/amdis/ProblemStat.hpp @@ -40,6 +40,10 @@ namespace AMDiS { + // forward declaration + template <class Traits> + class ProblemInstat; + template <class Traits> class ProblemStat : public ProblemStatBase @@ -47,6 +51,8 @@ namespace AMDiS { using Self = ProblemStat; + friend class ProblemInstat<Traits>; + public: // typedefs and static constants using GlobalBasis = typename Traits::GlobalBasis; @@ -153,15 +159,18 @@ namespace AMDiS public: // get-methods - /// Returns a pointer to system-matrix, \ref systemMatrix_ - std::shared_ptr<SystemMatrix> getSystemMatrix() { return systemMatrix_; } - std::shared_ptr<SystemMatrix> getSystemMatrix() const { return systemMatrix_; } + /// Returns a reference to system-matrix, \ref systemMatrix_ + SystemMatrix& getSystemMatrix() { return *systemMatrix_; } + SystemMatrix const& getSystemMatrix() const { return *systemMatrix_; } + + /// Returns a reference to the solution vector, \ref solution_ + SystemVector& getSolutionVector() { return *solution_; } + SystemVector const& getSolutionVector() const { return *solution_; } + + /// Return a reference to the rhs system-vector, \ref rhs + SystemVector& getRhsVector() { return *rhs_; } + SystemVector const& getRhsVector() const { return *rhs_; } - /// Returns a pointer to the solution vector, \ref solution_ - std::shared_ptr<SystemVector> getSolutionVector() const - { - return solution_; - } /// Return a mutable view to a solution component template <class TreePath = RootTreePath> @@ -180,27 +189,25 @@ namespace AMDiS } - /// Return a point to the rhs system-vector, \ref rhs - std::shared_ptr<SystemVector> getRhsVector() { return rhs_; } - std::shared_ptr<SystemVector> getRhsVector() const { return rhs_; } - - - /// Return a pointer to the linear solver, \ref linearSolver - std::shared_ptr<LinearSolverType> getSolver() { return linearSolver_; } + /// Return a reference to the linear solver, \ref linearSolver + LinearSolverType& getSolver() { return *linearSolver_; } + LinearSolverType const& getSolver() const { return *linearSolver_; } + /// Set a new linear solver for the problem void setSolver(std::shared_ptr<LinearSolverType> const& solver) { linearSolver_ = solver; } - /// Return a pointer to the grid, \ref grid - std::shared_ptr<Grid> getGrid() { return grid_; } + /// Return a reference to the grid, \ref grid + Grid& grid() { return *grid_; } + Grid const& grid() const { return *grid_; } - /// Set the mesh. Stores pointer to passed reference and initializes feSpaces + /// Set the grid. Stores pointer and initializes feSpaces /// matrices and vectors, as well as the file-writer. - void setGrid(Grid& grid) + void setGrid(std::shared_ptr<Grid> const& grid) { - grid_ = Dune::stackobject_to_shared_ptr(grid); + grid_ = grid; createGlobalBasis(); createMatricesAndVectors(); @@ -208,10 +215,10 @@ namespace AMDiS } /// Return the gridView of the leaf-level - auto const& gridView() { return globalBasis_->gridView(); } + GridView const& gridView() { return globalBasis_->gridView(); } /// Return the \ref feSpaces - std::shared_ptr<GlobalBasis> const& globalBasis() { return globalBasis_; } + GlobalBasis const& globalBasis() { return *globalBasis_; } /// Implementation of \ref ProblemStatBase::getName @@ -240,7 +247,7 @@ namespace AMDiS void createGlobalBasis(std::false_type) { - error_exit("Can not create GlobalBasis from type. Pass a BasisCreator instead!"); + error_exit("Cannot create GlobalBasis from type. Pass a BasisCreator instead!"); } void createGrid() diff --git a/src/amdis/utility/CMakeLists.txt b/src/amdis/utility/CMakeLists.txt index 69b9b57d916dd9b62f40fcc0bde6e78d96e5f719..bef683e075593a642d26cd49cdc7c90df883c729 100644 --- a/src/amdis/utility/CMakeLists.txt +++ b/src/amdis/utility/CMakeLists.txt @@ -10,6 +10,8 @@ install(FILES MultiIndex.hpp RangeType.hpp String.hpp + Traversal.hpp TreeData.hpp TreePath.hpp + Visitor.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/utility) diff --git a/src/amdis/utility/TreeData.hpp b/src/amdis/utility/TreeData.hpp index 68ae7a1118c2fc5268cedf22133f91f8b40fa1b2..760a8e44e53c48ebda33abb49fe6e2232e6373ff 100644 --- a/src/amdis/utility/TreeData.hpp +++ b/src/amdis/utility/TreeData.hpp @@ -5,7 +5,6 @@ #include <utility> #include <vector> -//#include <dune/typetree/traversal.hh> #include <dune/typetree/typetree.hh> #include <amdis/utility/Visitor.hpp>