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)
 

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

60 {
61 
62 }
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 4 of file init.c.

10 {
11  double x,y;
12  double c,s,alpha;
13 
15 
16  alpha = atan(2.0);
17 
18  x = x1;
19  y = x2;
20 
21  c = cos(alpha);
22  s = sin(alpha);
23 
24  if ( (s*y + c*(x - 0.5)) < 1.e-6){
25 
26  us[RHO] = g_inputParam[RHO_LEFT];
29  us[VX3] = g_inputParam[VZ_LEFT];
32  us[BX3] = g_inputParam[BZ_LEFT];
33  us[PRS] = g_inputParam[PR_LEFT];
34 
35  }else{
36 
37  us[RHO] = g_inputParam[RHO_RIGHT];
40  us[VX3] = g_inputParam[VZ_RIGHT];
43  us[BX3] = g_inputParam[BZ_RIGHT];
44  us[PRS] = g_inputParam[PR_RIGHT];
45  }
46 
47  us[BX1] /= sqrt(4.0*CONST_PI);
48  us[BX2] /= sqrt(4.0*CONST_PI);
49  us[BX3] /= sqrt(4.0*CONST_PI);
50 
51  us[AX1] = us[AX2] = 0.0;
52  us[AX3] = y*us[BX1] - x*us[BX2];
53 }
static double alpha
Definition: init.c:3
#define BZ_RIGHT
double g_gamma
Definition: globals.h:112
#define PR_RIGHT
#define VX2
Definition: mod_defs.h:29
#define PR_LEFT
#define RHO
Definition: mod_defs.h:19
#define BY_LEFT
#define AX2
Definition: mod_defs.h:86
#define VY_RIGHT
#define VX1
Definition: mod_defs.h:28
#define RHO_LEFT
#define RHO_RIGHT
#define VZ_LEFT
#define VY_LEFT
#define BZ_LEFT
#define AX3
Definition: mod_defs.h:87
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
double * x
Definition: structs.h:80
tuple c
Definition: menu.py:375
#define s
#define BX3
Definition: mod_defs.h:27
#define BX_CONST
#define VX_LEFT
#define VZ_RIGHT
#define GAMMA_EOS
#define BY_RIGHT
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define CONST_PI
.
Definition: pluto.h:269
#define BX2
Definition: mod_defs.h:26
#define VX_RIGHT
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 64 of file init.c.

85 {
86  int i, j, k, nv;
87  double x1, x2, x3;
88 
89  if (side == X2_BEG){ /* -- X2_BEG boundary -- */
90  k = 0;
91  for (j = JBEG; j--; ) {
92  for (i = 1; i < NX1_TOT; i++){
93  for (nv = NVAR; nv--; ){
94  d->Vc[nv][k][j][i] = d->Vc[nv][k][j + 1][i - 1];
95  }
96  #ifdef STAGGERED_MHD
97  d->Vs[BX1s][k][j][i] = d->Vs[BX1s][k][j + 1][i - 1];
98  #endif
99  }}
100  }
101 
102  if (side == X2_END){ /* -- X2_END boundary -- */
103  k = 0;
104  for (j = JEND + 1; j < NX2_TOT; j++) {
105  for (i = 0; i < NX1_TOT - 1; i++){
106  for (nv = NVAR; nv--; ){
107  d->Vc[nv][k][j][i] = d->Vc[nv][k][j - 1][i + 1];
108  }
109  #ifdef STAGGERED_MHD
110  d->Vs[BX1s][k][j][i] = d->Vs[BX1s][k][j - 1][i + 1];
111  #endif
112  }}
113  }
114 }
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
Definition: globals.h:57
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define X2_END
Boundary region at X2 end.
Definition: pluto.h:149
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
#define BX1s
Definition: ct.h:27
int i
Definition: analysis.c:2
#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
#define NVAR
Definition: pluto.h:609
long int JEND
Upper grid index of the computational domain in the the X2 direction for the local processor...
Definition: globals.h:41
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
Definition: globals.h:55