Radial Basis Function [CAD]¶
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 hano no more limitations. So we have the possibility to perform localized control points refiniments. The module is analogous to the freeform one.
- 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-quadratic biharmonic splines, Inverted multi-quadratic biharmonic splines, Thin-plate splines, Beckert and Wendland C^2 basis and Polyharmonic splines all defined and implemented below.
- class RBF(original_control_points=None, deformed_control_points=None, func='gaussian_spline', radius=0.5, extra_parameter=None, u_knots_to_add=0, v_knots_to_add=0, t_knots_to_add=0, tolerance=0.0001)[source]
Bases:
pygem.cad.cad_deformation.CADDeformation
,pygem.rbf.RBF
Class that handles the Radial Basis Functions interpolation on CAD geometries.
- Parameters
original_control_points (numpy.ndarray) – it is an (n_control_points, 3) array with the coordinates of the original interpolation control points before the deformation. The default is the vertices of the unit cube.
deformed_control_points (numpy.ndarray) – it is an (n_control_points, 3) array with the coordinates of the interpolation control points after the deformation. The default is the vertices of the unit cube.
func – the basis function to use in the transformation. Several basis function are already implemented and they are available through the
RBFFactory
by passing the name of the right function (see class documentation for the updated list of basis function). A callable object can be passed as basis function. Default is ‘gaussian_spline’.radius (float) – the scaling parameter r that affects the shape of the basis functions. For details see the class
RBF
. The default value is 0.5.extra_parameter (dict) – the additional parameters that may be passed to the kernel function. Default is None.
u_knots_to_add (int) – the number of knots to add to the NURBS surfaces along u direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.
v_knots_to_add (int) – the number of knots to add to the NURBS surfaces along v direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.
t_knots_to_add (int) – the number of knots to add to the NURBS curves before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.
tolerance (float) – the tolerance involved in several internal operations of the procedure (joining wires in a single curve before deformation and placing new poles on curves and surfaces). Change the default value only if the input file scale is significantly different form mm, making some of the aforementioned operations fail. Default is 0.0001.
- Variables
weights (numpy.ndarray) – the matrix formed by the weights corresponding to the a-priori selected N control points, associated to the basis functions and c and Q terms that describe the polynomial of order one p(x) = c + Qx. The shape is (n_control_points+1+3)-by-3. It is computed internally.
original_control_points (numpy.ndarray) – it is an (n_control_points, 3) array with the coordinates of the original interpolation control points before the deformation.
deformed_control_points (numpy.ndarray) – it is an (n_control_points, 3) array with the coordinates of the interpolation control points after the deformation.
basis (callable) – the basis functions to use in the transformation.
radius (float) – the scaling parameter that affects the shape of the basis functions.
extra_parameter (dict) – the additional parameters that may be passed to the kernel function.
u_knots_to_add (int) – the number of knots to add to the NURBS surfaces along u direction before the deformation.
v_knots_to_add (int) – the number of knots to add to the NURBS surfaces along v direction before the deformation.
t_knots_to_add (int) – the number of knots to add to the NURBS curves before the deformation.
tolerance (float) – the tolerance involved in several internal operations of the procedure (joining wires in a single curve before deformation and placing new poles on curves and surfaces).
- Example
>>> from pygem.cad import RBF >>> rbf = RBF() >>> rbf.read_parameters( >>> 'tests/test_datasets/parameters_test_ffd_iges.prm') >>> input_cad_file_name = "input.iges" >>> modified_cad_file_name = "output.iges" >>> rbf(input_cad_file_name, modified_cad_file_name)