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

29 {
30 
31 }
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 
12  g_gamma = 1.4;
13 
14  us[VX1] = (x1>0.6 && x2<0.2 ? 0.0:3.0);
15  us[VX2] = 0.0;
16  us[VX3] = 0.0;
17  us[TRC] = 0.0;
18 
19  us[RHO] = 1.4;
20  us[PRS] = 1.0;
21 
22 }
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
#define VX1
Definition: mod_defs.h:28
#define VX3
Definition: mod_defs.h:30
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.

Definition at line 34 of file init.c.

55 {
56  int i, j, k, i1, j1;
57  double *x, *y;
58 
59  x = grid[IDIR].x;
60  y = grid[JDIR].x;
61 
62  if (side == 0 && g_dir == IDIR){
63  KDOM_LOOP(k) {
64  JDOM_LOOP(j) {
65  if (y[j] > 0.2) continue;
66  IDOM_LOOP(i){
67  if (x[i] > 0.6 && x[i-1] < 0.6){
68  for (i1 = i; i1 <= i + 3; i1++){
69  d->Vc[RHO][k][j][i1] = d->Vc[RHO][k][j][2*i - i1 - 1];
70  d->Vc[VX1][k][j][i1] = -d->Vc[VX1][k][j][2*i - i1 - 1];
71  d->Vc[VX2][k][j][i1] = d->Vc[VX2][k][j][2*i - i1 - 1];
72  d->Vc[PRS][k][j][i1] = d->Vc[PRS][k][j][2*i - i1 - 1];
73  }
74  }
75  }
76  }}
77  }
78 
79  if (side == 0 && g_dir == JDIR){
80  KDOM_LOOP(k) {
81  IDOM_LOOP(i) {
82  if (x[i] < 0.6) continue;
83  JDOM_LOOP(j){
84  if (y[j] > 0.2 && y[j-1] < 0.2){
85  for (j1 = j - 1; j1 >= j - 4; j1--){
86  d->Vc[RHO][k][j1][i] = d->Vc[RHO][k][2*j - j1 - 1][i];
87  d->Vc[VX1][k][j1][i] = d->Vc[VX1][k][2*j - j1 - 1][i];
88  d->Vc[VX2][k][j1][i] = -d->Vc[VX2][k][2*j - j1 - 1][i];
89  d->Vc[PRS][k][j1][i] = d->Vc[PRS][k][2*j - j1 - 1][i];
90  }
91  }
92  }
93  }}
94  }
95 
96 
97  if (side == X1_BEG){
98  X1_BEG_LOOP(k,j,i){
99  d->Vc[RHO][k][j][i] = 1.4;
100  d->Vc[VX1][k][j][i] = 3.0;
101  d->Vc[VX2][k][j][i] = 0.0;
102  d->Vc[PRS][k][j][i] = 1.0;
103  }
104  }
105 
106 }
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
#define KDOM_LOOP(k)
Definition: macros.h:36
#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 VX1
Definition: mod_defs.h:28
#define JDOM_LOOP(j)
Definition: macros.h:35
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
#define X1_BEG_LOOP(k, j, i)
Definition: macros.h:46
int i
Definition: analysis.c:2
#define JDIR
Definition: pluto.h:194
#define IDOM_LOOP(i)
Definition: macros.h:34