:py:mod:`bempp.api.assembly.grid_function` ========================================== .. py:module:: bempp.api.assembly.grid_function .. autoapi-nested-parse:: Definition of Grid functions in Bempp. Documentation of the functionality of this module and examples can be found at https://bempp.com/handbook/api/grid_functions.html Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: bempp.api.assembly.grid_function.GridFunction Functions ~~~~~~~~~ .. autoapisummary:: bempp.api.assembly.grid_function.callable bempp.api.assembly.grid_function.real_callable bempp.api.assembly.grid_function.complex_callable bempp.api.assembly.grid_function._integrate bempp.api.assembly.grid_function.get_function_quadrature_information bempp.api.assembly.grid_function._project_function bempp.api.assembly.grid_function._project_function_vectorized .. py:function:: callable(*args, complex=False, jit=True, parameterized=False, vectorized=False) Wrap a callable for Bempp. .. py:function:: real_callable(*args, jit=True) Wrap function as a real Numba callable. .. py:function:: complex_callable(*args, jit=True) Wrap function as a complex Numba callable. .. py:class:: GridFunction(space, dual_space=None, fun=None, coefficients=None, projections=None, parameters=None, function_parameters=None) Bases: :py:obj:`object` Representation of functions on a grid. Attributes ---------- coefficients : np.ndarray Return or set the vector of coefficients. component_count : int Return the number of components of the grid function values. space : bemp.api.space.Space Return the space over which the GridFunction is defined. grid : bempp.api.grid.Grid Return the underlying grid. parameters : bempp.api.ParameterList Return the set of parameters. representation : string Return 'primal' if the coefficients of the Gridfunction are known. Return 'dual' if only the coefficients in the dual space are known. .. py:property:: space Return space. .. py:property:: dtype Return type. .. py:property:: parameters Return parameters. .. py:property:: dual_space Return dual space. .. py:property:: representation Return the representation of the grid function. If the grid function is given in terms of coefficients in the domain space return 'primal'. If the function is given by its projections return 'dual'. .. py:property:: coefficients Return coefficient vector. .. py:property:: grid_coefficients Return grid coefficients. .. py:property:: real Return a new grid function consisting of the real part of this function. .. py:property:: imag Return a new grid function consisting of the imaginary part of this function. .. py:property:: component_count Return number of components. .. py:method:: projections(dual_space=None) Compute the vector of projections onto the given dual space. Parameters ---------- dual_space : bempp.api.space.Space A representation of the dual space. If not specified then fun.dual_space is used. Returns ------- out : np.ndarray A vector of projections onto the dual space. .. py:method:: project_to_space(space) Return an L^2 projection on another space. .. py:method:: plot(mode=None, transformation=None) Plot the grid function. Attributes ---------- mode : string One of 'element' or 'node'. If 'element' is chosen the color is determined by the mid-point of the faces of the grid. For 'vertices' the vertex values are chosen transformation : string or object One of 'real', 'imag', 'abs', 'log_abs' or 'abs_squared' or a callable object. Describes the data transformation before plotting. For functions with vector values only 'abs', 'log_abs' or 'abs_squared' are allowed. If a callable object is given this is applied instead. It is important that the callable returns numpy arrays with the same number of dimensions as before. .. py:method:: evaluate(element_index, local_coordinates) Evaluate grid function on a single element. .. py:method:: evaluate_on_element_centers() Evaluate the grid function on all element centers. .. py:method:: evaluate_on_vertices() Evaluate the grid function on all vertices. If a function is discontinuous across elements a weighted average of the element values at the vertices is taken. .. py:method:: integrate() Integrate grid function over a grid. .. py:method:: l2_norm() Calculate the L^2 norm of the function. .. py:method:: __add__(other) Add two grid functions. .. py:method:: __mul__(alpha) Multiply a grid function. .. py:method:: __rmul__(alpha) Multiply a grid function. .. py:method:: __div__(alpha) Divide a grid function. .. py:method:: __truediv__(alpha) Divide a grid function. .. py:method:: __neg__() Negate a grid function. .. py:method:: __sub__(other) Subtract grid functions. .. py:method:: from_random(space) :classmethod: Create a random grid function normalized to unit norm. .. py:method:: from_ones(space) :classmethod: Create a grid function with all coefficients set to one. .. py:method:: from_zeros(space) :classmethod: Create a grid function with all coefficients set to one. .. py:function:: _integrate(coefficients, grid_data, support_elements, local2global, local_multipliers, normal_multipliers, evaluate_on_element, shapeset_evaluate, points, weights, codomain_dimension, number_of_shape_functions) Integrate a grid function over a grid. .. py:function:: get_function_quadrature_information(grid_data, support_elements, normal_multipliers, quad_points) Return vectorized version of quad_points, normals and domain_indices. .. py:function:: _project_function(fun, grid_data, support_elements, local2global, local_multipliers, normal_multipliers, evaluate_on_element, shapeset_evaluate, points, weights, codomain_dimension, projections, function_parameters) Project a Numba callable onto a grid. .. py:function:: _project_function_vectorized(function_data, grid_data, support_elements, local2global, local_multipliers, normal_multipliers, evaluate_on_element, shapeset_evaluate, points, weights, codomain_dimension, projections, function_parameters) Project a Numba callable onto a grid.