PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief MHD Shock Cloud interaction.
5 
6  Set the initial condition for the 2D or 3D shock-cloud problem.
7  The shock propagates in the x-direction and it is initially located
8  at \c x=0.6 with post- and -pre shock value equal to
9  \f[
10  \left(\begin{array}{l}
11  \rho \\ \noalign{\medskip}
12  v_x \\ \noalign{\medskip}
13  p \\ \noalign{\medskip}
14  B_y \\ \noalign{\medskip}
15  B_z
16  \end{array}\right)
17  =
18  \left(\begin{array}{l}
19  3.86859 \\ \noalign{\medskip}
20  0 \\ \noalign{\medskip}
21  167.345 \\ \noalign{\medskip}
22  B_{\rm post} \\ \noalign{\medskip}
23  -B_{\rm post} \\ \noalign{\medskip}
24  \end{array}\right)
25  \quad\mathrm{for}\quad x < 0.6\,,\qquad\qquad
26  \left(\begin{array}{l}
27  \rho \\ \noalign{\medskip}
28  v_x \\ \noalign{\medskip}
29  p \\ \noalign{\medskip}
30  B_y \\ \noalign{\medskip}
31  B_z
32  \end{array}\right)
33  =
34  \left(\begin{array}{l}
35  1 \\ \noalign{\medskip}
36  -11.2536 \\ \noalign{\medskip}
37  1 \\ \noalign{\medskip}
38  B_{\rm pre} \\ \noalign{\medskip}
39  -B_{\rm pre} \\ \noalign{\medskip}
40  \end{array}\right)
41  \quad\mathrm{for}\quad x > 0.6\,,\qquad
42  \f]
43  while the remaining vector components are 0.
44  The cloud has radius \f$R\f$ centered at
45  \f$r_0 = (x_0,y_0,z_0) = (0.8, 0.5, 0.5)\f$ and larger density
46  \f$\rho = 10\f$.
47 
48  The interaction may be divided into two phases: 1) the collapse stage
49  where the front of the cloud is strongly compressed and two fast shocks
50  are generated and 2) the reexpansion phase which begins when the
51  transmitted fast shock overtake the back of the cloud.
52 
53  The runtime parameters that are read from \c pluto.ini are
54  - <tt>g_inputParam[B_POST]</tt>: sets the post-shock magnetic field;
55  - <tt>g_inputParam[B_PRE]</tt>: sets the pre-shock magnetic field;
56  - <tt>g_inputParam[RADIUS]</tt>: sets the radius of the cloud;
57 
58  A list of the available configurations is given in the following table:
59 
60  <CENTER>
61  Conf.| GEOMETRY |DIM| T. STEPPING|RECONSTRUCTION|divB| AMR
62  -----|-----------|---|------------|--------------| ---|-------
63  #01 |CARTESIAN | 2 | RK2 | LINEAR | CT | NO
64  #02 |CARTESIAN | 2 | ChTr | LINEAR | CT | NO
65  #03 |CARTESIAN | 2 | HANCOCK | LINEAR | 8W | NO
66  #04 |CARTESIAN | 3 | ChTr | LINEAR | CT | NO
67  #05 |CARTESIAN | 3 | RK3 | LINEAR | CT | NO
68  #06 |CARTESIAN | 3 | ChTr | LINEAR | GLM| NO
69  #07 |CARTESIAN | 3 | RK3 | WENO3_FD | GLM| NO
70  #08 |CARTESIAN | 3 | HANCOK | LINEAR | GLM| YES
71  #09 |CARTESIAN | 2 | RK2 | LINEAR | CT | NO
72  </CENTER>
73 
74  \image html mhd_shock_cloud.02.jpg "Density map with overplotted field lines for configuration #02"
75 
76  \author A. Mignone (mignone@ph.unito.it)
77  \date Sept 17, 2014
78 
79  \b References:
80  - "Interactions between magnetohydrodynamical shocks and denser clouds"
81  W. Dai an P.R. Woodward, ApJ (1994) 436, 776.
82  - "The divB = 0 Constraint in Shock-Capturing MHD codes"
83  G. Toth, JCP 161, 605-652 (2000)
84  - "A central constrained transport scheme for ideal magnetohydrodynamics"
85  U. Ziegler, JCP 196 (2004), 393
86 */
87 /* ///////////////////////////////////////////////////////////////////// */
88 #include "pluto.h"
89 
90 /* ********************************************************************* */
91 void Init (double *v, double x, double y, double z)
92 /*
93  *
94  *********************************************************************** */
95 {
96  double r, x0, y0, z0;
97 
98  x0 = 0.8;
99  y0 = 0.5;
100  z0 = 0.5;
101 
102  if (x < 0.6) {
103  v[RHO] = 3.86859;
104  v[VX1] = 0.0;
105  v[VX2] = 0.0;
106  v[VX3] = 0.0;
107  v[BX1] = 0.0;
108  v[BX2] = g_inputParam[B_POST];
109  v[BX3] = -g_inputParam[B_POST];
110  v[PRS] = 167.345;
111  }else{
112  v[RHO] = 1.0;
113  v[VX1] = -11.2536;
114  v[VX2] = 0.0;
115  v[VX3] = 0.0;
116  v[BX1] = 0.0;
117  v[BX2] = g_inputParam[B_PRE];
118  v[BX3] = g_inputParam[B_PRE];
119  v[PRS] = 1.0;
120  }
121 
122  /* ---- CLOUD ---- */
123 
124  r = D_EXPAND((x-x0)*(x-x0), + (y-y0)*(y-y0) , + (z-z0)*(z-z0));
125 
126  if (sqrt(r) < g_inputParam[RADIUS]) v[RHO] = 10.0;
127 
128 /* no need for potential vector,
129  since CT_VEC_POT_INIT is set to NO
130 
131  v[AX1] = x3*v[BX2] - x2*v[BX3];
132  v[AX2] = 0.0;
133  v[AX3] = 0.0;
134 */
135 }
136 /* ********************************************************************* */
137 void Analysis (const Data *d, Grid *grid)
138 /*
139  *
140  *
141  *********************************************************************** */
142 {
143 }
144 
145 /* ********************************************************************* */
146 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
147 /*
148  *
149  *********************************************************************** */
150 {
151  int i, j, k;
152 
153  if (side == X1_END){ /* -- select the boundary side -- */
154  if (box->vpos == CENTER){ /* -- select the variable position -- */
155  BOX_LOOP(box,k,j,i){ /* -- Loop over boundary zones -- */
156  d->Vc[RHO][k][j][i] = 1.0;
157  EXPAND(d->Vc[VX1][k][j][i] = -11.2536; ,
158  d->Vc[VX2][k][j][i] = 0.0; ,
159  d->Vc[VX3][k][j][i] = 0.0;)
160  d->Vc[PRS][k][j][i] = 1.0;
161  EXPAND(d->Vc[BX1][k][j][i] = 0.0; ,
162  d->Vc[BX2][k][j][i] = g_inputParam[B_PRE]; ,
163  d->Vc[BX3][k][j][i] = g_inputParam[B_PRE];)
164  }
165  }else if (box->vpos == X2FACE){ /* -- y staggered field -- */
166  #ifdef STAGGERED_MHD
167  BOX_LOOP(box,k,j,i) d->Vs[BX2s][k][j][i] = g_inputParam[B_PRE];
168  #endif
169  }else if (box->vpos == X3FACE){ /* -- z staggered field -- */
170  #ifdef STAGGERED_MHD
171  BOX_LOOP(box,k,j,i) d->Vs[BX3s][k][j][i] = g_inputParam[B_PRE];
172  #endif
173  }
174  }
175 }
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#define VX2
Definition: mod_defs.h:29
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#define RHO
Definition: mod_defs.h:19
#define X3FACE
Definition: pluto.h:203
#define BOX_LOOP(B, k, j, i)
Definition: macros.h:70
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define BX3s
Definition: ct.h:29
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define VX1
Definition: mod_defs.h:28
Definition: structs.h:78
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
#define RADIUS
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
Definition: analysis.c:27
#define B_PRE
Definition: structs.h:30
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define BX2s
Definition: ct.h:28
#define BX2
Definition: mod_defs.h:26
Definition: structs.h:346
#define X2FACE
Definition: pluto.h:202
#define B_POST
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