Fix bug from assuming no MPI neighbour would always be -1

这个提交包含在:
Nathan Mannall
2025-06-27 12:39:30 +01:00
父节点 3c8d9e126a
当前提交 a020d9df35
共有 2 个文件被更改,包括 4 次插入4 次删除

查看文件

@@ -1,5 +1,5 @@
# Copyright (C) 2015-2025: The University of Edinburgh, United Kingdom
# Authors: Craig Warren, Antonis Giannopoulos, John Hartley,
# Authors: Craig Warren, Antonis Giannopoulos, John Hartley,
# and Nathan Mannall
#
# This file is part of gprMax.
@@ -370,7 +370,7 @@ class MPIGrid(FDTDGrid):
dir: Direction of halo to swap.
"""
neighbour = self.neighbours[dim][dir]
if neighbour != -1:
if neighbour >= 0:
send_request = self.comm.Isend([array, self.send_halo_map[dim][dir]], neighbour)
recv_request = self.comm.Irecv([array, self.recv_halo_map[dim][dir]], neighbour)
self.send_requests.append(send_request)
@@ -637,7 +637,7 @@ class MPIGrid(FDTDGrid):
has_neighbour: True if the current rank has a neighbour in
the specified dimension and direction.
"""
return self.neighbours[dim][dir] != -1
return self.neighbours[dim][dir] >= 0
def set_halo_map(self):
"""Create MPI DataTypes for field array halo exchanges."""

查看文件

@@ -328,7 +328,7 @@ class MPISnapshot(Snapshot[MPIGrid]):
self.neighbours[Dim.Z] = self.comm.Shift(direction=Dim.Z, disp=1)
def has_neighbour(self, dimension: Dim, direction: Dir) -> bool:
return self.neighbours[dimension][direction] != -1
return self.neighbours[dimension][direction] >= 0
def store(self):
"""Store (in memory) electric and magnetic field values for snapshot.