Skip to content

Commit 72e0c32

Browse files
fix: step_vector use self.dimensions to set length
1 parent e62e6ea commit 72e0c32

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

LoopStructural/datatypes/_bounding_box.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
class BoundingBox:
99
def __init__(
10-
self,
11-
origin: Optional[np.ndarray] = None,
12-
maximum: Optional[np.ndarray] = None,
13-
nsteps: Optional[np.ndarray] = None,
14-
step_vector: Optional[np.ndarray] = None,
15-
dimensions: int = 3,
10+
self,
11+
origin: Optional[np.ndarray] = None,
12+
maximum: Optional[np.ndarray] = None,
13+
nsteps: Optional[np.ndarray] = None,
14+
step_vector: Optional[np.ndarray] = None,
15+
dimensions: int = 3,
1616
):
1717
"""A bounding box for a model, defined by the
1818
origin, maximum and number of steps in each direction
@@ -93,10 +93,7 @@ def nelements(self, nelements):
9393
box_vol = self.volume
9494
ele_vol = box_vol / nelements
9595
# calculate the step vector of a regular cube
96-
if self.dimensions == 2:
97-
step_vector = np.zeros(2)
98-
else:
99-
step_vector = np.zeros(3)
96+
step_vector = np.zeros(self.dimensions)
10097
step_vector[:] = ele_vol ** (1.0 / 3.0)
10198
# number of steps is the length of the box / step vector
10299
nsteps = np.ceil((self.maximum - self.origin) / step_vector).astype(int)

0 commit comments

Comments
 (0)