HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BCSponge.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 
27  void *b,
28  int ndims,
29  int nvars,
30  int ghosts,
31  int *size,
32  double *grid,
33  double *u,
34  double *source
35  )
36 {
37  DomainBoundary *boundary = (DomainBoundary*) b;
38  int dim = boundary->dim;
39  int face = boundary->face;
40  double *uref = boundary->SpongeValue;
41  double *xmin = boundary->xmin;
42  double *xmax = boundary->xmax;
43  int v;
44 
45  if (boundary->on_this_proc) {
46  int bounds[ndims], indexb[ndims];
47  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
48  _ArraySetValue_(indexb,ndims,0);
49  int done = 0;
50  while (!done) {
51  int i = indexb[dim] + boundary->is[dim];
52  double x, xstart, xend;
53  _GetCoordinate_(dim,i,size,ghosts,grid,x);
54  xstart = xmin[dim];
55  xend = xmax[dim];
56  /* calculate sigma */
57  double sigma;
58  if (face > 0) sigma = (x - xstart) / (xend - xstart);
59  else sigma = (x - xend ) / (xstart - xend);
60  /* add to the source term */
61  int p; _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p);
62  for (v=0; v<nvars; v++) source[nvars*p+v] -= (sigma * (u[nvars*p+v]-uref[v]));
63  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
64  }
65  }
66  return(0);
67 }
68 
74  void *b,
75  void *m,
76  int ndims,
77  int nvars,
78  int *size,
79  int ghosts,
80  double *phi,
81  double waqt
82  )
83 {
84  return(0);
85 }
Containts the structures and definitions for boundary condition implementation.
Some basic definitions and macros.
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
int BCSpongeUDummy(void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
Definition: BCSponge.c:73
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int BCSpongeSource(void *b, int ndims, int nvars, int ghosts, int *size, double *grid, double *u, double *source)
Definition: BCSponge.c:26
Contains macros and function definitions for common array operations.