PLUTO
plm_coeffs.c File Reference

Compute linear reconstruction coefficients. More...

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

Go to the source code of this file.

Functions

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

Variables

static double ** cp3D
 
static double ** cm3D
 
static double ** wp3D
 
static double ** wm3D
 
static double ** dp3D
 
static double ** dm3D
 

Detailed Description

Compute linear reconstruction coefficients.

Reconstruction coefficients needed for linear interpolation are computed in the PLM_CoefficientsSet() each time a new grid is created. There's a different set of 1D coefficients in each direction.

The function PLM_CoefficientsGet() can be used to obtain a set of coefficients along a desired direction.

References

  • "High-order conservative reconstruction schemes for finite volume methods in cylindrical and spherical coordinates" A. Mignone, JCP (2014), 270, 784.
Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
May 19, 2014

Definition in file plm_coeffs.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:

Variable Documentation

double ** cm3D
static

Definition at line 25 of file plm_coeffs.c.

double** cp3D
static

Definition at line 25 of file plm_coeffs.c.

double ** dm3D
static

Definition at line 27 of file plm_coeffs.c.

double** dp3D
static

Definition at line 27 of file plm_coeffs.c.

double ** wm3D
static

Definition at line 26 of file plm_coeffs.c.

double** wp3D
static

Definition at line 26 of file plm_coeffs.c.