PLUTO
userdef_output.dt.c
Go to the documentation of this file.
1 #include "pluto.h"
2 
3 /* *************************************************************** */
4 void ComputeUserVar (const Data *d, Grid *grid)
5 /*
6  *
7  * PURPOSE
8  *
9  * Define user-defined output variables
10  *
11  *
12  *
13  ***************************************************************** */
14 {
15  int i, j, k, nv;
16  double inv_dl2;
17  double *inv_dl;
18  double ***Ch_dt, ***Cp_dt;
19  static double *cmax, **dcoeff;
20  static double ***T;
21  static State_1D state;
22  Index indx;
23 
24  if (state.rhs == NULL) {
25  MakeState(&state);
26  cmax = ARRAY_1D(NMAX_POINT, double);
27  dcoeff = ARRAY_2D(NMAX_POINT, NVAR, double);
28  T = ARRAY_3D(NX3_TOT, NX2_TOT, NX1_TOT, double);
29  }
30 
31  Ch_dt = GetUserVar("Ch_dt");
32  Cp_dt = GetUserVar("Cp_dt");
33 
34 /* ------------------------------------------------------
35  compute temperature array
36  ------------------------------------------------------ */
37 
38  TOT_LOOP(k,j,i){
39  T[k][j][i] = d->Vc[PRS][k][j][i]/d->Vc[RHO][k][j][i];
40  }
41 
42 /* ------------------------------------------------------
43  X1 sweep over computational zones
44  ------------------------------------------------------ */
45 
46  g_dir = IDIR;
47  SetIndexes (&indx, grid);
48  KDOM_LOOP(k){
49  JDOM_LOOP(j){
50  GetInverse_dl(grid);
51 
52  for (i = 0; i < NX1_TOT; i++){
53  for (nv = NVAR; nv--; ) state.v[i][nv] = d->Vc[nv][k][j][i];
54  }
55  States (&state, IBEG-1, IEND+1, grid);
56  HLL_Solver(&state, IBEG-1, IEND, cmax, grid);
57  TC_Flux (T, &state, dcoeff, IBEG-1, IEND, grid);
58 
59  Ch_dt[k][j][i] = 0.5*(cmax[i] + cmax[i-1])*inv_dl[i];
60 
61  inv_dl2 = 0.5*inv_dl[i]*inv_dl[i];
62  Cp_dt[k][j][i] = (dcoeff[i-1][ENG] + dcoeff[i][ENG])*inv_dl2;
63  }}
64 
65 /* ------------------------------------------------------
66  X2 sweep over computational zones
67  ------------------------------------------------------ */
68 
69  g_dir = JDIR;
70  SetIndexes (&indx, grid);
71  KDOM_LOOP(k){
72  IDOM_LOOP(i){
73  GetInverse_dl(grid);
74 
75  for (j = 0; j < NX2_TOT; j++){
76  for (nv = NVAR; nv--; ) state.v[j][nv] = d->Vc[nv][k][j][i];
77  }
78  States (&state, JBEG-1, JEND+1, grid);
79  HLL_Solver(&state, JBEG-1, JEND, cmax, grid);
80  TC_Flux (T, &state, dcoeff, JBEG-1, JEND, grid);
81 
82  Ch_dt[k][j][i] += 0.5*(cmax[j] + cmax[j-1])*inv_dl[j];
83 
84  inv_dl2 = 0.5*inv_dl[j]*inv_dl[j];
85  Cp_dt[k][j][i] += (dcoeff[j-1][ENG] + dcoeff[j][ENG])*inv_dl2;
86  }}
87 }
88 /* ************************************************************* */
90 /*
91  *
92  *
93  *************************************************************** */
94 {
95  Image *image;
96 
97 }
98 
99 
100 
101 
102 
tuple T
Definition: Sph_disk.py:33
double ** v
Cell-centered primitive varables at the base time level, v[i] = .
Definition: structs.h:134
#define KDOM_LOOP(k)
Definition: macros.h:36
void TC_Flux(double ***, const State_1D *, double **, int, int, Grid *)
Definition: tc_flux.c:57
double ** rhs
Conservative right hand side.
Definition: structs.h:163
void States(const State_1D *, int, int, Grid *)
Definition: plm_states.c:430
#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
double * GetInverse_dl(const Grid *)
Definition: set_geometry.c:205
#define ARRAY_3D(nx, ny, nz, type)
Definition: prototypes.h:172
void MakeState(State_1D *)
Definition: tools.c:51
void ComputeUserVar(const Data *d, Grid *grid)
#define JDOM_LOOP(j)
Definition: macros.h:35
double *** GetUserVar(char *)
Definition: set_output.c:251
#define TOT_LOOP(k, j, i)
Definition: macros.h:44
#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
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
Definition: globals.h:59
int j
Definition: analysis.c:2
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:37
int k
Definition: analysis.c:2
void SetIndexes(Index *indx, Grid *grid)
Definition: set_indexes.c:49
PLUTO main header file.
#define ARRAY_1D(nx, type)
Definition: prototypes.h:170
Definition: structs.h:30
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
Definition: globals.h:62
void ChangeDumpVar()
int i
Definition: analysis.c:2
Definition: structs.h:300
Riemann_Solver HLL_Solver
Definition: mod_defs.h:106
Definition: structs.h:317
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
#define JDIR
Definition: pluto.h:194
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
#define IDOM_LOOP(i)
Definition: macros.h:34
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
static Image image[MAX_IMAGE_NUMBER]
Definition: set_image.c:4
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35