diff --git a/LoopStructural/interpolators/supports/_2d_structured_grid.py b/LoopStructural/interpolators/supports/_2d_structured_grid.py index 61e8d825..3731c306 100644 --- a/LoopStructural/interpolators/supports/_2d_structured_grid.py +++ b/LoopStructural/interpolators/supports/_2d_structured_grid.py @@ -372,6 +372,22 @@ def node_indexes_to_position(self, node_indexes: np.ndarray) -> np.ndarray: return xy def position_to_cell_corners(self, pos): + """Get the global indices of the vertices (corner) nodes of the cell containing each point. + + Parameters + ---------- + pos : np.array + (N, 2) array of xy coordinates representing the positions of N points. + + Returns + ------- + globalidx : np.array + (N, 4) array of global indices corresponding to the 4 corner nodes of the cell + each point lies in. If a point lies outside the support, its corresponding entry + will be set to -1. + inside : np.array + (N,) boolean array indicating whether each point is inside the support domain. + """ corner_index, inside = self.position_to_cell_index(pos) corners = self.cell_corner_indexes(corner_index) globalidx = self.global_node_indices(corners) diff --git a/LoopStructural/interpolators/supports/_3d_base_structured.py b/LoopStructural/interpolators/supports/_3d_base_structured.py index 4c91322c..621da7be 100644 --- a/LoopStructural/interpolators/supports/_3d_base_structured.py +++ b/LoopStructural/interpolators/supports/_3d_base_structured.py @@ -373,6 +373,22 @@ def cell_corner_indexes(self, cell_indexes: np.ndarray) -> np.ndarray: return corner_indexes def position_to_cell_corners(self, pos): + """Get the global indices of the vertices (corners) of the cell containing each point. + + Parameters + ---------- + pos : np.array + (N, 3) array of xyz coordinates representing the positions of N points. + + Returns + ------- + globalidx : np.array + (N, 8) array of global indices corresponding to the 8 corner nodes of the cell + each point lies in. If a point lies outside the support, its corresponding entry + will be set to -1. + inside : np.array + (N,) boolean array indicating whether each point is inside the support domain. + """ cell_indexes, inside = self.position_to_cell_index(pos) corner_indexes = self.cell_corner_indexes(cell_indexes) globalidx = self.global_node_indices(corner_indexes)