File petsc.hxx

Defines

OPT_SIZE

Typedefs

using BoutReal = PetscScalar
using rhsfunc = int (*)(BoutReal)

Functions

PetscErrorCode PetscMonitor(TS, PetscInt, PetscReal, Vec, void *ctx)

Monitor function called on every internal timestep.

PetscErrorCode PetscSNESMonitor(SNES, PetscInt, PetscReal, void *ctx)

Monitor function for SNES.

PetscErrorCode solver_ijacobian(TS, PetscReal, Vec, Vec, PetscReal, Mat *, Mat *, MatStructure *, void *)

Compute IJacobian = dF/dU + a dF/dUdot - a dummy matrix used for pc=none.

Variables

BoutReal simtime
struct snes_info
#include <petsc.hxx>

Data for SNES.

Public Members

PetscInt it
PetscInt linear_its
PetscReal time
PetscReal norm
class PetscSolver : public Solver

Public Functions

PetscSolver(Options *opts = nullptr)
~PetscSolver()
void setPrecon(PhysicsPrecon f)
void setJacobian(Jacobian j)

Specify a Jacobian (optional)

int init(int nout, BoutReal tstep)

Initialise the solver NOTE: nout and tstep should be passed to run, not init. Needed because of how the PETSc TS code works

PetscErrorCode run()

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(TS ts, PetscReal t, Vec globalin, Vec globalout)

Wrapper for the RHS function.

PetscErrorCode pre(PC pc, Vec x, Vec y)

Wrapper for the preconditioner.

PetscErrorCode jac(Vec x, Vec y)

Wrapper for the Jacobian function.

Public Members

PetscLogEvent solver_event
PetscLogEvent loop_event
PetscLogEvent init_event

Private Members

PhysicsPrecon prefunc

Preconditioner.

Jacobian jacfunc

Jacobian - vector function.

BoutReal shift

Shift (alpha) parameter from TS.

Vec state
BoutReal ts_time

Internal PETSc timestepper time.

PetscLib lib

Handles initialising, finalising PETSc.

Vec u

PETSc solution vector.

TS ts

PETSc timestepper object.

Mat J
Mat Jmf

RHS Jacobian.

MatFDColoring matfdcoloring
int nout

The number of outputs.

BoutReal tstep

Time between outputs.

bool diagnose

If true, print some information about current stage.

BoutReal next_output

When the monitor should be called next.

PetscBool interpolate

Whether to interpolate or not.

char output_name[PETSC_MAX_PATH_LEN]
PetscBool output_flag
PetscInt prev_linear_its
BoutReal bout_snes_time
std::vector<snes_info> snes_list
bool adaptive

Use adaptive timestepping.

Friends

PetscErrorCode PetscMonitor(TS ts, PetscInt step, PetscReal t, Vec X, void *ctx)

Monitor function called on every internal timestep.

PetscErrorCode PetscSNESMonitor(SNES snes, PetscInt its, PetscReal norm, void *ctx)

Monitor function for SNES.

PetscErrorCode solver_ijacobian(TS, PetscReal, Vec, Vec, PetscReal, Mat *, Mat *, MatStructure *, void *)

Compute IJacobian = dF/dU + a dF/dUdot - a dummy matrix used for pc=none.