HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BCTurbulentSupersonicInflow.c File Reference

Turbulent supersonic inflow boundary condition (specific to the 3D Navier-Stokes system). More...

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <boundaryconditions.h>
#include <mpivars.h>

Go to the source code of this file.

Functions

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

Detailed Description

Turbulent supersonic inflow boundary condition (specific to the 3D Navier-Stokes system).

Author
Debojyoti Ghosh

Definition in file BCTurbulentSupersonicInflow.c.

Function Documentation

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

Applies the turbulent supersonic inflow boundary condition: The inflow consists of a mean supersonic inflow on which turbulent flow fluctuations are added. This boundary condition is specific to the 3D Navier-Stokes system (NavierStokes3D).

Note: Some parts of the code may be hardcoded for use with the shock-turbulence interaction problem (for which this boundary condition was written).

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 BCTurbulentSupersonicInflow.c.

31 {
32  DomainBoundary *boundary = (DomainBoundary*) b;
33 
34  int dim = boundary->dim;
35 
36  double *inflow_data = boundary->UnsteadyDirichletData;
37  int *inflow_size = boundary->UnsteadyDirichletSize;
38 
39  if (ndims == 3) {
40 
41  /* create a fake physics object */
42  double gamma;
43  gamma = boundary->gamma;
44  double inv_gamma_m1 = 1.0/(gamma-1.0);
45 
46  if (boundary->on_this_proc) {
47  /* the following bit is hardcoded for the inflow data
48  * representing fluctuations in a domain of length 2pi */
49  double xt = boundary->FlowVelocity[dim] * waqt;
50  int N = inflow_size[dim];
51  double L = 2.0 * (4.0*atan(1.0));
52  int it = ((int) ((xt/L) * ((double)N))) % N;
53 
54  int bounds[ndims], indexb[ndims];
55  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
56  _ArraySetValue_(indexb,ndims,0);
57  int done = 0;
58  while (!done) {
59  int p1; _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
60 
61  /* set the ghost point values - mean flow */
62  double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt;
63  rho_gpt = boundary->FlowDensity;
64  pressure_gpt = boundary->FlowPressure;
65  uvel_gpt = boundary->FlowVelocity[0];
66  vvel_gpt = boundary->FlowVelocity[1];
67  wvel_gpt = boundary->FlowVelocity[2];
68 
69  /* calculate the turbulent fluctuations */
70  double duvel , dvvel , dwvel ;
71  int index1[ndims]; _ArrayCopy1D_(indexb,index1,ndims);
72  index1[dim] = it;
73  int q; _ArrayIndex1D_(ndims,inflow_size,index1,0,q);
74  duvel = inflow_data[q*nvars+1];
75  dvvel = inflow_data[q*nvars+2];
76  dwvel = inflow_data[q*nvars+3];
77 
78  /* add the turbulent fluctuations to the velocity field */
79  uvel_gpt += duvel;
80  vvel_gpt += dvvel;
81  wvel_gpt += dwvel;
82 
83  /* set the ghost point values */
84  energy_gpt = inv_gamma_m1*pressure_gpt
85  + 0.5 * rho_gpt
86  * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt);
87  phi[nvars*p1+0] = rho_gpt;
88  phi[nvars*p1+1] = rho_gpt * uvel_gpt;
89  phi[nvars*p1+2] = rho_gpt * vvel_gpt;
90  phi[nvars*p1+3] = rho_gpt * wvel_gpt;
91  phi[nvars*p1+4] = energy_gpt;
92 
93  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
94  }
95  }
96 
97  }
98  return(0);
99 }
#define _ArraySetValue_(x, size, value)
double * UnsteadyDirichletData
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
Structure containing the variables and function pointers defining a boundary.
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)