Skip to content

Commit

Permalink
fix: adding debugging code for indexing structured grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Mar 21, 2022
1 parent 88b8fee commit 59e130a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion LoopStructural/interpolators/supports/_3d_structured_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,14 @@ def evaluate_value(self, evaluation_points, property_array):
)
)
idc, inside = self.position_to_cell_corners(evaluation_points)
# print(idc[inside,:], self.n_nodes,inside)

if idc.shape[0] != inside.shape[0]:
raise ValueError('index does not match number of nodes')
v = np.zeros(idc.shape)
v[:, :] = np.nan

v[inside, :] = self.position_to_dof_coefs(evaluation_points[inside, :]).T

v[inside, :] *= property_array[idc[inside, :]]

return np.sum(v, axis=1)
Expand Down Expand Up @@ -361,6 +364,19 @@ def evaluate_gradient(self, evaluation_points, property_array):
# indices = np.array([self.position_to_cell_index(evaluation_points)])
# idc = self.global_indicies(indices.swapaxes(0,1))
# print(idc)
if np.max(idc[inside,:]) > property_array.shape[0]:
cix, ciy, ciz = self.position_to_cell_index(evaluation_points)
if np.all(cix[inside] < self.nsteps_cells[0]) == False:
print(evaluation_points[inside,:][cix[inside] < self.nsteps_cells[0],0],self.origin[0],self.maximum[0])
if np.all(ciy[inside] < self.nsteps_cells[1]) == False:
print(evaluation_points[inside,:][ciy[inside] < self.nsteps_cells[1],1],self.origin[1],self.maximum[1])
if np.all(ciz[inside] < self.nsteps_cells[2]) == False:
print(ciz[inside],self.nsteps_cells[2])
print(self.step_vector, self.nsteps_cells,self.nsteps)
print(evaluation_points[inside,:][~(ciz[inside] < self.nsteps_cells[2]),2],self.origin[2],self.maximum[2])


raise ValueError('index does not match number of nodes')
T[inside, 0, :] *= property_array[idc[inside, :]]
T[inside, 1, :] *= property_array[idc[inside, :]]
T[inside, 2, :] *= property_array[idc[inside, :]]
Expand Down

0 comments on commit 59e130a

Please sign in to comment.