bempp.api.grid

The Grid classes.

Documentation of the functionality of this module and examples can be found at https://bempp.com/handbook/api/grids.html

Submodules

Package Contents

Classes

Grid

The Grid class.

Functions

union(grids[, domain_indices, swapped_normals])

Return the union of a given list of grids.

class bempp.api.grid.Grid(vertices, elements, domain_indices=None, grid_id=None, scatter=True)

Bases: object

The Grid class.

property vertex_adjacency

Vertex adjacency information.

Returns a matrix with 4 rows. Each column has the entries e0, e1, ind0, ind1, which means that element e0 is connected to element e1 via local vertex index ind0 in e0 and ind1 in e1. Only returnes connectivity via a single vertex. For connectivity via edges see edge_adjacency.

property edge_adjacency

Edge adjacency information.

Returns a matrix with 6 rows. Each column has the entries e0, e1, v00, v01, v11, v12, which means that element e0 is connected to element e1. Vertex v00 in element e0 is identical to vertex v11 in element e1, and vertex v01 in element 0 is identical to vertex v12 in element e1.

property element_to_vertex_matrix

Return the matrix mapping vertices to elements.

property element_to_element_matrix

Return element to element matrix.

If entry (i,j) has the value n > 0, element i and element j are connected via n vertices.

property element_neighbors

Return named tuple (indices, indexptr).

The neighbors of element i are given as element_neighbors.indices[

element_neighbors.indptr[i] : element_neighbors.indptr[i +1]].

Note that the element i is contained in the list of neighbors.

property number_of_vertices

Return number of vertices.

property number_of_edges

Return number of edges.

property number_of_elements

Return number of elements.

property vertices

Return vertices.

property elements

Return elements.

property edges

Return edges.

property centroids

Return the centroids of the elements.

property domain_indices

Return domain indices.

property element_edges

Return an array of edge indices for each element.

element_edges[i, j] is the index of the ith edge in the jth element.

property device_interfaces

Return the dictionary of device interfaces for the grid.

property as_array

Convert the grid to an array.

For a grid with N elements returns a 1d array with 9 * N entries. The three nodes for element with index e can be found in [9 * e, 9 * (e + 1)].

property bounding_box

Return the bounding box for the grid.

The bounding box is a 3x2 array box such that box[:, 0] contains (xmin, ymin, zmin) and box[:, 1] contains (xmax, ymax, zmax).

property volumes

Return element volumes.

property diameters

Return element diameters.

property maximum_element_diameter

Return the maximum element diameter.

property minimum_element_diameter

Return the maximum element diameter.

property normals

Return normals.

property jacobians

Return Jacobians.

property integration_elements

Return integration elements.

property jacobian_inverse_transposed

Return the jacobian inverse transposed.

property vertex_on_boundary

Return vertex boundary information.

property edge_on_boundary

Return edge boundary information.

property edge_neighbors

Return for each edge the list of neighboring elements..

property vertex_neighbors

Return for each vertex the list of neighboring elements.

property barycentric_refinement

Return the barycentric refinement of this grid.

property id

Return a unique id for the grid.

data(precision='double')

Return Numba container with all relevant grid data.

_scatter()

Initialise the grid on all workers.

entity_count(codim)

Return the number of entities of given codimension.

plot()

Plot the grid.

get_element(index)

Return element with a given index.

entity_iterator(codim)

Return an iterator for a given codim.

map_to_point_cloud(order=None, local_points=None, precision='double')

Return a point cloud representation of the grid on quadratur points.

Return a representation of the grid as a point cloud using points on each element either defined through a triangle Gauss qudrature order or by directly specifying an array of local points.

Parameters

orderInteger

Optional parameter. Specify a quadrature order for the point cloud generation.

local_points: Numpy array

A 2 x N array of N points in local reference coordinates that specify the points to use for each triangle.

precision: String

Either ‘single’ or ‘double’.

If neither order nor local_points is specified the quadrature order is obtained from the global parameters.

Returns a M x 3 array of M points that represent the grid on the specified points.

refine()

Return a new grid with all elements refined.

_compute_vertex_neighbors()

Return all elements adjacent to a given vertex.

_normalize_and_assign_input(vertices, elements, domain_indices)

Convert input into the right form.

_enumerate_edges()

Enumerate all edges in a given grid.

Assigns a tuple (edges, element_edges) to self._edges and self._element_edges. element_edges is an array a such that a[i, j] is the index of the ith edge in the jth elements, and edges is a 2 x nedges array such that the jth column stores the two nodes associated with the jth edge.

_get_element_adjacency_for_edges_and_vertices()

Get element adjacency.

The array edge_adjacency has 6 rows, such that for index j the element edge_adjacency[0, j] is connected with element edge_adjacency[1, j] via the vertices edge_adjacency[2:4, j] in the first element and the vertices edge_adjacency[4:6, j] in the second element. The vertex numbers here are local numbers (0, 1 or 2).

The array vertex_adjacency has 4 rows, such that for index j the element vertex_adjacency[0, j] is connected with vertex_adjacency[1, j] via the vertex vertex_adjacency[2, j] in the first element and the vertex vertex_adjacency[3, j] in the second element. The vertex numbers here are local numbers (0, 1 or 2).

_compute_geometric_quantities()

Compute geometric quantities for the grid.

_compute_boundary_information()

Return a boolean array with boundary information.

Computes arr0, arr1 such that arr0[j] is True if vertex j lies on the boundary and arr1[i] is True if edge i lies on the boundary.

_compute_edge_neighbors()

Get the neighbors of each edge.

bempp.api.grid.union(grids, domain_indices=None, swapped_normals=None)

Return the union of a given list of grids.

Parameters

grids: list

A list of grid objects.

domain_indiceslist

Attach a list of domain indices to the new grid such that grid[j] received the domain index domain_indices[j]

swapped_normalslist of boolean

A list of the form [False, True, …], that specifies for each grid if the normals should be swapped (True) or not (False). This is helpful if one grid is defined to be inside another grid.

This method returns a new grid object, which is the union of the input grid objects.