Recon1d_PLM_WLS module reference
Piecewise Linear Method using Weighted Conservative Least Squares 1D reconstruction
Data Types
PLM reconstruction using Weighted Least Squares constrained to conserve for central cell |
Functions/Subroutines
Initialize a 1D PLM reconstruction for n cells |
|
Calculate a 1D PLM_WLS reconstruction based on h(:) and u(:) |
|
Value of PLM_WLS reconstruction at a point in cell k [A] |
|
Derivative of PLM_WLS reconstruction at a point in cell k [A] |
|
Average between xa and xb for cell k of a 1D PLM reconstruction [A] |
|
Deallocate the PLM reconstruction |
|
Checks the PLM_WLS reconstruction for consistency |
|
Returns local least squares error for a particular cell |
|
Runs PLM_WLS reconstruction unit tests and returns True for any fails, False otherwise |
Detailed Description
This implementation of PLM fits the slope using least squares, but retains conservation for the central cell by passing through the central value. Cell-wise reconstructions are NOT limited by neighbours. Thus, this reconstruction does not yield monotonic profiles needed for the general remapping problem.
The algorithm solves the least squares problem of fitting a straight line through the neighboring data. The line is constained to pass through the center cell, \((x_{k}, y_{k})\), so that the construction is conservative. The more general function \(f(x) = a_{k} + b_{k} x\) would not conserve for arbitrary data.
The unknown parameter \(b_{k}\) in the line
is fit to neighbors \(x_{k-1}, y_{k-1}\) and \(x_{k+1}, y_{k+1}\).
Denoting \(y'_{k+j} = y_{k+j} - y_{k}\) and \(x'_{k+j} = x_{k+j} - x_{k}\) the local error is
We use volume weighting in the loss
When solving for \(b_k\), we solve \(dG/db = 0\) where
and where \(< a > = \frac{1}{2} ( a_{k-1} + a_{k+1} )\). Thus
When evaluating the loss, \(G\), some rearrangement is necessary to reduce truncation errors. Since
then
If we denote the value of b that yields the minimum value as \(b^*\) then
Let
Minimizing \(G''(b)\) is equivalent to minimizing \(G(b)\) for the same data. \(G''(b^*)=0\) so evaluation with the last form, in the vicinity of \(b^*\), avoids large cancelling terms.
Type Documentation
- type, extends(Recon1d) :: PLM_WLS
PLM reconstruction using Weighted Least Squares constrained to conserve for central cell
The source for the methods ultimately used by this class are:
init() *locally defined
reconstruct() *locally defined
average() *locally defined
f() *locally defined
dfdx() *locally defined
x() -> recon1d_type.x()
check_reconstruction() *locally defined
unit_tests() *locally defined
destroy() *locally defined
remap_to_sub_grid() -> recon1d_type.remap_to_sub_grid()
init_parent() -> init()
reconstruct_parent() -> reconstruct()
- Parameters
ul
Left edge value [A]
ur
Right edge value [A]
slp
Difference across cell, ur - ul [A]. This is redundant with ul and ur and not used in any evaluations, but is needed for testing.
Functions/Subroutine Documentation
- subroutine init(this, n, h_neglect, check)
Initialize a 1D PLM reconstruction for n cells
- Parameters
this [out]
This reconstruction
n [in]
Number of cells in this column
h_neglect [in]
A negligibly small width used in cell reconstructions [H]
check [in]
If true, enable some consistency checking
- subroutine reconstruct(this, h, u)
Calculate a 1D PLM_WLS reconstruction based on h(:) and u(:)
- Parameters
this [inout]
This reconstruction
h [in]
Grid spacing (thickness) [typically H]
u [in]
Cell mean values [A]
- real function f(this, k, x)
Value of PLM_WLS reconstruction at a point in cell k [A]
- Parameters
this [in]
This reconstruction
k [in]
Cell number
x [in]
Non-dimensional position within element [nondim]
- real function dfdx(this, k, x)
Derivative of PLM_WLS reconstruction at a point in cell k [A]
- Parameters
this [in]
This reconstruction
k [in]
Cell number
x [in]
Non-dimensional position within element [nondim]
- real function average(this, k, xa, xb)
Average between xa and xb for cell k of a 1D PLM reconstruction [A]
- Parameters
this [in]
This reconstruction
k [in]
Cell number
xa [in]
Start of averaging interval on element (0 to 1)
xb [in]
End of averaging interval on element (0 to 1)
- subroutine destroy(this)
Deallocate the PLM reconstruction
- Parameters
this [inout]
This reconstruction
- logical function check_reconstruction(this, h, u)
Checks the PLM_WLS reconstruction for consistency
- Parameters
this [in]
This reconstruction
h [in]
Grid spacing (thickness) [typically H]
u [in]
Cell mean values [A]
perturbed
A perturbed reconstruction
- real function LS_error(this, k, h, u)
Returns local least squares error for a particular cell
Note that this is the error relative to the minimum of the loss function so that at the true solution this function returns zero. See module documentation.
- Parameters
this [in]
This reconstruction
k [in]
Cell number
h [in]
Grid spacing (thickness) [typically H]
u [in]
Cell mean values [A]
Callers call graph
- logical function unit_tests(this, verbose, stdout, stderr)
Runs PLM_WLS reconstruction unit tests and returns True for any fails, False otherwise
- Parameters
this [inout]
This reconstruction
verbose [in]
True, if verbose
stdout [in]
I/O channel for stdout
stderr [in]
I/O channel for stderr