PLUTO
init.c File Reference

Stellar wind test problem. More...

#include "pluto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

void Init (double *us, double x1, double x2, double x3)
 
void Analysis (const Data *d, Grid *grid)
 
void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

Stellar wind test problem.

Sets initial condition for a spherically symmetric radial wind blowing from the origin of coordinates, see [Mig14] The initial condition consists of a constant-density ambient medium with

\[ \rho = \rho_a \,,\qquad p = p_a\,,\qquad \vec{v} = v_{csm}\hvec{j} \]

where v_csm is the velocity of the star with respect to the background. The wind is injeted using the INTERNAL_BOUNDARY where flow quantities are kept constant in time and equal to

\[ r^2v_r\rho = \rho_0 V_0^2r_0^2 \,,\qquad v_r = V_0\hvec{r} \,,\qquad p = \frac{c_s^2}{\Gamma}\rho^\Gamma \]

These value are defined through the UserDefBoundary() function when side is equal to 0.

Dimensions are chosen so that the spherical wind shell has radius 1, density 1 and velocity 1 ( $ r_0 = V_0 = \rho_0 = 1$).

The input parameters that control the problem dynamics are

  • g_inputParam[CS_WIND]: sets the sound speed in the wind region;
  • g_inputParam[RHO_AMB]: sets the ambient density
  • g_inputParam[CS_AMB]: sets the ambient sound speed;
  • g_inputParam[V_CSM]: sets the velocity of the star with respect to the background;

Configurations #01-05 and #07-08 work in 2D cylindrical axisymmetric coordinates while conf. #06 is 3D Cartesian. An AMR setup is available with configuration #04.

hd_stellar_wind.08.jpg
Density map at the end of computation for configuration #8
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Sept 25, 2012

References

  • [Mig14]: "High-order conservative reconstruction schemes for finite volume methods in cylindrical and spherical coordinates", Mignone, JCP (2014) 270, 784

Definition in file init.c.

Function Documentation

void Analysis ( const Data d,
Grid grid 
)

Perform runtime data analysis.

Parameters
[in]dthe PLUTO Data structure
[in]gridpointer to array of Grid structures

Definition at line 81 of file init.c.

85 {
86 
87 }
void Init ( double *  us,
double  x1,
double  x2,
double  x3 
)

The Init() function can be used to assign initial conditions as as a function of spatial position.

Parameters
[out]va pointer to a vector of primitive variables
[in]x1coordinate point in the 1st dimension
[in]x2coordinate point in the 2nd dimension
[in]x3coordinate point in the 3rdt dimension

The meaning of x1, x2 and x3 depends on the geometry:

\[ \begin{array}{cccl} x_1 & x_2 & x_3 & \mathrm{Geometry} \\ \noalign{\medskip} \hline x & y & z & \mathrm{Cartesian} \\ \noalign{\medskip} R & z & - & \mathrm{cylindrical} \\ \noalign{\medskip} R & \phi & z & \mathrm{polar} \\ \noalign{\medskip} r & \theta & \phi & \mathrm{spherical} \end{array} \]

Variable names are accessed by means of an index v[nv], where nv = RHO is density, nv = PRS is pressure, nv = (VX1, VX2, VX3) are the three components of velocity, and so forth.

Definition at line 51 of file init.c.

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 }
double g_gamma
Definition: globals.h:112
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
#define TRC
Definition: pluto.h:581
double g_smallPressure
Small value for pressure fix.
Definition: globals.h:110
#define VX1
Definition: mod_defs.h:28
#define CS_AMB
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
#define RHO_AMB
#define VX3
Definition: mod_defs.h:30
#define V_CSM
void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Assign user-defined boundary conditions.

Parameters
[in,out]dpointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies the boundary side where ghost zones need to be filled. It can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Assign user-defined boundary conditions in the lower boundary ghost zones. The profile is top-hat:

\[ V_{ij} = \left\{\begin{array}{ll} V_{\rm jet} & \quad\mathrm{for}\quad r_i < 1 \\ \noalign{\medskip} \mathrm{Reflect}(V) & \quad\mathrm{otherwise} \end{array}\right. \]

where $ V_{\rm jet} = (\rho,v,p)_{\rm jet} = (1,M,1/\Gamma)$ and M is the flow Mach number (the unit velocity is the jet sound speed, so $ v = M$).

Assign user-defined boundary conditions:

  • left side (x beg): constant shocked values
  • bottom side (y beg): constant shocked values for x < 1/6 and reflective boundary otherwise.
  • top side (y end): time-dependent boundary: for $ x < x_s(t) = 10 t/\sin\alpha + 1/6 + 1.0/\tan\alpha $ we use fixed (post-shock) values. Unperturbed values otherwise.

Definition at line 90 of file init.c.

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
#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 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
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
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
#define X3_BEG_LOOP(k, j, i)
Definition: macros.h:48