HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BCPeriodic.c
Go to the documentation of this file.
1 
5 #include <stdlib.h>
6 #include <basic.h>
7 #include <arrayfunctions.h>
8 #include <mpivars.h>
9 #include <boundaryconditions.h>
10 
20  void *b,
21  void *m,
22  int ndims,
23  int nvars,
24  int *size,
25  int ghosts,
26  double *phi,
27  double waqt
28  )
29 {
30  DomainBoundary *boundary = (DomainBoundary*) b;
31  MPIVariables *mpi = (MPIVariables*) m;
32 
33  int dim = boundary->dim;
34  int face = boundary->face;
35 
36  if ((boundary->on_this_proc) && (mpi->iproc[dim] == 1)) {
37  int bounds[ndims], index1[ndims], index2[ndims];
38  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
39  _ArraySetValue_(index1,ndims,0);
40  _ArraySetValue_(index2,ndims,0);
41  int done = 0;
42  while (!done) {
43  int p1 = 0, p2 = 0;
44  _ArrayCopy1D_(index1,index2,ndims);
45  if (face == 1) {
46  index2[dim] = index1[dim] + size[dim]-ghosts;
47  _ArrayIndex1DWO_(ndims,size,index1,boundary->is,ghosts,p1);
48  _ArrayIndex1D_(ndims,size,index2,ghosts,p2);
49  } else if (face == -1) {
50  _ArrayIndex1DWO_(ndims,size,index1,boundary->is,ghosts,p1);
51  _ArrayIndex1D_(ndims,size,index1,ghosts,p2);
52  }
53  _ArrayCopy1D_((phi+nvars*p2),(phi+nvars*p1),nvars);
54  _ArrayIncrementIndex_(ndims,bounds,index1,done);
55  }
56  }
57 
58  return(0);
59 }
Containts the structures and definitions for boundary condition implementation.
MPI related function definitions.
int BCPeriodicU(void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
Definition: BCPeriodic.c:19
Some basic definitions and macros.
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
Structure of MPI-related variables.
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.