HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BCSubsonicOutflow.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/euler2d.h>
13 
20  void *b,
21  void *m,
22  int ndims,
23  int nvars,
24  int *size,
25  int ghosts,
26  double *phi,
27  double waqt
28  )
29 {
30  DomainBoundary *boundary = (DomainBoundary*) b;
31 
32  int dim = boundary->dim;
33  int face = boundary->face;
34 
35  if (ndims == 2) {
36 
37  /* create a fake physics object */
38  Euler2D physics;
39  double gamma;
40  gamma = physics.gamma = boundary->gamma;
41  double inv_gamma_m1 = 1.0/(gamma-1.0);
42 
43  if (boundary->on_this_proc) {
44  int bounds[ndims], indexb[ndims], indexi[ndims];
45  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
46  _ArraySetValue_(indexb,ndims,0);
47  int done = 0;
48  while (!done) {
49  int p1, p2;
50  _ArrayCopy1D_(indexb,indexi,ndims);
51  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
52  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
53  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
54  else return(1);
55  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
56  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
57 
58  /* flow variables in the interior */
59  double rho, uvel, vvel, energy, pressure;
60  double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt;
61  _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics));
62  /* set the ghost point values */
63  rho_gpt = rho;
64  pressure_gpt = pressure; /* useless statement to avoid compiler warning */
65  pressure_gpt = boundary->FlowPressure;
66  uvel_gpt = uvel;
67  vvel_gpt = vvel;
68  energy_gpt = inv_gamma_m1*pressure_gpt
69  + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt);
70 
71  phi[nvars*p1+0] = rho_gpt;
72  phi[nvars*p1+1] = rho_gpt * uvel_gpt;
73  phi[nvars*p1+2] = rho_gpt * vvel_gpt;
74  phi[nvars*p1+3] = energy_gpt;
75 
76  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
77  }
78  }
79 
80  } else if (ndims == 3) {
81 
82  /* create a fake physics object */
83  double gamma;
84  gamma = boundary->gamma;
85  double inv_gamma_m1 = 1.0/(gamma-1.0);
86 
87  if (boundary->on_this_proc) {
88  int bounds[ndims], indexb[ndims], indexi[ndims];
89  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
90  _ArraySetValue_(indexb,ndims,0);
91  int done = 0;
92  while (!done) {
93  int p1, p2;
94  _ArrayCopy1D_(indexb,indexi,ndims);
95  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
96  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
97  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
98  else return(1);
99  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
100  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
101 
102  /* flow variables in the interior */
103  double rho, uvel, vvel, wvel, energy, pressure;
104  double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt;
105  _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma);
106  /* set the ghost point values */
107  rho_gpt = rho;
108  pressure_gpt = pressure; /* useless statement to avoid compiler warning */
109  pressure_gpt = boundary->FlowPressure;
110  uvel_gpt = uvel;
111  vvel_gpt = vvel;
112  wvel_gpt = wvel;
113  energy_gpt = inv_gamma_m1*pressure_gpt
114  + 0.5 * rho_gpt
115  * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt);
116 
117  phi[nvars*p1+0] = rho_gpt;
118  phi[nvars*p1+1] = rho_gpt * uvel_gpt;
119  phi[nvars*p1+2] = rho_gpt * vvel_gpt;
120  phi[nvars*p1+3] = rho_gpt * wvel_gpt;
121  phi[nvars*p1+4] = energy_gpt;
122 
123  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
124  }
125  }
126 
127  }
128  return(0);
129 }
Containts the structures and definitions for boundary condition implementation.
Some basic definitions and macros.
Structure containing the variables and function pointers defining a boundary.
3D Navier Stokes equations (compressible flows)
#define _Euler2DGetFlowVar_(u, rho, vx, vy, e, P, p)
Definition: euler2d.h:44
#define _ArraySubtract1D_(x, a, b, size)
int BCSubsonicOutflowU(void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
#define _ArrayAdd1D_(x, a, b, size)
double gamma
Definition: euler2d.h:245
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
static const int _NavierStokes3D_stride_
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.
#define _NavierStokes3DGetFlowVar_(u, stride, rho, vx, vy, vz, e, P, gamma)