Reference

WENO toolkit

pyweno.weno.reconstruct(q, k, points, n=None, smoothness=None, weights=None, return_smoothness=False, return_weights=False, squeeze=True)

Perform WENO reconstruction of q.

Parameters:
  • q – cell-averaged unknown to reconstruct
  • k – order of reconstruction (odd values from 5 to 11)
  • points – reconstruction points
  • n – number of reconstruction points (optional)
  • smoothness – use smoothness indicators smoothness (optional)
  • weights – use non-linear weights weights (optional)
  • return_smoothness – return smoothness indicators? (default: False)
  • return_weights – return weights? (default: False)
  • squeeze – squeeze the results? (default: True)

Supported reconstruction points points are:

  • 'left' - left edge of each cell
  • 'right' - right edge of each cell
  • 'middle' - the middle of each cell
  • '+/-' - returns two reconstructions per cell, both at the left edge of each cell; the first is considered as a limit from the left (-), the second is considered as a limit from the right (+).
  • 'gauss' or 'gauss_legendre' - n point Gauss-Legendre quadrature points
  • 'gauss_lobatto' - n point Gauss-Lobatto quadrature points
  • 'gauss_radau' - n point Gauss-Radau quadrature points

This function wraps several complied WENO kernels which were generated by PyWENO. If you need WENO reconstructions at points not supported by this wrapper, please checkout PyWENO.

Symbolics

pyweno.symbolic.polynomial_interpolator(x, y)

Build a symbolic polynomial that interpolates the points (x_i, y_i).

The returned polynomial is a function of the SymPy variable x.

pyweno.symbolic.primitive_polynomial_interpolator(x, y)

Build a symbolic polynomial that approximates the primitive function f such that f(x_i) = sum_j y_j * (x_{j+1} - x_{j}).

The returned polynomial is a function of the SymPy variable ‘x’.

pyweno.symbolic.reconstruction_coefficients(k, xi)

Compute the reconstruction coefficients for a 2k-1 order WENO scheme corresponding to the reconstruction points in xi.

The reconstruction points in xi should in \([-1, 1]\). This interval is then mapped to the cell \([x_{i-1/2}, x_{i+1/2}]\).

The returned coefficients are stored as SymPy variables in a dictionary indexed according to c[l,r,j]. That is

\[f^r(\xi_l) \approx \sum_j c^{l,r}_j \, f_{i-r+j}\]

for each \(l\) from 0 to len(xi).

pyweno.symbolic.optimal_weights(k, xi)

Compute the optimal weights for a 2k-1 order WENO scheme corresponding to the reconstruction points in xi.

The coefficients are stored as SymPy variables in a dictionary indexed according to w[l,r]. That is

\[f(\xi^l) \approx \sum_r w^r f^r\]

for each \(l\) from 0 to len(xi).

pyweno.symbolic.jiang_shu_smoothness_coefficients(k)

Compute the Jiang-Shu smoothness coefficients for a 2k-1 order WENO scheme.

The coefficients are stored as SymPy variables in a dictionary indexed according to beta[r,m,n]. That is

\[\sigma^r = \sum_{m=1}^{2k-1} \sum_{n=1}^{2k-1} \beta_{r,m,n}\, \overline{f}_{i-k+m}\, \overline{f}_{i-k+n}.\]
pyweno.symbolic.reconstruction_coefficients_for_derivative(k, bias)

XXX

pyweno.symbolic.optimal_weights_for_derivative(k, bias)

XXX

pyweno.symbolic.jiang_shu_smoothness_coefficients_for_derivative(k, bias)

XXX

Code generation

Kernels

PyWENO code generation tool kit (kernels).

class pyweno.kernels.KernelGenerator(lang, reuse=False, vectorize=False, **kwargs)

Generate kernels for WENO reconstructions.

Each method generates a ‘kernel’ for a specific WENO operation: computing smoothness indicators, non-linear weights, and reconstructions. These code snippets can, in-turn, be used to create seperate functions or larger kernels.

The local_names dictionary is used to define naming conventions:

  • smoothness indicators: sigma, default sigmaX
  • weights: omega, default omegaX
  • intermediate reconstructions: fr, default frX.

For each of the above, the occurance of X is replaced by the left-shift r. For example, for k=3 and omega='omegaX', the weights are stored in omega0, omega1, and omega2, each of which are assumed to be in scope. In some routines the accumulator variable acc is also assumed to be in scope.

Parameters:lang'c', 'opencl', or 'fortran'
reconstruction()

Fully un-rolled reconstruction kernel for uniform grids.

The reconstruction kernel computes the WENO reconstruction based on the weights omega (which have already been computed) and the reconstruction coefficients coeffs.

set_optimal_weights(varpi, split)

Set the optimal (linear) weights.

set_reconstruction_coefficients(coeffs)

Set the reconstruction coefficients.

set_smoothness(beta)

Set the smoothness indicator coefficients.

smoothness()

Fully un-rolled smoothness indicator kernel for uniform grids.

The smoothness indicator kernel computes the smoothness indicators sigma determined by the coefficients in beta. That is:

\[\sigma_r = \sum_{m=1}^{2k-1} \sum_{n=1}^{2k-1} \beta_{r,m,n}\, \overline{f}_{i-k+m}\, \overline{f}_{i-k+n}.\]
weights(normalise=True, power=2, epsilon='1.0e-6')

Fully un-rolled weights kernel for uniform grids.

The weights kernel computes the weights \(\omega^r\) determined by the smoothness coefficients \(\sigma^r\) (which have already been computed). The weights \(\omega^r\) are computed from the optimal weights \(\varpi^r\) according to:

\[\omega^r = \frac{\varpi^r}{(\sigma^r + \epsilon)^p}\]

The weights are subsequently renormalised (if requested) according to:

\[\omega^r = \frac{\omega^r}{\sum_j \omega^j}\]
Parameters:
  • normalise – re-normalise the weights?
  • power – power \(p\) of the denominator
  • epsilon\(\epsilon\)

If normalise is False the weights are not re-normalised. Instead, the re-normalisation occurs during the reconstruction step. This saves a few divisions if the weights are computed during the reconstruction.

Functions

PyWENO function generation class (callable functions).

class pyweno.functions.FunctionGenerator(*args, **kwargs)

Generate callable functions for WENO reconstructions.

Each method generates a function for a specific WENO operation (or combinations thereof): computing smoothness indicators, non-linear weights, and reconstructions.

Parameters:lang'c', 'opencl', or 'fortran'
generate(function, smoothness=True, weights=True, reconstruct=True, store_smoothness=False, store_weights=False, normalise=True)

Generate WENO function/subroutine called function.

Parameters:
  • function – function/subroutine name
  • smoothness – compute smoothness indicators (boolean)?
  • weights – compute non-linear weights (boolean)?
  • reconstruct – compute WENO reconstruction (boolean)?
Returns:

function source code as a string

set_nonuniform(k, n)

Set reconstruction coeffs, optimal weights, and smoothness coeffs to symbols appropriate for non-uniform reconstructions.

set_optimal_weights(*args)

Set the optimal (linear) weights.

set_reconstruction_coefficients(*args)

Set the reconstruction coefficients.

set_smoothness(*args)

Set the smoothness indicator coefficients.

Non-uniform reconstructions

PyWENO non-uniform reconstruction routines.

pyweno.nonuniform.jiang_shu_smoothness_coefficients(k, x)

Compute the Jiang-Shu smoothness coefficients for a 2k-1 order WENO scheme on the non-uniform grid x.

The coefficients are stored in a NumPy array indexed according to beta[i,r,m,n]. That is

\[\sigma^r = \sum_{m=1}^{2k-1} \sum_{n=1}^{2k-1} \beta_{r,m,n}\, \overline{f}_{i-k+m}\, \overline{f}_{i-k+n}.\]
pyweno.nonuniform.optimal_weights(k, xi, x, tolerance=1e-12)

Compute the optimal weights for a 2k-1 order WENO scheme corresponding to the reconstruction points in xi on the non-uniform grid x.

The coefficients are stored in a NumPy array that is indexed according to w[i,l,r]. That is

\[f(\xi^l) \approx \sum_r w^r f^r\]

for each \(l\) from 0 to len(xi).

pyweno.nonuniform.reconstruction_coefficients(k, xi, x)

Numerically compute the reconstruction coefficients for a 2k-1 order WENO scheme corresponding to the reconstruction points in xi on the non-uniform grid x.

The reconstruction points in xi should be in \([-1, 1]\). This interval is then mapped to the cell \([x_{i-1/2}, x_{i+1/2}]\).

Parameters:
  • xi – list of reconstruction points
  • k – reconstruction order
  • x – cell boundaries

The returned coefficients are stored in a NumPy array that is indexed according to c[i,l,r,j]. That is

\[f^r(\xi_l) \approx \sum_j c^{l,r}_{i,j} \, f_{i-r+j}\]

for each \(l\) from 0 to len(xi).

Version

PyWENO version information.

To obtain the version of PyWENO:

>>> import pyweno.version
>>> pyweno.version.version()
>>> pyweno.version.git_version()

Project Versions

Table Of Contents