File cyclic_reduction.hxx

template<class T>
class CyclicReduce

Public Functions

CyclicReduce(MPI_Comm c, int size)
void setup(MPI_Comm c, int size)

Set parameters

  • c: The communicator of all processors involved in the solve
  • size: The number of rows on this processor

void setPeriodic(bool p = true)

Specify that the tridiagonal system is periodic By default not periodic

void setCoefs(const Array<T> &a, const Array<T> &b, const Array<T> &c)
void setCoefs(const Matrix<T> &a, const Matrix<T> &b, const Matrix<T> &c)

Set the entries in the matrix to be inverted

  • a: Left diagonal. Should have size [nsys][N] where N is set in the constructor or setup
  • b: Diagonal values. Should have size [nsys][N]
  • c: Right diagonal. Should have size [nsys][N]

void solve(const Array<T> &rhs, Array<T> &x)

Solve a set of tridiagonal systems

  • rhs: Array storing Values of the rhs for a single system
  • x: Array storing the result for a single system

void solve(const Matrix<T> &rhs, Matrix<T> &x)

Solve a set of tridiagonal systems

  • rhs: Matrix storing Values of the rhs for each system
  • x: Matrix storing the result for each system

Private Functions

void allocMemory(int np, int nsys, int n)

Allocate memory arrays

  • np: Number of processors
  • nsys: Number of independent systems to solve
  • n: Size of each system of equations

void reduce(int ns, int nloc, Matrix<T> &co, Matrix<T> &ifc)

Calculate interface equations

This reduces ns separate systems of equations, each consisting of nloc rows on this processor, to two interface rows for each system, which are stored in ifc.

(a1 b1 c1 ) ( a2 b2 c2 ) (A1 B1 C1 ) ( a3 b3 c3 ) => ( A2 B2 C2) ( … ) ( an bn cn)

void back_solve(int ns, int nloc, const Matrix<T> &co, const Array<T> &x1, const Array<T> &xn, Matrix<T> &xa)

Back-solve from x at ends (x1, xn) to obtain remaining values Coefficients ordered [ns, nloc*(a,b,c,r)]

Private Members

MPI_Comm comm


int nprocs = {0}
int myproc = {-1}

Number of processors and ID of my processor.

int N = {0}

Total size of the problem.

int Nsys = {0}

Number of independent systems to solve.

int myns

Number of systems for interface solve on this processor.

int sys0

Starting system index for interface solve.

bool periodic = {false}

Is the domain periodic?

Matrix<T> coefs

Starting coefficients, rhs [Nsys, {3*coef,rhs}*N].

Matrix<T> myif

Interface equations for this processor.

Matrix<T> recvbuffer

Buffer for receiving from other processors.

Matrix<T> ifcs

Coefficients for interface solve.

Matrix<T> if2x2

2x2 interface equations on this processor

Matrix<T> ifx

Solution of interface equations.

Array<T> ifp

Interface equations returned to processor p.

Array<T> x1
Array<T> xn

Interface solutions for back-solving.