Skip to content

Commit

Permalink
fix: 🚑 number of steps was actually number of cells causing issues wi…
Browse files Browse the repository at this point in the history
…th indexing
  • Loading branch information
Lachlan Grose committed Mar 21, 2022
1 parent 9407ff7 commit 88b8fee
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions LoopStructural/interpolators/supports/_3d_base_structured.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
# inisialise the private attributes
if np.any(step_vector == 0):
logger.warning(f"Step vector {step_vector} has zero values")
self._nsteps = np.array(nsteps, dtype=int)
self._nsteps = np.array(nsteps+1, dtype=int)
self._step_vector = np.array(step_vector)
self._origin = np.array(origin)
self.supporttype = "Base"
Expand All @@ -50,6 +50,10 @@ def nsteps(self, nsteps):
self._step_vector /= change_factor
self._nsteps = nsteps

@property
def nsteps_cells(self):
return self.nsteps - 1

@property
def rotation_xy(self):
return self._rotation_xy
Expand Down Expand Up @@ -89,7 +93,7 @@ def origin(self, origin):

@property
def maximum(self):
return self.origin + self.nsteps * self.step_vector
return self.origin + self.nsteps_cells * self.step_vector

@maximum.setter
def maximum(self, maximum):
Expand All @@ -99,16 +103,12 @@ def maximum(self, maximum):
maximum = np.array(maximum, dtype=float)
length = maximum - self.origin
length /= self.step_vector
self._nsteps = np.ceil(length).astype(int)
self._nsteps = np.ceil(length).astype(int)+1

@property
def n_nodes(self):
return np.product(self.nsteps)

@property
def nsteps_cells(self):
return self.nsteps - 1

@property
def n_elements(self):
return np.product(self.nsteps_cells)
Expand Down Expand Up @@ -194,8 +194,7 @@ def inside(self, pos):
inside *= pos[:, i] > self.origin[None, i]
inside *= (
pos[:, i]
< self.origin[None, i]
+ self.step_vector[None, i] * self.nsteps_cells[None, i]
< self.maximum[None,i]
)
return inside

Expand Down

0 comments on commit 88b8fee

Please sign in to comment.