PLUTO
rbox.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Basic RBox database.
5 
6  The function SetRBox() defines an array of predefined RBox structures
7  needed to loop through different portions (or regions) of the
8  computational domain.
9 
10  - rbox_center: an array of RBoxes for looping over the cell-centered data.
11  - rbox_x1face: an array of RBoxes for looping over the X1-staggered data.
12  - rbox_x2face: an array of RBoxes for looping over the X2-staggered data.
13  - rbox_x3face: an array of RBoxes for looping over the X3-staggered data.
14 
15  Each array of structures has 8 elements corresponding to the six sides
16  of the computational domain (X1_BEG, ... , X3_END) and, in addition,
17  we also define the DOM and TOT array indices to loop over the active
18  computational zones or over the total
19  computational domain (interior + ghost zones), respectively.
20 
21  The function GetRBox() can be used to retrieve a pointer to a RBox
22  structure given the computational side and the variable position.
23 
24  \author A. Mignone (mignone@ph.unito.it)
25  \date May 13, 2015
26 */
27 /* ///////////////////////////////////////////////////////////////////// */
28 #include "pluto.h"
29 
31 
32 /* ********************************************************************* */
33 void SetRBox(void)
34 /*!
35  *
36  *
37  *********************************************************************** */
38 {
39  int s;
40 
41 /* ---------------------------------------------------
42  0. Set X1_BEG grid index ranges
43  --------------------------------------------------- */
44 
45  s = X1_BEG; s -= X1_BEG;
46 
47  rbox_center[s].vpos = CENTER;
48 
49  rbox_center[s].ib = IBEG-1; rbox_center[s].ie = 0;
50  rbox_center[s].jb = 0; rbox_center[s].je = NX2_TOT-1;
51  rbox_center[s].kb = 0; rbox_center[s].ke = NX3_TOT-1;
52 
53  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
54 
55  #ifndef CHOMBO /* -- useless for AMR -- */
56  rbox_x1face[s].vpos = X1FACE;
57  rbox_x2face[s].vpos = X2FACE;
58  rbox_x3face[s].vpos = X3FACE;
59 
60  D_EXPAND(rbox_x1face[s].ib--; rbox_x1face[s].ie--; ,
61  rbox_x2face[s].jb--; ,
62  rbox_x3face[s].kb--;)
63  #endif
64 
65 /* ---------------------------------------------------
66  1. set X1_END grid index ranges
67  --------------------------------------------------- */
68 
69  s = X1_END; s -= X1_BEG;
70 
71  rbox_center[s].vpos = CENTER;
72 
73  rbox_center[s].ib = IEND+1; rbox_center[s].ie = NX1_TOT-1;
74  rbox_center[s].jb = 0; rbox_center[s].je = NX2_TOT-1;
75  rbox_center[s].kb = 0; rbox_center[s].ke = NX3_TOT-1;
76 
77  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
78 
79  #ifndef CHOMBO /* -- useless for AMR -- */
80  rbox_x1face[s].vpos = X1FACE;
81  rbox_x2face[s].vpos = X2FACE;
82  rbox_x3face[s].vpos = X3FACE;
83 
84  D_EXPAND( ; ,
85  rbox_x2face[s].jb--; ,
86  rbox_x3face[s].kb--;)
87  #endif
88 
89 /* ---------------------------------------------------
90  2. set X2_BEG grid index ranges
91  --------------------------------------------------- */
92 
93  s = X2_BEG; s -= X1_BEG;
94 
95  rbox_center[s].vpos = CENTER;
96 
97  rbox_center[s].ib = 0; rbox_center[s].ie = NX1_TOT-1;
98  rbox_center[s].jb = JBEG-1; rbox_center[s].je = 0;
99  rbox_center[s].kb = 0; rbox_center[s].ke = NX3_TOT-1;
100 
101  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
102 
103  #ifndef CHOMBO /* -- useless for AMR -- */
104  rbox_x1face[s].vpos = X1FACE;
105  rbox_x2face[s].vpos = X2FACE;
106  rbox_x3face[s].vpos = X3FACE;
107 
108  D_EXPAND(rbox_x1face[s].ib--; ,
109  rbox_x2face[s].jb--; rbox_x2face[s].je--; ,
110  rbox_x3face[s].kb--;)
111  #endif
112 
113 /* ---------------------------------------------------
114  3. set X2_END grid index ranges
115  --------------------------------------------------- */
116 
117  s = X2_END; s -= X1_BEG;
118 
119  rbox_center[s].vpos = CENTER;
120 
121  rbox_center[s].ib = 0; rbox_center[s].ie = NX1_TOT-1;
122  rbox_center[s].jb = JEND+1; rbox_center[s].je = NX2_TOT-1;
123  rbox_center[s].kb = 0; rbox_center[s].ke = NX3_TOT-1;
124 
125  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
126 
127  #ifndef CHOMBO /* -- useless for AMR -- */
128  rbox_x1face[s].vpos = X1FACE;
129  rbox_x2face[s].vpos = X2FACE;
130  rbox_x3face[s].vpos = X3FACE;
131 
132  D_EXPAND(rbox_x1face[s].ib--; ,
133  ; ,
134  rbox_x3face[s].kb--;)
135  #endif
136 
137 /* ---------------------------------------------------
138  4. set X3_BEG grid index ranges
139  --------------------------------------------------- */
140 
141  s = X3_BEG; s -= X1_BEG;
142 
143  rbox_center[s].vpos = CENTER;
144 
145  rbox_center[s].ib = 0; rbox_center[s].ie = NX1_TOT-1;
146  rbox_center[s].jb = 0; rbox_center[s].je = NX2_TOT-1;
147  rbox_center[s].kb = KBEG-1; rbox_center[s].ke = 0;
148 
149  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
150 
151  #ifndef CHOMBO /* -- useless for AMR -- */
152  rbox_x1face[s].vpos = X1FACE;
153  rbox_x2face[s].vpos = X2FACE;
154  rbox_x3face[s].vpos = X3FACE;
155 
156  D_EXPAND(rbox_x1face[s].ib--; ,
157  rbox_x2face[s].jb--; ,
158  rbox_x3face[s].kb--; rbox_x3face[s].ke--;)
159  #endif
160 
161 /* ---------------------------------------------------
162  5. set X3_END grid index ranges
163  --------------------------------------------------- */
164 
165  s = X3_END; s -= X1_BEG;
166 
167  rbox_center[s].vpos = CENTER;
168 
169  rbox_center[s].ib = 0; rbox_center[s].ie = NX1_TOT-1;
170  rbox_center[s].jb = 0; rbox_center[s].je = NX2_TOT-1;
171  rbox_center[s].kb = KEND+1; rbox_center[s].ke = NX3_TOT-1;
172 
173  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
174 
175  #ifndef CHOMBO /* -- useless for AMR -- */
176  rbox_x1face[s].vpos = X1FACE;
177  rbox_x2face[s].vpos = X2FACE;
178  rbox_x3face[s].vpos = X3FACE;
179 
180  D_EXPAND(rbox_x1face[s].ib--; ,
181  rbox_x2face[s].jb--; ,
182  ;)
183  #endif
184 
185 /* ---------------------------------------------------
186  6. set DOM index ranges
187  --------------------------------------------------- */
188 
189  s = DOM; s -= X1_BEG;
190 
191  rbox_center[s].vpos = CENTER;
192  rbox_center[s].ib = IBEG; rbox_center[s].ie = IEND;
193  rbox_center[s].jb = JBEG; rbox_center[s].je = JEND;
194  rbox_center[s].kb = KBEG; rbox_center[s].ke = KEND;
195 
196  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
197 
198  #ifndef CHOMBO /* -- useless for AMR -- */
199  rbox_x1face[s].vpos = X1FACE;
200  rbox_x2face[s].vpos = X2FACE;
201  rbox_x3face[s].vpos = X3FACE;
202 
203  D_EXPAND(rbox_x1face[s].ib--; ,
204  rbox_x2face[s].jb--; ,
205  rbox_x3face[s].kb--;)
206  #endif
207 
208 /* ---------------------------------------------------
209  7. set TOT index ranges
210  --------------------------------------------------- */
211 
212  s = TOT; s -= X1_BEG;
213 
214  rbox_center[s].vpos = CENTER;
215  rbox_center[s].ib = 0; rbox_center[s].ie = NX1_TOT-1;
216  rbox_center[s].jb = 0; rbox_center[s].je = NX2_TOT-1;
217  rbox_center[s].kb = 0; rbox_center[s].ke = NX3_TOT-1;
218 
219  rbox_x1face[s] = rbox_x2face[s] = rbox_x3face[s] = rbox_center[s];
220 
221  #ifndef CHOMBO /* -- useless for AMR -- */
222  rbox_x1face[s].vpos = X1FACE;
223  rbox_x2face[s].vpos = X2FACE;
224  rbox_x3face[s].vpos = X3FACE;
225 
226  D_EXPAND(rbox_x1face[s].ib--; ,
227  rbox_x2face[s].jb--; ,
228  rbox_x3face[s].kb--;)
229  #endif
230 }
231 /* ********************************************************************* */
232 RBox *GetRBox(int side, int vpos)
233 /*!
234  * Returns a pointer to a local static RBox
235  *
236  * \param[in] side the region of the computational domain where
237  * the box is required. There 8 possible values:
238  * X1_BEG, ... , X3_END, DOM, TOT.
239  * \param[in] vpos the variable position inside the cell:
240  * CENTER, X1FACE, X2FACE or X3FACE.
241  *
242  *********************************************************************** */
243 {
244  if (vpos == CENTER) return &(rbox_center[side-X1_BEG]);
245  else if (vpos == X1FACE) return &(rbox_x1face[side-X1_BEG]);
246  else if (vpos == X2FACE) return &(rbox_x2face[side-X1_BEG]);
247  else if (vpos == X3FACE) return &(rbox_x3face[side-X1_BEG]);
248 }
249 
#define X3_BEG
Boundary region at X3 beg.
Definition: pluto.h:150
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
int jb
Lower corner index in the x2 direction.
Definition: structs.h:349
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#define X3FACE
Definition: pluto.h:203
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
Definition: globals.h:57
RBox * GetRBox(int side, int vpos)
Definition: rbox.c:232
int kb
Lower corner index in the x3 direction.
Definition: structs.h:351
#define DOM
Computational domain (interior)
Definition: pluto.h:152
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define TOT
Computational domain (total)
Definition: pluto.h:153
int ib
Lower corner index in the x1 direction.
Definition: structs.h:347
#define X1FACE
Definition: pluto.h:201
#define X2_END
Boundary region at X2 end.
Definition: pluto.h:149
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
Definition: globals.h:59
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:37
void SetRBox(void)
Definition: rbox.c:33
static RBox rbox_x1face[8]
Definition: rbox.c:30
static RBox rbox_x3face[8]
Definition: rbox.c:30
#define s
static RBox rbox_center[8]
Definition: rbox.c:30
#define X3_END
Boundary region at X3 end.
Definition: pluto.h:151
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
int ie
Upper corner index in the x1 direction.
Definition: structs.h:348
int ke
Upper corner index in the x3 direction.
Definition: structs.h:352
int je
Upper corner index in the x2 direction.
Definition: structs.h:350
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:43
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:45
static RBox rbox_x2face[8]
Definition: rbox.c:30
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
Definition: globals.h:39
Definition: structs.h:346
#define X2FACE
Definition: pluto.h:202
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