:py:mod:`bempp.api.utils.interpolation` ======================================= .. py:module:: bempp.api.utils.interpolation .. autoapi-nested-parse:: Helper routines for Chebychev interpolation. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: bempp.api.utils.interpolation.ChebychevInterpolation Functions ~~~~~~~~~ .. autoapisummary:: bempp.api.utils.interpolation.chebychev_nodes_and_weights_second_kind bempp.api.utils.interpolation.evaluate_kernel_on_interpolation_points bempp.api.utils.interpolation.evaluate_laplace_kernel_on_interpolation_points bempp.api.utils.interpolation.evaluate_helmholtz_kernel_on_interpolation_points bempp.api.utils.interpolation.chebychev_tensor_points_3d bempp.api.utils.interpolation.evaluate_interp_polynomial bempp.api.utils.interpolation.evaluate_tensor_interp_polynomial bempp.api.utils.interpolation.chebychev_differentiation_matrix .. py:class:: ChebychevInterpolation(order) Bases: :py:obj:`object` Class providing methods for Chebychev interpolation. .. py:property:: nodes Return nodes. .. py:property:: weights Return weights. .. py:property:: differentiation_matrix Return Chebychev differentiation matrix. .. py:method:: evaluate(values, evaluation_points) Evaluate interpolation polynomial. Evaluates the interpolation polynomial with data given in the array values at the points in the array evaluation_points. .. py:method:: differentiate(values) Differentiate the polynomial defined by values. .. py:function:: chebychev_nodes_and_weights_second_kind(order) Return the Chebychev nodes and weights for a given order. This function computes the Chebychev nodes of the second kind defined as x_j = cos (pi * j / order) for j = 0 .. order. The corresponding weights w_j are required for the evaluation of the associated interpolation polynomial via barycentric interpolation. For the Chebychev nodes of the second kind it holds that w_j = (-1)^j * d_j with d_j = 1/2 for j = 0 or j = order and d_j = 1 otherwise. .. py:function:: evaluate_kernel_on_interpolation_points(kernel_type, lboundx, uboundx, lboundy, uboundy, nodes, device_interface=None, precision='double', **kwargs) Return a kernel evaluation on Chebychev points. This routine supports the evaluation of Laplace and Helmholtz kernels of the form k(x, y) on 3d Tensor grids. It returns a matrix (k(x,_i, y_j)), where the x_i are points in the box defined by lboundx and uboundx and y_i are points in the box defined by lboundy and uboundy. The x_i and y_i are obtained from the 1d array of nodes by iterating the nodes array over the three space dimensions and scaling them appropriately to fit in the boxes. The points are generated in the same order as the following code snippet (scaling excluded for simplicity): npoints = len(nodes) tensor_points = _np.empty((npoints**3, 3), _np.float64) for i in range(npoints): for j in range(npoints): for k in range(npoints): tensor_points[i * npoints**2 + j * npoints + k, :] = nodes[i], nodes[j], nodes[k] Hence, the inner dimension is the fastest changing one. Attributes ---------- kernel_type : string Either 'laplace' or 'helmholtz' to specify whether to evaluate a Laplace or a Helmholtz kernel. lboundx : Numpy array An array specifying the lower bound for the x-component box. uboundx : Numpy array An array specifying the upper bound for the x-component box. lboundy : Numpy array An array specifying the lower bound for the y-component box. uboundy : Numpy array An array specifying the upper bound for the y-component box. nodes : array An array of 1d nodes defined in the interval [-1, 1] which are used as basis for the tensor points. kwargs : keyword arguments The currently supported keyword argument is wavenumber to specify the wavenumber for Helmholtz kernels. .. py:function:: evaluate_laplace_kernel_on_interpolation_points(pointsx, pointsy) Evaluate the Laplace kernel at the given points. .. py:function:: evaluate_helmholtz_kernel_on_interpolation_points(pointsx, pointsy, wavenumber) Evaluate the Laplace kernel at the given points. .. py:function:: chebychev_tensor_points_3d(lbound, ubound, nodes) Create Chebychev points associated with a 3d tensor grid. .. py:function:: evaluate_interp_polynomial(nodes, weights, values, evaluation_points) Evaluate an interpolation polynomial. This function uses barycentric evaluation for stability. The data values are assumed to be real. .. py:function:: evaluate_tensor_interp_polynomial(nodes, weights, values, evaluation_points) Evaluate a tensor interpolation polynomial. This function evaluates a tensor chebychev basis with specified weights at a given set of evaluation points. Attributes ---------- nodes : Numpy array 1d array of interpolation points weights : Numpy array Associated array of barycentric weights values : Numpy array 3d array of values at interpolation points. The dimensions specify the values along the (x, y, z) axis with z being the inner most axis. For k interpolation nodes there are k values along each dimension. evaluation_points : Numpy array (N x 3) array of N evaluation points in 3 dimension. .. py:function:: chebychev_differentiation_matrix(nodes, weights) Return a Chebychev differentiation matrix.