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

Reflection boundary condition. More...

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

Go to the source code of this file.

Functions

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

Detailed Description

Reflection boundary condition.

Author
Debojyoti Ghosh

Definition in file BCReflect.c.

Function Documentation

◆ BCReflectU()

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

Applies the reflection boundary condition: The values at the physical boundary ghost points are set to the negative of the interior values adjacent to the boundary.

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 14 of file BCReflect.c.

24 {
25  DomainBoundary *boundary = (DomainBoundary*) b;
26 
27  int dim = boundary->dim;
28  int face = boundary->face;
29 
30  if (boundary->on_this_proc) {
31  int bounds[ndims], indexb[ndims], indexi[ndims];
32  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
33  _ArraySetValue_(indexb,ndims,0);
34  int done = 0;
35  while (!done) {
36  int p1, p2;
37  _ArrayCopy1D_(indexb,indexi,ndims);
38  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
39  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
40  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
41  else return(1);
42  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
43  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
44  _ArrayScaleCopy1D_((phi+nvars*p2),(-1.0),(phi+nvars*p1),nvars);
45  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
46  }
47  }
48  return(0);
49 }
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayScaleCopy1D_(x, a, y, size)
#define _ArrayAdd1D_(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)
#define _ArrayCopy1D_(x, y, size)