PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Double Mach reflection test problem.
5 
6  Sets the initial condition for a planar shock front making an angle of
7  \f$ \pi/3 \f$ with a reflecting wall:
8  \f[
9  \left(\rho,v_x,v_y,p\right)
10  =
11  \left\{\begin{array}{ll}
12  (1.4,0,0,1) & \qquad {\rm for} \quad x >x_s(0) \\ \noalign{\medskip}
13  (8,8,25,-8.25,116.5) & \qquad {\rm otherwise}
14  \end{array}\right.
15  \f]
16  where \f$x_s(t) = 10t/\sin\alpha + 1/6 + y/\tan\alpha\f$ is the shock
17  position.
18  The ideal equation of state with \f$ \Gamma = 1.4\f$ is used.
19  The wedge is represented by a reflecting boundary starting at x=1/6
20  along the lower y-boundary.
21  As the shock reflects off the lower wall, a complex flow structure
22  develops with two curved reflected shocks propagating at directions
23  almost orthogonal to each other and a tangential discontinuity
24  separating them.
25  At the wall, a pressure gradient sets up a denser fluid jet
26  propagating along the wall. Kelvin-Helmholtz instability
27  patterns may be identified with the rolls developing at
28  the slip line.
29  This feature is very sensitive to numerical diffusion and it
30  becomes visible at high resolution and/or low dissipative schemes.
31 
32  In the frames below we show configuration \# 02 using a high-order
33  finite difference scheme with 5-th order WENO-Z reconstruction and
34  \c RK3 time stepping.
35  The resolution is 960 x 240.
36 
37  \image html dmr_rho.gif "Density contours for the double Mach reflection test"
38  \image html dmr_prs.gif "Pressure contours for the double Mach reflection test"
39 
40  \author A. Mignone (mignone@ph.unito.it)
41  \date May 23, 2014
42 
43  \b References
44  - "The Numerical Simulation of Two-Dimensional Fluid Flow with Strong Shocks"\n
45  Woodward, P.R., & Colella, P., JCP (1984) 54, 115.
46  - "The PLUTO Code for computational astrophysics"\n
47  Mignone et al., ApJS(2007) 170,228
48  - "Comparison of some FLux Corrected Transport and Total variatiion
49  diminishing numerical schemes for hydrodynamics and magnetohydrodynamic
50  problems" \n
51  Toth, G., Odstrcil, D., JCP (1996) 128, 82.
52 
53 */
54 /* ///////////////////////////////////////////////////////////////////// */
55 #include "pluto.h"
56 
57 /* ********************************************************************* */
58 void Init (double *us, double x1, double x2, double x3)
59 /*
60  *
61  *********************************************************************** */
62 {
63  double alpha, xs;
64 
65  g_gamma = 1.4;
66  alpha = 1.0/3.0*CONST_PI;
67  xs = 1.0/6.0 + x2/tan(alpha);
68 
69  if (x1 > xs){
70  us[RHO] = 1.4;
71  us[VX1] = 0.0;
72  us[VX2] = 0.0;
73  us[PRS] = 1.0;
74  }else{
75  us[RHO] = 8.0;
76  us[VX1] = 8.25*sin(alpha);
77  us[VX2] = -8.25*cos(alpha);
78  us[PRS] = 116.5;
79  }
80 }
81 /* ********************************************************************* */
82 void Analysis (const Data *d, Grid *grid)
83 /*
84  *
85  *********************************************************************** */
86 {
87 
88 }
89 /* ********************************************************************* */
90 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
91 /*!
92  * Assign user-defined boundary conditions:
93  * - left side (x beg): constant shocked values
94  * - bottom side (y beg): constant shocked values for
95  * <tt> x < 1/6 </tt> and reflective boundary
96  * otherwise.
97  * - top side (y end): time-dependent boundary:
98  * for \f$ x < x_s(t) = 10 t/\sin\alpha + 1/6 + 1.0/\tan\alpha \f$ we use
99  * fixed (post-shock) values. Unperturbed values otherwise.
100  *
101  *********************************************************************** */
102 {
103  int i, j, k;
104  double x1, x2, x3;
105  double alpha,xs;
106 
107  alpha = 60./180.*CONST_PI;
108 
109  if (side == X1_BEG){
110 
111  X1_BEG_LOOP(k,j,i) {
112  d->Vc[RHO][k][j][i] = 8.0;
113  d->Vc[VX1][k][j][i] = 8.25*sin(alpha);
114  d->Vc[VX2][k][j][i] = - 8.25*cos(alpha);
115  d->Vc[PRS][k][j][i] = 116.5;
116  }
117 
118  } else if (side == X2_BEG){
119 
120  X2_BEG_LOOP(k,j,i) {
121  x1 = grid[IDIR].x[i];
122  if (x1 < 1.0/6.0){
123  d->Vc[RHO][k][j][i] = 8.0;
124  d->Vc[VX1][k][j][i] = 8.25*sin(alpha);
125  d->Vc[VX2][k][j][i] = - 8.25*cos(alpha);
126  d->Vc[PRS][k][j][i] = 116.5;
127  }else{ /* reflective boundary */
128  d->Vc[RHO][k][j][i] = d->Vc[RHO][k][2*JBEG - j - 1][i];
129  d->Vc[VX1][k][j][i] = d->Vc[VX1][k][2*JBEG - j - 1][i];
130  d->Vc[VX2][k][j][i] = - d->Vc[VX2][k][2*JBEG - j - 1][i];
131  d->Vc[PRS][k][j][i] = d->Vc[PRS][k][2*JBEG - j - 1][i];
132  }
133  }
134 
135  } else if (side == X2_END) {
136 
137  X2_END_LOOP(k,j,i){
138 
139  x1 = grid[IDIR].x[i];
140  xs = 10.0*g_time/sin(alpha) + 1.0/6.0 + 1.0/tan(alpha);
141  if (x1 < xs){
142  d->Vc[RHO][k][j][i] = 8.0;
143  d->Vc[VX1][k][j][i] = 8.25*sin(alpha);
144  d->Vc[VX2][k][j][i] = - 8.25*cos(alpha);
145  d->Vc[PRS][k][j][i] = 116.5;
146  }else{ /* reflective boundary */
147  d->Vc[RHO][k][j][i] = 1.4;
148  d->Vc[VX1][k][j][i] = 0.;
149  d->Vc[VX2][k][j][i] = 0.;
150  d->Vc[PRS][k][j][i] = 1.;
151  }
152  }
153  }
154 }
155 
static double alpha
Definition: init.c:3
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
double g_gamma
Definition: globals.h:112
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define VX1
Definition: mod_defs.h:28
#define X2_BEG_LOOP(k, j, i)
Definition: macros.h:47
#define X2_END_LOOP(k, j, i)
Definition: macros.h:51
#define IDIR
Definition: pluto.h:193
#define X2_END
Boundary region at X2 end.
Definition: pluto.h:149
Definition: structs.h:78
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
PLUTO main header file.
#define X1_BEG_LOOP(k, j, i)
Definition: macros.h:46
Definition: structs.h:30
int i
Definition: analysis.c:2
double g_time
The current integration time.
Definition: globals.h:117
#define CONST_PI
.
Definition: pluto.h:269
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
Definition: globals.h:39
Definition: structs.h:346
void Analysis(const Data *d, Grid *grid)
Definition: init.c:66
void Init(double *v, double x1, double x2, double x3)
Definition: init.c:17