bempp.api.utils.interpolation

Helper routines for Chebychev interpolation.

Module Contents

Classes

ChebychevInterpolation

Class providing methods for Chebychev interpolation.

Functions

chebychev_nodes_and_weights_second_kind(order)

Return the Chebychev nodes and weights for a given order.

evaluate_kernel_on_interpolation_points(kernel_type, ...)

Return a kernel evaluation on Chebychev points.

evaluate_laplace_kernel_on_interpolation_points(...)

Evaluate the Laplace kernel at the given points.

evaluate_helmholtz_kernel_on_interpolation_points(...)

Evaluate the Laplace kernel at the given points.

chebychev_tensor_points_3d(lbound, ubound, nodes)

Create Chebychev points associated with a 3d tensor grid.

evaluate_interp_polynomial(nodes, weights, values, ...)

Evaluate an interpolation polynomial.

evaluate_tensor_interp_polynomial(nodes, weights, ...)

Evaluate a tensor interpolation polynomial.

chebychev_differentiation_matrix(nodes, weights)

Return a Chebychev differentiation matrix.

class bempp.api.utils.interpolation.ChebychevInterpolation(order)

Bases: object

Class providing methods for Chebychev interpolation.

property nodes

Return nodes.

property weights

Return weights.

property differentiation_matrix

Return Chebychev differentiation matrix.

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.

differentiate(values)

Differentiate the polynomial defined by values.

bempp.api.utils.interpolation.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.

bempp.api.utils.interpolation.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_typestring

Either ‘laplace’ or ‘helmholtz’ to specify whether to evaluate a Laplace or a Helmholtz kernel.

lboundxNumpy array

An array specifying the lower bound for the x-component box.

uboundxNumpy array

An array specifying the upper bound for the x-component box.

lboundyNumpy array

An array specifying the lower bound for the y-component box.

uboundyNumpy array

An array specifying the upper bound for the y-component box.

nodesarray

An array of 1d nodes defined in the interval [-1, 1] which are used as basis for the tensor points.

kwargskeyword arguments

The currently supported keyword argument is wavenumber to specify the wavenumber for Helmholtz kernels.

bempp.api.utils.interpolation.evaluate_laplace_kernel_on_interpolation_points(pointsx, pointsy)

Evaluate the Laplace kernel at the given points.

bempp.api.utils.interpolation.evaluate_helmholtz_kernel_on_interpolation_points(pointsx, pointsy, wavenumber)

Evaluate the Laplace kernel at the given points.

bempp.api.utils.interpolation.chebychev_tensor_points_3d(lbound, ubound, nodes)

Create Chebychev points associated with a 3d tensor grid.

bempp.api.utils.interpolation.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.

bempp.api.utils.interpolation.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

nodesNumpy array

1d array of interpolation points

weightsNumpy array

Associated array of barycentric weights

valuesNumpy 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_pointsNumpy array

(N x 3) array of N evaluation points in 3 dimension.

bempp.api.utils.interpolation.chebychev_differentiation_matrix(nodes, weights)

Return a Chebychev differentiation matrix.