Commit 9e425be9 authored by Timo Koch's avatar Timo Koch Committed by Dennis Gläser
Browse files

[linear] Remove common linear solver base class. Allow individual constructors.

parent 61af9c65
......@@ -31,7 +31,6 @@
#include <dune/istl/paamg/pinfo.hh>
#include <dune/istl/solvers.hh>
#include <dumux/linear/solver.hh>
#include <dumux/linear/linearsolverproperties.hh>
#include <dumux/linear/amgproperties.hh>
#include <dumux/linear/amgparallelhelpers.hh>
......@@ -72,7 +71,7 @@ void scaleLinearSystem(Matrix& matrix, Vector& rhs)
* \brief Provides a linear solver using the ISTL AMG.
*/
template <class TypeTag>
class AMGBackend : public LinearSolver<TypeTag>
class AMGBackend
{
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Grid = typename GET_PROP_TYPE(TypeTag, Grid);
......@@ -96,8 +95,9 @@ public:
*
* \param problem the problem at hand
*/
AMGBackend(const GridView& gridView, const DofMapper& mapper)
: LinearSolver<TypeTag>(gridView, mapper)
AMGBackend(const GridView& gridView, const DofMapper& dofMapper)
: gridView_(gridView)
, dofMapper_(dofMapper)
, phelper_(gridView, mapper)
, firstCall_(true)
{}
......@@ -183,9 +183,12 @@ private:
{
LinearAlgebraPreparator<TypeTag, isParallel>
::prepareLinearAlgebra(A, b, rank, comm, fop, sp,
this->gridView(), this->dofMapper(), phelper_, firstCall_);
gridView_, dofMapper_, phelper_, firstCall_);
}
GridView gridView_;
DofMapper dofMapper_;
ParallelISTLHelper<TypeTag> phelper_;
Dune::InverseOperatorResult result_;
bool firstCall_;
......
......@@ -33,7 +33,6 @@
#include <dumux/common/parameters.hh>
#include <dumux/common/basicproperties.hh>
#include <dumux/linear/linearsolverproperties.hh>
#include <dumux/linear/solver.hh>
namespace Dumux
{
......@@ -188,12 +187,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class ILUnBiCGSTABBackend : public LinearSolver<TypeTag>
class ILUnBiCGSTABBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -229,12 +226,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class SORBiCGSTABBackend : public LinearSolver<TypeTag>
class SORBiCGSTABBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -270,12 +265,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class SSORBiCGSTABBackend : public LinearSolver<TypeTag>
class SSORBiCGSTABBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -311,12 +304,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class GSBiCGSTABBackend : public LinearSolver<TypeTag>
class GSBiCGSTABBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -351,12 +342,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class JacBiCGSTABBackend : public LinearSolver<TypeTag>
class JacBiCGSTABBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -391,12 +380,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class ILUnCGBackend : public LinearSolver<TypeTag>
class ILUnCGBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -431,12 +418,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class SORCGBackend : public LinearSolver<TypeTag>
class SORCGBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -471,12 +456,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class SSORCGBackend : public LinearSolver<TypeTag>
class SSORCGBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -511,12 +494,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class GSCGBackend : public LinearSolver<TypeTag>
class GSCGBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -550,12 +531,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class JacCGBackend : public LinearSolver<TypeTag>
class JacCGBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -591,12 +570,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class SSORRestartedGMResBackend : public LinearSolver<TypeTag>
class SSORRestartedGMResBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -631,12 +608,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class ILU0BiCGSTABBackend : public LinearSolver<TypeTag>
class ILU0BiCGSTABBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -670,12 +645,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class ILU0CGBackend : public LinearSolver<TypeTag>
class ILU0CGBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -710,12 +683,10 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class ILU0RestartedGMResBackend : public LinearSolver<TypeTag>
class ILU0RestartedGMResBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -751,13 +722,11 @@ public:
* See: Golub, G. H., and Van Loan, C. F. (2012). Matrix computations. JHU Press.
*/
template <class TypeTag>
class ILUnRestartedGMResBackend : public LinearSolver<TypeTag>
class ILUnRestartedGMResBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
enum { blockLevel = GET_PROP_VALUE(TypeTag, LinearSolverPreconditionerBlockLevel) };
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -779,13 +748,11 @@ public:
* http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
*/
template <class TypeTag>
class SuperLUBackend : public LinearSolver<TypeTag>
class SuperLUBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
enum { blockSize = GET_PROP_VALUE(TypeTag, LinearSolverBlockSize) };
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......@@ -843,13 +810,11 @@ private:
* http://faculty.cse.tamu.edu/davis/suitesparse.html
*/
template <class TypeTag>
class UMFPackBackend : public LinearSolver<TypeTag>
class UMFPackBackend
{
const std::string paramGroup = GET_PROP_VALUE(TypeTag, ModelParameterGroup);
enum { blockSize = GET_PROP_VALUE(TypeTag, LinearSolverBlockSize) };
public:
//! constructor for compatibility with parallel solvers
using LinearSolver<TypeTag>::LinearSolver;
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Dumux linear solver backend
*/
#ifndef DUMUX_SOLVER_BACKEND_HH
#define DUMUX_SOLVER_BACKEND_HH
namespace Dumux
{
namespace Properties
{
NEW_PROP_TAG(GridView);
NEW_PROP_TAG(ImplicitIsBox);
NEW_PROP_TAG(VertexMapper);
NEW_PROP_TAG(ElementMapper);
}
/*!
* \ingroup Linear
* \brief Base class for linear solvers
*/
template<class TypeTag>
class LinearSolver
{
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using DofMapper = std::conditional_t<GET_PROP_VALUE(TypeTag, ImplicitIsBox),
typename GET_PROP_TYPE(TypeTag, VertexMapper),
typename GET_PROP_TYPE(TypeTag, ElementMapper)>;
public:
LinearSolver (const GridView& gridView, const DofMapper& mapper)
: gridView_(gridView)
, mapper_(mapper)
{}
//! solve the linear system Ax = b
template<class Matrix, class Vector>
bool solve(const Matrix& A, Vector& x, const Vector& b)
{ return false; };
//! the name of the linear solver
std::string name() const
{ return "undefined solver"; }
protected:
//! the grid view for communication in parallel
const GridView& gridView() const
{ return gridView_; }
//! the dof mapper for communication in parallel
const DofMapper& dofMapper() const
{ return mapper_; }
private:
const GridView gridView_;
const DofMapper mapper_;
};
} // end namespace Dumux
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment