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

Slip-wall boundary conditions for shallow water equations. More...

#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <boundaryconditions.h>
#include <physicalmodels/shallowwater1d.h>
#include <physicalmodels/shallowwater2d.h>

Go to the source code of this file.

Functions

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

Detailed Description

Slip-wall boundary conditions for shallow water equations.

Author
Debojyoti Ghosh

Definition in file BCSWSlipWall.c.

Function Documentation

◆ BCSWSlipWallU()

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

Applies the slip-wall boundary condition: This is specific to the one and two dimenstional shallow water equations (ShallowWater1D, ShallowWater2D). It is used for simulating inviscid walls or symmetric boundaries. The height, and tangential velocity at the ghost points are extrapolated from the interior, while the normal velocity at the ghost points is set such that the interpolated value at the boundary face is equal to the specified wall velocity.

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 21 of file BCSWSlipWall.c.

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 }
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
#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 _ShallowWater1DGetFlowVar_(u, h, v)
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayCopy1D_(x, y, size)
#define _ShallowWater2DGetFlowVar_(u, h, uvel, vvel)