HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BCTurbulentSupersonicInflow.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <math.h>
9 #include <basic.h>
10 #include <arrayfunctions.h>
11 #include <boundaryconditions.h>
12 #include <mpivars.h>
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 
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 }
Containts the structures and definitions for boundary condition implementation.
MPI related function definitions.
Some basic definitions and macros.
Structure containing the variables and function pointers defining a boundary.
int BCTurbulentSupersonicInflowU(void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
#define _ArraySubtract1D_(x, a, b, size)
double * UnsteadyDirichletData
#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 _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.