Parallel Sweeping Preconditioner 0.1 documentation

The DistUniformGrid class

«  Build system   ::   Contents   ::   The DistHelmholtz class  »

The DistUniformGrid class

The purpose of this class is to provide a convenient mechanism for manipulating and visualizing scalar fields defined on three-dimensional uniform grids and distributed over large numbers of processes. The basic strategy is straightforward: given \(p\) processes and a factorization \(p_x p_y p_z = p\), grid-point \((x,y,z)\) is assigned to the process in the \((x \bmod p_x,y \bmod p_y,z \bmod p_z)\) position in the grid. By default, an XYZ lexicographical ordering is used, but any of the other five permutations may be used.

The two visualization subroutines, DistUniformGrid<F>::WritePlane() and DistUniformGrid<F>::WriteVolume(), output (parallel) VTK image files, which the author typically views using ParaView.

type enum GridDataOrder

Specifies the lexicographical order in which the data is to be stored. The choices are

  • XYZ
  • XZY
  • YXZ
  • YZX
  • ZXY
  • ZYX
type enum PlaneType

Specifies a plane type based upon the dimensions it includes. The choices are

  • XY
  • XZ
  • YZ
type class DistUniformGrid<F>
DistUniformGrid(int nx, int ny, int nz, int px, int py, int pz, mpi::Comm comm, int numScalars=1, GridDataOrder order=XYZ )

Generates an \(n_x \times n_y \times n_z\) grid, where each node contains numScalars entries of type F, and the grid is distributed over a \(p_x \times p_y \times p_z\) logical grid of processes using the specified communicator.

DistUniformGrid(int nx, int ny, int nz, mpi::Comm comm, int numScalars=1, GridDataOrder order=XYZ )

Same as above, but the 3D process grid is determined automatically.

int XSize() const

Number of grid points in \(X\) direction.

int YSize() const

Number of grid points in \(Y\) direction.

int ZSize() const

Number of grid points in \(Z\) direction.

mpi::Comm Comm() const

Communicator for the processes sharing the uniform grid.

int OwningProcess(int naturalIndex) const

The rank of the process which will own the grid point \((x,y,z)\), where naturalIndex equals \(x + y n_x + z n_x n_y\).

int OwningProcess(int x, int y, int z) const

The rank of the process which will own the grid point \((x,y,z)\).

int NumScalars() const

The number of scalar entries stored at each grid point.

int LocalIndex(int naturalIndex) const

The first local entry (assuming it exists) which stores data at the grid point with the specified natural index.

int LocalIndex(int x, int y, int z) const

The first local entry (assuming it exists) which stores data at the specified grid point.

int NaturalIndex(int x, int y, int z) const

The natural index, \(x + y n_x + z n_x n_y\), of the grid point \((x,y,z)\).

F* LocalBuffer()

A pointer to the locally-stored data.

const F* LockedLocalBuffer() const

A const pointer to the locally-stored data.

int XShift() const

The first \(X\)-coordinate which this process can store given the existing \(p_x \times p_y \times p_z\) process grid.

int YShift() const

The first \(Y\)-coordinate which this process can store given the existing \(p_x \times p_y \times p_z\) process grid.

int ZShift() const

The first \(Z\)-coordinate which this process can store given the existing \(p_x \times p_y \times p_z\) process grid.

int XStride() const

The stride between consecutive \(X\) grid points which each process would store given a sufficiently large uniform grid. This is equal to the number of processes in the \(X\) dimension, \(p_x\), of the three-dimensional process grid.

int YStride() const

The stride between consecutive \(Y\) grid points which this process would store given a sufficiently large uniform grid. This is equal to the number of processes in the \(Y\) dimension, \(p_y\), of the three-dimensional process grid.

int ZStride() const

The stride between consecutive \(Z\) grid points which this process would store given a sufficiently large uniform grid. This is equal to the number of processes in the \(Z\) dimension, \(p_z\), of the three-dimensional process grid.

XLocalSize() const

The number of \(X\) coordinates assigned to this process given the existing values of \(n_x\), the number of grid points in the \(X\) direction, and \(p_x\), the number of processes in the \(X\) direction of the logical process grid.

YLocalSize() const

The number of \(Y\) coordinates assigned to this process given the existing values of \(n_y\), the number of grid points in the \(Y\) direction, and \(p_y\), the number of processes in the \(Y\) direction of the logical process grid.

ZLocalSize() const

The number of \(Z\) coordinates assigned to this process given the existing values of \(n_z\), the number of grid points in the \(Z\) direction, and \(p_z\), the number of processes in the \(Z\) direction of the logical process grid.

GridDataOrder Order() const

The lexicographical ordering imposed on the grid points.

void SequentialLoad(std::string filename)

Each process reads in its portion of the data from the sequential data stores in the specified file. Note that the data must use the lexicographical ordering specified by DistUniformGrid<F>::Order(), and the model must be over a grid which matches that of the parent class.

void InterpolateTo(int nx, int ny, int nz)

The existing grid data is linearly interpolated into a new grid with the specified dimensions. This is particularly useful in conjunction with DistUniformGrid<F>::SequentialLoad(), as a predefined velocity model can be loaded and interpolated in parallel with two lines of code.

void WritePlane(PlaneType planeType, int whichPlane, std::string basename) const

Outputs a sequential VTK file for visualizing the grid data in the specified plane (one file for each scalar).

void WriteVolume(std::string basename) const

Outputs a parallel VTK file for visualizing the grid data over the entire volume (one set of files for each scalar).

«  Build system   ::   Contents   ::   The DistHelmholtz class  »