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

Subsonic inflow boundary conditions (specific to Euler/Navier-Stokes systems) More...

#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <boundaryconditions.h>
#include <physicalmodels/euler2d.h>
#include <physicalmodels/navierstokes3d.h>

Go to the source code of this file.

Functions

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

Detailed Description

Subsonic inflow boundary conditions (specific to Euler/Navier-Stokes systems)

Author
Debojyoti Ghosh

Definition in file BCSubsonicInflow.c.

Function Documentation

◆ BCSubsonicInflowU()

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

Applies the subsonic inflow boundary condition: The density and velocity at the physical boundary ghost points are specified, while the pressure is extrapolated from the interior of the domain. This boundary condition is specific to two and three dimension Euler and Navier-Stokes systems (Euler2D, NavierStokes2D, NavierStokes3D).

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 20 of file BCSubsonicInflow.c.

30 {
31  DomainBoundary *boundary = (DomainBoundary*) b;
32 
33  int dim = boundary->dim;
34  int face = boundary->face;
35 
36  if (ndims == 2) {
37 
38  /* create a fake physics object */
39  Euler2D physics;
40  double gamma;
41  gamma = physics.gamma = boundary->gamma;
42  double inv_gamma_m1 = 1.0/(gamma-1.0);
43 
44  if (boundary->on_this_proc) {
45  int bounds[ndims], indexb[ndims], indexi[ndims];
46  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
47  _ArraySetValue_(indexb,ndims,0);
48  int done = 0;
49  while (!done) {
50  int p1, p2;
51  _ArrayCopy1D_(indexb,indexi,ndims);
52  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
53  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
54  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
55  else return(1);
56  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
57  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
58 
59  /* flow variables in the interior */
60  double rho, uvel, vvel, energy, pressure;
61  double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt;
62  _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics));
63  /* set the ghost point values */
64  rho_gpt = boundary->FlowDensity;
65  pressure_gpt = pressure;
66  uvel_gpt = boundary->FlowVelocity[0];
67  vvel_gpt = boundary->FlowVelocity[1];
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 = boundary->FlowDensity;
108  pressure_gpt = pressure;
109  uvel_gpt = boundary->FlowVelocity[0];
110  vvel_gpt = boundary->FlowVelocity[1];
111  wvel_gpt = boundary->FlowVelocity[2];
112  energy_gpt = inv_gamma_m1*pressure_gpt
113  + 0.5 * rho_gpt
114  * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt);
115 
116  phi[nvars*p1+0] = rho_gpt;
117  phi[nvars*p1+1] = rho_gpt * uvel_gpt;
118  phi[nvars*p1+2] = rho_gpt * vvel_gpt;
119  phi[nvars*p1+3] = rho_gpt * wvel_gpt;
120  phi[nvars*p1+4] = energy_gpt;
121 
122  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
123  }
124  }
125 
126  }
127  return(0);
128 }
Structure containing the variables and function pointers defining a boundary.
#define _Euler2DGetFlowVar_(u, rho, vx, vy, e, P, p)
Definition: euler2d.h:44
#define _ArraySubtract1D_(x, a, b, size)
#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)
#define _NavierStokes3DGetFlowVar_(u, stride, rho, vx, vy, vz, e, P, gamma)