PLUTO
init.c
Go to the documentation of this file.
1 #include "pluto.h"
2 
3 /* ********************************************************************* */
4 void Init (double *us, double x1, double x2, double x3)
5 /*
6  *
7  *
8  *
9  *********************************************************************** */
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 }
23 /* ********************************************************************* */
24 void Analysis (const Data *d, Grid *grid)
25 /*
26  *
27  *
28  *********************************************************************** */
29 {
30 
31 }
32 
33 /* ********************************************************************* */
34 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
35 /*!
36  * Assign user-defined boundary conditions.
37  *
38  * \param [in,out] d pointer to the PLUTO data structure containing
39  * cell-centered primitive quantities (d->Vc) and
40  * staggered magnetic fields (d->Vs, when used) to
41  * be filled.
42  * \param [in] box pointer to a RBox structure containing the lower
43  * and upper indices of the ghost zone-centers/nodes
44  * or edges at which data values should be assigned.
45  * \param [in] side specifies the boundary side where ghost zones need
46  * to be filled. It can assume the following
47  * pre-definite values: X1_BEG, X1_END,
48  * X2_BEG, X2_END,
49  * X3_BEG, X3_END.
50  * The special value side == 0 is used to control
51  * a region inside the computational domain.
52  * \param [in] grid pointer to an array of Grid structures.
53  *
54  *********************************************************************** */
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 }
107 
108 
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
#define KDOM_LOOP(k)
Definition: macros.h:36
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 TRC
Definition: pluto.h:581
#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
Definition: structs.h:78
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
PLUTO main header file.
#define X1_BEG_LOOP(k, j, i)
Definition: macros.h:46
Definition: structs.h:30
int i
Definition: analysis.c:2
#define VX3
Definition: mod_defs.h:30
#define JDIR
Definition: pluto.h:194
Definition: structs.h:346
#define IDOM_LOOP(i)
Definition: macros.h:34
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