discretize.tree_mesh.TreeCell#

Inheritance diagram of TreeCell
class discretize.tree_mesh.TreeCell#

A class for defining cells within instances of TreeMesh.

This cannot be created in python, it can only be accessed by indexing the TreeMesh object. TreeCell is the object being passed to the user defined refine function when calling the refine method for a TreeMesh.

Examples

Here, we define a basic TreeMesh whose refinement is defined by a simple function handle. After we have finalized the mesh, we index a TreeCell from the mesh. Once indexed, the user may examine its properties (center location, dimensions, index of its neighbors, etc…)

>>> from discretize import TreeMesh
>>> import numpy as np

Refine a tree mesh radially outward from the center

>>> mesh = TreeMesh([32,32])
>>> def func(cell):
...     r = np.linalg.norm(cell.center-0.5)
...     return mesh.max_level if r<0.2 else mesh.max_level-2
>>> mesh.refine(func)

Then we can index the mesh to get access to the cell,

>>> tree_cell = mesh[16]
>>> tree_cell.origin
array([0.375, 0.25 ])

Attributes

center

Cell center location for the tree cell.

dim

Dimension of the tree cell; 1, 2 or 3.

edges

Indices for this cell's edges within its parent tree mesh.

faces

Indices for this cell's faces within its parent tree mesh.

h

Cell dimension along each axis direction.

index

Index of the tree cell within its parent tree mesh.

neighbors

Indices for this cell's neighbors within its parent tree mesh.

nodes

Indices for this cell's nodes within its parent tree mesh.

origin

Origin location ('anchor point') for the tree cell.

x0

Origin location ('anchor point') for the tree cell.