17 #include "../config/config.hpp"
27 class ParFiniteElementSpace;
58 PetscParVector(MPI_Comm comm, PetscInt glob_size, PetscScalar *_data,
69 bool transpose =
false,
bool allocate =
true);
75 bool allocate =
true);
89 MPI_Comm
GetComm()
const {
return PetscObjectComm((PetscObject)
x); }
95 operator Vec()
const {
return x; }
123 void Print(
const char *fname = NULL,
bool binary =
false)
const;
159 void BlockDiagonalConstructor(MPI_Comm comm, PetscInt *row_starts,
161 bool assembled, Mat *
A);
196 PetscParMatrix(MPI_Comm comm, PetscInt glob_size, PetscInt *row_starts,
205 PetscInt global_num_cols, PetscInt *row_starts,
226 {
Mult(1.0, x, 0.0, y); }
232 MPI_Comm
GetComm()
const {
return PetscObjectComm((PetscObject)
A); }
235 operator Mat()
const {
return A; }
258 PetscInt
NNZ()
const;
274 void Print(
const char *fname = NULL,
bool binary =
false)
const;
303 PetscParMatrix *
RAP(PetscParMatrix *Rt, PetscParMatrix *A, PetscParMatrix *P);
306 PetscParMatrix *
RAP(PetscParMatrix *A, PetscParMatrix *P);
313 void EliminateBC(PetscParMatrix &A, PetscParMatrix &Ae,
314 const Array<int> &ess_dof_list,
const Vector &X, Vector &B);
317 class PetscSolverMonitor;
363 void Customize(
bool customize =
true)
const;
372 operator PetscObject()
const {
return obj; }
386 const std::string &prefix = std::string());
392 const std::string &prefix = std::string());
403 operator KSP()
const {
return (KSP)
obj; }
410 PetscPCGSolver(MPI_Comm comm,
const std::string &prefix = std::string());
413 const std::string &prefix = std::string());
422 const std::string &prefix = std::string());
424 const std::string &prefix = std::string());
426 const std::string &prefix = std::string());
435 operator PC()
const {
return (PC)
obj; }
483 const std::string &prefix = std::string());
486 const std::string &prefix = std::string());
494 const std::string &prefix = std::string());
503 const std::string &prefix = std::string());
505 const std::string &prefix = std::string());
515 operator SNES()
const {
return (SNES)
obj; }
523 PetscODESolver(MPI_Comm comm,
const std::string &prefix = std::string());
528 virtual void Step(
Vector &x,
double &t,
double &dt);
529 virtual void Run(
Vector &x,
double &t,
double &dt,
double t_final);
532 operator TS()
const {
return (TS)
obj; }
549 MFEM_ABORT(
"MonitorSolution() is not implemented!")
555 MFEM_ABORT(
"MonitorResidual() is not implemented!")
561 #endif // MFEM_USE_MPI
562 #endif // MFEM_USE_PETSC
virtual void SetPreconditioner(Solver &precond)
void SetPrintLevel(int plev)
PetscParVector * B
Right-hand side and solution vector.
void Print(const char *fname=NULL, bool binary=false) const
Prints the matrix (to stdout if fname is NULL)
virtual void SetOperator(const Operator &op)
Specification of the nonlinear operator.
Abstract class for PETSc's preconditioners.
PetscParMatrix & operator+=(const PetscParMatrix &B)
PetscParVector(MPI_Comm comm, PetscInt glob_size, PetscInt *col)
Creates vector with given global size and partitioning of the columns.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
bool clcustom
Boolean to handle SetFromOptions calls.
Wrapper for PETSc's matrix class.
const Array< int > * nat_dof
Abstract class for PETSc's linear solvers.
Vec x
The actual PETSc object.
Abstract class for PETSc's solvers.
virtual void Run(Vector &x, double &t, double &dt, double t_final)
Perform time integration from time t [in] to time tf [in].
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
ParFiniteElementSpace * fespace
Base abstract class for time dependent operators.
PetscInt GetNumCols() const
Returns the local number of columns.
void Mult(double a, const Vector &x, double b, Vector &y) const
Matvec: y = a A x + b y.
PetscBDDCSolver(MPI_Comm comm, Operator &op, const PetscBDDCSolverParams &opts=PetscBDDCSolverParams(), const std::string &prefix=std::string())
virtual ~PetscSolver()
Destroy the PetscParVectors allocated (if any).
PetscNonlinearSolver(MPI_Comm comm, const std::string &prefix=std::string())
PetscInt GetGlobalNumRows() const
Returns the global number of rows.
virtual void Step(Vector &x, double &t, double &dt)
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in]...
Abstract class for solving systems of ODEs: dx/dt = f(x,t)
void Init()
Initialize with defaults. Does not initialize inherited members.
PetscPreconditioner(MPI_Comm comm, const std::string &prefix=std::string())
PetscClassId cid
The class id of the actual PETSc object.
Abstract parallel finite element space.
void SetRelTol(double tol)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
PetscPCGSolver(MPI_Comm comm, const std::string &prefix=std::string())
void Destroy()
Delete all owned data. Does not perform re-initialization with defaults.
void SetMonitor(PetscSolverMonitor *ctx)
Sets user-defined monitoring routine.
void SetMaxIter(int max_iter)
Abstract class for PETSc's ODE solvers.
Wrapper for PETSc's vector class.
void Customize(bool customize=true) const
Customize object with options set.
PetscInt M() const
Returns the global number of rows.
virtual void Mult(const Vector &b, Vector &x) const
Application of the solver.
virtual ~PetscLinearSolver()
PetscInt GetNumRows() const
Returns the local number of rows.
void Randomize(PetscInt seed)
Set random values.
void Print(const char *fname=NULL, bool binary=false) const
Prints the vector (to stdout if fname is NULL)
void EliminateBC(HypreParMatrix &A, HypreParMatrix &Ae, const Array< int > &ess_dof_list, const Vector &X, Vector &B)
void ResetArray()
Reset the PETSc Vec object to use its default data. Call this method after the use of PlaceArray()...
PetscParMatrix * Transpose(bool action=false)
Returns the transpose of the PetscParMatrix.
PetscObject obj
The actual PETSc object (KSP, PC, SNES or TS).
Abstract class for monitoring PETSc's solvers.
Auxiliary class for BDDC customization.
virtual ~PetscPreconditioner()
MPI_Comm GetComm() const
Get the associated MPI communicator.
HypreParMatrix * RAP(HypreParMatrix *A, HypreParMatrix *P)
Returns the matrix P^t * A * P.
PetscParMatrix & operator=(const PetscParMatrix &B)
virtual ~PetscParVector()
Calls PETSc's destroy function.
PetscFieldSplitSolver(MPI_Comm comm, Operator &op, const std::string &prefix=std::string())
PetscParMatrix()
Create an empty matrix to be used as a reference to an existing matrix.
Abstract class for PETSc's nonlinear solvers.
PetscLinearSolver(MPI_Comm comm, const std::string &prefix=std::string())
Wrapper for hypre's parallel vector class.
Type
Enumeration defining IDs for some classes derived from Operator.
PetscInt NNZ() const
Returns the number of nonzeros.
virtual void Mult(const Vector &b, Vector &x) const
Application of the preconditioner.
Mat A
The actual PETSc object.
PetscInt N() const
Returns the global number of columns.
PetscParVector * GetY() const
Returns the inner vector in the range of A (it creates it if needed)
void MakeWrapper(MPI_Comm comm, const Operator *op, Mat *B)
Creates a wrapper around a mfem::Operator op using PETSc's MATSHELL object and returns the Mat in B...
bool operatorset
Boolean to handle SetOperator calls.
PetscParVector * X
Auxiliary vectors for typecasting.
void MultTranspose(double a, const Vector &x, double b, Vector &y) const
Matvec transpose: y = a A^T x + b y.
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
virtual ~PetscSolverMonitor()
virtual ~PetscNonlinearSolver()
virtual ~PetscODESolver()
PetscSolver()
Construct an empty PetscSolver. Initialize protected objects to NULL.
Mat ReleaseMat(bool dereference)
Release the PETSc Mat object. If dereference is true, decrement the refcount of the Mat object...
virtual void MonitorSolution(PetscInt it, PetscReal norm, const Vector &x)
Monitor the solution vector x.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void SetSpace(ParFiniteElementSpace *fe)
MPI_Comm GetComm() const
Get the associated MPI communicator.
PetscInt GlobalSize() const
Returns the global number of rows.
const Array< int > * ess_dof
void SetAbsTol(double tol)
void EliminateRowsCols(const Array< int > &rows_cols, const HypreParVector &X, HypreParVector &B)
Eliminate rows and columns from the matrix, and rows from the vector B. Modify B with the BC values i...
PetscParVector * GetX() const
Returns the inner vector in the domain of A (it creates it if needed)
PetscParVector & operator=(PetscScalar d)
Set constant values.
PetscSolverMonitor(bool monitor_sol=false, bool monitor_res=true)
virtual void MonitorResidual(PetscInt it, PetscReal norm, const Vector &r)
Monitor the residual vector r.
void PlaceArray(PetscScalar *temp_data)
Temporarily replace the data of the PETSc Vec object. To return to the original data array...
Vector * GlobalVector() const
Returns the global vector in each processor.
PetscODESolver(MPI_Comm comm, const std::string &prefix=std::string())
PetscInt GetGlobalNumCols() const
Returns the global number of columns.
PetscSolverMonitor * monitor_ctx
Monitor context.
void SetNatBdrDofs(const Array< int > *natdofs, bool loc=false)
Specify dofs on the natural boundary.
Wrapper for hypre's ParCSR matrix class.
virtual void Mult(const Vector &b, Vector &x) const
Application of the solver.
void operator*=(double s)
Scale all entries by s: A_scaled = s*A.
void SetEssBdrDofs(const Array< int > *essdofs, bool loc=false)
Specify dofs on the essential boundary.
void ConvertOperator(MPI_Comm comm, const Operator &op, Mat *B, bool assembled)
Convert an mfem::Operator into a Mat B; op can be destroyed.
void MakeRef(const PetscParMatrix &master)
Makes this object a reference to another PetscParMatrix.
virtual ~PetscParMatrix()
Calls PETSc's destroy function.