PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Stellar wind test problem.
5 
6  Sets initial condition for a spherically symmetric radial wind blowing
7  from the origin of coordinates, see [Mig14]
8  The initial condition consists of a constant-density ambient medium with
9  \f[
10  \rho = \rho_a \,,\qquad p = p_a\,,\qquad \vec{v} = v_{csm}\hvec{j}
11  \f]
12  where \c v_csm is the velocity of the star with respect to the background.
13  The wind is injeted using the \c INTERNAL_BOUNDARY where flow quantities are
14  kept constant in time and equal to
15  \f[
16  r^2v_r\rho = \rho_0 V_0^2r_0^2 \,,\qquad
17  v_r = V_0\hvec{r} \,,\qquad
18  p = \frac{c_s^2}{\Gamma}\rho^\Gamma
19  \f]
20  These value are defined through the UserDefBoundary() function when
21  \c side is equal to 0.
22 
23  Dimensions are chosen so that the spherical wind shell has radius 1,
24  density 1 and velocity 1 (\f$ r_0 = V_0 = \rho_0 = 1\f$).
25 
26  The input parameters that control the problem dynamics are
27 
28  - <tt>g_inputParam[CS_WIND]</tt>: sets the sound speed in the wind region;
29  - <tt>g_inputParam[RHO_AMB]</tt>: sets the ambient density
30  - <tt>g_inputParam[CS_AMB]</tt>: sets the ambient sound speed;
31  - <tt>g_inputParam[V_CSM]</tt>: sets the velocity of the star with
32  respect to the background;
33 
34  Configurations #01-05 and #07-08 work in 2D cylindrical axisymmetric
35  coordinates while conf. #06 is 3D Cartesian.
36  An AMR setup is available with configuration #04.
37 
38  \image html hd_stellar_wind.08.jpg "Density map at the end of computation for configuration #8"
39 
40  \author A. Mignone (mignone@ph.unito.it)
41  \date Sept 25, 2012
42 
43  \b References
44  - [Mig14]: "High-order conservative reconstruction schemes for finite volume methods in cylindrical and spherical coordinates",
45  Mignone, JCP (2014) 270, 784
46 */
47 /* ///////////////////////////////////////////////////////////////////// */
48 #include "pluto.h"
49 
50 /* ********************************************************************* */
51 void Init (double *us, double x1, double x2, double x3)
52 /*
53  *
54  *********************************************************************** */
55 {
56  double rho, cs, R;
57 
58  rho = g_inputParam[RHO_AMB];
59  cs = g_inputParam[CS_AMB];
60  us[RHO] = rho;
61  us[PRS] = cs*cs*rho/g_gamma;
62 
63  #if GEOMETRY == CARTESIAN
64  us[VX1] = 0.0;
65  us[VX2] = 0.0;
66  us[VX3] = -g_inputParam[V_CSM];
67  #elif GEOMETRY == CYLINDRICAL
68  us[VX1] = 0.0;
69  us[VX2] = -g_inputParam[V_CSM];
70  #elif GEOMETRY == SPHERICAL
71  us[VX1] = g_inputParam[V_CSM]*cos(x2);
72  us[VX2] = -g_inputParam[V_CSM]*sin(x2);
73  #endif
74 
75  R = sqrt(x1*x1 + x2*x2);
76  us[TRC] = (R <= 1.0 ? 1.0:0.0);
77  g_smallPressure = 1.e-5;
78 }
79 
80 /* **************************************************************** */
81 void Analysis (const Data *d, Grid *grid)
82 /*
83  *
84  ****************************************************************** */
85 {
86 
87 }
88 
89 /* ********************************************************************* */
90 void UserDefBoundary (const Data *d, RBox * box, int side, Grid *grid)
91 /*
92  * Sets inflow boundary condition at the top boundary (side == X2_END)
93  * and the stellar wind region when side == 0.
94  *
95  *********************************************************************** */
96 {
97  int i, j, k, nv;
98  double *x1, *x2, *x3;
99  double r, r0, cs;
100  double Vwind = 1.0, rho, vr;
101 
102  x1 = grid[IDIR].xgc;
103  x2 = grid[JDIR].xgc;
104  x3 = grid[KDIR].xgc;
105 
106  if (side == 0){
107  r0 = 1.0;
108  cs = g_inputParam[CS_WIND];
109  TOT_LOOP(k,j,i){
110  #if GEOMETRY == CARTESIAN
111  r = sqrt(x1[i]*x1[i] + x2[j]*x2[j] + x3[k]*x3[k]);
112  if (r <= r0){
113  vr = tanh(r/r0/0.1)*Vwind;
114  rho = Vwind*r0*r0/(vr*r*r);
115  d->Vc[RHO][k][j][i] = rho;
116  d->Vc[VX1][k][j][i] = Vwind*x1[i]/r;
117  d->Vc[VX2][k][j][i] = Vwind*x2[j]/r;
118  d->Vc[VX3][k][j][i] = Vwind*x3[k]/r;
119  d->Vc[PRS][k][j][i] = cs*cs/g_gamma*pow(rho,g_gamma);
120  d->flag[k][j][i] |= FLAG_INTERNAL_BOUNDARY;
121  }
122  #elif GEOMETRY == CYLINDRICAL
123  r = sqrt(x1[i]*x1[i] + x2[j]*x2[j]);
124  if (r <= r0){
125  vr = tanh(r/r0/0.1)*Vwind;
126  rho = Vwind*r0*r0/(vr*r*r);
127  d->Vc[RHO][k][j][i] = rho;
128  d->Vc[VX1][k][j][i] = Vwind*x1[i]/r;
129  d->Vc[VX2][k][j][i] = Vwind*x2[j]/r;
130  d->Vc[PRS][k][j][i] = cs*cs/g_gamma*pow(rho,g_gamma);
131  d->flag[k][j][i] |= FLAG_INTERNAL_BOUNDARY;
132  }
133  #endif
134  }
135  }
136 
137  if (side == X1_BEG){ /* -- X1_BEG boundary -- */
138  }
139 
140  if (side == X1_END){ /* -- X1_END boundary -- */
141  }
142 
143  if (side == X2_BEG){ /* -- X2_BEG boundary -- */
144  X2_BEG_LOOP(k,j,i){ }
145  }
146 
147  if (side == X2_END){ /* -- X2_END boundary -- */
148 
149  cs = g_inputParam[CS_AMB];
150  rho = g_inputParam[RHO_AMB];
151  X2_END_LOOP(k,j,i){
152  #if GEOMETRY == CYLINDRICAL
153  d->Vc[VX1][k][j][i] = 0.0;
154  d->Vc[VX2][k][j][i] = -g_inputParam[V_CSM];
155  d->Vc[RHO][k][j][i] = rho;
156  d->Vc[PRS][k][j][i] = cs*cs*rho/g_gamma;
157  #endif
158  }
159  }
160 
161  if (side == X3_BEG){ /* -- X3_BEG boundary -- */
162  X3_BEG_LOOP(k,j,i){}
163  }
164 
165  if (side == X3_END){ /* -- X3_END boundary -- */
166 
167  cs = g_inputParam[CS_AMB];
168  rho = g_inputParam[RHO_AMB];
169  X3_END_LOOP(k,j,i){
170  #if GEOMETRY == CARTESIAN
171  d->Vc[VX1][k][j][i] = 0.0;
172  d->Vc[VX2][k][j][i] = 0.0;
173  d->Vc[VX3][k][j][i] = -g_inputParam[V_CSM];
174  d->Vc[RHO][k][j][i] = rho;
175  d->Vc[PRS][k][j][i] = cs*cs*rho/g_gamma;
176  #endif
177  }
178  }
179 }
#define CS_WIND
#define FLAG_INTERNAL_BOUNDARY
Zone belongs to an internal boundary region and should be excluded from being updated in time...
Definition: pluto.h:184
#define X3_BEG
Boundary region at X3 beg.
Definition: pluto.h:150
#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 X3_END_LOOP(k, j, i)
Definition: macros.h:52
#define TRC
Definition: pluto.h:581
double g_smallPressure
Small value for pressure fix.
Definition: globals.h:110
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define VX1
Definition: mod_defs.h:28
#define X2_BEG_LOOP(k, j, i)
Definition: macros.h:47
#define KDIR
Definition: pluto.h:195
unsigned char *** flag
Pointer to a 3D array setting useful integration flags that are retrieved during integration.
Definition: structs.h:55
#define CS_AMB
#define X2_END_LOOP(k, j, i)
Definition: macros.h:51
#define TOT_LOOP(k, j, i)
Definition: macros.h:44
#define IDIR
Definition: pluto.h:193
#define X2_END
Boundary region at X2 end.
Definition: pluto.h:149
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
double * xgc
Cell volumetric centroid (!= x when geometry != CARTESIAN).
Definition: structs.h:84
#define X3_END
Boundary region at X3 end.
Definition: pluto.h:151
PLUTO main header file.
Definition: structs.h:30
int i
Definition: analysis.c:2
#define RHO_AMB
#define VX3
Definition: mod_defs.h:30
#define V_CSM
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define JDIR
Definition: pluto.h:194
Definition: structs.h:346
#define X3_BEG_LOOP(k, j, i)
Definition: macros.h:48
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