NdinterpolatorΒΆ

RBF.beckert_wendland_c2_basis It implements the following formula:
RBF.gaussian_spline It implements the following formula:
RBF.inv_multi_quadratic_biharmonic_spline It implements the following formula:
RBF.multi_quadratic_biharmonic_spline It implements the following formula:
RBF.thin_plate_spline It implements the following formula:
RBF.weights_matrix This method returns the following matrix:
reconstruct_f Reconstruct a function by using the radial basis function approximations.
scipy_bspline Construct B-Spline curve via the control points.
class RBF(basis, radius)[source]

Module focused on the implementation of the Radial Basis Functions interpolation technique. This technique is still based on the use of a set of parameters, the so-called control points, as for FFD, but RBF is interpolatory. Another important key point of RBF strategy relies in the way we can locate the control points: in fact, instead of FFD where control points need to be placed inside a regular lattice, with RBF we havo no more limitations. So we have the possibility to perform localized control points refiniments.

Theoretical Insight:
 

As reference please consult M.D. Buhmann, Radial Basis Functions, volume 12 of Cambridge monographs on applied and computational mathematics. Cambridge University Press, UK, 2003. This implementation follows D. Forti and G. Rozza, Efficient geometrical parametrization techniques of interfaces for reduced order modelling: application to fluid-structure interaction coupling problems, International Journal of Computational Fluid Dynamics.

RBF shape parametrization technique is based on the definition of a map \mathcal{M}(\boldsymbol{x}) : \mathbb{R}^n \rightarrow
\mathbb{R}^n, that allows the possibility of transferring data across non-matching grids and facing the dynamic mesh handling. The map introduced is defines as follows

\mathcal{M}(\boldsymbol{x}) = p(\boldsymbol{x}) + 
\sum_{i=1}^{\mathcal{N}_C} \gamma_i
\varphi(\| \boldsymbol{x} - \boldsymbol{x_{C_i}} \|)

where p(\boldsymbol{x}) is a low_degree polynomial term, \gamma_i is the weight, corresponding to the a-priori selected \mathcal{N}_C control points, associated to the i-th basis function, and \varphi(\| \boldsymbol{x} -
\boldsymbol{x_{C_i}} \|) a radial function based on the Euclidean distance between the control points position \boldsymbol{x_{C_i}} and \boldsymbol{x}. A radial basis function, generally, is a real-valued function whose value depends only on the distance from the origin, so that \varphi(\boldsymbol{x}) = \tilde{\varphi}(
\|\boldsymbol{x} \|).

The matrix version of the formula above is:

\mathcal{M}(\boldsymbol{x}) = \boldsymbol{c} +
\boldsymbol{Q}\boldsymbol{x} +
\boldsymbol{W^T}\boldsymbol{d}(\boldsymbol{x})

The idea is that after the computation of the weights and the polynomial terms from the coordinates of the control points before and after the deformation, we can deform all the points of the mesh accordingly. Among the most common used radial basis functions for modelling 2D and 3D shapes, we consider Gaussian splines, Multi- uadratic biharmonic splines, Inverted multi-quadratic biharmonic splines, Thin-plate splines, Beckert and Wendland C^2 basis all defined and implemented below.

Parameters:
  • basis (string) – RBF basis function
  • radius (float) – cut-off radius
static beckert_wendland_c2_basis(X, r)[source]

It implements the following formula:

\varphi(\| \boldsymbol{x} \|) =
\left( 1 - \frac{\| \boldsymbol{x} \|}{r} \right)^4 +
\left( 4 \frac{\| \boldsymbol{x} \|}{r} + 1 \right)

Parameters:
  • X (numpy.ndarray) – l2-norm between given inputs of a function and the locations to perform rbf approximation to that function.
  • r (float) – smoothing length, also called the cut-off radius.
Returns:

result: the result of the formula above.

Return type:

float

static gaussian_spline(X, r)[source]

It implements the following formula:

\varphi(\| \boldsymbol{x} \|) =
e^{-\frac{\| \boldsymbol{x} \|^2}{r^2}}

Parameters:
  • X (numpy.ndarray) – l2-norm between given inputs of a function and the locations to perform rbf approximation to that function.
  • r (float) – smoothing length, also called the cut-off radius.
Returns:

result: the result of the formula above.

Return type:

float

static inv_multi_quadratic_biharmonic_spline(X, r)[source]

It implements the following formula:

\varphi(\| \boldsymbol{x} \|) =
(\| \boldsymbol{x} \|^2 + r^2 )^{-\frac{1}{2}}

Parameters:
  • X (numpy.ndarray) – l2-norm between given inputs of a function and the locations to perform rbf approximation to that function.
  • r (float) – smoothing length, also called the cut-off radius.
Returns:

result: the result of the formula above.

Return type:

float

static multi_quadratic_biharmonic_spline(X, r)[source]

It implements the following formula:

\varphi(\| \boldsymbol{x} \|) =
\sqrt{\| \boldsymbol{x} \|^2 + r^2}

Parameters:
  • X (numpy.ndarray) – l2-norm between given inputs of a function and the locations to perform rbf approximation to that function.
  • r (float) – smoothing length, also called the cut-off radius.
Returns:

result: the result of the formula above.

Return type:

float

static thin_plate_spline(X, r)[source]

It implements the following formula:

\varphi(\| \boldsymbol{x} \|) =
\left\| \frac{\boldsymbol{x} }{r} \right\|^2
\ln \left\| \frac{\boldsymbol{x} }{r} \right\|

Parameters:
  • X (numpy.ndarray) – l2-norm between given inputs of a function and the locations to perform rbf approximation to that function.
  • r (float) – smoothing length, also called the cut-off radius.
Returns:

result: the result of the formula above.

Return type:

float

weights_matrix(X1, X2)[source]

This method returns the following matrix:

\boldsymbol{D_{ij}} = \varphi(\| \boldsymbol{x_i} -
\boldsymbol{y_j} \|)

Parameters:
Returns:

matrix: the matrix D.

Return type:

numpy.ndarray

reconstruct_f(original_input, original_output, rbf_input, rbf_output, basis, radius)[source]

Reconstruct a function by using the radial basis function approximations.

Parameters:
  • original_input (array_like) – the original values of function inputs.
  • original_output (array_like) – the original values of function output.
  • rbf_input (array_like) – the input data for RBF approximation.
  • rbf_output (array_like) – the array elements to be updated with the RBF interpolated outputs after the approximation.
  • basis (string) – radial basis function.
  • radius (float) – smoothing length, also called the cut-off radius.
Example:
>>> import numpy as np
>>> from bladex.ndinterpolator import reconstruct_f
>>> x = np.arange(10)
>>> y = np.square(x)
>>> radius = 10
>>> n_interp = 50
>>> x_rbf = np.linspace(x[0], x[-1], num=n_interp)
>>> y_rbf = np.zeros(n_interp)
>>> reconstruct_f(original_input=x, original_output=y, rbf_input=x_rbf,
    rbf_output=y_rbf, radius=radius, basis='beckert_wendland_c2_basis')
scipy_bspline(cv, npoints, degree)[source]

Construct B-Spline curve via the control points.

Parameters:
  • cv (array_like) – control points vector (spline coefficients).
  • npoints (int) – number of points on the curve.
  • degree (int) – BSpline degree.