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

Merge branch 'issue/istl_direct_solvers' into 'master'

corrected solver creator for istl solvers and preconditioners

See merge request !56
parents ae94a0e6 5fdb2044
Branches
Tags
1 merge request!56corrected solver creator for istl solvers and preconditioners
...@@ -46,11 +46,13 @@ namespace AMDiS ...@@ -46,11 +46,13 @@ namespace AMDiS
init(); init();
auto it = creatorMap.find(key); auto it = creatorMap.find(key);
if (it == creatorMap.end()) if (it == creatorMap.end()) {
warning("No creator for key `{}` defined (used in init-file parameter `{}`). Falling back to `default`.", key, initFileStr);
key = "default"; key = "default";
}
auto creator = creatorMap[key]; auto creator = creatorMap[key];
test_exit(creator, "No creator for key `{}` defined in init file for parameter `{}`", key, initFileStr); test_exit(creator, "Undefined creator for `{}` (used in init-file parameter `{}`)", key, initFileStr);
return creator; return creator;
} }
......
...@@ -84,6 +84,7 @@ namespace AMDiS ...@@ -84,6 +84,7 @@ namespace AMDiS
= typename ISTLPreconCreator<Precon, Mat>::Creator; = typename ISTLPreconCreator<Precon, Mat>::Creator;
using Map = CreatorMap<ISTLPreconCreatorInterface<Mat, Sol, Rhs>>; using Map = CreatorMap<ISTLPreconCreatorInterface<Mat, Sol, Rhs>>;
using FTraits = Dune::FieldTraits<typename Mat::field_type>;
public: public:
static void init() static void init()
...@@ -102,23 +103,33 @@ namespace AMDiS ...@@ -102,23 +103,33 @@ namespace AMDiS
auto ssor = new PreconCreator<Dune::SeqSSOR<Mat, Sol, Rhs>>; auto ssor = new PreconCreator<Dune::SeqSSOR<Mat, Sol, Rhs>>;
Map::addCreator("ssor", ssor); Map::addCreator("ssor", ssor);
init_ilu(std::is_arithmetic<typename Dune::FieldTraits<Mat>::field_type>{}); init_ilu(std::is_arithmetic<typename FTraits::field_type>{});
init_amg(std::is_same<typename Dune::FieldTraits<Mat>::real_type, double>{}); init_amg(std::is_same<typename FTraits::real_type, double>{});
auto richardson = new PreconCreator<Dune::Richardson<Sol, Rhs>>; auto richardson = new PreconCreator<Dune::Richardson<Sol, Rhs>>;
Map::addCreator("richardson", richardson); Map::addCreator("richardson", richardson);
Map::addCreator("default", richardson); Map::addCreator("default", richardson);
} }
static void init_ilu(std::false_type) {} static void init_ilu(std::false_type)
{
warning("ILU preconditioners not created for the matrix with field_type = {}.",
Dune::className<typename FTraits::field_type>());
}
static void init_ilu(std::true_type) static void init_ilu(std::true_type)
{ {
auto ilu = new PreconCreator<Dune::SeqILU<Mat, Sol, Rhs>>; auto ilu = new PreconCreator<Dune::SeqILU<Mat, Sol, Rhs>>;
Map::addCreator("ilu", id(ilu)); Map::addCreator("ilu", ilu);
Map::addCreator("ilu0", id(ilu)); Map::addCreator("ilu0", ilu);
}
static void init_amg(std::false_type)
{
warning("AMG preconditioners not created for the matrix with real_type = {}.",
Dune::className<typename FTraits::real_type>());
} }
static void init_amg(std::false_type) {}
static void init_amg(std::true_type) static void init_amg(std::true_type)
{ {
auto amg = new AMGPreconCreator<Dune::Amg::AMG, Mat, Sol, Rhs>; auto amg = new AMGPreconCreator<Dune::Amg::AMG, Mat, Sol, Rhs>;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <memory> #include <memory>
#include <dune/common/classname.hh>
#include <dune/istl/solvers.hh> #include <dune/istl/solvers.hh>
#include <dune/istl/umfpack.hh> #include <dune/istl/umfpack.hh>
#include <dune/istl/superlu.hh> #include <dune/istl/superlu.hh>
...@@ -141,6 +142,7 @@ namespace AMDiS ...@@ -141,6 +142,7 @@ namespace AMDiS
class DefaultCreators<LinearSolverInterface<Dune::BCRSMatrix<Block,Alloc>, VectorX, VectorB>> class DefaultCreators<LinearSolverInterface<Dune::BCRSMatrix<Block,Alloc>, VectorX, VectorB>>
{ {
using Matrix = Dune::BCRSMatrix<Block,Alloc>; using Matrix = Dune::BCRSMatrix<Block,Alloc>;
using FTraits = Dune::FieldTraits<typename Matrix::field_type>;
using SolverBase = LinearSolverInterface<Matrix, VectorX, VectorB>; using SolverBase = LinearSolverInterface<Matrix, VectorX, VectorB>;
template <class Solver> template <class Solver>
...@@ -178,10 +180,15 @@ namespace AMDiS ...@@ -178,10 +180,15 @@ namespace AMDiS
// default iterative solver // default iterative solver
Map::addCreator("default", gmres); Map::addCreator("default", gmres);
init_direct(std::is_same<typename Dune::FieldTraits<Matrix>::real_type, double>{}); init_direct(std::is_same<typename FTraits::real_type, double>{});
}
static void init_direct(std::false_type)
{
warning("Direct solvers not created for the matrix with real_type = {}.",
Dune::className<typename FTraits::real_type>());
} }
static void init_direct(std::false_type) {}
static void init_direct(std::true_type) static void init_direct(std::true_type)
{ {
#if HAVE_SUITESPARSE_UMFPACK #if HAVE_SUITESPARSE_UMFPACK
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment