Loading...
Searching...
No Matches
PETScPreconditioner.h
// Copyright (C) 2010-2016 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/>.
//
// Modified by Anders Logg 2011
#ifndef __DOLFIN_PETSC_PRECONDITIONER_H
#define __DOLFIN_PETSC_PRECONDITIONER_H
#ifdef HAS_PETSC
#include <memory>
#include <string>
#include <vector>
#include <petscpc.h>
#include <dolfin/common/types.h>
#include <dolfin/common/Variable.h>
#include <dolfin/la/PETScObject.h>
#include <dolfin/parameter/Parameters.h>
namespace dolfin
{
// Forward declarations
class PETScKrylovSolver;
class PETScSNESSolver;
class VectorSpaceBasis;
class PETScPreconditioner : public PETScObject, public Variable
{
public:
static void set_type(PETScKrylovSolver& solver, std::string type);
explicit PETScPreconditioner(std::string type = "default");
virtual ~PETScPreconditioner();
virtual void set(PETScKrylovSolver& solver);
void set_coordinates(const std::vector<double>& x, std::size_t dim);
static void set_fieldsplit(PETScKrylovSolver& solver,
const std::vector<std::vector<dolfin::la_index>>& fields,
const std::vector<std::string>& split_names);
std::string str(bool verbose) const;
static std::map<std::string, std::string> preconditioners();
friend class PETScSNESSolver;
friend class PETScTAOSolver;
private:
// Named preconditioner
std::string _type;
// Available names preconditioners
static const std::map<std::string, const PCType> _methods;
// Available preconditioner descriptions
static const std::map<std::string, std::string>
_methods_descr;
// Operator row coordinates
std::vector<double> _coordinates;
// Geometric dimension associates with coordinates
std::size_t gdim;
};
}
#endif
#endif
dolfin::PETScKrylovSolver
Definition PETScKrylovSolver.h:55
dolfin::PETScObject::PETScObject
PETScObject()
Constructor. Ensures that PETSc has been initialised.
Definition PETScObject.h:38
dolfin::PETScPreconditioner::set_fieldsplit
static void set_fieldsplit(PETScKrylovSolver &solver, const std::vector< std::vector< dolfin::la_index > > &fields, const std::vector< std::string > &split_names)
Definition PETScPreconditioner.cpp:218
dolfin::PETScPreconditioner::PETScPreconditioner
PETScPreconditioner(std::string type="default")
Create a particular preconditioner object.
Definition PETScPreconditioner.cpp:117
dolfin::PETScPreconditioner::set_coordinates
void set_coordinates(const std::vector< double > &x, std::size_t dim)
Definition PETScPreconditioner.cpp:211
dolfin::PETScPreconditioner::~PETScPreconditioner
virtual ~PETScPreconditioner()
Destructor.
Definition PETScPreconditioner.cpp:131
dolfin::PETScPreconditioner::str
std::string str(bool verbose) const
Definition PETScPreconditioner.cpp:254
dolfin::PETScPreconditioner::preconditioners
static std::map< std::string, std::string > preconditioners()
Return a list of available preconditioners.
Definition PETScPreconditioner.cpp:80
dolfin::PETScPreconditioner::set_type
static void set_type(PETScKrylovSolver &solver, std::string type)
Select type by name.
Definition PETScPreconditioner.cpp:85
dolfin::PETScPreconditioner::set
virtual void set(PETScKrylovSolver &solver)
Set the preconditioner type and parameters.
Definition PETScPreconditioner.cpp:136
dolfin::PETScSNESSolver
Definition PETScSNESSolver.h:46
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin::VectorSpaceBasis
Definition VectorSpaceBasis.h:34
dolfin
Definition adapt.h:30