File petsc.hxx#

class PetscSolver : public Solver#

Public Functions

PetscSolver(Options *opts = nullptr)#
~PetscSolver()#
virtual int init() override#

Initialise the solver.

virtual int run() override#

Run the solver, calling monitors nout times, at intervals of tstep. This function is called by solve(), and is specific to each solver type

This should probably be protected, since it shouldn’t be called by users.

PetscErrorCode rhs(BoutReal t, Vec udata, Vec dudata, bool linear)#

Wrapper for the RHS function.

PetscErrorCode formFunction(Vec U, Vec F)#

Residual calculation.

PetscErrorCode pre(Vec x, Vec y)#

Wrapper for the preconditioner.

Private Functions

void updateColoring()#

Updates the coloring using Jfd.

Private Members

BoutReal shift#

Shift (alpha) parameter from TS.

Vec state#
BoutReal ts_time#

Internal PETSc timestepper time.

PetscLib lib#

Handles initialising, finalising PETSc.

Vec u = {nullptr}#

PETSc solution vector.

TS ts = {nullptr}#

PETSc timestepper object.

SNES snes = {nullptr}#

PETSc nonlinear solver object.

KSP ksp = {nullptr}#

PETSc linear solver.

Mat Jmf = {nullptr}#

Matrix Free Jacobian.

Mat Jfd = {nullptr}#

Finite Difference Jacobian.

MatFDColoring fdcoloring = {nullptr}#

Matrix coloring context.

BoutReal next_output#

When the monitor should be called next.

bool interpolate#

Interpolate to regular times?

bool diagnose#

If true, print some information about current stage.

bool user_precon#

Use user-supplied preconditioning function?

BoutReal atol#

Absolute tolerance.

BoutReal rtol#

Relative tolerance.

BoutReal stol#

Convergence tolerance.

int maxnl#

Maximum nonlinear iterations per SNES solve.

int maxf#

Maximum number of function evaluations allowed in the solver (default: 10000)

int maxl#

Maximum linear iterations.

std::string ts_type#

PETSc TS time solver type.

std::string adapt_type#

TSAdaptType timestep adaptation.

std::string snes_type#

PETSc SNES nonlinear solver type.

std::string ksp_type#

PETSc KSP linear solver type.

std::string pc_type#

Preconditioner type.

std::string pc_hypre_type#

Hypre preconditioner type.

std::string line_search_type#

Line search type.

bool matrix_free#

Use matrix free Jacobian.

bool matrix_free_operator#

Use matrix free Jacobian in the operator?

int lag_jacobian#

Re-use Jacobian.

bool use_coloring#

Use matrix coloring.

bool kspsetinitialguessnonzero#

Set initial guess to non-zero.

BoutReal start_timestep#
int mxstep#

Friends

friend PetscErrorCode PetscMonitor(TS, PetscInt, PetscReal, Vec, void *ctx)#
friend PetscErrorCode solver_ijacobian(TS, BoutReal, Vec, Vec, PetscReal shift, Mat J, Mat Jpre, void *ctx)#
friend PetscErrorCode solver_ijacobian_color(TS ts, PetscReal t, Vec U, Vec Udot, PetscReal shift, Mat J, Mat B, void *ctx)#