MOM6
|
Cubic interpolation functions.
Date of creation: 2008.06.09 L. White
This module contains p3m interpolation routines.
p3m interpolation is performed by estimating the edge values and slopes and constructing a cubic polynomial. We then make sure that the edge values are bounded and continuous and we then modify the slopes to get a monotonic cubic curve.
Functions/Subroutines | |
subroutine, public | p3m_interpolation (N, h, u, ppoly_E, ppoly_S, ppoly_coef, h_neglect) |
Set up a piecewise cubic interpolation from cell averages and estimated edge slopes and values. More... | |
subroutine | p3m_limiter (N, h, u, ppoly_E, ppoly_S, ppoly_coef, h_neglect) |
Adust a piecewise cubic reconstruction with a limiter that adjusts the edge values and slopes. More... | |
subroutine, public | p3m_boundary_extrapolation (N, h, u, ppoly_E, ppoly_S, ppoly_coef, h_neglect, h_neglect_edge) |
Calculate the edge values and slopes at boundary cells as part of building a piecewise cubic sub-grid scale profiles. More... | |
subroutine | build_cubic_interpolant (h, k, ppoly_E, ppoly_S, ppoly_coef) |
Build cubic interpolant in cell k. More... | |
logical function | is_cubic_monotonic (ppoly_coef, k) |
Check whether the cubic reconstruction in cell k is monotonic. More... | |
subroutine | monotonize_cubic (h, u0_l, u0_r, sigma_l, sigma_r, slope, u1_l, u1_r) |
Monotonize a cubic curve by modifying the edge slopes. More... | |
Variables | |
real, parameter | hneglect_dflt = 1.E-30 |
Default value of a negligible cell thickness. More... | |
real, parameter | hneglect_edge_dflt = 1.E-10 |
Default value of a negligible edge thickness. More... | |
|
private |
Build cubic interpolant in cell k.
Given edge values and edge slopes, compute coefficients of cubic in cell k.
NOTE: edge values and slopes MUST have been properly calculated prior to calling this routine.
[in] | h | cell widths (size N) [H] |
[in] | k | The index of the cell to work on |
[in] | ppoly_e | Edge value of polynomial in arbitrary units [A] |
[in] | ppoly_s | Edge slope of polynomial [A H-1] |
[in,out] | ppoly_coef | Coefficients of polynomial [A] |
Definition at line 342 of file P3M_functions.F90.
Referenced by p3m_boundary_extrapolation(), and p3m_limiter().
|
private |
Check whether the cubic reconstruction in cell k is monotonic.
This function checks whether the cubic curve in cell k is monotonic. If so, returns 1. Otherwise, returns 0.
The cubic is monotonic if the first derivative is single-signed in (0,1). Hence, we check whether the roots (if any) lie inside this interval. If there is no root or if both roots lie outside this interval, the cubic is monotonic.
[in] | ppoly_coef | Coefficients of cubic polynomial in arbitary units [A] |
[in] | k | The index of the cell to work on |
Definition at line 384 of file P3M_functions.F90.
Referenced by p3m_boundary_extrapolation(), and p3m_limiter().
|
private |
Monotonize a cubic curve by modifying the edge slopes.
This routine takes care of monotonizing a cubic on [0,1] by modifying the edge slopes. The edge values are NOT modified. The cubic is entirely determined by the four degrees of freedom u0_l, u0_r, u1_l and u1_r.
u1_l and u1_r are the edge slopes expressed in the GLOBAL coordinate system.
The monotonization occurs as follows.
[in] | h | cell width [H] |
[in] | u0_l | left edge value in arbitrary units [A] |
[in] | u0_r | right edge value [A] |
[in] | sigma_l | left 2nd-order slopes [A H-1] |
[in] | sigma_r | right 2nd-order slopes [A H-1] |
[in] | slope | limited PLM slope [A H-1] |
[in,out] | u1_l | left edge slopes [A H-1] |
[in,out] | u1_r | right edge slopes [A H-1] |
Definition at line 434 of file P3M_functions.F90.
Referenced by p3m_boundary_extrapolation(), and p3m_limiter().
subroutine, public p3m_functions::p3m_boundary_extrapolation | ( | integer, intent(in) | N, |
real, dimension(:), intent(in) | h, | ||
real, dimension(:), intent(in) | u, | ||
real, dimension(:,:), intent(inout) | ppoly_E, | ||
real, dimension(:,:), intent(inout) | ppoly_S, | ||
real, dimension(:,:), intent(inout) | ppoly_coef, | ||
real, intent(in), optional | h_neglect, | ||
real, intent(in), optional | h_neglect_edge | ||
) |
Calculate the edge values and slopes at boundary cells as part of building a piecewise cubic sub-grid scale profiles.
The following explanations apply to the left boundary cell. The same reasoning holds for the right boundary cell.
A cubic needs to be built in the cell and requires four degrees of freedom, which are the edge values and slopes. The right edge values and slopes are taken to be that of the neighboring cell (i.e., the left edge value and slope of the neighboring cell). The left edge value and slope are determined by computing the parabola based on the cell average and the right edge value and slope. The resulting cubic is not necessarily monotonic and the slopes are subsequently modified to yield a monotonic cubic.
[in] | n | Number of cells |
[in] | h | cell widths (size N) [H] |
[in] | u | cell averages (size N) in arbitrary units [A] |
[in,out] | ppoly_e | Edge value of polynomial [A] |
[in,out] | ppoly_s | Edge slope of polynomial [A H-1] |
[in,out] | ppoly_coef | Coefficients of polynomial [A] |
[in] | h_neglect | A negligibly small width for the purpose of cell reconstructions [H] |
[in] | h_neglect_edge | A negligibly small width for the purpose of finding edge values [H] |
Definition at line 190 of file P3M_functions.F90.
References build_cubic_interpolant(), hneglect_dflt, hneglect_edge_dflt, is_cubic_monotonic(), and monotonize_cubic().
Referenced by regrid_interp::regridding_set_ppolys().
subroutine, public p3m_functions::p3m_interpolation | ( | integer, intent(in) | N, |
real, dimension(:), intent(in) | h, | ||
real, dimension(:), intent(in) | u, | ||
real, dimension(:,:), intent(inout) | ppoly_E, | ||
real, dimension(:,:), intent(inout) | ppoly_S, | ||
real, dimension(:,:), intent(inout) | ppoly_coef, | ||
real, intent(in), optional | h_neglect | ||
) |
Set up a piecewise cubic interpolation from cell averages and estimated edge slopes and values.
Cubic interpolation between edges.
The edge values and slopes MUST have been estimated prior to calling this routine.
It is assumed that the size of the array 'u' is equal to the number of cells defining 'grid' and 'ppoly'. No consistency check is performed here.
[in] | n | Number of cells |
[in] | h | cell widths (size N) [H] |
[in] | u | cell averages (size N) in arbitrary units [A] |
[in,out] | ppoly_e | Edge value of polynomial [A] |
[in,out] | ppoly_s | Edge slope of polynomial [A H-1]. |
[in,out] | ppoly_coef | Coefficients of polynomial [A] |
[in] | h_neglect | A negligibly small width for the purpose of cell reconstructions [H] |
Definition at line 29 of file P3M_functions.F90.
References p3m_limiter().
Referenced by regrid_interp::regridding_set_ppolys().
|
private |
Adust a piecewise cubic reconstruction with a limiter that adjusts the edge values and slopes.
The p3m limiter operates as follows:
Step 3 of the monotonization process leaves all edge values unchanged.
[in] | n | Number of cells |
[in] | h | cell widths (size N) [H] |
[in] | u | cell averages (size N) in arbitrary units [A] |
[in,out] | ppoly_e | Edge value of polynomial [A] |
[in,out] | ppoly_s | Edge slope of polynomial [A H-1] |
[in,out] | ppoly_coef | Coefficients of polynomial [A] |
[in] | h_neglect | A negligibly small width for the purpose of cell reconstructions [H] |
Definition at line 61 of file P3M_functions.F90.
References regrid_edge_values::average_discontinuous_edge_values(), regrid_edge_values::bound_edge_values(), build_cubic_interpolant(), hneglect_dflt, is_cubic_monotonic(), and monotonize_cubic().
Referenced by p3m_interpolation().
|
private |
Default value of a negligible cell thickness.
Definition at line 13 of file P3M_functions.F90.
Referenced by p3m_boundary_extrapolation(), and p3m_limiter().
|
private |
Default value of a negligible edge thickness.
Definition at line 14 of file P3M_functions.F90.
Referenced by p3m_boundary_extrapolation().