19 #ifndef LA_LINSYS_PETSC_HH_
20 #define LA_LINSYS_PETSC_HH_
28 #include "petscmath.h"
59 void set_tolerances(
double r_tol,
double a_tol,
double d_tol,
unsigned int max_it)
override;
79 PetscErrorCode
set_matrix(Mat &matrix, MatStructure str)
override
82 return MatCopy(matrix,
matrix_, str);
88 return VecCopy(rhs,
rhs_);
101 return VecSet(
rhs_, 0);
135 void view(
string text=
"")
override;
165 return static_cast<double>(
arg );
unsigned int size() const
void finish_assembly() override
void start_add_assembly() override
void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals) override
PetscErrorCode set_rhs(Vec &rhs) override
void apply_constrains(double scalar=1.) override
double compute_residual() override
const Distribution * get_ds()
Mat matrix_
Petsc matrix of the problem.
void preallocate_matrix()
LinSys::SolveInfo solve() override
double solution_precision_
void preallocate_values(int nrow, int *rows, int ncol, int *cols)
bool init_guess_nonzero
flag for starting from nonzero guess
void start_insert_assembly() override
void set_from_input(const Input::Record in_rec) override
static const Input::Type::Record & get_input_type()
void set_initial_guess_nonzero(bool set_nonzero=true)
std::string params_
command-line-like options for the PETSc solver
LinSys_PETSC(const Distribution *rows_ds, const std::string ¶ms="")
KSPConvergedReason reason
PetscErrorCode set_matrix(Mat &matrix, MatStructure str) override
PetscErrorCode mat_zero_entries() override
PetscErrorCode rhs_zero_entries() override
static const int registrar
Registrar of class to factory.
double get_absolute_accuracy() override
Vec rhs_
PETSc vector constructed with vx array.
Vec off_vec_
Vectors for counting non-zero entries in off-diagonal block.
Vec on_vec_
Vectors for counting non-zero entries in diagonal block.
const Mat * get_matrix() override
T * makePetscPointer_(std::vector< T > &array)
void view(string text="") override
void rhs_set_values(int nrow, int *rows, double *vals) override
double * v_rhs_
local RHS array pointing to Vec rhs_
void start_allocation() override
double get_solution_precision() override
const Vec * get_rhs() override
void set_tolerances(double r_tol, double a_tol, double d_tol, unsigned int max_it) override
ConstraintVec_ constraints_
double a_tol_
absolute tolerance of linear solver
const Distribution * rows_ds_
final distribution of rows of MH matrix
bool matrix_changed_
true if the matrix was changed since the last solve
bool rhs_changed_
true if the right hand side was changed since the last solve
Wrappers for linear systems based on MPIAIJ and MATIS format.
internal::NamedArg< char > arg(StringRef name, const T &arg)
double operator()(PetscScalar arg)