I wrote a small test file/script to see how paraview (6.0 RC-1) interprets different descriptors. It seems that if you give conflicting descriptors for the same tree it only considers the last piece rather than some sort of union of the two. Maybe this is intentional but unfortunately my tree-AMR program does domain decomposition within a single tree and so I’m not sure I will be able to make use it of it if that is the case.
Since I can’t upload the file as a new user I’ll put the python code I generated it with here:
EDIT: The file is attached below. The two descriptor fields are “1 1100” and “1 0110” but if you load the file you may see that only a tree with the second piece’s descriptors is visible.
import h5py
import numpy as np
branch_factor = np.array(2, dtype='i8') # H5T_STD_I64LE scalar
dimensions = np.array([2, 2, 1], dtype='i8') # H5T_STD_I64LE shape=(3,)
transposed_root_indexing = np.array(0, dtype='i8') # H5T_STD_I64LE scalar
type_dtype = h5py.string_dtype(encoding='ascii', length=13)
type_value = np.array("HyperTreeGrid", dtype=type_dtype)
version = np.array([2, 4], dtype='i8') # H5T_STD_I64LE shape=(2,)
def pack_binary_string(bitstr: str) -> np.ndarray:
bits = "".join(bitstr.split())
nbits = len(bits)
nbytes = (nbits + 7) // 8
arr = np.zeros(nbytes, dtype='u1')
for i in range(nbytes):
chunk = bits[i*8 : i*8 + 8]
if len(chunk) < 8:
chunk = chunk.ljust(8, "0")
arr[i] = int(chunk, 2)
return arr
descriptors = pack_binary_string("1 1100 000 1 0110 000")
descriptors_size = np.array([8,8], dtype='i8')
number_of_cells = np.array([9,9], dtype='i8')
depth_per_tree = np.array([3,3], dtype='i8')
number_of_cells_per_tree_depth = np.array([1,4,4,1,4,4], dtype='i8')
number_of_depths = np.array([3,3], dtype='i8')
number_of_trees = np.array([1,1], dtype='i8')
tree_ids = np.array([0,0],dtype='i8')
x_coordinates = np.array([0,1], dtype='f8')
y_coordinates = np.array([0,1], dtype='f8')
z_coordinates = np.array([0], dtype='f8')
# -----------------------------------------------------------------------------
# 2) Create the HDF5 file and reproduce the exact group/dataset structure
# -----------------------------------------------------------------------------
import os
script_path = os.path.abspath(__file__)
script_dir = os.path.dirname(script_path)
htg_path = os.path.join(script_dir, "multipiece_htg.hdf")
with h5py.File(htg_path, "w") as f:
# 2.1 Create the top‐level VTKHDF group
vtkgrp = f.create_group("VTKHDF")
# 2.2 Write the five attributes onto "/VTKHDF"
vtkgrp.attrs.create("BranchFactor", branch_factor, dtype='i8')
vtkgrp.attrs.create("Dimensions", dimensions, dtype='i8')
vtkgrp.attrs.create("TransposedRootIndexing", transposed_root_indexing, dtype='i8')
vtkgrp.attrs.create("Type", type_value, dtype=type_dtype)
vtkgrp.attrs.create("Version", version, dtype='i8')
# 2.3 Create "/VTKHDF/CellData" and its "Depth" dataset
celldata_grp = vtkgrp.create_group("CellData")
# 2.4 Create all other datasets directly under "/VTKHDF"
vtkgrp.create_dataset(
"DepthPerTree",
data=depth_per_tree,
dtype='i8',
shape=depth_per_tree.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"Descriptors",
data=descriptors,
dtype='u1',
shape=descriptors.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"DescriptorsSize",
data=descriptors_size,
dtype='i8',
shape=descriptors_size.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"NumberOfCells",
data=number_of_cells,
dtype='i8',
shape=number_of_cells.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"NumberOfCellsPerTreeDepth",
data=number_of_cells_per_tree_depth,
dtype='i8',
shape=number_of_cells_per_tree_depth.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"NumberOfDepths",
data=number_of_depths,
dtype='i8',
shape=number_of_depths.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"NumberOfTrees",
data=number_of_trees,
dtype='i8',
shape=number_of_trees.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"TreeIds",
data=tree_ids,
dtype='i8',
shape=tree_ids.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"XCoordinates",
data=x_coordinates,
dtype='f8',
shape=x_coordinates.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"YCoordinates",
data=y_coordinates,
dtype='f8',
shape=y_coordinates.shape,
maxshape=(None,)
)
vtkgrp.create_dataset(
"ZCoordinates",
data=z_coordinates,
dtype='f8',
shape=z_coordinates.shape,
maxshape=(None,)
)
multipiece_htg.hdf (31.5 KB)