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 generality, this routine does use globalIndex() in the inner loop, although this may be slightly less efficient than incrementing an integer for the global index, the finite-volume and finite-difference implementations have slightly different indexing patterns, so incrementing an integer would be tricky.

void savePerformance(Solver &solver, const std::string &name = "")#

If this method is called, save some performance monitoring information

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.

void setPreallocationFiniteVolume(PetscInt *d_nnz, PetscInt *o_nnz)#
void setPreallocationFiniteDifference(PetscInt *d_nnz, PetscInt *o_nnz)#
void setMatrixElementsFiniteVolume(const Field2D &A, const Field2D &B)#
void setMatrixElementsFiniteDifference(const Field2D &A, const Field2D &B)#
void solveFiniteVolume(const Field2D &x0)#
void solveFiniteDifference(const Field2D &x0)#

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.

std::string default_prefix#

default prefix for writing performance logging variables

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 finite_volume = {true}#
bool include_y_derivs#
bool x_inner_dirichlet#
bool x_outer_dirichlet#
std::string y_bndry = {"neumann"}#
CELL_LOC location#
Field2D indexXY#

Global index (integer stored as BoutReal)

bool save_performance = false#
BoutReal average_iterations = 0.#
BoutReal output_average_iterations = 0.#
int n_calls = 0#
LaplaceXYMonitor monitor#

Friends

friend class LaplaceXYMonitor
class LaplaceXYMonitor : public Monitor#

Public Functions

inline LaplaceXYMonitor(LaplaceXY &owner)#
int call(Solver*, BoutReal, int, int) override#
void outputVars(Options &output_options, const std::string &time_dimension) override#

Private Members

LaplaceXY &laplacexy#