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

Removed runner from SolverInterface and Preconditioner from RunnerInterface

parent 4ee80f61
No related branches found
No related tags found
1 merge request!107Restructuring of Matrix and Vector and linear-algebra backends
This commit is part of merge request !107. Comments created here will be created in the context of that merge request.
Showing
with 21 additions and 104 deletions
...@@ -36,10 +36,8 @@ namespace AMDiS ...@@ -36,10 +36,8 @@ namespace AMDiS
using ColBasis = CB; using ColBasis = CB;
using ColLocalView = typename ColBasis::LocalView; using ColLocalView = typename ColBasis::LocalView;
using Traits = typename Backend::Traits;
/// The type of the matrix filled on an element with local contributions /// The type of the matrix filled on an element with local contributions
using ElementMatrix = FlatMatrix<typename Traits::CoefficientType>; using ElementMatrix = FlatMatrix<T>;
public: public:
/// Constructor. Wraps the reference into a non-destroying shared_ptr or moves the basis into a new shared_ptr. /// 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 ...@@ -50,6 +48,7 @@ namespace AMDiS
operators_.init(*Super::rowBasis(), *Super::colBasis()); operators_.init(*Super::rowBasis(), *Super::colBasis());
} }
/// Prepare the matrix for insertion. Clears all the entries.
void init(SymmetryStructure symmetry = SymmetryStructure::unknown) void init(SymmetryStructure symmetry = SymmetryStructure::unknown)
{ {
Super::init(symmetry); Super::init(symmetry);
......
...@@ -17,7 +17,7 @@ namespace AMDiS ...@@ -17,7 +17,7 @@ namespace AMDiS
, id_(id) , id_(id)
{} {}
BoundaryCondition(BoundaryManagerBase& boundaryManager, BoundaryType id) BoundaryCondition(BoundaryManagerBase const& boundaryManager, BoundaryType id)
: BoundaryCondition(Dune::stackobject_to_shared_ptr(boundaryManager), id) : BoundaryCondition(Dune::stackobject_to_shared_ptr(boundaryManager), id)
{} {}
......
...@@ -17,14 +17,6 @@ ...@@ -17,14 +17,6 @@
#include <amdis/linearalgebra/eigen/MatrixBackend.hpp> #include <amdis/linearalgebra/eigen/MatrixBackend.hpp>
#include <amdis/linearalgebra/eigen/VectorBackend.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 #else // ISTL
#include <amdis/linearalgebra/istl/Constraints.hpp> #include <amdis/linearalgebra/istl/Constraints.hpp>
......
...@@ -24,32 +24,6 @@ namespace AMDiS ...@@ -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 /// Default attribute set used to classify DOFs. Can be specialized for own
/// Communication type `C`. /// Communication type `C`.
...@@ -73,7 +47,4 @@ namespace AMDiS ...@@ -73,7 +47,4 @@ namespace AMDiS
using type = typename AttributeSet<TL>::type; using type = typename AttributeSet<TL>::type;
}; };
template <class C>
using AttributeSet_t = typename AttributeSet<C>::type;
} // end namespace AMDiS } // end namespace AMDiS
...@@ -148,7 +148,7 @@ namespace AMDiS ...@@ -148,7 +148,7 @@ namespace AMDiS
class ParallelDofMapping class ParallelDofMapping
{ {
using ParallelIndexSet = PIS; using ParallelIndexSet = PIS;
using Attribute = AttributeSet_t<PIS>; using Attribute = typename AttributeSet<PIS>::type;
using RemoteIndices = Dune::RemoteIndices<ParallelIndexSet>; using RemoteIndices = Dune::RemoteIndices<ParallelIndexSet>;
public: public:
......
...@@ -27,7 +27,6 @@ namespace AMDiS ...@@ -27,7 +27,6 @@ namespace AMDiS
using Self = LinearSolver; using Self = LinearSolver;
using Super = LinearSolverInterface<Traits>; using Super = LinearSolverInterface<Traits>;
using RunnerBase = typename Super::RunnerBase;
using Mat = typename Traits::Mat; using Mat = typename Traits::Mat;
using Vec = typename Traits::Vec; using Vec = typename Traits::Vec;
using Comm = typename Traits::Comm; using Comm = typename Traits::Comm;
...@@ -45,15 +44,9 @@ namespace AMDiS ...@@ -45,15 +44,9 @@ namespace AMDiS
public: public:
/// Constructor /// Constructor
explicit LinearSolver(std::string prefix) 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: private:
/// Implements \ref LinearSolverInterface::solveSystemImpl() /// Implements \ref LinearSolverInterface::solveSystemImpl()
void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm& comm, SolverInfo& solverInfo) override void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm& comm, SolverInfo& solverInfo) override
...@@ -61,22 +54,22 @@ namespace AMDiS ...@@ -61,22 +54,22 @@ namespace AMDiS
Dune::Timer t; Dune::Timer t;
if (solverInfo.doCreateMatrixData()) { if (solverInfo.doCreateMatrixData()) {
// init matrix or wrap block-matrix or ... // init matrix or wrap block-matrix or ...
runner_->init(A, comm); runner_.init(A, comm);
} }
if (solverInfo.info() > 0) if (solverInfo.info() > 0)
msg("prepare solver needed {} seconds", t.elapsed()); 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); solverInfo.setError(error);
if (!solverInfo.doStoreMatrixData()) if (!solverInfo.doStoreMatrixData())
runner_->exit(); runner_.exit();
} }
private: private:
/// redirect the implementation to a runner. Implements a \ref RunnerInterface /// redirect the implementation to a runner. Implementing a \ref RunnerInterface
std::shared_ptr<Runner> runner_; Runner runner_;
}; };
} // end namespace AMDiS } // end namespace AMDiS
...@@ -11,20 +11,15 @@ ...@@ -11,20 +11,15 @@
* systems. * systems.
*/ */
#include <amdis/common/TypeTraits.hpp>
#include <amdis/linearalgebra/PreconditionerInterface.hpp>
#include <amdis/linearalgebra/RunnerInterface.hpp>
#include <amdis/linearalgebra/SolverInfo.hpp>
namespace AMDiS namespace AMDiS
{ {
class SolverInfo;
/// Abstract base class for linear solvers /// Abstract base class for linear solvers
template <class Traits> template <class Traits>
class LinearSolverInterface class LinearSolverInterface
{ {
protected: protected:
using RunnerBase = RunnerInterface<Traits>;
using Mat = typename Traits::Mat; using Mat = typename Traits::Mat;
using Vec = typename Traits::Vec; using Vec = typename Traits::Vec;
using Comm = typename Traits::Comm; using Comm = typename Traits::Comm;
...@@ -48,9 +43,6 @@ namespace AMDiS ...@@ -48,9 +43,6 @@ namespace AMDiS
solveImpl(A, x, b, comm, solverInfo); solveImpl(A, x, b, comm, solverInfo);
} }
// return the runner/worker corresponding to this solver (optional)
virtual std::shared_ptr<RunnerBase> runner() { return {}; };
private: private:
/// main methods that all solvers must implement /// main methods that all solvers must implement
virtual void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm& comm, SolverInfo& solverInfo) = 0; virtual void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm& comm, SolverInfo& solverInfo) = 0;
......
...@@ -17,7 +17,7 @@ namespace AMDiS ...@@ -17,7 +17,7 @@ namespace AMDiS
inline void buildParallelIndexSet(Basis const& basis, ParallelIndexSet& pis) inline void buildParallelIndexSet(Basis const& basis, ParallelIndexSet& pis)
{ {
Dune::Timer t; Dune::Timer t;
using Attribute = AttributeSet_t<ParallelIndexSet>; using Attribute = typename AttributeSet<ParallelIndexSet>::type;
using GI = typename ParallelIndexSet::GlobalIndex; using GI = typename ParallelIndexSet::GlobalIndex;
using LI = typename ParallelIndexSet::LocalIndex; using LI = typename ParallelIndexSet::LocalIndex;
......
#pragma once #pragma once
#include <amdis/common/TypeTraits.hpp> #include <amdis/Output.hpp>
#include <amdis/linearalgebra/PreconditionerInterface.hpp>
namespace AMDiS namespace AMDiS
{ {
...@@ -12,7 +11,6 @@ namespace AMDiS ...@@ -12,7 +11,6 @@ namespace AMDiS
class RunnerInterface class RunnerInterface
{ {
protected: protected:
using PreconBase = PreconditionerInterface<Traits>;
using Mat = typename Traits::Mat; using Mat = typename Traits::Mat;
using Vec = typename Traits::Vec; using Vec = typename Traits::Vec;
using Comm = typename Traits::Comm; using Comm = typename Traits::Comm;
...@@ -36,9 +34,6 @@ namespace AMDiS ...@@ -36,9 +34,6 @@ namespace AMDiS
error_exit("Must be implemented by derived class."); error_exit("Must be implemented by derived class.");
return 0; return 0;
} }
virtual std::shared_ptr<PreconBase> leftPrecon() { return {}; }
virtual std::shared_ptr<PreconBase> rightPrecon() { return {}; }
}; };
} // end namespace AMDiS } // end namespace AMDiS
...@@ -28,7 +28,7 @@ namespace AMDiS ...@@ -28,7 +28,7 @@ namespace AMDiS
using Matrix = typename Traits::Mat; using Matrix = typename Traits::Mat;
using Vector = typename Traits::Vec; using Vector = typename Traits::Vec;
using Comm = typename Traits::Comm; using Comm = typename Traits::Comm;
using PreconBase = typename Super::PreconBase; using PreconBase = PreconditionerInterface<Traits>;
public: public:
/// Constructor. /// Constructor.
...@@ -41,30 +41,6 @@ namespace AMDiS ...@@ -41,30 +41,6 @@ namespace AMDiS
Parameters::get(prefix + "->print cycle", printCycle_); 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() /// Implementation of \ref RunnerInterface::init()
void init(Matrix const& A, Comm& comm) override void init(Matrix const& A, Comm& comm) override
{ {
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
namespace AMDiS namespace AMDiS
{ {
/// \brief The basic container that stores a base matrix /// \brief The basic container that stores a base matrix
template <class T> template <class TraitsType>
class MatrixBackend class MatrixBackend
{ {
public: public:
using Traits = T; using Traits = TraitsType;
/// The matrix type of the underlying base matrix /// The matrix type of the underlying base matrix
using BaseMatrix = typename Traits::Mat; using BaseMatrix = typename Traits::Mat;
......
...@@ -32,7 +32,6 @@ namespace AMDiS ...@@ -32,7 +32,6 @@ namespace AMDiS
using Vector = typename Traits::Vec; using Vector = typename Traits::Vec;
using Comm = typename Traits::Comm; using Comm = typename Traits::Comm;
using Super = RunnerInterface<Traits>; using Super = RunnerInterface<Traits>;
using PreconBase = typename Super::PreconBase;
using SolverType = mtl::mat::umfpack::solver<Matrix>; using SolverType = mtl::mat::umfpack::solver<Matrix>;
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
namespace AMDiS namespace AMDiS
{ {
/// The basic container that stores a base vector data /// \brief The basic container that stores a base vector data
template <class T> template <class TraitsType>
class VectorBackend class VectorBackend
{ {
public: public:
using Traits = T; using Traits = TraitsType;
/// The type of the base vector /// The type of the base vector
using BaseVector = typename Traits::Vec; using BaseVector = typename Traits::Vec;
......
...@@ -43,7 +43,7 @@ void test_basis(Basis const& basis, std::string gridName, std::string basisName) ...@@ -43,7 +43,7 @@ void test_basis(Basis const& basis, std::string gridName, std::string basisName)
buildParallelIndexSet(basis, pis); buildParallelIndexSet(basis, pis);
using IdType = typename ParallelIndexSet::GlobalIndex; 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::vector<std::vector<std::pair<IdType,Attribute>>> data(world.size());
std::size_t owner = 0, notOwner = 0; std::size_t owner = 0, notOwner = 0;
......
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