discretize.tree_mesh.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 therefine
method for aTreeMesh
.Attributes
Bounds of the cell.
Cell center location for the tree cell.
Dimension of the tree cell; 1, 2 or 3.
Indices for this cell's edges within its parent tree mesh.
Indices for this cell's faces within its parent tree mesh.
Cell dimension along each axis direction.
Index of the tree cell within its parent tree mesh.
Indices for this cell's neighbors within its parent tree mesh.
Indices for this cell's nodes within its parent tree mesh.
Origin location ('anchor point') for the tree cell.
Origin location ('anchor point') for the tree cell.
Examples
Here, we define a basic
TreeMesh
whose refinement is defined by a simple function handle. After we have finalized the mesh, we index aTreeCell
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 ])