Loading...
Searching...
No Matches
PETScLUSolver.h
// Copyright (C) 2005-2017 Anders Logg and Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
#ifndef __DOLFIN_PETSC_LU_SOLVER_H
#define __DOLFIN_PETSC_LU_SOLVER_H
#ifdef HAS_PETSC
#if PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR <= 8 && PETSC_VERSION_RELEASE == 1
#define MatSolverType MatSolverPackage
#define PCFactorGetMatSolverType PCFactorGetMatSolverPackage
#define PCFactorSetMatSolverType PCFactorSetMatSolverPackage
#endif
#include <map>
#include <memory>
#include <string>
#include <petscmat.h>
#include <petscpc.h>
#include <dolfin/common/MPI.h>
#include "PETScKrylovSolver.h"
namespace dolfin
{
class GenericLinearOperator;
class GenericVector;
class PETScLinearOperator;
class PETScMatrix;
class PETScVector;
class PETScLUSolver : public GenericLinearSolver
{
public:
PETScLUSolver(MPI_Comm comm, std::string method="default");
PETScLUSolver(std::string method="default");
PETScLUSolver(MPI_Comm comm,
std::shared_ptr<const PETScMatrix> A,
std::string method="default");
PETScLUSolver(std::shared_ptr<const PETScMatrix> A,
std::string method="default");
~PETScLUSolver();
void set_operator(std::shared_ptr<const GenericLinearOperator> A);
void set_operator(const PETScMatrix& A);
std::size_t solve(GenericVector& x, const GenericVector& b);
std::size_t solve(GenericVector& x, const GenericVector& b,
bool transpose);
std::size_t solve(const GenericLinearOperator& A, GenericVector& x,
const GenericVector& b);
std::size_t solve(const PETScMatrix& A, PETScVector& x,
const PETScVector& b);
void set_options_prefix(std::string options_prefix);
std::string get_options_prefix() const;
void set_from_options() const;
MPI_Comm mpi_comm() const;
std::string str(bool verbose) const;
KSP ksp() const;
static std::map<std::string, std::string> methods();
static Parameters default_parameters();
std::string parameter_type() const
{ return "lu_solver"; }
// FIXME: These should not be friend classes
friend class PETScSNESSolver;
friend class PETScTAOSolver;
private:
// FIXME: Remove
// Available LU solvers
static std::map<std::string, const MatSolverType> lumethods;
// Select LU solver type
static const MatSolverType select_solver(MPI_Comm comm,
std::string method);
PETScKrylovSolver _solver;
};
}
#endif
#endif
dolfin::GenericLinearOperator
Definition GenericLinearOperator.h:43
dolfin::GenericLinearSolver
This class provides a general solver for linear systems Ax = b.
Definition GenericLinearSolver.h:38
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::PETScKrylovSolver
Definition PETScKrylovSolver.h:55
dolfin::PETScLUSolver::get_options_prefix
std::string get_options_prefix() const
Definition PETScLUSolver.cpp:277
dolfin::PETScLUSolver::methods
static std::map< std::string, std::string > methods()
Return a list of available solver methods.
Definition PETScLUSolver.cpp:116
dolfin::PETScLUSolver::set_from_options
void set_from_options() const
Set options from the PETSc options database.
Definition PETScLUSolver.cpp:282
dolfin::PETScLUSolver::PETScLUSolver
PETScLUSolver(MPI_Comm comm, std::string method="default")
Constructor.
Definition PETScLUSolver.cpp:129
dolfin::PETScLUSolver::parameter_type
std::string parameter_type() const
Return parameter type: "krylov_solver" or "lu_solver".
Definition PETScLUSolver.h:121
dolfin::PETScLUSolver::mpi_comm
MPI_Comm mpi_comm() const
Returns the MPI communicator.
Definition PETScLUSolver.cpp:287
dolfin::PETScLUSolver::solve
std::size_t solve(GenericVector &x, const GenericVector &b)
Solve linear system Ax = b.
Definition PETScLUSolver.cpp:229
dolfin::PETScLUSolver::ksp
KSP ksp() const
Return PETSc KSP pointer.
Definition PETScLUSolver.cpp:308
dolfin::PETScLUSolver::set_operator
void set_operator(std::shared_ptr< const GenericLinearOperator > A)
Set operator (matrix).
Definition PETScLUSolver.cpp:219
dolfin::PETScLUSolver::~PETScLUSolver
~PETScLUSolver()
Destructor.
Definition PETScLUSolver.cpp:213
dolfin::PETScLUSolver::str
std::string str(bool verbose) const
Return informal string representation (pretty-print).
Definition PETScLUSolver.cpp:292
dolfin::PETScLUSolver::default_parameters
static Parameters default_parameters()
Default parameter values.
Definition PETScLUSolver.cpp:121
dolfin::PETScLUSolver::set_options_prefix
void set_options_prefix(std::string options_prefix)
Definition PETScLUSolver.cpp:272
dolfin::PETScLinearOperator
PETSc version of the GenericLinearOperator.
Definition PETScLinearOperator.h:46
dolfin::PETScMatrix
Definition PETScMatrix.h:59
dolfin::PETScSNESSolver
Definition PETScSNESSolver.h:46
dolfin::PETScTAOSolver
Definition PETScTAOSolver.h:52
dolfin::PETScVector
Definition PETScVector.h:61
dolfin::Parameters
Definition Parameters.h:95
dolfin
Definition adapt.h:30