:py:mod:`bempp.api.space.space` =============================== .. py:module:: bempp.api.space.space .. autoapi-nested-parse:: Generic access to spaces. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: bempp.api.space.space.SpaceBuilder bempp.api.space.space.FunctionSpace Functions ~~~~~~~~~ .. autoapisummary:: bempp.api.space.space.function_space bempp.api.space.space.return_compatible_representation bempp.api.space.space.check_if_compatible bempp.api.space.space.map_space_to_points bempp.api.space.space.map_space_to_points_impl bempp.api.space.space._process_segments bempp.api.space.space.invert_local2global bempp.api.space.space.make_localised_space bempp.api.space.space._space_scatter_worker bempp.api.space.space._numba_evaluate .. py:function:: function_space(grid, kind, degree, scatter=True, **kwargs) Initialize a function space. Parameters ---------- grid : bempp.Grid The grid that the space is defined on. kind : str The space type degree : int The polynomial degree of the space support_elements : np.array The element indices of elements that make up the part of the mesh on which the space is defined. segments : list The segment numbers of the part of the mesh on which the space is defined. swapped_normals : bool TODO scatter : bool TODO include_boundary_dofs : bool Should degrees of freedom on the boundary of the grid segments be included? truncate_at_segment_edge : bool Should basis functions be truncated at the edge of the grid segment? If this is set to true, continuous spaces will no longer be continuous across the segment edge. .. py:class:: SpaceBuilder(grid) Bases: :py:obj:`object` Configure and builds a space object. .. py:method:: set_codomain_dimension(codomain_dimension) Set the codomain dimension. .. py:method:: set_support(support) Set the support. .. py:method:: set_normal_multipliers(normal_multipliers) Set normal multipliers. .. py:method:: set_order(order) Set the order of the space. .. py:method:: set_shapeset(shapeset) Set the shapeset string. .. py:method:: set_local2global(local2global) Set the local2global map. .. py:method:: set_global2local(global2local) Set the global2local map. .. py:method:: set_local_multipliers(local_multipliers) Set the local multipliers. .. py:method:: set_identifier(identifier) Set the identifier. .. py:method:: set_is_localised(is_localised) Set to true if space is localised. .. py:method:: set_dof_transformation(dof_transformation) Set the dof transformation. .. py:method:: set_is_barycentric(is_barycentric) Call to define space as barycentric. .. py:method:: set_numba_evaluator(basis_evaluator) Hand over Numba method that evaluates the basis. .. py:method:: set_numba_surface_gradient(surface_gradient) Hand over Numba method that evaluates surface gradient. .. py:method:: set_numba_surface_curl(surface_curl) Hand over Numba method that evaluates surface curl. .. py:method:: set_barycentric_representation(barycentric_representation) Set barycentric representation. .. py:method:: set_collocation_points(collocation_points) Define the collocation points. .. py:method:: build() Build a space object. .. py:class:: FunctionSpace(grid, codomain_dimension, order, shapeset, local2global_map, global2local_map, local_multipliers, identifier, is_localised, support, normal_multipliers, requires_dof_transformation, is_barycentric, barycentric_representation, dof_transformation, numba_evaluator, numba_surface_gradient, numba_surface_curl, collocation_points) Bases: :py:obj:`object` Main class for function spaces. This class is not meant to be initialized on its own. Rather there are functions for each type of space that configure this object through a builder pattern. .. py:property:: grid Return the grid. .. py:property:: grid_id Return id of base grid. .. py:property:: codomain_dimension Return the codomain dimension. .. py:property:: global_dof_count Return the global dof count. .. py:property:: grid_dof_count Return the grid dof count. .. py:property:: order Return order of the space. .. py:property:: local2global Return local to global map. .. py:property:: local_multipliers Return the multipliers for each local dof. .. py:property:: normal_multipliers Return the normal multipliers for each grid element. .. py:property:: global2local Return global to local map. .. py:property:: number_of_shape_functions Return the number of shape functions on each element. .. py:property:: number_of_support_elements Return the number of elements that form the support. .. py:property:: support_elements Return the list of elements on which space is supported. .. py:property:: identifier Return the identifier. .. py:property:: support Return support of the space. .. py:property:: id Return id string of the space. .. py:property:: shapeset Return the shapeset. .. py:property:: localised_space Return the elementwise defined space. .. py:property:: is_localised Return true if space is localised. .. py:property:: color_map Return a coloring of the grid associated with the space. The coloring is defined such that if two elements have the same color then their associated global degrees of freedom do not intersect. This is important for the efficient summation of global dofs during the assembly. .. py:property:: map_to_localised_space Return a sparse matrix that maps dofs to localised space. .. py:property:: map_to_full_grid Return a sparse matrix that maps dofs to localised space on full grid. .. py:property:: dof_transformation Return transformation from global dofs to space dofs. .. py:property:: requires_dof_transformation Return true if the dof transformation matrix is not the identity. .. py:property:: is_barycentric Return true if space is defined over barycentric grid. .. py:property:: hash Return hash string for space comparison. .. py:property:: numba_evaluate Return the basis evaluator. .. py:property:: numba_surface_gradient Return the surface gradient evaluator. .. py:property:: numba_surface_curl Return the surface curl evaluator. .. py:property:: has_surface_gradient Return True if surface gradient is defined. .. py:property:: has_surface_curl Return True if surface curl is defined. .. py:property:: collocation_points Return collocation points. .. py:method:: cell_dofs(cell_index) Return the DOF numbers associated with the cell. .. py:method:: barycentric_representation() Return barycentric_representation if it exists. .. py:method:: map_to_points(quadrature_order=None, return_transpose=False) Return a map from function space coefficients to point evaluations. Creates a mapping from function space coefficients to Green's fct. coefficients. Needed mainly for FMM evaluations. The point definition is the quadrature order of the underlying quadrature rule. If 'return_transpose' is true then then transpose of the operator is returned. .. py:method:: get_elements_by_color() Return color sorted elements and their index positions. This method returns a tuple (sorted_indices, indexptr) so that all element indices with color i are contained in sorted_indices[indexptr[i]:indexptr[i+1]]. .. py:method:: evaluate(element_index, local_coordinates) Evaluate the basis on an element. Returns an array of the form (codomain_dimension, number_of_shape_functions, number_of_eval_points) that contains the basis functions evaluated at the given points. .. py:method:: surface_gradient(element_index, local_coordinates) Return the surface gradient. .. py:method:: surface_curl(element_index, element, local_coordinates) Return the surface gradient. .. py:method:: mass_matrix() Return the mass matrix associated with this space. .. py:method:: inverse_mass_matrix() Return the inverse mass matrix for this space. .. py:method:: _generate_hash() Generate a hash for the space object. .. py:method:: is_compatible(other) Check if space is compatible with other space. .. py:method:: _set_id(new_id) Assign a new id string to the space. .. py:method:: _compute_color_map() Compute the color map. .. py:method:: _sort_elements_by_color() Implement elements by color computation. .. py:method:: __eq__(other) Check if spaces are compatible. .. py:function:: return_compatible_representation(*args) Return representation of spaces on same grid. .. py:function:: check_if_compatible(space1, space2) Return true if two spaces are compatible. .. py:function:: map_space_to_points(space, quadrature_order=None, return_transpose=False) Return mapper from grid coeffs to point evaluations. .. py:function:: map_space_to_points_impl(grid_data, local2global, local_multipliers, normal_multipliers, support_elements, numba_evaluate, shape_fun, local_points, weights, number_of_shape_functions) Run Numba accelerated computational parts for point map. .. py:function:: _process_segments(grid, support_elements, segments, swapped_normals) Process information from support_elements and segments vars. .. py:function:: invert_local2global(local2global_map, local_multipliers) Obtain the global to local dof map from the local to global map. .. py:function:: make_localised_space(space) Return the associated localised space. .. py:function:: _space_scatter_worker(grid_id, space_id, kind, degree, kwargs) Copy a space to a worker. .. py:function:: _numba_evaluate(element_index, shapeset_evaluate, local_coordinates, grid_data, local_multipliers, normal_multipliers) Evaluate the basis on an element.