File laplacexy.hxx

class LaplaceXY

Public Functions

LaplaceXY(Mesh *m = nullptr, Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE)

Constructor

~LaplaceXY()

Destructor

void setCoefs(const Field2D &A, const Field2D &B)

Set coefficients (A, B) in equation: Div( A * Grad_perp(x) ) + B*x = b

const Field2D solve(const Field2D &rhs, const Field2D &x0)

Solve Laplacian in X-Y

Inputs

rhs - The field to be inverted. This must be allocated and contain valid data. x0 - Initial guess at the solution. If this is unallocated then an initial guess of zero will be used.

Returns

The solution as a Field2D. On failure an exception will be raised

int precon(Vec x, Vec y)

Preconditioner function This is called by PETSc via a static function. and should not be called by external users

Preconditioner NOTE: For efficiency, this routine does not use globalIndex() in the inner loop. Instead, the indexing must be ordered in exactly the same way as in the construction of indexXY

Private Functions

int localSize()

Number of grid points on this processor

MPI_Comm communicator()

Return the communicator for XY

int globalIndex(int x, int y)

Return the global index of a local (x,y) coordinate including guard cells. Boundary cells have a global index of -1

To do this, a Field2D (indexXY) is used to store the index as a floating point number which is then rounded to an integer. Guard cells are filled by communication so no additional logic is needed in Mesh.

Private Members

PetscLib lib

Requires PETSc library.

Mat MatA

Matrix to be inverted.

Vec xs
Vec bs

Solution and RHS vectors.

KSP ksp

Krylov Subspace solver.

PC pc

Preconditioner.

Mesh *localmesh

The mesh this operates on, provides metrics and communication.

int xstart
int xend
int nloc
int nsys
Matrix<BoutReal> acoef
Matrix<BoutReal> bcoef
Matrix<BoutReal> ccoef
Matrix<BoutReal> xvals
Matrix<BoutReal> bvals
std::unique_ptr<CyclicReduce<BoutReal>> cr

Tridiagonal solver.

bool include_y_derivs
bool x_inner_dirichlet
bool x_outer_dirichlet
bool y_bndry_dirichlet
CELL_LOC location
Field2D indexXY

Global index (integer stored as BoutReal)