File petsc_laplace.hxx¶
-
class
LaplacePetsc
: public Laplacian¶ Public Functions
-
LaplacePetsc
(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr)¶
-
~LaplacePetsc
()¶
-
FieldPerp
solve
(const FieldPerp &b, const FieldPerp &x0)¶ Solves Ax=b for x given a b and an initial guess for x (x0)
This function will:
- Set the matrix element of the matrix A, used to solve Ax=b (this includes setting the values for the bounary condition)
- Solve the matrix Ax = b
- Return
- sol The solution x of the problem Ax=b.
- Parameters
b
: The RHS of the equation Ax=b. This is an y-slice of the original field. The field wil be flattened to an 1D array in order to write the equation on the form Ax=bx0
: The initial guess for the solver. May also contain the boundary condition if flag 32 - INVERT_SET is set
-
int
precon
(Vec x, Vec y)¶ Preconditioner function.
Private Functions
-
void
Element
(int i, int x, int z, int xshift, int zshift, PetscScalar ele, Mat &MatA)¶ Sets the elements of the matrix A, which is used to solve the problem Ax=b.
- Parameters
i
: The row of the PETSc matrixx
: Local x index of the meshz
: Local z index of the meshxshift
: The shift in rows from the index xzshift
: The shift in columns from the index zele
: Value of the elementMatA
: The matrix A used in the inversionMatA
: The matrix A used in the inversion
-
void
Coeffs
(int x, int y, int z, BoutReal &A1, BoutReal &A2, BoutReal &A3, BoutReal &A4, BoutReal &A5)¶ Set the matrix components of A in Ax=b, solving D*Laplace_perp(x) + (1/C1)Grad_perp(C2)*Grad_perp(x) + Ax = B
- Note
- ”A” in the equation above is not added here. For calculations of the coefficients, please refer to the user manual.
- Parameters
x
: The current x indexy
: The current y indexz
: The current y indexcoef1
: Placeholder for convenient variable used to set matrix (see manual for details)coef2
: Convenient variable used to set matrix (see manual for details)coef3
: Placeholder for convenient variable used to set matrix (see manual for details)coef4
: Placeholder for convenient variable used to set matrix (see manual for details)coef5
: Placeholder for convenient variable used to set matrix (see manual for details)coef1
: Convenient variable used to set matrix (see manual for details)coef2
: Convenient variable used to set matrix (see manual for details)coef3
: Convenient variable used to set matrix (see manual for details)coef4
: Convenient variable used to set matrix (see manual for details)coef5
: Convenient variable used to set matrix (see manual for details)
Private Members
-
bool
issetD
¶
-
bool
issetC
¶
-
bool
issetE
¶
-
int
lastflag
¶
-
int
Istart
¶
-
int
Iend
¶
-
int
meshx
¶
-
int
meshz
¶
-
int
size
¶
-
int
localN
¶
-
MPI_Comm
comm
¶
-
Mat
MatA
¶
-
Vec
xs
¶
-
Vec
bs
¶
-
KSP
ksp
¶
-
std::string
ksptype
¶ KSP solver type.
-
std::string
pctype
¶ Preconditioner type.
-
int
gmres_max_steps
¶
-
int
maxits
¶
-
bool
direct
¶
-
bool
fourth_order
¶
-
bool
use_precon
¶
-
bool
rightprec
¶
-
int
implemented_flags
¶
-
int
implemented_boundary_flags
¶
-