HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BCThermalNoslipWall.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 #include <mpivars.h>
11 
12 #include <physicalmodels/euler1d.h>
13 #include <physicalmodels/euler2d.h>
15 
28  void *b,
29  void *m,
30  int ndims,
31  int nvars,
32  int *size,
33  int ghosts,
34  double *phi,
35  double waqt
36  )
37 {
38  DomainBoundary *boundary = (DomainBoundary*) b;
39 
40  int dim = boundary->dim;
41  int face = boundary->face;
42 
43  if (ndims == 3) {
44 
45  /* create a fake physics object */
46  double gamma;
47  gamma = boundary->gamma;
48  double inv_gamma_m1 = 1.0/(gamma-1.0);
49 
50  if (boundary->on_this_proc) {
51 
52  int *temperature_field_size = boundary->UnsteadyTemperatureSize;
53  int n_time_levels = temperature_field_size[dim];
54  double *time_levels = boundary->UnsteadyTimeLevels;
55  double *temperature_data = boundary->UnsteadyTemperatureData;
56 
57  int it = n_time_levels - 1;
58  while ((time_levels[it] > waqt) && (it > 0)) it--;
59 
60  int bounds[ndims], indexb[ndims], indexi[ndims];
61  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
62  _ArraySetValue_(indexb,ndims,0);
63 
64  int done = 0;
65  while (!done) {
66 
67  int p1, p2;
68  _ArrayCopy1D_(indexb,indexi,ndims);
69  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
70  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
71  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
72  else return(1);
73  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
74  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
75 
76  /* get the specified temperature */
77  int index1[ndims]; _ArrayCopy1D_(indexb,index1,ndims);
78  index1[dim] = it;
79  int q; _ArrayIndex1D_(ndims,temperature_field_size,index1,0,q);
80  double temperature_b = temperature_data[q];
81 
82  /* flow variables in the interior */
83  double rho, uvel, vvel, wvel, energy, pressure;
84  _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma);
85  /* set the ghost point values */
86  double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt;
87  rho_gpt = rho;
88  uvel_gpt = 2.0*boundary->FlowVelocity[0] - uvel;
89  vvel_gpt = 2.0*boundary->FlowVelocity[1] - vvel;
90  wvel_gpt = 2.0*boundary->FlowVelocity[2] - wvel;
91  pressure_gpt = rho_gpt * temperature_b;
92  energy_gpt = inv_gamma_m1*pressure_gpt
93  + 0.5 * rho_gpt
94  * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt);
95 
96  phi[nvars*p1+0] = rho_gpt;
97  phi[nvars*p1+1] = rho_gpt * uvel_gpt;
98  phi[nvars*p1+2] = rho_gpt * vvel_gpt;
99  phi[nvars*p1+3] = rho_gpt * wvel_gpt;
100  phi[nvars*p1+4] = energy_gpt;
101 
102  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
103  }
104  }
105 
106  }
107  return(0);
108 }
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.
3D Navier Stokes equations (compressible flows)
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayAdd1D_(x, a, b, size)
double * UnsteadyTimeLevels
#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)
int BCThermalNoslipWallU(void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
1D Euler Equations (inviscid, compressible flows)
double * UnsteadyTemperatureData
#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)