@@ -234,7 +234,12 @@ def evaluate_gradient(self, evaluation_points, property_array):
234234 return values
235235
236236 def get_element_for_location (
237- self , points : np .ndarray
237+ self ,
238+ points : np .ndarray ,
239+ return_verts = True ,
240+ return_bc = True ,
241+ return_inside = True ,
242+ return_tri = True ,
238243 ) -> Tuple [np .ndarray , np .ndarray , np .ndarray , np .ndarray ]:
239244 """
240245 Determine the elements from a numpy array of points
@@ -249,14 +254,18 @@ def get_element_for_location(
249254 -------
250255
251256 """
252- verts = np .zeros ((points .shape [0 ], self .dimension + 1 , self .dimension ))
257+ if return_verts :
258+ verts = np .zeros ((points .shape [0 ], self .dimension + 1 , self .dimension ))
259+ else :
260+ verts = np .zeros ((0 , 0 , 0 ))
253261 bc = np .zeros ((points .shape [0 ], self .dimension + 1 ))
254262 tetras = np .zeros (points .shape [0 ], dtype = "int64" )
255263 inside = np .zeros (points .shape [0 ], dtype = bool )
256264 npts = 0
257265 npts_step = int (1e4 )
258266 # break into blocks of 10k points
259267 while npts < points .shape [0 ]:
268+ print (npts , npts_step , points .shape [0 ])
260269 cell_index , inside = self .aabb_grid .position_to_cell_index (
261270 points [: npts + npts_step , :]
262271 )
@@ -266,6 +275,7 @@ def get_element_for_location(
266275 row = tetra_indices .row
267276 col = tetra_indices .col
268277 # using returned indexes calculate barycentric coords to determine which tetra the points are in
278+
269279 vertices = self .nodes [self .elements [col , : self .dimension + 1 ]]
270280 pos = points [row , : self .dimension ]
271281 row = tetra_indices .row
@@ -286,8 +296,8 @@ def get_element_for_location(
286296 c [:, 2 ] = 1.0 - c [:, 0 ] - c [:, 1 ]
287297
288298 mask = np .all (c >= 0 , axis = 1 )
289-
290- verts [: npts + npts_step , :, :][row [mask ], :, :] = vertices [mask , :, :]
299+ if return_verts :
300+ verts [: npts + npts_step , :, :][row [mask ], :, :] = vertices [mask , :, :]
291301 bc [: npts + npts_step , :][row [mask ], :] = c [mask , :]
292302 tetras [: npts + npts_step ][row [mask ]] = col [mask ]
293303 inside [: npts + npts_step ][row [mask ]] = True
@@ -312,5 +322,5 @@ def get_element_gradient_for_location(
312322 -------
313323
314324 """
315- verts , c , tri , inside = self .get_element_for_location (pos )
325+ verts , c , tri , inside = self .get_element_for_location (pos , return_verts = False )
316326 return self .evaluate_shape_derivatives (pos , tri )
0 commit comments