HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BCNoFlux.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <basic.h>
8 #include <arrayfunctions.h>
9 #include <boundaryconditions.h>
10 
11 #include <physicalmodels/numa2d.h>
12 #include <physicalmodels/numa3d.h>
13 
23  void *b,
24  void *m,
25  int ndims,
26  int nvars,
27  int *size,
28  int ghosts,
29  double *phi,
30  double waqt
31  )
32 {
33  DomainBoundary *boundary = (DomainBoundary*) b;
34 
35  int dim = boundary->dim;
36  int face = boundary->face;
37 
38  if (boundary->on_this_proc) {
39  int bounds[ndims], indexb[ndims], indexi[ndims];
40  _ArraySubtract1D_ (bounds,boundary->ie,boundary->is,ndims);
41  _ArraySetValue_ (indexb,ndims,0);
42  int done = 0;
43  while (!done) {
44  int p1, p2;
45  _ArrayCopy1D_ (indexb,indexi,ndims);
46  _ArrayAdd1D_ (indexi,indexi,boundary->is,ndims);
47  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
48  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
49  else return(1);
50  _ArrayIndex1DWO_ (ndims,size,indexb,boundary->is,ghosts,p1);
51  _ArrayIndex1D_ (ndims,size,indexi,ghosts,p2);
52 
53  if (nvars == 4) {
54  phi[nvars*p1+0] = phi[nvars*p2+0];
55  phi[nvars*p1+1] = (dim == _XDIR_ ? -phi[nvars*p2+1] : phi[nvars*p2+1] );
56  phi[nvars*p1+2] = (dim == _YDIR_ ? -phi[nvars*p2+2] : phi[nvars*p2+2] );
57  phi[nvars*p1+3] = phi[nvars*p2+3];
58  } else if (nvars == 5) {
59  phi[nvars*p1+0] = phi[nvars*p2+0];
60  phi[nvars*p1+1] = (dim == _XDIR_ ? -phi[nvars*p2+1] : phi[nvars*p2+1] );
61  phi[nvars*p1+2] = (dim == _YDIR_ ? -phi[nvars*p2+2] : phi[nvars*p2+2] );
62  phi[nvars*p1+3] = (dim == _ZDIR_ ? -phi[nvars*p2+3] : phi[nvars*p2+3] );
63  phi[nvars*p1+4] = phi[nvars*p2+4];
64  }
65 
66  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
67  }
68  }
69  return(0);
70 }
Containts the structures and definitions for boundary condition implementation.
#define _ZDIR_
Some basic definitions and macros.
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
int BCNoFluxU(void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
Definition: BCNoFlux.c:22
#define _ArrayAdd1D_(x, a, b, size)
#define _YDIR_
Definition: euler2d.h:41
#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 _XDIR_
Definition: euler1d.h:75
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.