Update triangles for parallel build

这个提交包含在:
Nathan Mannall
2025-02-14 16:08:01 +00:00
父节点 b0ecf50688
当前提交 fea6243173
共有 9 个文件被更改,包括 124 次插入19 次删除

查看文件

@@ -445,6 +445,12 @@ cpdef void build_triangle(
j2 = round_value(np.amax([z1, z2, z3]) / dz) + 1 j2 = round_value(np.amax([z1, z2, z3]) / dz) + 1
levelcells = round_value(x1 / dx) levelcells = round_value(x1 / dx)
thicknesscells = round_value(thickness / dx) thicknesscells = round_value(thickness / dx)
# Bound to the size of the grid
if i2 > solid.shape[1]:
i2 = solid.shape[1]
if j2 > solid.shape[2]:
j2 = solid.shape[2]
elif normal == 'y': elif normal == 'y':
area = 0.5 * (-z2 * x3 + z1 * (-x2 + x3) + x1 * (z2 - z3) + x2 * z3) area = 0.5 * (-z2 * x3 + z1 * (-x2 + x3) + x1 * (z2 - z3) + x2 * z3)
i1 = round_value(np.amin([x1, x2, x3]) / dx) - 1 i1 = round_value(np.amin([x1, x2, x3]) / dx) - 1
@@ -453,6 +459,12 @@ cpdef void build_triangle(
j2 = round_value(np.amax([z1, z2, z3]) / dz) + 1 j2 = round_value(np.amax([z1, z2, z3]) / dz) + 1
levelcells = round_value(y1 /dy) levelcells = round_value(y1 /dy)
thicknesscells = round_value(thickness / dy) thicknesscells = round_value(thickness / dy)
# Bound to the size of the grid
if i2 > solid.shape[0]:
i2 = solid.shape[0]
if j2 > solid.shape[2]:
j2 = solid.shape[2]
elif normal == 'z': elif normal == 'z':
area = 0.5 * (-y2 * x3 + y1 * (-x2 + x3) + x1 * (y2 - y3) + x2 * y3) area = 0.5 * (-y2 * x3 + y1 * (-x2 + x3) + x1 * (y2 - y3) + x2 * y3)
i1 = round_value(np.amin([x1, x2, x3]) / dx) - 1 i1 = round_value(np.amin([x1, x2, x3]) / dx) - 1
@@ -462,6 +474,18 @@ cpdef void build_triangle(
levelcells = round_value(z1 / dz) levelcells = round_value(z1 / dz)
thicknesscells = round_value(thickness / dz) thicknesscells = round_value(thickness / dz)
# Bound to the size of the grid
if i2 > solid.shape[0]:
i2 = solid.shape[0]
if j2 > solid.shape[1]:
j2 = solid.shape[1]
# Bound to the start of the grid
if i1 < 0:
i1 = 0
if j1 < 0:
j1 = 0
sign = np.sign(area) sign = np.sign(area)
for i in range(i1, i2): for i in range(i1, i2):

查看文件

@@ -96,36 +96,60 @@ class Triangle(RotatableMixin, GeometryUserObject):
logger.exception(f"{self.__str__()} no materials have been specified") logger.exception(f"{self.__str__()} no materials have been specified")
raise raise
if thickness < 0:
logger.exception(f"{self.__str__()} requires a positive value for thickness")
raise ValueError
uip = self._create_uip(grid) uip = self._create_uip(grid)
p4 = uip.round_to_grid_static_point(up1)
p5 = uip.round_to_grid_static_point(up2)
p6 = uip.round_to_grid_static_point(up3)
# Check whether points are valid against grid # Check whether points are valid against grid
uip.check_tri_points(up1, up2, up3, object) uip.check_tri_points(up1, up2, up3, self.__str__())
# Convert points to metres # Convert points to metres
x1, y1, z1 = uip.round_to_grid(up1) x1, y1, z1 = uip.round_to_grid(up1)
x2, y2, z2 = uip.round_to_grid(up2) x2, y2, z2 = uip.round_to_grid(up2)
x3, y3, z3 = uip.round_to_grid(up3) x3, y3, z3 = uip.round_to_grid(up3)
if thickness < 0:
logger.exception(f"{self.__str__()} requires a positive value for thickness")
raise ValueError
# Check for valid orientations # Check for valid orientations
# yz-plane triangle # yz-plane triangle
if x1 == x2 == x3: if x1 == x2 == x3:
normal = "x" normal = "x"
start = x1
# xz-plane triangle # xz-plane triangle
elif y1 == y2 == y3: elif y1 == y2 == y3:
normal = "y" normal = "y"
start = y1
# xy-plane triangle # xy-plane triangle
elif z1 == z2 == z3: elif z1 == z2 == z3:
normal = "z" normal = "z"
start = z1
else: else:
logger.exception(f"{self.__str__()} the triangle is not specified correctly") logger.exception(f"{self.__str__()} the triangle is not specified correctly")
raise ValueError raise ValueError
triangle_within_grid, start, thickness = uip.check_thickness(normal, start, thickness)
# Exit early if none of the triangle is in this grid as there is
# nothing else to do.
if not triangle_within_grid:
return
# Update start bound of the triangle
# yz-plane triangle
if normal == "x":
x1 = start
x2 = start
x3 = start
# xz-plane triangle
elif normal == "y":
y1 = start
y2 = start
y3 = start
# xy-plane triangle
elif normal == "z":
z1 = start
z2 = start
z3 = start
# Look up requested materials in existing list of material instances # Look up requested materials in existing list of material instances
materials = [y for x in materialsrequested for y in grid.materials if y.ID == x] materials = [y for x in materialsrequested for y in grid.materials if y.ID == x]
@@ -202,6 +226,10 @@ class Triangle(RotatableMixin, GeometryUserObject):
grid.ID, grid.ID,
) )
p4 = uip.round_to_grid_static_point(up1)
p5 = uip.round_to_grid_static_point(up2)
p6 = uip.round_to_grid_static_point(up3)
if thickness > 0: if thickness > 0:
dielectricsmoothing = "on" if averaging else "off" dielectricsmoothing = "on" if averaging else "off"
logger.info( logger.info(

查看文件

@@ -0,0 +1,13 @@
#title: Hertzian dipole over a half-space
#domain: 0.100 0.100 0.100
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 3e-9
#waveform: gaussiandot 1 1e9 myWave
#hertzian_dipole: z 0.020 0.020 0.020 myWave
#rx: 0.080 0.080 0.080
#material: 8 0 1 0 half_space
#triangle: 0 0 0 0 0.1 0.05 0 0 0.1 0.1 half_space
#geometry_objects_write: 0 0 0 0.1 0.1 0.1 full_volume

查看文件

@@ -0,0 +1,13 @@
#title: Hertzian dipole over a half-space
#domain: 0.100 0.100 0.100
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 3e-9
#waveform: gaussiandot 1 1e9 myWave
#hertzian_dipole: z 0.020 0.020 0.020 myWave
#rx: 0.080 0.080 0.080
#material: 8 0 1 0 half_space
#triangle: 0.06 0.06 0.06 0.08 0.06 0.075 0.072 0.06 0.06 0.03 half_space
#geometry_objects_write: 0 0 0 0.1 0.1 0.1 full_volume

查看文件

@@ -0,0 +1,13 @@
#title: Hertzian dipole over a half-space
#domain: 0.100 0.100 0.100
#dx_dy_dz: 0.001 0.001 0.001
#time_window: 3e-9
#waveform: gaussiandot 1 1e9 myWave
#hertzian_dipole: z 0.020 0.020 0.020 myWave
#rx: 0.080 0.080 0.080
#material: 8 0 1 0 half_space
#triangle: 0.05 0 0.01 0.1 0.07 0.01 0 0.05 0.01 0.08 half_space n
#geometry_objects_write: 0 0 0 0.1 0.1 0.1 full_volume

查看文件

@@ -72,6 +72,13 @@ class TestCylindricalSectorGeometry(GprMaxRegressionTest):
) )
@rfm.simple_test
class TestEdgeGeometry(AntennaModelMixin, GprMaxRegressionTest):
tags = {"test", "serial", "geometry", "edge", "transmission_line", "waveform", "antenna"}
sourcesdir = "src/geometry_tests/edge_geometry"
model = parameter(["antenna_wire_dipole_fs"])
@rfm.simple_test @rfm.simple_test
class TestEllipsoidGeometry(GprMaxRegressionTest): class TestEllipsoidGeometry(GprMaxRegressionTest):
tags = {"test", "serial", "geometery", "ellipsoid"} tags = {"test", "serial", "geometery", "ellipsoid"}
@@ -97,10 +104,10 @@ class TestSphereGeometry(GprMaxRegressionTest):
@rfm.simple_test @rfm.simple_test
class TestEdgeGeometry(AntennaModelMixin, GprMaxRegressionTest): class TestTriangleGeometry(GprMaxRegressionTest):
tags = {"test", "serial", "geometry", "edge", "transmission_line", "waveform", "antenna"} tags = {"test", "serial", "geometery", "triangle"}
sourcesdir = "src/geometry_tests/edge_geometry" sourcesdir = "src/geometry_tests/triangle_geometry"
model = parameter(["antenna_wire_dipole_fs"]) model = parameter(["triangle_x_full", "triangle_y_small", "triangle_z_rigid"])
"""Test MPI Functionality """Test MPI Functionality
@@ -128,6 +135,13 @@ class TestConeGeometryMpi(MpiMixin, TestConeGeometry):
test_dependency = TestConeGeometry test_dependency = TestConeGeometry
@rfm.simple_test
class TestCylinderGeometryMpi(MpiMixin, TestCylinderGeometry):
tags = {"test", "mpi", "geometery", "cylindrical", "sector", "cylindrical_sector"}
mpi_layout = parameter([[2, 2, 2], [3, 3, 3], [4, 4, 4]])
test_dependency = TestCylinderGeometry
@rfm.simple_test @rfm.simple_test
class TestCylindricalSectorGeometryMpi(MpiMixin, TestCylindricalSectorGeometry): class TestCylindricalSectorGeometryMpi(MpiMixin, TestCylindricalSectorGeometry):
tags = {"test", "mpi", "geometery", "cylinder"} tags = {"test", "mpi", "geometery", "cylinder"}
@@ -136,10 +150,10 @@ class TestCylindricalSectorGeometryMpi(MpiMixin, TestCylindricalSectorGeometry):
@rfm.simple_test @rfm.simple_test
class TestCylinderGeometryMpi(MpiMixin, TestCylinderGeometry): class TestEdgeGeometryMpi(MpiMixin, TestEdgeGeometry):
tags = {"test", "mpi", "geometery", "cylindrical", "sector", "cylindrical_sector"} tags = {"test", "mpi", "geometry", "edge", "transmission_line", "waveform", "antenna"}
mpi_layout = parameter([[2, 2, 2], [3, 3, 3], [4, 4, 4]]) mpi_layout = parameter([[2, 2, 2], [3, 3, 3], [4, 4, 4]])
test_dependency = TestCylinderGeometry test_dependency = TestEdgeGeometry
@rfm.simple_test @rfm.simple_test
@@ -164,7 +178,7 @@ class TestSphereGeometryMpi(MpiMixin, TestSphereGeometry):
@rfm.simple_test @rfm.simple_test
class TestEdgeGeometryMpi(MpiMixin, TestEdgeGeometry): class TestTriangleGeometryMpi(MpiMixin, TestTriangleGeometry):
tags = {"test", "mpi", "geometry", "edge", "transmission_line", "waveform", "antenna"} tags = {"test", "mpi", "geometery", "triangle"}
mpi_layout = parameter([[3, 3, 3]]) mpi_layout = parameter([[2, 2, 2], [3, 3, 3], [4, 4, 4]])
test_dependency = TestEdgeGeometry test_dependency = TestTriangleGeometry