Skip to content

Commit d9a22f1

Browse files
committed
use isclose when matching patches of parallel domain
In spherical geometry, rounding errors can occur resulting in patch limits being slightly different rather than stricly equal.
1 parent db688e9 commit d9a22f1

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/stagpy/parsers/h5/field.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,23 @@ def _ncores(
5454
nnpb -= 1
5555
cpu = lambda icy: icy * nns[0] # noqa: E731
5656
if twod is None or "Y" in twod:
57-
while (
58-
nnpb > 1
59-
and meshes[cpu(nns[1])]["Y"][0, 0, 0]
60-
== meshes[cpu(nns[1] - 1)]["Y"][0, -1, 0]
57+
while nnpb > 1 and np.isclose(
58+
meshes[cpu(nns[1])]["Y"][0, 0, 0],
59+
meshes[cpu(nns[1] - 1)]["Y"][0, -1, 0],
60+
rtol=1e-10,
6161
):
6262
nns[1] += 1
6363
nnpb -= nns[0]
6464
cpu = lambda icz: icz * nns[0] * nns[1] # noqa: E731
65-
while (
66-
nnpb > 1
67-
and meshes[cpu(nns[2])]["Z"][0, 0, 0] == meshes[cpu(nns[2] - 1)]["Z"][0, 0, -1]
65+
while nnpb > 1 and np.isclose(
66+
meshes[cpu(nns[2])]["Z"][0, 0, 0],
67+
meshes[cpu(nns[2] - 1)]["Z"][0, 0, -1],
68+
rtol=1e-10,
6869
):
6970
nns[2] += 1
7071
nnpb -= nns[0] * nns[1]
72+
assert nnpb == 1
73+
assert len(meshes) == np.prod(nns)
7174
return np.array(nns)
7275

7376

0 commit comments

Comments
 (0)