HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
MPILocalDomainLimits.c File Reference

Compute local domain limites of a MPI rank. More...

#include <stdlib.h>
#include <basic.h>
#include <mpivars.h>

Go to the source code of this file.

Functions

int MPILocalDomainLimits (int ndims, int p, void *m, int *dim_global, int *is, int *ie)
 

Detailed Description

Compute local domain limites of a MPI rank.

Author
Debojyoti Ghosh

Definition in file MPILocalDomainLimits.c.

Function Documentation

◆ MPILocalDomainLimits()

int MPILocalDomainLimits ( int  ndims,
int  p,
void *  m,
int *  dim_global,
int *  is,
int *  ie 
)

Computes the local domain limites: Given a MPI rank p, this function will compute the starting and ending indices of the local domain on this rank. These indices are global.

  • The starting and ending indices are stored in preallocated integer arrays, whose elements are these indices in each spatial dimension.
  • The ending index is 1 + actual last index; thus the one can write the loop as (i=start; i<end; i++) and not (i=start; i<=end; i++).
Parameters
ndimsNumber of spatial dimensions
pMPI rank
mMPI object of type MPIVariables
dim_globalInteger array with elements as global size in each spatial dimension
isInteger array whose elements will contain the starting index of the local domain on rank p
ieInteger array whose elements will contain the ending index of the local domain on rank p

Definition at line 18 of file MPILocalDomainLimits.c.

26 {
27  MPIVariables *mpi = (MPIVariables*) m;
28  int i;
30 
31  int ip[ndims];
32  IERR MPIRanknD(ndims,p,mpi->iproc,ip); CHECKERR(ierr);
33 
34  for (i=0; i<ndims; i++) {
35  int imax_local, isize, root = 0;
36  imax_local = MPIPartition1D(dim_global[i],mpi->iproc[i],root );
37  isize = MPIPartition1D(dim_global[i],mpi->iproc[i],ip[i]);
38  if (is) is[i] = ip[i]*imax_local;
39  if (ie) ie[i] = ip[i]*imax_local + isize;
40  }
41  return(0);
42 }
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
int MPIPartition1D(int, int, int)
Structure of MPI-related variables.
int MPIRanknD(int, int, int *, int *)
Definition: MPIRanknD.c:27
#define _DECLARE_IERR_
Definition: basic.h:17