Skip to content

Commit 23219b8

Browse files
committed
restrict topography cells to the mesh extents when calculating the active cells
1 parent 03406c0 commit 23219b8

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

simpeg_drivers/components/topography.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,22 @@ def active_cells(self, mesh: InversionMesh, data: InversionData) -> np.ndarray:
101101
self.params.active_cells.active_model, mesh.entity
102102
)
103103
else:
104-
topo_surface = self.params.active_cells.topography_object.copy()
105-
topo_surface.mask_by_extent(mesh.entity.extent)
104+
centers = self.params.active_cells.topography_object.centroids
105+
xmin, xmax, ymin, ymax, zmin, zmax = mesh.entity.extent.ravel(order="F")
106+
mask = (
107+
(centers[:, 0] > xmin)
108+
& (centers[:, 0] < xmax)
109+
& (centers[:, 1] > ymin)
110+
& (centers[:, 1] < ymax)
111+
& (centers[:, 2] > zmin)
112+
& (centers[:, 2] < zmax)
113+
)
114+
cells = self.params.active_cells.topography_object.cells[mask, :]
106115
active_cells = active_from_xyz(
107116
mesh.entity,
108117
self.locations,
109118
grid_reference="bottom" if forced_to_surface else "center",
110-
triangulation=getattr(topo_surface, "cells", None),
119+
triangulation=cells,
111120
)
112121

113122
active_cells = (mesh.permutation @ active_cells).astype(bool)

0 commit comments

Comments
 (0)