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

Functions

 round_sig (x, sig)
 Round a number to a specified number of significant figures.
 
 read_patches (file_path, size_group, dimensions)
 Parse a single Peano grid patch file and extract spatial information.
 
 GridPatchFileReader (name=None, file_path=None, dimensions=None)
 Main function to read Peano grid patch files and convert to Tree structure.
 

Function Documentation

◆ GridPatchFileReader()

GridPatchFileReader.GridPatchFileReader (   name = None,
  file_path = None,
  dimensions = None 
)

Main function to read Peano grid patch files and convert to Tree structure.

This function processes a directory of Peano grid patch files and constructs a Tree object suitable for load balancing analysis. It handles multiple subtrees, determines domain boundaries, and creates the hierarchical array structure.

Processing Steps

  1. File Discovery: Scans directory for files with 'grid-' prefix
  2. Patch Extraction: Parses each file to extract spatial information
  3. Level Determination: Groups patches by size to identify refinement levels
  4. Domain Analysis: Determines overall domain boundaries from largest patches
  5. Tree Construction: Builds hierarchical array structure
  6. Subtree Assignment: Assigns patches to subtrees based on source files

Multi-subtree Handling

Each 'grid-' file represents a different subtree in the domain decomposition. The function automatically:

  • Processes all subtree files in the directory
  • Assigns appropriate subtree IDs based on file order
  • Merges spatial information into unified tree structure
  • Reports distribution statistics for analysis

Args: name (str, optional): Descriptive name for the resulting tree. If not provided, a deterministic default name is generated. file_path (str): Path to directory containing grid patch files dimensions (int): Spatial dimensions count (2 for 2D, 3 for 3D)

Returns: Tree: Tree object with complete spatial structure and subtree assignments

Example: ```python

Read 3D grid data from checkpoint

tree = GridPatchFileReader( name="CCZ4_Simulation_T100", file_path="/path/to/checkpoint/grid/files", dimensions=3 )

print(f"Loaded tree with {tree._leaf_count} leaves") print(f"Domain: {tree._domain_offset} to {tree._domain_size}") print(f"Subtrees: {tree._subtree_count}") ```

Definition at line 141 of file GridPatchFileReader.py.

References read_patches(), and round_sig().

Here is the call graph for this function:

◆ read_patches()

GridPatchFileReader.read_patches (   file_path,
  size_group,
  dimensions 
)

Parse a single Peano grid patch file and extract spatial information.

This function reads a grid patch file and extracts offset and size information for each patch using regular expressions. Patches are grouped by size to determine refinement levels.

Args: file_path (str): Path to the grid patch file size_group (defaultdict): Dictionary to store {size: [offsets]} mapping dimensions (int): Spatial dimensions count (2 or 3)

Returns: defaultdict: Updated size_group with patch information

Note: The regular expression patterns match the standard Peano patch format:

  • 'begin patch' blocks with offset and size specifications
  • Floating point numbers in scientific notation
  • Space-separated coordinate values

Definition at line 93 of file GridPatchFileReader.py.

Referenced by GridPatchFileReader().

Here is the caller graph for this function:

◆ round_sig()

GridPatchFileReader.round_sig (   x,
  sig 
)

Round a number to a specified number of significant figures.

Args: x (float): Number to round sig (int): Number of significant figures

Returns: float: Rounded number

Definition at line 80 of file GridPatchFileReader.py.

Referenced by GridPatchFileReader().

Here is the caller graph for this function: