Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions LoopStructural/interpolators/supports/_2d_structured_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions LoopStructural/interpolators/supports/_3d_base_structured.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down