landlab.grid.unstructured.cells¶
- class CellGrid[source]¶
Bases:
object
- Parameters:
vertices (array-like) – Vertex IDs at each grid cell
vertices_per_cell (array-like) – Number of vertices per grid cell
- Returns:
A newly-created CellGrid
- Return type:
Examples
Create a grid of two cells where the first cell has four vertices and the second has three.
>>> from landlab.grid.unstructured.cells import CellGrid >>> cgrid = CellGrid([0, 1, 3, 2, 1, 4, 3], [4, 3]) >>> cgrid.number_of_cells 2 >>> cgrid.number_of_vertices_at_cell(0) 4 >>> cgrid.number_of_vertices_at_cell(1) 3 >>> cgrid.vertices_at_cell(0) array([0, 1, 3, 2]) >>> cgrid.vertices_at_cell(1) array([1, 4, 3])
Associate nodes with each cell.
>>> cgrid = CellGrid([0, 1, 2, 3, 1, 3, 4], [4, 3], node_at_cell=[10, 11]) >>> cgrid.node_at_cell array([10, 11]) >>> cgrid.cell_at_node[10] 0 >>> cgrid.cell_at_node[11] 1
- Parameters:
vertices (array-like) – Vertex IDs at each grid cell
vertices_per_cell (array-like) – Number of vertices per grid cell
- Returns:
A newly-created CellGrid
- Return type:
Examples
Create a grid of two cells where the first cell has four vertices and the second has three.
>>> from landlab.grid.unstructured.cells import CellGrid >>> cgrid = CellGrid([0, 1, 3, 2, 1, 4, 3], [4, 3]) >>> cgrid.number_of_cells 2 >>> cgrid.number_of_vertices_at_cell(0) 4 >>> cgrid.number_of_vertices_at_cell(1) 3 >>> cgrid.vertices_at_cell(0) array([0, 1, 3, 2]) >>> cgrid.vertices_at_cell(1) array([1, 4, 3])
Associate nodes with each cell.
>>> cgrid = CellGrid([0, 1, 2, 3, 1, 3, 4], [4, 3], node_at_cell=[10, 11]) >>> cgrid.node_at_cell array([10, 11]) >>> cgrid.cell_at_node[10] 0 >>> cgrid.cell_at_node[11] 1
- __init__(vertices, vertices_per_cell, node_at_cell=None)[source]¶
- Parameters:
vertices (array-like) – Vertex IDs at each grid cell
vertices_per_cell (array-like) – Number of vertices per grid cell
- Returns:
A newly-created CellGrid
- Return type:
Examples
Create a grid of two cells where the first cell has four vertices and the second has three.
>>> from landlab.grid.unstructured.cells import CellGrid >>> cgrid = CellGrid([0, 1, 3, 2, 1, 4, 3], [4, 3]) >>> cgrid.number_of_cells 2 >>> cgrid.number_of_vertices_at_cell(0) 4 >>> cgrid.number_of_vertices_at_cell(1) 3 >>> cgrid.vertices_at_cell(0) array([0, 1, 3, 2]) >>> cgrid.vertices_at_cell(1) array([1, 4, 3])
Associate nodes with each cell.
>>> cgrid = CellGrid([0, 1, 2, 3, 1, 3, 4], [4, 3], node_at_cell=[10, 11]) >>> cgrid.node_at_cell array([10, 11]) >>> cgrid.cell_at_node[10] 0 >>> cgrid.cell_at_node[11] 1
- __new__(**kwargs)¶
- property cell_at_node¶
- property cell_id¶
- iter()[source]¶
Iterate over the cells of the grid.
- Returns:
Nodes entering and leaving each node
- Return type:
ndarray
- property node_at_cell¶
- property number_of_cells¶