:py:mod:`bempp.api.grid` ======================== .. py:module:: bempp.api.grid .. autoapi-nested-parse:: The Grid classes. Documentation of the functionality of this module and examples can be found at https://bempp.com/handbook/api/grids.html Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 grid/index.rst io/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: bempp.api.grid.Grid Functions ~~~~~~~~~ .. autoapisummary:: bempp.api.grid.union .. py:class:: Grid(vertices, elements, domain_indices=None, grid_id=None, scatter=True) Bases: :py:obj:`object` The Grid class. .. py: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. .. py: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. .. py:property:: element_to_vertex_matrix Return the matrix mapping vertices to elements. .. py: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. .. py: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. .. py:property:: number_of_vertices Return number of vertices. .. py:property:: number_of_edges Return number of edges. .. py:property:: number_of_elements Return number of elements. .. py:property:: vertices Return vertices. .. py:property:: elements Return elements. .. py:property:: edges Return edges. .. py:property:: centroids Return the centroids of the elements. .. py:property:: domain_indices Return domain indices. .. py: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. .. py:property:: device_interfaces Return the dictionary of device interfaces for the grid. .. py: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)]. .. py: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). .. py:property:: volumes Return element volumes. .. py:property:: diameters Return element diameters. .. py:property:: maximum_element_diameter Return the maximum element diameter. .. py:property:: minimum_element_diameter Return the maximum element diameter. .. py:property:: normals Return normals. .. py:property:: jacobians Return Jacobians. .. py:property:: integration_elements Return integration elements. .. py:property:: jacobian_inverse_transposed Return the jacobian inverse transposed. .. py:property:: vertex_on_boundary Return vertex boundary information. .. py:property:: edge_on_boundary Return edge boundary information. .. py:property:: edge_neighbors Return for each edge the list of neighboring elements.. .. py:property:: vertex_neighbors Return for each vertex the list of neighboring elements. .. py:property:: barycentric_refinement Return the barycentric refinement of this grid. .. py:property:: id Return a unique id for the grid. .. py:method:: data(precision='double') Return Numba container with all relevant grid data. .. py:method:: _scatter() Initialise the grid on all workers. .. py:method:: entity_count(codim) Return the number of entities of given codimension. .. py:method:: plot() Plot the grid. .. py:method:: get_element(index) Return element with a given index. .. py:method:: entity_iterator(codim) Return an iterator for a given codim. .. py:method:: 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 ---------- order : Integer 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. .. py:method:: refine() Return a new grid with all elements refined. .. py:method:: _compute_vertex_neighbors() Return all elements adjacent to a given vertex. .. py:method:: _normalize_and_assign_input(vertices, elements, domain_indices) Convert input into the right form. .. py:method:: _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. .. py:method:: _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). .. py:method:: _compute_geometric_quantities() Compute geometric quantities for the grid. .. py:method:: _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. .. py:method:: _compute_edge_neighbors() Get the neighbors of each edge. .. py:function:: 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_indices : list Attach a list of domain indices to the new grid such that grid[j] received the domain index domain_indices[j] swapped_normals : list 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.