MPI_mgparc
Classes | Macros | Functions
mg.h File Reference

Go to the source code of this file.

Classes

struct  PointerStruct
 
struct  ControlStruct
 

Macros

#define MAXLEVEL   20
 

Functions

void ApplyDirichletBC1 (const int nx, const int ny, const int neigh[], const double u[], double sk[], const int id[], const int ik[], double f[])
 
int AdrCRS (const int row, const int col, const int id[], const int ik[], const int nnode)
 
int AllocLevels (const int nlevels, const int nx, const int ny, PointerStruct *pp)
 
int IniLevels (const double xl, const double xr, const double yb, const double yt, const int neigh[], const int color, const int myid, const MPI::Intracomm &icomm, const int nlevels, const PointerStruct *pp)
 
int FreeLevels (const int nlevels, PointerStruct *pp)
 
int GlobalCoarse (const int neigh[], const int color, const int myid, const MPI::Intracomm &icomm, const int nlevels, PointerStruct *pp)
 
void Interpolate (const int nx, const int ny, double w[], const int nx_c, const int ny_c, const double w_c[], const int neigh[])
 
void Restrict (const int nx, const int ny, const double w[], const int nx_c, const int ny_c, double w_c[], const int neigh[])
 
void JacobiSmooth (const int nx, const int ny, const int neigh[], const int color, const int myid, const MPI::Intracomm &icomm, const double sk[], const int id[], const int ik[], const double f[], double u[], const double dd[], double aux[], const int maxiter)
 
void JacobiSolveGlob (const int myid, const MPI::Intracomm &icomm, const int nnode, const int nglob, const double sk[], const int id[], const int ik[], const int l2g[], const double f[], double u[])
 
void JacobiSolve2 (const int nx, const int ny, const int neigh[], const int color, const MPI::Intracomm &icomm, const double sk[], const int id[], const int ik[], const double f[], double u[], const double dd[], double aux[])
 
void MGM (const PointerStruct *const pp, const ControlStruct *const crtl, const int level, const int neigh[], const int color, const int myid, const MPI::Intracomm &icomm)
 
void MGMSolver (const PointerStruct *const pp, const ControlStruct *const crtl, const int level, const int neigh[], const int color, const int myid, const MPI::Intracomm &icomm)
 

Macro Definition Documentation

#define MAXLEVEL   20

Function Documentation

int AdrCRS ( const int  row,
const int  col,
const int  id[],
const int  ik[],
const int  nnode 
)

Determines for a symmetrix CSR matrix the index of element (row, col).

Parameters
[in]rowrow index
[in]colcolum index
[in]idindex vector containing the last entry in a CSR row
[in]ikcolumn index vector of CSR matrix
Returns
index of element (row, col). -1 indicates that this entry is not available.
int AllocLevels ( const int  nlevels,
const int  nx,
const int  ny,
PointerStruct pp 
)

Allocates the memory for nlevels levels for a rectangle discretized into nx x ny equidistant intervals on the coarsest grid at level 0. The geometric multigrid hierarchy assume bisection of intervals as refinement strategy.

Parameters
[in]nlevelsnumber of multigrid levels
[in]nxnumber of discretization intervals in x-direction
[in]nynumber of discretization intervals in y-direction
[out]*pppointer to the structure performing the grid management
Returns
-1 indicates an error.
void ApplyDirichletBC1 ( const int  nx,
const int  ny,
const int  neigh[],
const double  u[],
double  sk[],
const int  id[],
const int  ik[],
double  f[] 
)

Applies Dirichlet boundary conditions to symmetric CSR matrix (sk,id, ik) and right hand side f of a system of equations resulting from a FEM/FDM discretization. This is a special version function ApplyDirichletBC for parallel matrix generation taking into account distributed matrix and distributed rhs.

See also
ApplyDirichletBC
Parameters
[in]nxnumber of discretization intervals in x-direction
[in]nynumber of discretization intervals in y-direction
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a boundary in this direction
[in]ulocal vector with appropriately initialized b.c.
[in,out]skvector non-zero entries of CSR matrix
[in]idindex vector containing the last entry in a CSR row
[in]ikcolumn index vector of CSR matrix
[in,out]fright hand side
int FreeLevels ( const int  nlevels,
PointerStruct pp 
)

Frees the memory allocated for the multigrid hierarchy.

Parameters
[in]nlevelsnumber of multigrid levels
[out]*pppointer to the structure performing the grid management
Returns
-1 indicates an error.
See also
AllocLevels
int GlobalCoarse ( const int  neigh[],
const int  color,
const int  myid,
const MPI::Intracomm &  icomm,
const int  nlevels,
PointerStruct pp 
)

Creates a global coarse grid system with an accumulated sparse matrix on this discretization.

Parameters
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a boundary in this direction
[in]colorred/black coloring of subdomains (0/1)
[in]myidmy rank
[in]icommcommunicator
[in]nlevelsnumber of multigrid levels
[out]*pppointer to the structure performing the grid management
Returns
-1 indicates an error.
See also
AllocLevels
int IniLevels ( const double  xl,
const double  xr,
const double  yb,
const double  yt,
const int  neigh[],
const int  color,
const int  myid,
const MPI::Intracomm &  icomm,
const int  nlevels,
const PointerStruct pp 
)

Inializes the stiffness matrix, right hand side, and boundary conditions for the discretization on level nlevels in the domain [xl, xr] x [yb, yt].

memory for nlevels levels for a rectangle discretized into nx x ny equidistant intervals on the coarsest grid at level 0. The geometric multigrid hierarchy assume bisection of intervals as refinement strategy.

Parameters
[in]xlx-coordinate of left boundary
[in]xrx-coordinate of right boundary
[in]yby-coordinate of lower boundary
[in]yty-coordinate of upper boundary
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a boundary in this direction
[in]colorred/black coloring of subdomains (0/1)
[in]myidmy rank
[in]icommcommunicator
[in]nlevelsnumber of multigrid levels
[in]*pppointer to the structure performing the grid management
Returns
-1 indicates an error.
void Interpolate ( const int  nx,
const int  ny,
double  w[],
const int  nx_c,
const int  ny_c,
const double  w_c[],
const int  neigh[] 
)

Bilinear interpolation of a coarse grid vector w_c onto a fine grid vector w. The underlying discretization is a tensor product grid.

Parameters
[in]nxnumber of fine grid intervals in x-direction
[in]nynumber of fine grid intervals in y-direction
[out]winterpolated vector on fine grid
[in]nx_cnumber of fine grid intervals in x-direction
[in]ny_cnumber of fine grid intervals in y-direction
[in]w_coriginal vector on coarse grid
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a Dirichlet boundary in this direction. Use other negative values for Neumann boundary
void JacobiSmooth ( const int  nx,
const int  ny,
const int  neigh[],
const int  color,
const int  myid,
const MPI::Intracomm &  icomm,
const double  sk[],
const int  id[],
const int  ik[],
const double  f[],
double  u[],
const double  dd[],
double  aux[],
const int  maxiter 
)

Iterates maxiter with the linear system of equations K u = f via the Jacobi iteration. We use a distributed symmetric CSR matrix K(sk,id, ik).

Parameters
[in]nxnumber of discretization intervals in x-direction
[in]nynumber of discretization intervals in y-direction
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a boundary in this direction
[in]colorred/black coloring of subdomains (0/1)
[in]myidrank of my process
[in]icommcommunicator
[in]skvector non-zero entries of CSR matrix
[in]idindex vector containing the last entry in a CSR row
[in]ikcolumn index vector of CSR matrix
[in]fdistributed local vector storing the right hand side
[in,out]uaccumulated local vector storing the solution.
[in]ddaccumualted diagonal of striffness matrix
[out]auxauxilliary vector used for the intermediate residuum in the iteration
[in]maxiternumber of iterations / smoothing weeps
void JacobiSolve2 ( const int  nx,
const int  ny,
const int  neigh[],
const int  color,
const MPI::Intracomm &  icomm,
const double  sk[],
const int  id[],
const int  ik[],
const double  f[],
double  u[],
const double  dd[],
double  aux[] 
)

Solves the global parallel system with Jacobi iterations until a predefined accuracy is reached. We use a distributed symmetric CSR matrix K(sk,id, ik).

Parameters
[in]nxnumber of discretization intervals in x-direction
[in]nynumber of discretization intervals in y-direction
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a boundary in this direction
[in]colorred/black coloring of subdomains (0/1)
[in]icommcommunicator
[in]skvector non-zero entries of CSR matrix
[in]idindex vector containing the last entry in a CSR row
[in]ikcolumn index vector of CSR matrix
[in]fdistributed local vector storing the right hand side
[in,out]uaccumulated local vector storing the solution.
[in]ddaccumualted diagonal of striffness matrix
[out]auxauxilliary vector used for the intermediate residuum in the iteration
void JacobiSolveGlob ( const int  myid,
const MPI::Intracomm &  icomm,
const int  nnode,
const int  nglob,
const double  sk[],
const int  id[],
const int  ik[],
const int  l2g[],
const double  f[],
double  u[] 
)

Solves the global parallel system with Jacobi iterations until a predefined accuracy is reached. We use a distributed symmetric CSR matrix K(sk,id, ik).

Parameters
[in]myidrank of my process
[in]icommcommunicator
[in]nloclocal number of unknowns
[in]nglobglobal number of unknowns
[in]skvector non-zero entries of CSR matrix
[in]idindex vector containing the last entry in a CSR row
[in]ikcolumn index vector of CSR matrix
[in]l2gindex vector containing global indices of local degrees of freedom
[in]fdistributed local vector storing the right hand side
[out]uaccumulated local vector storing the solution.
void MGM ( const PointerStruct *const  pp,
const ControlStruct *const  crtl,
const int  level,
const int  neigh[],
const int  color,
const int  myid,
const MPI::Intracomm &  icomm 
)
void MGMSolver ( const PointerStruct *const  pp,
const ControlStruct *const  crtl,
const int  level,
const int  neigh[],
const int  color,
const int  myid,
const MPI::Intracomm &  icomm 
)
void Restrict ( const int  nx,
const int  ny,
const double  w[],
const int  nx_c,
const int  ny_c,
double  w_c[],
const int  neigh[] 
)

Bilinear restriction of a fine grid vector w onto a coarse grid vector w_c. The underlying discretization is a tensor product grid.

Parameters
[in]nxnumber of fine grid intervals in x-direction
[in]nynumber of fine grid intervals in y-direction
[in]winterpolated vector on fine grid
[in]nx_cnumber of fine grid intervals in x-direction
[in]ny_cnumber of fine grid intervals in y-direction
[out]w_coriginal vector on coarse grid
[in]neighvector of 4 elements containing the ranks of neighbouring processes, -1 indicates a Dirichlet boundary in this direction. Use other negative values for Neumann boundary
See also
Interpolate