File pcr.hxx

class LaplacePCR : public Laplacian

Public Functions

LaplacePCR(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr, Solver *solver = nullptr, Datafile *dump = nullptr)
~LaplacePCR() = default
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 FieldPerp solve(const FieldPerp &b) override
virtual FieldPerp solve(const FieldPerp &rhs, const FieldPerp &x0) override
inline virtual Field3D solve(const Field3D &b) override
virtual Field3D solve(const Field3D &rhs, const Field3D &x0) override

Performs the laplacian inversion y-slice by y-slice

Parameters
  • b[in] All the y-slices of b_slice, which is the right hand side of the equation A*x_slice = b_slice

  • x0[in] All the y-slices of the variable eventually used to set BC

Returns

x All the y-slices of x_slice in the equation A*x_slice = b_slice

void cr_solver(double *a_mpi, double *b_mpi, double *c_mpi, double *r_mpi, double *x_mpi)
void cr_pcr_solver(Matrix<dcomplex> &a_mpi, Matrix<dcomplex> &b_mpi, Matrix<dcomplex> &c_mpi, Matrix<dcomplex> &r_mpi, Matrix<dcomplex> &x_mpi)

CR-PCR solver: cr_forward_multiple + pcr_forward_single + cr_backward_multiple.

Parameters
  • a_mpi – (input) Lower off-diagonal coeff., which is assigned to local private pointer a

  • b_mpi – (input) Diagonal coeff., which is assigned to local private pointer b

  • c_mpi – (input) Upper off-diagonal coeff.,, which is assigned to local private pointer c

  • r_mpi – (input) RHS vector, which is assigned to local private pointer r

  • x_mpi – (output) Solution vector, which is assigned to local private pointer x

void Thomas_pcr_solver(double *a_mpi, double *b_mpi, double *c_mpi, double *r_mpi, double *x_mpi)
void verify_solution(double *a_ver, double *b_ver, double *c_ver, double *r_ver, double *x_sol)

Private Functions

void cr_forward_multiple_row(Matrix<dcomplex> &a, Matrix<dcomplex> &b, Matrix<dcomplex> &c, Matrix<dcomplex> &r) const

Forward elimination of CR until a single row per MPI process remains.

After a single row per MPI process remains, PCR or CR between a single row is performed.

void cr_backward_multiple_row(Matrix<dcomplex> &a, Matrix<dcomplex> &b, Matrix<dcomplex> &c, Matrix<dcomplex> &r, Matrix<dcomplex> &x) const

Backward substitution of CR after single-row solution per MPI process is obtained.

void apply_boundary_conditions(const Matrix<dcomplex> &a, const Matrix<dcomplex> &b, const Matrix<dcomplex> &c, const Matrix<dcomplex> &r, Matrix<dcomplex> &x)

Apply the boundary conditions on the first and last X processors

void eliminate_boundary_rows(Matrix<dcomplex> &a, Matrix<dcomplex> &b, Matrix<dcomplex> &c, Matrix<dcomplex> &r)

Eliminate boundary rows - perform row elimination to uncouple the first and last interior rows from their respective boundary rows. This is necessary to ensure we pass a square system of interior rows to the PCR library.

void cr_forward_single_row()
void cr_backward_single_row()
void pcr_forward_single_row(Matrix<dcomplex> &a, Matrix<dcomplex> &b, Matrix<dcomplex> &c, Matrix<dcomplex> &r, Matrix<dcomplex> &x) const

PCR between a single row per MPI process and 2x2 matrix solver between i and i+nprocs/2 rows.

void verify_solution(const Matrix<dcomplex> &a_ver, const Matrix<dcomplex> &b_ver, const Matrix<dcomplex> &c_ver, const Matrix<dcomplex> &r_ver, const Matrix<dcomplex> &x_sol) const

Solution check.

Parameters
  • *a_ver – Coefficients of a with original values

  • *b_ver – Coefficients of b with original values

  • *c_ver – Coefficients of c with original values

  • *r_ver – RHS vector with original values

  • *x_sol – Solution vector

inline bool isGlobalFlagSet(int flag) const
inline bool isInnerBoundaryFlagSet(int flag) const
inline bool isOuterBoundaryFlagSet(int flag) const

Private Members

Field2D Acoef
Field2D C1coef
Field2D C2coef
Field2D Dcoef
Matrix<dcomplex> bcmplx
Matrix<dcomplex> xcmplx
int n_mpi

Number of rows per MPI process and should be 2^n.

int nprocs

Number of MPI process and should be also 2^m.

int myrank

MPI process ID.

int xproc

MPI process x ID.

int inbndry

Number of inner boundary cells.

int outbndry

Number of outer boundary cells.

Matrix<dcomplex> a

Local private pointer for coefficient maxtix a.

Matrix<dcomplex> aa
Matrix<dcomplex> b

Local private pointer for coefficient maxtix b.

Matrix<dcomplex> bb
Matrix<dcomplex> c

Local private pointer for coefficient maxtix c.

Matrix<dcomplex> cc
Matrix<dcomplex> r

Local private pointer for RHS vector r.

Matrix<dcomplex> x

Local private pointer for solution vector x.

int nmode

Number of unfiltered Fourier modes.

int nsys = {}

Number of systems to solve = number of unfiltered Fourier modes times number of y points

int ncx

Number of local x, y points.

int ny
Tensor<dcomplex> avec

Lower-, on- and upper-diagonal terms of the operator matrix.

Tensor<dcomplex> bvec
Tensor<dcomplex> cvec
int ncalls = {0}

Counter for the number of times the solver has been called.

int xs

First and last interior points xstart, xend.

int xe
bool dst = {false}