Add properties to access start, stop, and size

这个提交包含在:
Nathan Mannall
2025-04-14 18:00:39 +01:00
父节点 540207871e
当前提交 1deb32cdb3

查看文件

@@ -167,15 +167,8 @@ class FractalVolume:
self.ID = None self.ID = None
self.operatingonID = None self.operatingonID = None
self.xs = xs self.start = np.array([xs, ys, zs], dtype=np.int32)
self.xf = xf self.stop = np.array([xf, yf, zf], dtype=np.int32)
self.ys = ys
self.yf = yf
self.zs = zs
self.zf = zf
self.nx = xf - xs
self.ny = yf - ys
self.nz = zf - zs
self.originalxs = xs self.originalxs = xs
self.originalxf = xf self.originalxf = xf
self.originalys = ys self.originalys = ys
@@ -192,6 +185,70 @@ class FractalVolume:
self.nbins = 0 self.nbins = 0
self.fractalsurfaces = [] self.fractalsurfaces = []
@property
def xs(self) -> int:
return self.start[0]
@xs.setter
def xs(self, value: int):
self.start[0] = value
@property
def ys(self) -> int:
return self.start[1]
@ys.setter
def ys(self, value: int):
self.start[1] = value
@property
def zs(self) -> int:
return self.start[2]
@zs.setter
def zs(self, value: int):
self.start[2] = value
@property
def xf(self) -> int:
return self.stop[0]
@xf.setter
def xf(self, value: int):
self.stop[0] = value
@property
def yf(self) -> int:
return self.stop[1]
@yf.setter
def yf(self, value: int):
self.stop[1] = value
@property
def zf(self) -> int:
return self.stop[2]
@zf.setter
def zf(self, value: int):
self.stop[2] = value
@property
def size(self) -> npt.NDArray[np.int32]:
return self.stop - self.start
@property
def nx(self) -> int:
return self.xf - self.xs
@property
def ny(self) -> int:
return self.yf - self.ys
@property
def nz(self) -> int:
return self.zf - self.zs
def generate_fractal_volume(self) -> bool: def generate_fractal_volume(self) -> bool:
"""Generate a 3D volume with a fractal distribution.""" """Generate a 3D volume with a fractal distribution."""
@@ -308,10 +365,6 @@ class MPIFractalVolume(FractalVolume):
def generate_fractal_volume(self) -> bool: def generate_fractal_volume(self) -> bool:
"""Generate a 3D volume with a fractal distribution.""" """Generate a 3D volume with a fractal distribution."""
self.start = np.array([self.xs, self.ys, self.zs], dtype=np.int32)
self.stop = np.array([self.xf, self.yf, self.zf], dtype=np.int32)
self.size = self.stop - self.start
# Exit early if this rank does not contain the Fractal Volume # Exit early if this rank does not contain the Fractal Volume
# The size of a fractal volume can increase if a Fractal Surface # The size of a fractal volume can increase if a Fractal Surface
# is attached. Hence the check needs to happen here once that # is attached. Hence the check needs to happen here once that
@@ -511,13 +564,13 @@ class MPIFractalVolume(FractalVolume):
if len(requests) > 0: if len(requests) > 0:
requests[0].Waitall(requests) requests[0].Waitall(requests)
self.nx = self.fractalvolume.shape[0] # Update start and stop to local bounds
self.ny = self.fractalvolume.shape[1] self.start = np.maximum(self.start, 0)
self.nz = self.fractalvolume.shape[2] self.stop = np.minimum(self.stop, self.upper_bound)
self.xs = max(0, self.xs) logger.debug(
self.ys = max(0, self.ys) f"Generated fractal volume: start={self.start}, stop={self.stop}, size={self.size}"
self.zs = max(0, self.zs) )
return True return True