PLUTO
init.c File Reference
#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)
 

Variables

static double alpha
 
static double pe
 

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

Compute volume-integrated magnetic pressure, Maxwell and Reynolds stresses. Save them to "averages.dat"

Definition at line 63 of file init.c.

68 {
69 
70 }

Here is the caller graph for this function:

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 6 of file init.c.

12 {
13  double vj, cs, Mach;
14  double lor, vy_in, rhob, rhom, pm, pb, hb, hm, eta, vjet;
15  double sigma;
16  static int first_call = 1;
17 
18  g_gamma = 4.0/3.0;
19 
22 
23  us[RHO] = 1.e3;
24  us[VX1] = 0.0;
25  us[VX2] = 0.0;
26  us[VX3] = 0.0;
27  us[BX1] = 0.0;
28  us[BX2] = 0.0;
29  us[BX3] = 0.0;
30  us[PRS] = pe;
31 
32  us[AX1] = us[AX2] = us[AX3] = 0.0;
33 
34  if (first_call){
35  first_call = 0;
36  vj = sqrt(1.0 - 1.0/100.);
37  cs = sqrt(g_gamma*pe/(us[RHO] + pe*g_gamma/(g_gamma-1.0)));
38  Mach = vj/cs;
39  print ("Mach number = %12.6e\n",Mach);
40 
41 /* ----- estimate jet velocity --------- */
42 
43  lor = 10.0;
44  vy_in = sqrt(1.0 - 1.0/lor/lor);
45  rhob = g_inputParam[RHO_IN];
46  rhom = 1.e3;
47  pm = pb = pe;
48  hb = 1.0 + g_gamma/(g_gamma - 1.0)*pb/rhob;
49  hm = 1.0 + g_gamma/(g_gamma - 1.0)*pm/rhom;
50 
51  eta = rhob*hb/(rhom*hm)*lor*lor;
52  vjet = sqrt(eta)/(1.0 + sqrt(eta))*vy_in;
53  print (" Estimated jet velocity = %f\n",vjet);
54 
55 /* ---- estimate sigma (= b^2/rho) ---- */
56 
57  sigma = g_inputParam[RM]*g_inputParam[RM]*(0.5 - 2.0*log(g_inputParam[RM]));
58  print (" sigma = %f\n",1.0/sigma);
59 
60  }
61 }
static double alpha
Definition: init.c:3
double g_gamma
Definition: globals.h:112
#define VX2
Definition: mod_defs.h:29
#define BM
#define BETA
#define RHO_IN
#define RHO
Definition: mod_defs.h:19
static double *** eta[3]
Definition: res_functions.c:94
#define AX2
Definition: mod_defs.h:86
#define VX1
Definition: mod_defs.h:28
#define AX3
Definition: mod_defs.h:87
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
#define BX3
Definition: mod_defs.h:27
#define RM
static double pe
Definition: init.c:3
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define BX2
Definition: mod_defs.h:26

Here is the call graph for this function:

Here is the caller graph for this function:

void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Assign user-defined boundary conditions.

Parameters
[in/out]d pointer 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 on which side boundary conditions need to be assigned. side 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.

Definition at line 73 of file init.c.

94 {
95  int i, j, k, nv;
96  double rho_out, vx_out, vy_out, vz_out;
97  double pr_out, bx_out, by_out, bz_out;
98  double prof, lor, pr_in, vy_in, bz_in, *r;
99 
100 
101  #ifdef STAGGERED_MHD
102  #error Boundary not implemented for Staggered MHD
103  #endif
104 
105  if (side == X2_BEG){
106  if (box->vpos == CENTER){
107  r = grid[IDIR].x;
108  BOX_LOOP(box,k,j,i){
109 
110  rho_out = d->Vc[RHO][k][2*JBEG - j - 1][i];
111  EXPAND(vx_out = d->Vc[VX1][k][2*JBEG - j - 1][i]; ,
112  vy_out = -d->Vc[VX2][k][2*JBEG - j - 1][i]; ,
113  vz_out = d->Vc[VX3][k][2*JBEG - j - 1][i];)
114  EXPAND(bx_out = d->Vc[BX1][k][2*JBEG - j - 1][i]; ,
115  by_out = d->Vc[BX2][k][2*JBEG - j - 1][i]; ,
116  bz_out = -d->Vc[BX3][k][2*JBEG - j - 1][i];)
117  pr_out = d->Vc[PRS][k][2*JBEG - j - 1][i];
118 
119  prof = (r[i] <= 1.0 ? 1.0 : 0.0);
120 
121  lor = 10.0;
122  vy_in = sqrt(1.0 - 1.0/lor/lor);
123 
124  if (r[i] <= 1.0) {
125  prof = 1.0;
126  bz_in = lor*g_inputParam[BM]*g_inputParam[RM]/r[i];
127  pr_in = alpha*pe;
128  if (r[i] <= g_inputParam[RM]) {
129  bz_in = lor*g_inputParam[BM]*r[i]/g_inputParam[RM];
130  pr_in = pe*(alpha + 2.0/g_inputParam[BETA]*(1.0 - r[i]*r[i]/g_inputParam[RM]/g_inputParam[RM]));
131  }
132  }else{
133  prof = 0.0;
134  }
135 
136  d->Vc[RHO][k][j][i] = rho_out - (rho_out - g_inputParam[RHO_IN])*prof;
137  EXPAND(d->Vc[VX1][k][j][i] = vx_out*(1.0 - prof); ,
138  d->Vc[VX2][k][j][i] = vy_out - (vy_out - vy_in)*prof; ,
139  d->Vc[VX3][k][j][i] = vz_out*(1.0 - prof);)
140 
141  EXPAND(d->Vc[BX1][k][j][i] = bx_out*(1.0 - prof); ,
142  d->Vc[BX2][k][j][i] = by_out*(1.0 - prof); ,
143  d->Vc[BX3][k][j][i] = bz_out - (bz_out - bz_in)*prof; )
144  d->Vc[PRS][k][j][i] = pr_out - (pr_out - pr_in)*prof;
145  }
146  }
147  }
148 }
static double alpha
Definition: init.c:3
#define VX2
Definition: mod_defs.h:29
#define BM
#define BETA
#define RHO_IN
#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 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 VX1
Definition: mod_defs.h:28
#define IDIR
Definition: pluto.h:193
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
int j
Definition: analysis.c:2
if(divB==NULL)
Definition: analysis.c:10
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
#define BX3
Definition: mod_defs.h:27
int i
Definition: analysis.c:2
#define RM
static double pe
Definition: init.c:3
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define BX2
Definition: mod_defs.h:26
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
Definition: globals.h:39

Here is the caller graph for this function:

Variable Documentation

double alpha
static

Definition at line 3 of file init.c.

double pe
static

Definition at line 3 of file init.c.