PLUTO
failsafe.c
Go to the documentation of this file.
1 #include"pluto.h"
2 
3 static int nstep0;
4 static Data_Arr V0, Vs0;
5 static double t0, dt0;
6 
7 /* ************************************************************ */
8 void SAVE_SOL (Data *d, Grid *grid)
9 /*
10  *
11  * Save all necessary information to re-start the
12  * computation at runtime level.
13  *
14  ************************************************************** */
15 {
16  int i, j, k;
17 
18  if (V0 == NULL){
19  V0 = ARRAY_4D(NVAR, NX3_TOT, NX2_TOT, NX1_TOT, double);
20  #ifdef STAGGERED_MHD
21  Vs0 = ARRAY_4D(NVAR, NX3_TOT, NX2_TOT, NX1_TOT, double);
22  #endif
23  }
24 
25  for (nv = NVAR; nv--; ){
26  DOM_LOOP(k,j,i){
27  V0[nv][k][j][i] = d->Vc[nv][k][j][i];
28  }}
29 
30  #ifdef STAGGERED_MHD
31  for (k = KBEG-1; k <= KEND; k++){
32  for (j = JBEG-1; j <= JEND; j++){
33  for (i = IBEG-1; i <= IEND; i++){
34  D_EXPAND(
35  Vs0[BX1s][k][j][i] = d->Vs[BX1s][k][j][i]; ,
36  Vs0[BX2s][k][j][i] = d->Vs[BX2s][k][j][i]; ,
37  Vs0[BX3s][k][j][i] = d->Vs[BX3s][k][j][i];)
38  }}}
39  #endif
40 
42  dt0 = g_dt;
43  t0 = g_time;
44 }
45 
46 /* ************************************************************ */
47 void GET_SOL (Data *d, Grid *grid)
48 /*
49  *
50  * Restore previously saved solution array
51  *
52  ************************************************************** */
53 
54 {
55  for (nv = NVAR; nv--; ){
56  DOM_LOOP(k,j,i){
57  d->Vc[nv][k][j][i] = V0[nv][k][j][i];
58  }}
59 
60  #ifdef STAGGERED_MHD
61  for (k = KBEG-1; k <= KEND; k++){
62  for (j = JBEG-1; j <= JEND; j++){
63  for (i = IBEG-1; i <= IEND; i++){
64  D_EXPAND(
65  d->Vs[BX1s][k][j][i] = Vs0[BX1s][k][j][i]; ,
66  d->Vs[BX2s][k][j][i] = Vs0[BX2s][k][j][i]; ,
67  d->Vs[BX3s][k][j][i] = Vs0[BX3s][k][j][i];)
68  }}}
69  #endif
71  g_dt = dt0;
72  t0 = g_time;
73 
74 }
75 
static Data_Arr V0
Definition: failsafe.c:4
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
double **** Data_Arr
Definition: pluto.h:492
DOM_LOOP(k, j, i)
Definition: analysis.c:22
void GET_SOL(Data *d, Grid *grid)
Definition: failsafe.c:47
void SAVE_SOL(Data *d, Grid *grid)
Definition: failsafe.c:8
static Data_Arr Vs0
Definition: failsafe.c:4
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 g_dt
The current integration time step.
Definition: globals.h:118
#define BX3s
Definition: ct.h:29
long int g_stepNumber
Gives the current integration step number.
Definition: globals.h:97
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
#define ARRAY_4D(nx, ny, nz, nv, type)
Definition: prototypes.h:173
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
#define BX1s
Definition: ct.h:27
static double dt0
Definition: failsafe.c:5
PLUTO main header file.
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
Definition: analysis.c:27
Definition: structs.h:30
int i
Definition: analysis.c:2
double g_time
The current integration time.
Definition: globals.h:117
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:43
#define BX2s
Definition: ct.h:28
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:45
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
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35
static double t0
Definition: failsafe.c:5
static int nstep0
Definition: failsafe.c:3