Skip to content

Commit d772718

Browse files
committed
TL: simplified fieldsIO to two generic classes (Scalar + Rectilinear)
1 parent 51aa701 commit d772718

File tree

3 files changed

+173
-418
lines changed

3 files changed

+173
-418
lines changed

pySDC/helpers/blocks.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import numpy as np
2+
3+
14
class BlockDecomposition(object):
25
"""
36
Class decomposing a cartesian space domain (1D to 3D) into a given number of processors.
@@ -92,16 +95,9 @@ def __init__(self, nProcs, gridSizes, algo="Hybrid", gRank=None, order="C"):
9295

9396
@property
9497
def ranks(self):
95-
gRank, order = self.gRank, self.order
96-
assert gRank is not None, "gRank attribute need to be set"
97-
dim, nBlocks = self.dim, self.nBlocks
98-
if dim == 1:
99-
return (gRank,)
100-
elif dim == 2:
101-
div = nBlocks[-1] if order == "C" else nBlocks[0]
102-
return (gRank // div, gRank % div)
103-
else:
104-
raise NotImplementedError(f"dim={dim}")
98+
assert self.gRank is not None, "gRank attribute needs to be set"
99+
cart = np.arange(np.prod(self.nBlocks)).reshape(self.nBlocks, order=self.order)
100+
return list(np.argwhere(cart == self.gRank)[0])
105101

106102
@property
107103
def localBounds(self):

0 commit comments

Comments
 (0)