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

Periodic boundary conditions. More...

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

Go to the source code of this file.

Functions

int BCPeriodicU (void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
 

Detailed Description

Periodic boundary conditions.

Author
Debojyoti Ghosh

Definition in file BCPeriodic.c.

Function Documentation

◆ BCPeriodicU()

int BCPeriodicU ( void *  b,
void *  m,
int  ndims,
int  nvars,
int *  size,
int  ghosts,
double *  phi,
double  waqt 
)

Applies periodic boundary conditions: Implemented by copying the solution from the other end of the domain into the physical boundary ghost points.

Note**: This function only acts if the the number of processors is 1 along the spatial dimension this boundary corresponds to. If there are more than 1 processors along this dimension, periodicity is handled by MPIExchangeBoundariesnD() to minimize communication.

Parameters
bBoundary object of type DomainBoundary
mMPI object of type MPIVariables
ndimsNumber of spatial dimensions
nvarsNumber of variables/DoFs per grid point
sizeInteger array with the number of grid points in each spatial dimension
ghostsNumber of ghost points
phiThe solution array on which to apply the boundary condition
waqtCurrent solution time

Definition at line 19 of file BCPeriodic.c.

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 }
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)