-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
This minimal example demonstrates the issue. The cell state appears not preserved if the cell size is negative.
from discretize import TreeMesh
import numpy as np
point = [0, 0, 0]
# All positive cell sizes
mesh = TreeMesh([[10] * 16, [10] * 4, [10] * 8], [0, 0, 0])
mesh.insert_cells(point, [3], finalize=True)
# New mesh using state of first
mesh2 = TreeMesh([[10] * 16, [10] * 4, [10] * 8], [0, 0, 0])
mesh2.__setstate__((mesh.cell_state['indexes'], mesh.cell_state['levels']))
assert np.all(mesh.cell_centers == mesh2.cell_centers) # Both meshes are equal
# Repeat with negative z cell size
mesh = TreeMesh([[10] * 16, [10] * 4, [-10] * 8], [0, 0, 0])
mesh.insert_cells(point, [3], finalize=True)
# New mesh using state of first
mesh2 = TreeMesh([[10] * 16, [10] * 4, [-10] * 8], [0, 0, 0])
mesh2.__setstate__((mesh.cell_state['indexes'], mesh.cell_state['levels']))
assert np.all(mesh.cell_centers == mesh2.cell_centers) # Not equal
Metadata
Metadata
Assignees
Labels
No labels