Peano
Loading...
Searching...
No Matches
RegularGridGenerator Namespace Reference

Functions

 RegularGridGenerator (name=None, max_level=None, dimensions=None)
 Generate an artificial regular grid with uniform refinement for testing purposes.
 

Function Documentation

◆ RegularGridGenerator()

RegularGridGenerator.RegularGridGenerator (   name = None,
  max_level = None,
  dimensions = None 
)

Generate an artificial regular grid with uniform refinement for testing purposes.

This function creates a complete regular grid structure where all regions are refined uniformly to the specified maximum level. All cells are initially assigned to subtree 0, providing a clean starting point for load balancing experiments and algorithm testing.

Grid Structure

The generated grid follows Peano's hierarchical structure:

  • Level 0: 3^1 cells per dimension (3x3 for 2D, 3x3x3 for 3D)
  • Level k: 3^(k+1) cells per dimension
  • All cells have weight=1 (exist) and subtree_id=0 (single resource)

Use Cases

  • Algorithm Development: Test splitting strategies on predictable structures
  • Performance Benchmarking: Measure algorithm performance with known complexity
  • Regression Testing: Ensure consistent behavior across code changes
  • Educational Examples: Demonstrate API functionality with simple cases

Args: name (str, optional): Descriptive name for the generated tree (e.g., "TestGrid_L4"). If not provided, a deterministic default name is generated from dimensions and level. max_level (int): Maximum refinement level (must be > 0) dimensions (int): Spatial dimensions (2 for 2D, 3 for 3D)

Returns: Tree: Tree object with complete regular grid structure

Example: ```python

Create a 2D regular grid for testing

test_tree = RegularGridGenerator( name="Uniform_Test_2D", max_level=4, dimensions=2 )

print(f"Generated tree: {test_tree._name}") print(f"Total cells: {test_tree._leaf_count}") print(f"Levels: {test_tree._max_level}")

Apply splitting for load balancing test

from strategies.SplitTrees import split_tree split_tree(test_tree, number_of_subtrees=3) ```

Note:

  • Domain offset and size are set to placeholder values (origin and unit size)
  • For large max_level values, memory usage grows as 3^(dimensions * max_level)
  • Generated trees are deterministic - same parameters always produce identical results

Definition at line 98 of file RegularGridGenerator.py.

Referenced by 35_offline-load-balancing.offline_decomposition(), 35_offline-load-balancing-split-modes.offline_decomposition(), 35_offline-load-balancing-plan-vs-run.offline_plan(), and 35_offline-load-balancing-quantised.owner_of_cells().

Here is the caller graph for this function: