PLUTO
plm_coeffs.h File Reference

Reconstruction coefficients header file. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PLM_COEFFS
 

Macros

#define UNIFORM_CARTESIAN_GRID   YES
 
#define CHECK_MONOTONICITY   NO
 
Limiter macros.

The following macros define a few limiter functions that can be used for piecewise linear reconstruction. Each limiter has the form SET_XX_LIMITER(dv, dvp, dvm, cp, cm) where dvp and dvm are the geometrically weighted forward and backward slopes ( $\Delta Q^{F}$ and $\Delta Q^{B}$ in Eq. [29]), cp and cm are weight coefficients depending on the distance between the cell interfaces and the centroid of volume (Eq. [33] in the reference paper). The limited slope (used in Eq. [30]) is returned in dv.

Usually cp and cm are used only for a few limiters and when the grid is either non-uniform or the geometry is not Cartesian. For this reason, the OSPRE (OS), van Leer (VL) and monotonized central (MC) are

#define SET_FL_LIMITER(dv, dvp, dvm, cp, cm)   dv = 0.0
 
#define SET_MM_LIMITER(dv, dvp, dvm, cp, cm)   dv = (dvp*dvm > 0.0 ? ABS_MIN(dvp, dvm): 0.0)
 
#define SET_VA_LIMITER(dv, dvp, dvm, cp, cm)
 
#define SET_UM_LIMITER(dv, dvp, dvm, cp, cm)
 
#define SET_GM_LIMITER(dv, dvp, dvm, cp, cm)
 
#define SET_OS_LIMITER(dv, dvp, dvm, cp, cm)
 
#define SET_VL_LIMITER(dv, dvp, dvm, cp, cm)   dv = (dvp*dvm > 0.0 ? 2.0*dvp*dvm/(dvp + dvm) :0.0)
 
#define SET_MC_LIMITER(dv, dvp, dvm, cp, cm)
 

Typedefs

typedef struct PLM_COEFFS PLM_Coeffs
 

Functions

void PLM_CoefficientsSet (Grid *grid)
 
void PLM_CoefficientsGet (PLM_Coeffs *, int)
 

Detailed Description

Reconstruction coefficients header file.

Define some useful macros for the computation of slope limiters in the piecewise linear method.

The macro UNIFORM_CARTESIAN_GRID can be set to YES to enable faster computation when the grid is uniform and Cartesian. In the general case (non-uniform and/or non-Cartesian), set it to NO.

Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
May 19, 2014

References

  • "High-order conservative reconstruction schemes for finite volume methods in cylindrical and spherical coordinates" A. Mignone, JCP (2014), 270, 784.

Definition in file plm_coeffs.h.

Macro Definition Documentation

#define CHECK_MONOTONICITY   NO

Definition at line 31 of file plm_coeffs.h.

#define SET_FL_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)    dv = 0.0

Set flat (zero slope) reconstruction (also non-uniform).

Definition at line 72 of file plm_coeffs.h.

#define SET_GM_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)
Value:
if (dvp*dvm > 0.0) { \
double _qc = 0.5*(dvm + dvp), _scrh = ABS_MIN((dvp)*(cp), (dvm)*(cm)); \
dv = ABS_MIN(_qc, _scrh); \
}else dv = 0.0;
#define ABS_MIN(a, b)
Definition: macros.h:107

Generalised minmod limiter

Definition at line 96 of file plm_coeffs.h.

#define SET_MC_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)
Value:
if (dvp*dvm > 0.0) { \
double _qc = 0.5*(dvm + dvp), _scrh = 2.0*ABS_MIN(dvp, dvm); \
dv = ABS_MIN(_qc, _scrh); \
}else dv = 0.0;
#define ABS_MIN(a, b)
Definition: macros.h:107

Monotonized central limiter (uniform cart. grid). Here cp and cm are useless.

Definition at line 119 of file plm_coeffs.h.

#define SET_MM_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)    dv = (dvp*dvm > 0.0 ? ABS_MIN(dvp, dvm): 0.0)

Set Minmod limiter.

Definition at line 76 of file plm_coeffs.h.

#define SET_OS_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)
Value:
dv = (dvp*dvm > 0.0? \
dv = 1.5*dvp*dvm*(dvm + dvp)/(dvp*dvp + dvm*dvm + dvp*dvm): 0.0);

OSPRE limiter (uniform Cart. grid)

Definition at line 109 of file plm_coeffs.h.

#define SET_UM_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)
Value:
if (dvp*dvm > 0.0){ \
double _ddp = 0.25*(dvp + 3.0*dvm), _ddm = 0.25*(dvm + 3.0*dvp); \
double _d2 = 2.0*ABS_MIN(dvp, dvm);\
_d2 = ABS_MIN(_d2, _ddp);\
dv = ABS_MIN(_d2, _ddm);\
}else dv = 0.0;
#define ABS_MIN(a, b)
Definition: macros.h:107

Umist limiter

Definition at line 87 of file plm_coeffs.h.

#define SET_VA_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)
Value:
if (dvp*dvm > 0.0) { \
double _dpp= dvp*dvp, _dmm = dvm*dvm; \
dv = (dvp*(_dmm + 1.e-18) + dvm*(_dpp + 1.e-18))/(_dpp + _dmm + 1.e-18); \
}else dv = 0.0;

Van Albada limiter

Definition at line 80 of file plm_coeffs.h.

#define SET_VL_LIMITER (   dv,
  dvp,
  dvm,
  cp,
  cm 
)    dv = (dvp*dvm > 0.0 ? 2.0*dvp*dvm/(dvp + dvm) :0.0)

Van Leer limiter (uniform Cartesian grid)

Definition at line 114 of file plm_coeffs.h.

#define UNIFORM_CARTESIAN_GRID   YES

Definition at line 25 of file plm_coeffs.h.

Typedef Documentation

typedef struct PLM_COEFFS PLM_Coeffs

Simple structure used to retrieve 1D reconstruction weights (c, w, d) used by piecewise linear interpolation (see states_plm.c)

Function Documentation

void PLM_CoefficientsGet ( PLM_Coeffs plm_coeffs,
int  dir 
)

Retrieve reconstruction coefficients in the PLM_Coeffs structure. This function can be called only if the previous one has been completed already.

Parameters
[out]plm_coeffsa pointer to a PLM_Coeffs structure containing the 1D coefficients needed for reconstruction
[in]dirthe desired direction

Definition at line 79 of file plm_coeffs.c.

90 {
91  if (cp3D == NULL) {
92  print1 ("! PLM_Coefficients: coefficients not set.\n");
93  QUIT_PLUTO(1);
94  }
95 
96  plm_coeffs->cp = cp3D[dir];
97  plm_coeffs->cm = cm3D[dir];
98 
99  plm_coeffs->wp = wp3D[dir];
100  plm_coeffs->wm = wm3D[dir];
101 
102  plm_coeffs->dp = dp3D[dir];
103  plm_coeffs->dm = dm3D[dir];
104 
105 }
void print1(const char *fmt,...)
Definition: amrPluto.cpp:511
double * cm
Definition: plm_coeffs.h:40
static double ** dm3D
Definition: plm_coeffs.c:27
static double ** cp3D
Definition: plm_coeffs.c:25
static double ** wp3D
Definition: plm_coeffs.c:26
double * cp
Definition: plm_coeffs.h:39
static double ** wm3D
Definition: plm_coeffs.c:26
static double ** cm3D
Definition: plm_coeffs.c:25
double * dm
Definition: plm_coeffs.h:44
static double ** dp3D
Definition: plm_coeffs.c:27
double * dp
Definition: plm_coeffs.h:43
double * wm
Definition: plm_coeffs.h:42
#define QUIT_PLUTO(e_code)
Definition: macros.h:125
double * wp
Definition: plm_coeffs.h:41

Here is the call graph for this function:

Here is the caller graph for this function:

void PLM_CoefficientsSet ( Grid grid)

Compute interpolation coefficients for linear reconstruction.

Parameters
[in]gridpointer to array of grid structure
Returns
This function has no return value

Definition at line 30 of file plm_coeffs.c.

38 {
39  int i, d, beg, end;
40  double *dx, *xr, *xgc;
41 
42  if (cp3D == NULL) {
43  cp3D = ARRAY_2D(DIMENSIONS, NMAX_POINT, double);
44  cm3D = ARRAY_2D(DIMENSIONS, NMAX_POINT, double);
45  dp3D = ARRAY_2D(DIMENSIONS, NMAX_POINT, double);
46  dm3D = ARRAY_2D(DIMENSIONS, NMAX_POINT, double);
47  wp3D = ARRAY_2D(DIMENSIONS, NMAX_POINT, double);
48  wm3D = ARRAY_2D(DIMENSIONS, NMAX_POINT, double);
49  }
50 
51 /* -----------------------------------------------------
52  Compute interpolation coefficients.
53  This must be the first call to this function in
54  order to store coefficients into memory.
55  ----------------------------------------------------- */
56 
57  for (d = 0; d < DIMENSIONS; d++){
58  dx = grid[d].dx;
59  xgc = grid[d].xgc;
60  xr = grid[d].xr;
61 
62  /* -- first and last zone are excluded -- */
63 
64  beg = 1;
65  end = grid[d].np_tot - 2;
66  for (i = beg; i <= end; i++){
67  wp3D[d][i] = dx[i]/(xgc[i+1] - xgc[i]); /* coeff. for dQF in Eq. [29] */
68  wm3D[d][i] = dx[i]/(xgc[i] - xgc[i-1]); /* coeff. for dQB in Eq. [29] */
69 
70  cp3D[d][i] = (xgc[i+1] - xgc[i])/(xr[i] - xgc[i]); /* Eq. [33], cF */
71  cm3D[d][i] = (xgc[i] - xgc[i-1])/(xgc[i] - xr[i-1]); /* Eq. [33], cB */
72 
73  dp3D[d][i] = (xr[i] - xgc[i])/dx[i]; /* Eq. [30], plus sign */
74  dm3D[d][i] = (xgc[i] - xr[i-1])/dx[i]; /* Eq. [30], minus sign */
75  }
76  }
77 }
int end
Global end index for the local array.
Definition: structs.h:116
double * xr
Definition: structs.h:81
static double ** dm3D
Definition: plm_coeffs.c:27
static double ** cp3D
Definition: plm_coeffs.c:25
static double ** wp3D
Definition: plm_coeffs.c:26
double * dx
Definition: structs.h:83
int beg
Global start index for the local array.
Definition: structs.h:115
static double ** wm3D
Definition: plm_coeffs.c:26
double * xgc
Cell volumetric centroid (!= x when geometry != CARTESIAN).
Definition: structs.h:84
static double ** cm3D
Definition: plm_coeffs.c:25
static double ** dp3D
Definition: plm_coeffs.c:27
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 ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
int np_tot
Total number of points in the local domain (boundaries included).
Definition: structs.h:100
#define DIMENSIONS
Definition: definitions_01.h:2

Here is the caller graph for this function: