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  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 }
54 /* ********************************************************************* */
55 void Analysis (const Data *d, Grid *grid)
56 /*
57  *
58  *
59  *********************************************************************** */
60 {
61 
62 }
63 /* ********************************************************************* */
64 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
65 /*!
66  * Assign user-defined boundary conditions.
67  *
68  * \param [in/out] d pointer to the PLUTO data structure containing
69  * cell-centered primitive quantities (d->Vc) and
70  * staggered magnetic fields (d->Vs, when used) to
71  * be filled.
72  * \param [in] box pointer to a RBox structure containing the lower
73  * and upper indices of the ghost zone-centers/nodes
74  * or edges at which data values should be assigned.
75  * \param [in] side specifies on which side boundary conditions need
76  * to be assigned. side can assume the following
77  * pre-definite values: X1_BEG, X1_END,
78  * X2_BEG, X2_END,
79  * X3_BEG, X3_END.
80  * The special value side == 0 is used to control
81  * a region inside the computational domain.
82  * \param [in] grid pointer to an array of Grid structures.
83  *
84  *********************************************************************** */
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 }
115 
static double alpha
Definition: init.c:3
#define BZ_RIGHT
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
double g_gamma
Definition: globals.h:112
#define PR_RIGHT
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#define VX2
Definition: mod_defs.h:29
#define PR_LEFT
#define RHO
Definition: mod_defs.h:19
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 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 X2_END
Boundary region at X2 end.
Definition: pluto.h:149
Definition: structs.h:78
#define AX3
Definition: mod_defs.h:87
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
#define BX1s
Definition: ct.h:27
tuple c
Definition: menu.py:375
#define s
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
#define BX_CONST
#define VX_LEFT
Definition: structs.h:30
#define VZ_RIGHT
#define GAMMA_EOS
int i
Definition: analysis.c:2
#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 X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define BX2
Definition: mod_defs.h:26
#define VX_RIGHT
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
Definition: structs.h:346
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
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