PLUTO
mappers3D.c File Reference

3D wrapper for conservative/primitive conversion. More...

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

Go to the source code of this file.

Functions

void ConsToPrim3D (Data_Arr U, Data_Arr V, unsigned char ***flag, RBox *box)
 
void PrimToCons3D (Data_Arr V, Data_Arr U, RBox *box)
 

Detailed Description

3D wrapper for conservative/primitive conversion.

Provide 3D wrappers to the standard 1D conversion functions ConsToPrim() and PrimToCons().

Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
June 24, 2015

Definition in file mappers3D.c.

Function Documentation

void ConsToPrim3D ( Data_Arr  U,
Data_Arr  V,
unsigned char ***  flag,
RBox box 
)

Convert a 3D array of conservative variables U to an array of primitive variables V. Note that [nv] is the fastest running index for U while it is the slowest running index for V.

Parameters
[in]Upointer to 3D array of conserved variables, with array indexing [k][j][i][nv]
[out]Vpointer to 3D array of primitive variables, with array indexing [nv][k][j][i]
[in,out]flagpointer to 3D array of flags.
[in]boxpointer to RBox structure containing the domain portion over which conversion must be performed.

Definition at line 16 of file mappers3D.c.

32 {
33  int i, j, k, nv, err;
34  int ibeg, iend, jbeg, jend, kbeg, kend;
35  int current_dir;
36  static double **v, **u;
37 
38  if (v == NULL){
39  v = ARRAY_2D(NMAX_POINT, NVAR, double);
40  u = ARRAY_2D(NMAX_POINT, NVAR, double);
41  }
42 
43 /* ----------------------------------------------
44  Save current sweep direction and by default,
45  perform the conversion along X1 stripes
46  ---------------------------------------------- */
47 
48  current_dir = g_dir;
49  g_dir = IDIR;
50 
51 /* -----------------------------------------------
52  Set (beg,end) indices in ascending order for
53  proper call to ConsToPrim()
54  ----------------------------------------------- */
55 
56  ibeg = (box->ib <= box->ie) ? (iend=box->ie, box->ib):(iend=box->ib, box->ie);
57  jbeg = (box->jb <= box->je) ? (jend=box->je, box->jb):(jend=box->jb, box->je);
58  kbeg = (box->kb <= box->ke) ? (kend=box->ke, box->kb):(kend=box->kb, box->ke);
59 
60  for (k = kbeg; k <= kend; k++){ g_k = k;
61  for (j = jbeg; j <= jend; j++){ g_j = j;
62 
63 #ifdef CHOMBO
64  for (i = ibeg; i <= iend; i++) NVAR_LOOP(nv) u[i][nv] = U[nv][k][j][i];
65  #if COOLING == MINEq || COOLING == H2_COOL
66  if (g_intStage == 1) for (i = ibeg; i <= iend; i++) NormalizeIons(u[i]);
67  #endif
68  err = ConsToPrim (u, v, ibeg, iend, flag[k][j]);
69 
70  /* -------------------------------------------------------------
71  Ensure any change to 1D conservative arrays is not lost.
72  Note: Conversion must be done even when err = 0 in case
73  ENTROPY_SWITCH is employed.
74  ------------------------------------------------------------- */
75 
76  for (i = ibeg; i <= iend; i++) NVAR_LOOP(nv) U[nv][k][j][i] = u[i][nv];
77 #else
78  err = ConsToPrim (U[k][j], v, ibeg, iend, flag[k][j]);
79 #endif
80  for (i = ibeg; i <= iend; i++) NVAR_LOOP(nv) V[nv][k][j][i] = v[i][nv];
81  }}
82  g_dir = current_dir;
83 
84 }
int jb
Lower corner index in the x2 direction.
Definition: structs.h:349
int g_intStage
Gives the current integration stage of the time stepping method (predictor = 0, 1st corrector = 1...
Definition: globals.h:98
int kb
Lower corner index in the x3 direction.
Definition: structs.h:351
double v[NVAR]
Definition: eos.h:106
void NormalizeIons(double *)
int ib
Lower corner index in the x1 direction.
Definition: structs.h:347
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
#define NVAR_LOOP(n)
Definition: pluto.h:618
int ConsToPrim(double **ucons, double **uprim, int ibeg, int iend, unsigned char *flag)
Definition: mappers.c:89
int g_j
x2 grid index when sweeping along the x1 or x3 direction.
Definition: globals.h:83
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int g_k
x3 grid index when sweeping along the x1 or x2 direction.
Definition: globals.h:84
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
Definition: globals.h:62
int i
Definition: analysis.c:2
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
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
#define NVAR
Definition: pluto.h:609

Here is the call graph for this function:

Here is the caller graph for this function:

void PrimToCons3D ( Data_Arr  V,
Data_Arr  U,
RBox box 
)

Convert a 3D array of primitive variables V to an array of conservative variables U. Note that [nv] is the fastest running index for U while it is the slowest running index for V.

Parameters
[in]Vpointer to 3D array of primitive variables, with array indexing [nv][k][j][i]
[out]Upointer to 3D array of conserved variables, with array indexing [k][j][i][nv]
[in]boxpointer to RBox structure containing the domain portion over which conversion must be performed.

Definition at line 86 of file mappers3D.c.

101 {
102  int i, j, k, nv;
103  int ibeg, iend, jbeg, jend, kbeg, kend;
104  int current_dir;
105  static double **v, **u;
106 
107  if (v == NULL) {
108  v = ARRAY_2D(NMAX_POINT, NVAR, double);
109  u = ARRAY_2D(NMAX_POINT, NVAR, double);
110  }
111 
112  current_dir = g_dir; /* save current direction */
113  g_dir = IDIR;
114 
115 /* -----------------------------------------------
116  Set (beg,end) indices in ascending order for
117  proper call to ConsToPrim()
118  ----------------------------------------------- */
119 
120  ibeg = (box->ib <= box->ie) ? (iend=box->ie, box->ib):(iend=box->ib, box->ie);
121  jbeg = (box->jb <= box->je) ? (jend=box->je, box->jb):(jend=box->jb, box->je);
122  kbeg = (box->kb <= box->ke) ? (kend=box->ke, box->kb):(kend=box->kb, box->ke);
123 
124  for (k = kbeg; k <= kend; k++){ g_k = k;
125  for (j = jbeg; j <= jend; j++){ g_j = j;
126  for (i = ibeg; i <= iend; i++) VAR_LOOP(nv) v[i][nv] = V[nv][k][j][i];
127 #ifdef CHOMBO
128  PrimToCons(v, u, ibeg, iend);
129  for (i = ibeg; i <= iend; i++) VAR_LOOP(nv) U[nv][k][j][i] = u[i][nv];
130 #else
131  PrimToCons (v, U[k][j], ibeg, iend);
132 #endif
133  }}
134  g_dir = current_dir; /* restore current direction */
135 
136 }
int jb
Lower corner index in the x2 direction.
Definition: structs.h:349
int kb
Lower corner index in the x3 direction.
Definition: structs.h:351
double v[NVAR]
Definition: eos.h:106
int ib
Lower corner index in the x1 direction.
Definition: structs.h:347
#define VAR_LOOP(n)
Definition: macros.h:226
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
int g_j
x2 grid index when sweeping along the x1 or x3 direction.
Definition: globals.h:83
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int g_k
x3 grid index when sweeping along the x1 or x2 direction.
Definition: globals.h:84
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
Definition: globals.h:62
void PrimToCons(double **uprim, double **ucons, int ibeg, int iend)
Definition: mappers.c:26
int i
Definition: analysis.c:2
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
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
#define NVAR
Definition: pluto.h:609

Here is the call graph for this function:

Here is the caller graph for this function: