你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Limit thickness of circular sectors to within a grid
这个提交包含在:
@@ -211,6 +211,53 @@ class MainGridUserInput(UserInput[GridType]):
|
||||
p3_checked,
|
||||
)
|
||||
|
||||
def check_thickness(
|
||||
self, dimension: str, start: float, thickness: float
|
||||
) -> Tuple[bool, float, float]:
|
||||
"""Check the thickness of an object in a specified dimension.
|
||||
|
||||
Args:
|
||||
dimension: Dimension to check the thickness value for.
|
||||
This must have value x, y, or z.
|
||||
start: Start coordinate of the object in the specified
|
||||
dimension. This must be in the local grid coordinate
|
||||
system - i.e. previously translated using the
|
||||
round_to_grid function.
|
||||
thickness: Thickness of the object.
|
||||
|
||||
Raises:
|
||||
ValueError: Raised if dimension has an invalid value.
|
||||
|
||||
Returns:
|
||||
within_grid: True if part of the object is within the
|
||||
current grid. False otherwise.
|
||||
start: Start value limited to the bounds of the grid.
|
||||
thickness: Thickness value such that start + thickness is
|
||||
within the bounds of the grid.
|
||||
"""
|
||||
if dimension == "x":
|
||||
grid_size = self.grid.nx * self.grid.dx
|
||||
elif dimension == "y":
|
||||
grid_size = self.grid.ny * self.grid.dy
|
||||
elif dimension == "z":
|
||||
grid_size = self.grid.nz * self.grid.dz
|
||||
else:
|
||||
raise ValueError("Dimension should have value x, y, or z")
|
||||
|
||||
end = start + thickness
|
||||
|
||||
if start > grid_size:
|
||||
return False, start, thickness
|
||||
elif end < 0:
|
||||
return False, start, thickness
|
||||
|
||||
if start < 0:
|
||||
start = 0
|
||||
if end > grid_size:
|
||||
thickness = grid_size - start
|
||||
|
||||
return True, start, thickness
|
||||
|
||||
|
||||
class MPIUserInput(MainGridUserInput[MPIGrid]):
|
||||
"""Handles (x, y, z) points supplied by the user for MPI grids.
|
||||
|
@@ -74,6 +74,29 @@ class CylindricalSector(GeometryUserObject):
|
||||
logger.exception(self.__str__())
|
||||
raise
|
||||
|
||||
# Check thickness of the object first as may be able to exit
|
||||
# early if fully outside the grid.
|
||||
uip = self._create_uip(grid)
|
||||
|
||||
# yz-plane cylindrical sector
|
||||
if normal == "x":
|
||||
level, ctr1, ctr2 = uip.round_to_grid((extent1, ctr1, ctr2))
|
||||
|
||||
# xz-plane cylindrical sector
|
||||
elif normal == "y":
|
||||
ctr1, level, ctr2 = uip.round_to_grid((ctr1, extent1, ctr2))
|
||||
|
||||
# xy-plane cylindrical sector
|
||||
elif normal == "z":
|
||||
ctr1, ctr2, level = uip.round_to_grid((ctr1, ctr2, extent1))
|
||||
|
||||
sector_within_grid, level, thickness = uip.check_thickness(normal, level, thickness)
|
||||
|
||||
# Exit early if none of the cylindrical sector is in this grid
|
||||
# as there is nothing else to do.
|
||||
if not sector_within_grid:
|
||||
return
|
||||
|
||||
# Check averaging
|
||||
try:
|
||||
# Try user-specified averaging
|
||||
@@ -162,19 +185,6 @@ class CylindricalSector(GeometryUserObject):
|
||||
numIDy = materials[1].numID
|
||||
numIDz = materials[2].numID
|
||||
|
||||
uip = self._create_uip(grid)
|
||||
# yz-plane cylindrical sector
|
||||
if normal == "x":
|
||||
level, ctr1, ctr2 = uip.round_to_grid((extent1, ctr1, ctr2))
|
||||
|
||||
# xz-plane cylindrical sector
|
||||
elif normal == "y":
|
||||
ctr1, level, ctr2 = uip.round_to_grid((ctr1, extent1, ctr2))
|
||||
|
||||
# xy-plane cylindrical sector
|
||||
elif normal == "z":
|
||||
ctr1, ctr2, level = uip.round_to_grid((ctr1, ctr2, extent1))
|
||||
|
||||
build_cylindrical_sector(
|
||||
ctr1,
|
||||
ctr2,
|
||||
|
在新工单中引用
屏蔽一个用户