PLUTO
bckgrnd_field.c
Go to the documentation of this file.
1 #include "pluto.h"
2 
3 #if BACKGROUND_FIELD == YES
4 /* ********************************************************************* */
5 double **GetBackgroundField (int beg, int end, int where, Grid *grid)
6 /*
7  *
8  *
9  *
10  *
11  *
12  *********************************************************************** */
13 {
14  int i;
15  double *x1, *x2, *x3;
16  static double **bck_fld;
17 
18 /* ----------------------------------------------------
19  Check for incompatibilities
20  ---------------------------------------------------- */
21 
22  #if (TIME_STEPPING != RK2) && (TIME_STEPPING != RK3)
23  print1 ("! Background field splitting works with RK integrators ONLY \n");
24  QUIT_PLUTO(1);
25  #endif
26  #if DIVB_CONTROL == EIGHT_WAVES
27  print1 ("! Background field splitting works with CT or GLM ONLY \n");
28  QUIT_PLUTO(1);
29  #elif DIVB_CONTROL == CONSTRAINED_TRANSPORT
30  #if (CT_EMF_AVERAGE != ARITHMETIC) && (CT_EMF_AVERAGE != UCT_HLL)
31  print1 ("! Background field splitting works with ARITHMETIC or");
32  print1 (" UCT_HLL averages only\n");
33  QUIT_PLUTO(1);
34  #endif
35  #endif
36 
37  if (bck_fld == NULL) {
38  bck_fld = ARRAY_2D(NMAX_POINT, NVAR, double);
39  }
40 
41 /* ----------------------------------
42  get pointers to coordinates
43  ---------------------------------- */
44 
45  x1 = grid[IDIR].x;
46  x2 = grid[JDIR].x;
47  x3 = grid[KDIR].x;
48 
49  if (g_dir == IDIR){
50  if (where == FACE_CENTER) x1 = grid[IDIR].xr;
51  for (i = beg; i <= end; i++){
52  BackgroundField (x1[i],x2[g_j],x3[g_k], bck_fld[i] + BX1);
53  }
54  }else if (g_dir == JDIR){
55  if (where == FACE_CENTER) x2 = grid[JDIR].xr;
56  for (i = beg; i <= end; i++){
57  BackgroundField (x1[g_i],x2[i],x3[g_k], bck_fld[i] + BX1);
58  }
59  }else{
60  if (where == FACE_CENTER) x3 = grid[KDIR].xr;
61  for (i = beg; i <= end; i++){
62  BackgroundField (x1[g_i],x2[g_j],x3[i], bck_fld[i] + BX1);
63  }
64  }
65 
66  return(bck_fld);
67 }
68 #endif
void print1(const char *fmt,...)
Definition: amrPluto.cpp:511
double * xr
Definition: structs.h:81
void BackgroundField(double x1, double x2, double x3, double *B0)
Definition: init.c:79
double ** GetBackgroundField(int beg, int end, int where, Grid *grid)
Definition: bckgrnd_field.c:5
#define KDIR
Definition: pluto.h:195
int g_i
x1 grid index when sweeping along the x2 or x3 direction.
Definition: globals.h:82
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
#define FACE_CENTER
Definition: pluto.h:206
int g_j
x2 grid index when sweeping along the x1 or x3 direction.
Definition: globals.h:83
Definition: structs.h:78
double * x
Definition: structs.h:80
int g_k
x3 grid index when sweeping along the x1 or x2 direction.
Definition: globals.h:84
PLUTO main header file.
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
Definition: globals.h:62
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
#define JDIR
Definition: pluto.h:194
#define NVAR
Definition: pluto.h:609
#define QUIT_PLUTO(e_code)
Definition: macros.h:125