HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BCSWSlipWall.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 
13 
22  void *b,
23  void *m,
24  int ndims,
25  int nvars,
26  int *size,
27  int ghosts,
28  double *phi,
29  double waqt
30  )
31 {
32  DomainBoundary *boundary = (DomainBoundary*) b;
33 
34  int dim = boundary->dim;
35  int face = boundary->face;
36 
37  if (ndims == 1) {
38 
39  if (boundary->on_this_proc) {
40  int bounds[ndims], indexb[ndims], indexi[ndims];
41  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
42  _ArraySetValue_(indexb,ndims,0);
43  int done = 0;
44  while (!done) {
45  int p1, p2;
46  _ArrayCopy1D_(indexb,indexi,ndims);
47  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
48  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
49  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
50  else return(1);
51  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
52  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
53 
54  /* flow variables in the interior */
55  double h, uvel;
56  double h_gpt, uvel_gpt;
57  _ShallowWater1DGetFlowVar_((phi+nvars*p2),h,uvel);
58  /* set the ghost point values */
59  h_gpt = h;
60  uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel;
61 
62  phi[nvars*p1+0] = h_gpt;
63  phi[nvars*p1+1] = h_gpt * uvel_gpt;
64 
65  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
66  }
67  }
68 
69  } else if (ndims == 2) {
70 
71  if (boundary->on_this_proc) {
72  int bounds[ndims], indexb[ndims], indexi[ndims];
73  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
74  _ArraySetValue_(indexb,ndims,0);
75  int done = 0;
76  while (!done) {
77  int p1, p2;
78  _ArrayCopy1D_(indexb,indexi,ndims);
79  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
80  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
81  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
82  else return(1);
83  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
84  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
85 
86  /* flow variables in the interior */
87  double h, uvel, vvel;
88  double h_gpt, uvel_gpt, vvel_gpt;
89  _ShallowWater2DGetFlowVar_((phi+nvars*p2),h,uvel,vvel);
90  /* set the ghost point values */
91  h_gpt = h;
92  if (dim == _XDIR_) {
93  uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel;
94  vvel_gpt = vvel;
95  } else if (dim == _YDIR_) {
96  uvel_gpt = uvel;
97  vvel_gpt = 2.0*boundary->FlowVelocity[_YDIR_] - vvel;
98  } else {
99  uvel_gpt = 0.0;
100  vvel_gpt = 0.0;
101  }
102 
103  phi[nvars*p1+0] = h_gpt;
104  phi[nvars*p1+1] = h_gpt * uvel_gpt;
105  phi[nvars*p1+2] = h_gpt * vvel_gpt;
106 
107  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
108  }
109  }
110 
111  }
112  return(0);
113 }
#define _YDIR_
Definition: euler2d.h:41
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
Containts the structures and definitions for boundary condition implementation.
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
Structure containing the variables and function pointers defining a boundary.
2D Shallow Water Equations
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
int BCSWSlipWallU(void *, void *, int, int, int *, int, double *, double)
Definition: BCSWSlipWall.c:21
#define _ShallowWater2DGetFlowVar_(u, h, uvel, vvel)
1D Shallow Water Equations
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
#define _ArrayAdd1D_(x, a, b, size)
#define _XDIR_
Definition: euler1d.h:75
#define _ShallowWater1DGetFlowVar_(u, h, v)