grid_apps.octree_creation package

Submodules

grid_apps.octree_creation.driver module

class grid_apps.octree_creation.driver.OctreeDriver(params: OctreeOptions)

Bases: Driver

Driver for octree mesh creation.

static base_treemesh(params: OctreeOptions) discretize.TreeMesh

Create a base TreeMesh object from extents.

static cell_size_from_level(octree, level: int, axis: int = 0)

Computes the cell size at a given level of refinement for a given tree mesh.

Parameters:
  • octree – Tree mesh to refine.

  • level – Level of refinement.

  • axis – Axis of refinement.

Returns:

Cell size at the given level of refinement.

static minimum_level(mesh: discretize.TreeMesh, level: int) int

Computes the minimum level of refinement for a given tree mesh.

static octree_from_params(params: OctreeOptions) Octree

Create an Octree object from input parameters.

Parameters:

params – OctreeOptions containing the parameters for octree creation.

Returns:

Octree object.

static refine_by_object_type(mesh: discretize.TreeMesh, refinement_object: ObjectBase, levels: list[int], *, horizon: bool, distance: float | None, diagonal_balance: bool = True) discretize.TreeMesh

Refine Treemesh as a based on object type.

Parameters:
  • mesh – Tree mesh to refine.

  • refinement_object – Object to use for refinement.

  • levels – Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest.

  • horizon – Whether the refinement is a surface or radial.

  • distance – Distance from the object to refine.

  • diagonal_balance – Whether to apply diagonal balancing after refinement.

Returns:

Refined tree mesh object.

static refine_minimum_level(mesh: discretize.TreeMesh, minimum_level: int) discretize.TreeMesh

Refine a TreeMesh with the minimum level of refinement.

static refine_objects(mesh: discretize.TreeMesh, refinements: list[RefinementOptions | None], diagonal_balance: bool = True) discretize.TreeMesh

Refine by object or object + complement.

Parameters:
  • mesh – Tree mesh to refine.

  • refinements – List of refinements to apply.

  • diagonal_balance – Whether to apply diagonal balancing after refinement.

Returns:

Refined tree mesh.

static refine_tree_from_curve(mesh: discretize.TreeMesh, curve: Curve, levels: list[int] | ndarray, *, finalize: bool = False, diagonal_balance: bool = True) discretize.TreeMesh

Refine a tree mesh along the segments of a curve densified by the mesh cell size.

Parameters:
  • mesh – Tree mesh to refine.

  • curve – Curve object to use for refinement.

  • levels – Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest.

  • finalize – Finalize the tree mesh after refinement.

  • diagonal_balance – Whether to apply diagonal balancing after refinement.

Returns:

Refined tree mesh.

static refine_tree_from_points(mesh: discretize.TreeMesh, points: ObjectBase | ndarray, levels: list[int] | ndarray, *, finalize: bool = False, diagonal_balance: bool = True) discretize.TreeMesh

Refine a tree mesh along the vertices of an object.

Parameters:
  • mesh – Tree mesh to refine.

  • points – Object to use for refinement.

  • levels – Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest.

  • finalize – Finalize the tree mesh after refinement.

  • diagonal_balance – Whether to apply diagonal balancing after refinement.

Returns:

Refined tree mesh.

static refine_tree_from_surface(mesh: discretize.TreeMesh, surface: ObjectBase, levels: list[int] | ndarray, *, max_distance: float = inf, finalize: bool = False, diagonal_balance: bool = True) discretize.TreeMesh

Refine a tree mesh along the simplicies of a surface.

Parameters:
  • mesh – Tree mesh to refine.

  • surface – Surface object to use for refinement.

  • levels – Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest.

  • max_distance – Maximum distance from the surface to refine.

  • finalize – Finalize the tree mesh after refinement.

  • diagonal_balance – Whether to apply diagonal balancing after refinement.

Returns:

Refined tree mesh.

static refine_tree_from_triangulation(mesh: discretize.TreeMesh, surface, levels: list[int] | ndarray, finalize=False, diagonal_balance: bool = True) discretize.TreeMesh

Refine a tree mesh along the simplicies of a surface.

Parameters:
  • mesh – Tree mesh to refine.

  • surface – Surface object to use for refinement.

  • levels – Number of cells requested at each refinement level. Defined in reversed order from highest octree to lowest.

  • finalize – Finalize the tree mesh after refinement.

  • diagonal_balance – Whether to apply diagonal balancing after refinement.

Returns:

Refined tree mesh.

run() Octree

Create an octree mesh from input values.

static tree_offset(mesh: discretize.TreeMesh, vertices: ndarray) ndarray

Compute the offset required to center the mesh around the vertices.

Parameters:
  • mesh – Tree mesh to center.

  • vertices – Vertices to center around.

Returns:

Offset required to center

static treemesh_from_params(params: OctreeOptions) discretize.TreeMesh

Create a TreeMesh object from input parameters.

Parameters:

params – OctreeOptions containing the parameters for mesh creation.

Returns:

TreeMesh object.

grid_apps.octree_creation.options module

class grid_apps.octree_creation.options.OctreeOptions(*args: Any, **kwargs: Any)

Bases: Options

Octree creation parameters.

Parameters:
  • objects – Object used to define the core of the mesh.

  • depth_core – Limit the depth of the core of the mesh.

  • diagonal_balance – Whether to limit the cell size change to one level in the transition between diagonally adjacent cells.

  • minimum_level – Provides a minimum level of refinement for the whole mesh to prevent excessive coarsenin in padding regions.

  • u_cell_size – Cell size in the x-direction.

  • v_cell_size – Cell size in the y-direction.

  • w_cell_size – Cell size in the z-direction.

  • horizontal_padding – Padding in the x and y directions.

  • vertical_padding – Padding in the z direction.

  • refinements – List of refinements to be applied.

classmethod collect_input_from_dict(model: type[pydantic.BaseModel], data: dict[str, Any])

Recursively replace BaseModel objects with dictionary of ‘data’ values.

Parameters:
  • model – BaseModel object holding data and possibly other nested BaseModel objects.

  • data – Dictionary of parameters and values without nesting structure.

collect_refinements()

Collect refinements from the input dictionary.

conda_environment: str = 'grid_apps'
default_ui_json: ClassVar[Path] = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mirageoscience-grid-apps/conda/latest/lib/python3.12/site-packages/grid_apps-assets/uijson/octree_mesh.ui.json')
depth_core: float = 500.0
diagonal_balance: bool = True
distribute_refinements(handler, info)

Convert refinements to a individual parameters.

ga_group_name: str = 'Octree Mesh'
get_padding() list

Utility to get the padding values as a list of padding along each axis.

horizontal_padding: float = 500.0
minimum_level: int = 8
name: ClassVar[str] = 'Octree_Mesh'
objects: Points
out_group: UIJsonGroup | None = None
refinements: list[RefinementOptions | None] | None = None
run_command: str = 'grid_apps.octree_creation.driver'
title: str = 'Octree Mesh Creator'
u_cell_size: float = 25.0
v_cell_size: float = 25.0
vertical_padding: float = 200.0
w_cell_size: float = 25.0
class grid_apps.octree_creation.options.RefinementOptions(*args: Any, **kwargs: Any)

Bases: BaseModel

Refinement parameters.

Parameters:
  • object – Object used to define the core of the mesh.

  • levels – Levels of refinement.

  • horizon – Whether the refinement is a surface or radial.

  • distance – Distance from the object to refine.

horizon: bool = False
int_2_list()

Convert single integer to list.

levels: list[int] = [4, 2]
list_to_string(value)

Convert list of integers to comma-separated string.

refinement_object: Points
string_2_list()

Convert comma-separated string to list of integers.

grid_apps.octree_creation.options.collect_refinements_from_dict(data: dict) list[dict | None]

Collect active refinement dictionaries from input dictionary.

grid_apps.octree_creation.options.refinement_identifiers(data: dict) list[str]

Return identifiers for active refinements (object not none).

Module contents