PLUTO
jet_domain.c File Reference

Adjust the effective domain size when the -xNjet option is given. More...

#include "pluto.h"
Include dependency graph for jet_domain.c:

Go to the source code of this file.

Functions

static int GetRightmostIndex (int, double ***)
 
void SetJetDomain (const Data *d, int dir, int log_freq, Grid *grid)
 
void UnsetJetDomain (const Data *d, int dir, Grid *grid)
 

Variables

static int jd_nbeg
 
static int jd_nend
 
static int jd_npt
 
static int jd_ntot
 
static int rbound
 

Detailed Description

Adjust the effective domain size when the -xNjet option is given.

The SetJetDomain() function shortens the domain integration index in the direction specified by either '-x1jet', '-x2jet' or '-x3jet' to save computational time. This is done by setting the final integration index in the direction of jet propagation to that of the first zone (counting from the top) with non-zero pressure gradient (GetRightmostIndex()). The function UnsetJetDomain() restores the initial computational domain size. Useful for problems involving jet propagation.

Note
In parallel, the domain is not decomposed along the propagation direction (see ParseCmdLineArgs()).
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Dec 24, 2014

Definition in file jet_domain.c.

Function Documentation

int GetRightmostIndex ( int  dir,
double ***  q 
)
static

Find the local index j where grad(p) exceeds a ceratin threshold

Definition at line 194 of file jet_domain.c.

201 {
202  int i, j, k;
203  double dp;
204 
205 /* -- backward sweep on x-axis -- */
206 
207  if (dir == IDIR){
208  for (i = jd_nend; i >= jd_nbeg; i--){
209  KDOM_LOOP(k){
210  JDOM_LOOP(j){
211 
212  dp = q[k][j][i+1] - q[k][j][i-1];
213  dp /= q[k][j][i+1] + q[k][j][i-1];
214 
215  if (fabs(dp) > 1.e-5) return(i);
216  }}}
217  }
218 
219 /* -- backward sweep on y-axis -- */
220 
221  if (dir == JDIR){
222  for (j = jd_nend; j >= jd_nbeg; j--){
223  KDOM_LOOP(k){
224  IDOM_LOOP(i){
225 
226  dp = q[k][j+1][i] - q[k][j-1][i];
227  dp /= q[k][j+1][i] + q[k][j-1][i];
228 
229  if (fabs(dp) > 1.e-5) return(j);
230  }}}
231  }
232 
233 /* -- backward sweep on z-axis -- */
234 
235  if (dir == KDIR){
236  for (k = jd_nend; k >= jd_nbeg; k--){
237  JDOM_LOOP(j){
238  IDOM_LOOP(i){
239 
240  dp = q[k+1][j][i] - q[k-1][j][i];
241  dp /= q[k+1][j][i] + q[k-1][j][i];
242 
243  if (fabs(dp) > 1.e-5) return(k);
244  }}}
245  }
246 
247  return(-1);
248 }
#define KDOM_LOOP(k)
Definition: macros.h:36
#define KDIR
Definition: pluto.h:195
#define JDOM_LOOP(j)
Definition: macros.h:35
#define IDIR
Definition: pluto.h:193
static int jd_nend
Definition: jet_domain.c:25
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
static int jd_nbeg
Definition: jet_domain.c:25
#define JDIR
Definition: pluto.h:194
static Runtime q
#define IDOM_LOOP(i)
Definition: macros.h:34

Here is the caller graph for this function:

void SetJetDomain ( const Data d,
int  dir,
int  log_freq,
Grid grid 
)

Adjust the size of computational domain by reducing the final computationa index in the direction of propagation.

Parameters
[in]dpointer to Data structure
[in]dirthe direction of propagation
[in]log_freqthe output log frequency
[in,out]gridpointer to array of Grid structures

Definition at line 29 of file jet_domain.c.

41 {
42  int i, j, k, ngh;
43  int n, n_glob;
44  static int first_call = 1;
45  double ***pr, ***dn, dp;
46 
47  dn = d->Vc[RHO];
48  #if HAVE_ENERGY
49  pr = d->Vc[PRS];
50  #else
51  pr = d->Vc[RHO];
52  #endif
53 
54  ngh = grid[dir].nghost;
55 
56 /* -- save original domain offsets
57  and return for the first time -- */
58 
59  if (first_call){
60  if (dir == IDIR) {
61  jd_nbeg = IBEG; jd_nend = IEND;
63  }else if (dir == JDIR){
64  jd_nbeg = JBEG; jd_nend = JEND;
66  }else if (dir == KDIR){
67  jd_nbeg = KBEG; jd_nend = KEND;
69  }
70 
71  rbound = grid[dir].rbound;
72  first_call = 0;
73  return;
74  }
75 
76 /* --------------------------------------
77  find where grad(p) is not zero and
78  add safety guard cells
79  -------------------------------------- */
80 
81  n = GetRightmostIndex(dir, pr) + 2*ngh;
82 
83  if (n < jd_nbeg + ngh) n = jd_nbeg + ngh;
84  if (n > jd_nend) n = jd_nend;
85 
86  #ifdef PARALLEL
87  MPI_Allreduce (&n, &n_glob, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
88  n = n_glob;
89  #endif
90 
91  if (g_stepNumber%log_freq==0){
92 /* print1 ("- SetJetDomain: index %d / %d\n",n,jd_nend); */
93  }
94 
95 /* ------------------------------------------------------------------
96  Change global integer variables giving the rightmost integration
97  indexes. Also, suppress the rightmost physics boundary (rbound)
98  if solution has not yet reached it.
99  ------------------------------------------------------------------ */
100 
101  if (dir == IDIR) {
102  IEND = grid[IDIR].lend = n;
103  NX1_TOT = IEND + ngh;
104  NX1 = IEND - ngh;
105 
106  grid[IDIR].rbound = rbound;
107  if (jd_nend != IEND) grid[IDIR].rbound = 0;
108 
109  } else if (dir == JDIR){
110 
111  JEND = grid[JDIR].lend = n;
112  NX2_TOT = JEND + ngh;
113  NX2 = JEND - ngh;
114  grid[JDIR].rbound = rbound;
115  if (jd_nend != JEND) grid[JDIR].rbound = 0;
116 
117  }else if (dir == KDIR){
118 
119  KEND = grid[KDIR].lend = n;
120  NX3_TOT = KEND + ngh;
121  NX3 = KEND - ngh;
122 
123  grid[KDIR].rbound = rbound;
124  if (jd_nend != KEND) grid[KDIR].rbound = 0;
125  }
126 
127 /* ------------------------------------------------------
128  Recompute RBox(es) after indices have been changed
129  ------------------------------------------------------ */
130 
131  SetRBox();
132 
133 /*
134  print1 ("Box = %d/%d\n", n, jd_nend);
135  {
136  double t0, t1, i0, i1;
137  FILE *fp;
138  t0 = g_time;
139  t1 = t0 + g_dt;
140  i0 = (int)(t0/0.5);
141  i1 = (int)(t1/0.5);
142 
143  if (i0 != i1){
144  fp = fopen("box.out","w");
145  fprintf (fp,"%f %f %f %f\n",0.0, grid[IDIR].x[IEND],
146  0.0, grid[JDIR].x[JEND]);
147  fclose(fp);
148  }
149  }
150 */
151 }
static int jd_ntot
Definition: jet_domain.c:25
static int jd_npt
Definition: jet_domain.c:25
static int n
Definition: analysis.c:3
static int rbound
Definition: jet_domain.c:25
long int NX1
Number of interior zones in the X1 directions (boundaries excluded) for the local processor...
Definition: globals.h:48
#define RHO
Definition: mod_defs.h:19
int rbound
Same as lbound, but for the right edge of the grid.
Definition: structs.h:112
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
int lend
Local end index for the local array.
Definition: structs.h:118
#define KDIR
Definition: pluto.h:195
long int g_stepNumber
Gives the current integration step number.
Definition: globals.h:97
long int NX2
Number of interior zones in the X2 directions (boundaries excluded) for the local processor...
Definition: globals.h:50
#define IDIR
Definition: pluto.h:193
static int GetRightmostIndex(int, double ***)
Definition: jet_domain.c:194
static int jd_nend
Definition: jet_domain.c:25
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
int nghost
Number of ghost zones.
Definition: structs.h:104
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 SetRBox(void)
Definition: rbox.c:33
int i
Definition: analysis.c:2
static int jd_nbeg
Definition: jet_domain.c:25
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:43
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:45
#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
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 NX3
Number of interior zones in the X3 directions (boundaries excluded) for the local processor...
Definition: globals.h:52
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

void UnsetJetDomain ( const Data d,
int  dir,
Grid grid 
)

Restore original (full domain) indexes.

Definition at line 154 of file jet_domain.c.

159 {
160 
161  if (dir == IDIR){
162  IBEG = grid[IDIR].lbeg = jd_nbeg;
163  IEND = grid[IDIR].lend = jd_nend;
164  NX1_TOT = jd_ntot;
165  NX1 = jd_npt;
166  grid[IDIR].rbound = rbound;
167  }
168 
169  if (dir == JDIR){
170  JBEG = grid[JDIR].lbeg = jd_nbeg;
171  JEND = grid[JDIR].lend = jd_nend;
172  NX2_TOT = jd_ntot;
173  NX2 = jd_npt;
174  grid[JDIR].rbound = rbound;
175  }
176 
177  if (dir == KDIR){
178  KBEG = grid[KDIR].lbeg = jd_nbeg;
179  KEND = grid[KDIR].lend = jd_nend;
180  NX3_TOT = jd_ntot;
181  NX3 = jd_npt;
182  grid[KDIR].rbound = rbound;
183  }
184 
185 /* ------------------------------------------------------
186  Recompute RBox(es) after indices have been changed
187  ------------------------------------------------------ */
188 
189  SetRBox();
190 
191 }
static int jd_ntot
Definition: jet_domain.c:25
static int jd_npt
Definition: jet_domain.c:25
static int rbound
Definition: jet_domain.c:25
long int NX1
Number of interior zones in the X1 directions (boundaries excluded) for the local processor...
Definition: globals.h:48
int rbound
Same as lbound, but for the right edge of the grid.
Definition: structs.h:112
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
Definition: globals.h:57
int lend
Local end index for the local array.
Definition: structs.h:118
int lbeg
Local start index for the local array.
Definition: structs.h:117
#define KDIR
Definition: pluto.h:195
long int NX2
Number of interior zones in the X2 directions (boundaries excluded) for the local processor...
Definition: globals.h:50
#define IDIR
Definition: pluto.h:193
static int jd_nend
Definition: jet_domain.c:25
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 int jd_nbeg
Definition: jet_domain.c:25
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:43
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
Definition: globals.h:45
#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
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 NX3
Number of interior zones in the X3 directions (boundaries excluded) for the local processor...
Definition: globals.h:52
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int jd_nbeg
static

Definition at line 25 of file jet_domain.c.

int jd_nend
static

Definition at line 25 of file jet_domain.c.

int jd_npt
static

Definition at line 25 of file jet_domain.c.

int jd_ntot
static

Definition at line 25 of file jet_domain.c.

int rbound
static

Definition at line 25 of file jet_domain.c.