Skip to content

Commit a97728a

Browse files
authored
TL: generic FieldsIO class for n-dimensional rectilinear grids + VTK support (#533)
* TL: simplified fieldsIO to two generic classes (Scalar + Rectilinear) * TL: trying something * TL: restriction to python 3.11 * TL: another try * TL: I'm dumb * TL: yet another try ... * TL: added vtk support for 3D VTR files * TL: avoided clashing name, gitignore update * TL: you gotta be kiding me ... * TL: VTK output support for Rectilinear FieldsIO * TL: added documentation * TL: polished documentation * TL: minor typo * TL: refactoring following thomas's suggestions * TL: minor typo * TL: corrected Rectilinear.toVTR for paraview groups
1 parent 51aa701 commit a97728a

File tree

7 files changed

+423
-443
lines changed

7 files changed

+423
-443
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ step_*.png
1111
*_data.json
1212
!_dataRef.json
1313
*.pysdc
14+
*.vtr
1415

1516
# Created by https://www.gitignore.io
1617

etc/environment-base.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- sympy>=1.0
1111
- numba>=0.35
1212
- dill>=0.2.6
13+
- vtk
1314
- pip
1415
- pip:
1516
- qmat>=0.1.8

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)