File petsc_laplace.hxx#

Perpendicular Laplacian inversion using PETSc Solvers

Equation solved is:

\[ d\nabla^2_\perp x + (1/c1)\nabla_perp c2\cdot\nabla_\perp x + ex\nabla_x x + ez\nabla_z x + a x = b \]

class LaplacePetsc : public Laplacian#

Public Functions

LaplacePetsc(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr, Solver *solver = nullptr)#
inline ~LaplacePetsc()#
inline virtual void setCoefA(const Field2D &val) override#

Set coefficients for inversion. Re-builds matrices if necessary.

inline virtual void setCoefC(const Field2D &val) override#
inline virtual void setCoefC1(const Field2D &val) override#
inline virtual void setCoefC2(const Field2D &val) override#
inline virtual void setCoefD(const Field2D &val) override#
inline virtual void setCoefEx(const Field2D &val) override#
inline virtual void setCoefEz(const Field2D &val) override#
inline virtual void setCoefA(const Field3D &val) override#
inline virtual void setCoefC(const Field3D &val) override#
inline virtual void setCoefC1(const Field3D &val) override#
inline virtual void setCoefC2(const Field3D &val) override#
inline virtual void setCoefD(const Field3D &val) override#
inline virtual void setCoefEx(const Field3D &val) override#
inline virtual void setCoefEz(const Field3D &val) override#
virtual FieldPerp solve(const FieldPerp &b) override#
virtual FieldPerp solve(const FieldPerp &b, const FieldPerp &x0) override#
int precon(Vec x, Vec y)#

Preconditioner function.

void setCoefA(const Field2D &val) = 0

Set coefficients for inversion. Re-builds matrices if necessary.

inline void setCoefA(const Field3D &val)
inline void setCoefA(BoutReal r)#
void setCoefC(const Field2D &val) = 0
inline void setCoefC(const Field3D &val)
inline void setCoefC(BoutReal r)#
inline void setCoefC1(const Field2D &val)
inline void setCoefC1(const Field3D &val)
inline void setCoefC1(BoutReal r)#
inline void setCoefC2(const Field2D &val)
inline void setCoefC2(const Field3D &val)
inline void setCoefC2(BoutReal r)#
void setCoefD(const Field2D &val) = 0
inline void setCoefD(const Field3D &val)
inline void setCoefD(BoutReal r)#
void setCoefEx(const Field2D &val) = 0
inline void setCoefEx(const Field3D &val)
inline void setCoefEx(BoutReal r)#
void setCoefEz(const Field2D &val) = 0
inline void setCoefEz(const Field3D &val)
inline void setCoefEz(BoutReal r)#
FieldPerp solve(const FieldPerp &b) = 0
Field3D solve(const Field3D &b)#
Field2D solve(const Field2D &b)#
inline FieldPerp solve(const FieldPerp &b, const FieldPerp &x0)
Field3D solve(const Field3D &b, const Field3D &x0)#
Field2D solve(const Field2D &b, const Field2D &x0)#

Private Functions

void Element(int i, int x, int z, int xshift, int zshift, PetscScalar ele, Mat &MatA)#
void Coeffs(int x, int y, int z, BoutReal &A1, BoutReal &A2, BoutReal &A3, BoutReal &A4, BoutReal &A5)#
void vecToField(Vec x, FieldPerp &f)#
void fieldToVec(const FieldPerp &f, Vec x)#
void checkFlags()#

Private Members

Field3D A#
Field3D C1#
Field3D C2#
Field3D D#
Field3D Ex#
Field3D Ez#
bool issetD#
bool issetC#
bool issetE#
FieldPerp sol#
int Istart#
int Iend#
int meshx#
int meshz#
int size#
int localN#
MPI_Comm comm#
Mat MatA#
Vec xs#
Vec bs#
KSP ksp#
Options *opts#
std::string ksptype#

KSP solver type.

std::string pctype#

Preconditioner type.

BoutReal richardson_damping_factor#
BoutReal chebyshev_max#
BoutReal chebyshev_min#
int gmres_max_steps#
BoutReal rtol#
BoutReal atol#
BoutReal dtol#
int maxits#
bool direct#
bool fourth_order#
PetscLib lib#
bool rightprec#
std::unique_ptr<Laplacian> pcsolve#

Private Static Attributes

static constexpr int implemented_flags = INVERT_START_NEW#
static constexpr int implemented_boundary_flags = INVERT_AC_GRAD | INVERT_SET | INVERT_RHS#