diff --git a/src/amdis/BiLinearForm.hpp b/src/amdis/BiLinearForm.hpp index 56667e8a6c7d96a597502ccc94f04cb4ecb1b761..992afd5f3fe75c027fff81d59ff15b24338e9004 100644 --- a/src/amdis/BiLinearForm.hpp +++ b/src/amdis/BiLinearForm.hpp @@ -36,10 +36,8 @@ namespace AMDiS using ColBasis = CB; using ColLocalView = typename ColBasis::LocalView; - using Traits = typename Backend::Traits; - /// The type of the matrix filled on an element with local contributions - using ElementMatrix = FlatMatrix<typename Traits::CoefficientType>; + using ElementMatrix = FlatMatrix<T>; public: /// Constructor. Wraps the reference into a non-destroying shared_ptr or moves the basis into a new shared_ptr. @@ -50,6 +48,7 @@ namespace AMDiS operators_.init(*Super::rowBasis(), *Super::colBasis()); } + /// Prepare the matrix for insertion. Clears all the entries. void init(SymmetryStructure symmetry = SymmetryStructure::unknown) { Super::init(symmetry); diff --git a/src/amdis/BoundaryCondition.hpp b/src/amdis/BoundaryCondition.hpp index 1c25f8386ba70c503108cb9395f74f1aa55ba420..aa6c134099c2cabcacc74c3c8aef706d7734b718 100644 --- a/src/amdis/BoundaryCondition.hpp +++ b/src/amdis/BoundaryCondition.hpp @@ -17,7 +17,7 @@ namespace AMDiS , id_(id) {} - BoundaryCondition(BoundaryManagerBase& boundaryManager, BoundaryType id) + BoundaryCondition(BoundaryManagerBase const& boundaryManager, BoundaryType id) : BoundaryCondition(Dune::stackobject_to_shared_ptr(boundaryManager), id) {} diff --git a/src/amdis/LinearAlgebra.hpp b/src/amdis/LinearAlgebra.hpp index ce3ef3fe6f8e403c49b43ef8209175371db8f64f..ff7a21a9ee759099156dfb38813288710bd6e966 100644 --- a/src/amdis/LinearAlgebra.hpp +++ b/src/amdis/LinearAlgebra.hpp @@ -17,14 +17,6 @@ #include <amdis/linearalgebra/eigen/MatrixBackend.hpp> #include <amdis/linearalgebra/eigen/VectorBackend.hpp> -#elif HAVE_PETSC - -#include <amdis/linearalgebra/petsc/Constraints.hpp> -#include <amdis/linearalgebra/petsc/SolverCreator.hpp> -#include <amdis/linearalgebra/petsc/Traits.hpp> -#include <amdis/linearalgebra/petsc/MatrixBackend.hpp> -#include <amdis/linearalgebra/petsc/VectorBackend.hpp> - #else // ISTL #include <amdis/linearalgebra/istl/Constraints.hpp> diff --git a/src/amdis/linearalgebra/AttributeSet.hpp b/src/amdis/linearalgebra/AttributeSet.hpp index 8b453794fa15e549493ac96346b36565147b58b5..a88c2e1bd0aba051a8635f1e7bfa40653b27e9f1 100644 --- a/src/amdis/linearalgebra/AttributeSet.hpp +++ b/src/amdis/linearalgebra/AttributeSet.hpp @@ -24,32 +24,6 @@ namespace AMDiS }; }; - inline DefaultAttributeSet::Type attributeSet(std::string str) - { - if (str == "owner") - return DefaultAttributeSet::owner; - else if (str == "overlap") - return DefaultAttributeSet::overlap; - else if (str == "copy") - return DefaultAttributeSet::copy; - else - return DefaultAttributeSet::unknown; - } - - inline std::string to_string(DefaultAttributeSet::Type state) - { - switch (state) { - case DefaultAttributeSet::owner: - return "owner"; - case DefaultAttributeSet::overlap: - return "overlap"; - case DefaultAttributeSet::copy: - return "copy"; - default: - return "unknown"; - } - } - /// Default attribute set used to classify DOFs. Can be specialized for own /// Communication type `C`. @@ -73,7 +47,4 @@ namespace AMDiS using type = typename AttributeSet<TL>::type; }; - template <class C> - using AttributeSet_t = typename AttributeSet<C>::type; - } // end namespace AMDiS diff --git a/src/amdis/linearalgebra/DOFMapping.hpp b/src/amdis/linearalgebra/DOFMapping.hpp index b32d8e8847b1f6790f6fda0e6be06ac63fa40a0b..bb937024acec58dcf5ce913a2094afbbf51cff37 100644 --- a/src/amdis/linearalgebra/DOFMapping.hpp +++ b/src/amdis/linearalgebra/DOFMapping.hpp @@ -148,7 +148,7 @@ namespace AMDiS class ParallelDofMapping { using ParallelIndexSet = PIS; - using Attribute = AttributeSet_t<PIS>; + using Attribute = typename AttributeSet<PIS>::type; using RemoteIndices = Dune::RemoteIndices<ParallelIndexSet>; public: diff --git a/src/amdis/linearalgebra/LinearSolver.hpp b/src/amdis/linearalgebra/LinearSolver.hpp index faaf2851b2ea9ae7de7d0d99ad7f62057202a574..85df72428f768e36cffdb177f0af441f0b5fafc5 100644 --- a/src/amdis/linearalgebra/LinearSolver.hpp +++ b/src/amdis/linearalgebra/LinearSolver.hpp @@ -27,7 +27,6 @@ namespace AMDiS using Self = LinearSolver; using Super = LinearSolverInterface<Traits>; - using RunnerBase = typename Super::RunnerBase; using Mat = typename Traits::Mat; using Vec = typename Traits::Vec; using Comm = typename Traits::Comm; @@ -45,15 +44,9 @@ namespace AMDiS public: /// Constructor explicit LinearSolver(std::string prefix) - : runner_(std::make_shared<Runner>(prefix)) + : runner_(prefix) {} - /// Implements \ref LinearSolverInterface::runner() - virtual std::shared_ptr<RunnerBase> runner() override - { - return runner_; - } - private: /// Implements \ref LinearSolverInterface::solveSystemImpl() void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm& comm, SolverInfo& solverInfo) override @@ -61,22 +54,22 @@ namespace AMDiS Dune::Timer t; if (solverInfo.doCreateMatrixData()) { // init matrix or wrap block-matrix or ... - runner_->init(A, comm); + runner_.init(A, comm); } if (solverInfo.info() > 0) msg("prepare solver needed {} seconds", t.elapsed()); - int error = runner_->solve(A, x, b, solverInfo); + int error = runner_.solve(A, x, b, solverInfo); solverInfo.setError(error); if (!solverInfo.doStoreMatrixData()) - runner_->exit(); + runner_.exit(); } private: - /// redirect the implementation to a runner. Implements a \ref RunnerInterface - std::shared_ptr<Runner> runner_; + /// redirect the implementation to a runner. Implementing a \ref RunnerInterface + Runner runner_; }; } // end namespace AMDiS diff --git a/src/amdis/linearalgebra/LinearSolverInterface.hpp b/src/amdis/linearalgebra/LinearSolverInterface.hpp index f0f79817c887c5564afbe6f62ccb9a6c19cbe625..083878a5b8593c86adc9753f84b60cf53ef13f55 100644 --- a/src/amdis/linearalgebra/LinearSolverInterface.hpp +++ b/src/amdis/linearalgebra/LinearSolverInterface.hpp @@ -11,20 +11,15 @@ * systems. */ -#include <amdis/common/TypeTraits.hpp> - -#include <amdis/linearalgebra/PreconditionerInterface.hpp> -#include <amdis/linearalgebra/RunnerInterface.hpp> -#include <amdis/linearalgebra/SolverInfo.hpp> - namespace AMDiS { + class SolverInfo; + /// Abstract base class for linear solvers template <class Traits> class LinearSolverInterface { protected: - using RunnerBase = RunnerInterface<Traits>; using Mat = typename Traits::Mat; using Vec = typename Traits::Vec; using Comm = typename Traits::Comm; @@ -48,9 +43,6 @@ namespace AMDiS solveImpl(A, x, b, comm, solverInfo); } - // return the runner/worker corresponding to this solver (optional) - virtual std::shared_ptr<RunnerBase> runner() { return {}; }; - private: /// main methods that all solvers must implement virtual void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm& comm, SolverInfo& solverInfo) = 0; diff --git a/src/amdis/linearalgebra/ParallelIndexSet.hpp b/src/amdis/linearalgebra/ParallelIndexSet.hpp index d55db5f1582aecf6f116f8374557435b31f8970b..cb69b4eec00a9817c14c8388e3afcc46551bd95d 100644 --- a/src/amdis/linearalgebra/ParallelIndexSet.hpp +++ b/src/amdis/linearalgebra/ParallelIndexSet.hpp @@ -17,7 +17,7 @@ namespace AMDiS inline void buildParallelIndexSet(Basis const& basis, ParallelIndexSet& pis) { Dune::Timer t; - using Attribute = AttributeSet_t<ParallelIndexSet>; + using Attribute = typename AttributeSet<ParallelIndexSet>::type; using GI = typename ParallelIndexSet::GlobalIndex; using LI = typename ParallelIndexSet::LocalIndex; diff --git a/src/amdis/linearalgebra/RunnerInterface.hpp b/src/amdis/linearalgebra/RunnerInterface.hpp index d0941e4d684d52c7833a2c275d1adfe8cae5581a..4f46d3e456c0d23b32b4dc451ba72cca81b7e5a9 100644 --- a/src/amdis/linearalgebra/RunnerInterface.hpp +++ b/src/amdis/linearalgebra/RunnerInterface.hpp @@ -1,7 +1,6 @@ #pragma once -#include <amdis/common/TypeTraits.hpp> -#include <amdis/linearalgebra/PreconditionerInterface.hpp> +#include <amdis/Output.hpp> namespace AMDiS { @@ -12,7 +11,6 @@ namespace AMDiS class RunnerInterface { protected: - using PreconBase = PreconditionerInterface<Traits>; using Mat = typename Traits::Mat; using Vec = typename Traits::Vec; using Comm = typename Traits::Comm; @@ -36,9 +34,6 @@ namespace AMDiS error_exit("Must be implemented by derived class."); return 0; } - - virtual std::shared_ptr<PreconBase> leftPrecon() { return {}; } - virtual std::shared_ptr<PreconBase> rightPrecon() { return {}; } }; } // end namespace AMDiS diff --git a/src/amdis/linearalgebra/mtl/KrylovRunner.hpp b/src/amdis/linearalgebra/mtl/KrylovRunner.hpp index 54548b0ea19ffb3949fd9dee73918c040e52a77d..a17f1feb5ab9af5b100b1d032063f53a0fd844ea 100644 --- a/src/amdis/linearalgebra/mtl/KrylovRunner.hpp +++ b/src/amdis/linearalgebra/mtl/KrylovRunner.hpp @@ -28,7 +28,7 @@ namespace AMDiS using Matrix = typename Traits::Mat; using Vector = typename Traits::Vec; using Comm = typename Traits::Comm; - using PreconBase = typename Super::PreconBase; + using PreconBase = PreconditionerInterface<Traits>; public: /// Constructor. @@ -41,30 +41,6 @@ namespace AMDiS Parameters::get(prefix + "->print cycle", printCycle_); } - /// Implements \ref RunnerInterface::lLeftPrecon(), Returns \ref L_ - std::shared_ptr<PreconBase> leftPrecon() override - { - return L_; - } - - /// Implements \ref RunnerInterface::rightPrecon(), Returns \ref R_ - std::shared_ptr<PreconBase> rightPrecon() override - { - return R_; - } - - /// Set a new left preconditioner \ref L_ - void setLeftPrecon(std::shared_ptr<PreconBase> const& precon) - { - L_ = precon; - } - - /// Set a new right preconditioner \ref R_ - void setRightPrecon(std::shared_ptr<PreconBase> const& precon) - { - R_ = precon; - } - /// Implementation of \ref RunnerInterface::init() void init(Matrix const& A, Comm& comm) override { diff --git a/src/amdis/linearalgebra/mtl/MatrixBackend.hpp b/src/amdis/linearalgebra/mtl/MatrixBackend.hpp index a26dc34e30f9263975a9ffa886225cba856c50a3..ea4c0e71ddc95398e2f26f1a364d29189db0d485 100644 --- a/src/amdis/linearalgebra/mtl/MatrixBackend.hpp +++ b/src/amdis/linearalgebra/mtl/MatrixBackend.hpp @@ -15,11 +15,11 @@ namespace AMDiS { /// \brief The basic container that stores a base matrix - template <class T> + template <class TraitsType> class MatrixBackend { public: - using Traits = T; + using Traits = TraitsType; /// The matrix type of the underlying base matrix using BaseMatrix = typename Traits::Mat; diff --git a/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp b/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp index aa49fb7ea8977140cd4ab6fcff130922091c763c..643cfbaf865402ec4b316768547ac191c1ccc4c5 100644 --- a/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp +++ b/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp @@ -32,7 +32,6 @@ namespace AMDiS using Vector = typename Traits::Vec; using Comm = typename Traits::Comm; using Super = RunnerInterface<Traits>; - using PreconBase = typename Super::PreconBase; using SolverType = mtl::mat::umfpack::solver<Matrix>; diff --git a/src/amdis/linearalgebra/mtl/VectorBackend.hpp b/src/amdis/linearalgebra/mtl/VectorBackend.hpp index 4fddc501e0547a6cc5e79138410e2fb24cbdfe12..884e2fd5e37a6ab3f0303b16b281e5327d78df1e 100644 --- a/src/amdis/linearalgebra/mtl/VectorBackend.hpp +++ b/src/amdis/linearalgebra/mtl/VectorBackend.hpp @@ -7,12 +7,12 @@ namespace AMDiS { - /// The basic container that stores a base vector data - template <class T> + /// \brief The basic container that stores a base vector data + template <class TraitsType> class VectorBackend { public: - using Traits = T; + using Traits = TraitsType; /// The type of the base vector using BaseVector = typename Traits::Vec; diff --git a/test/ParallelIndexSetTest.cpp b/test/ParallelIndexSetTest.cpp index e2bda6c7264d0cb1661143a3d2d60fc107f1e241..c4739cf15f3d8af1b7bd09210def567c9dab4bdc 100644 --- a/test/ParallelIndexSetTest.cpp +++ b/test/ParallelIndexSetTest.cpp @@ -43,7 +43,7 @@ void test_basis(Basis const& basis, std::string gridName, std::string basisName) buildParallelIndexSet(basis, pis); using IdType = typename ParallelIndexSet::GlobalIndex; - using Attribute = AttributeSet_t<ParallelIndexSet>; + using Attribute = typename AttributeSet<ParallelIndexSet>::type; std::vector<std::vector<std::pair<IdType,Attribute>>> data(world.size()); std::size_t owner = 0, notOwner = 0;