@@ -417,7 +417,7 @@ def setHeader(self, nVar, coords):
417417 @property
418418 def hInfos (self ):
419419 """Array representing the grid structure to be written in the binary file."""
420- return [np .array ([self .nVar , self .dim , * self .nX ], dtype = np .int32 )] + [
420+ return [np .array ([self .nVar , self .dim , * self .gridSizes ], dtype = np .int32 )] + [
421421 np .array (coord , dtype = np .float64 ) for coord in self .header ["coords" ]
422422 ]
423423
@@ -431,31 +431,31 @@ def readHeader(self, f):
431431 File to read the header from.
432432 """
433433 nVar , dim = np .fromfile (f , dtype = np .int32 , count = 2 )
434- nX = np .fromfile (f , dtype = np .int32 , count = dim )
435- coords = [np .fromfile (f , dtype = np .float64 , count = n ) for n in nX ]
434+ gridSizes = np .fromfile (f , dtype = np .int32 , count = dim )
435+ coords = [np .fromfile (f , dtype = np .float64 , count = n ) for n in gridSizes ]
436436 self .setHeader (nVar , coords )
437437
438438 def reshape (self , fields : np .ndarray ):
439439 """Reshape the fields to a N-d array (inplace operation)"""
440- fields .shape = (self .nVar , * self .nX )
440+ fields .shape = (self .nVar , * self .gridSizes )
441441
442442 # -------------------------------------------------------------------------
443443 # Class specifics
444444 # -------------------------------------------------------------------------
445445 @property
446- def nX (self ):
446+ def gridSizes (self ):
447447 """Number of points in y direction"""
448448 return [coord .size for coord in self .header ["coords" ]]
449449
450450 @property
451451 def dim (self ):
452452 """Number of grid dimensions"""
453- return len (self .nX )
453+ return len (self .gridSizes )
454454
455455 @property
456456 def nDoF (self ):
457457 """Number of degrees of freedom for one variable"""
458- return np .prod (self .nX )
458+ return np .prod (self .gridSizes )
459459
460460 def toVTR (self , baseName , varNames , suffix = "{:06d}_t={:1.2f}s" ):
461461 """
@@ -625,22 +625,22 @@ def addField(self, time, field):
625625 self .MPI_WRITE (np .array (time , dtype = T_DTYPE ))
626626 offset0 += self .tSize
627627
628- for (iVar , * iX ) in itertools .product (range (self .nVar ), * [range (nX ) for nX in self .nLoc [:- 1 ]]):
629- offset = offset0 + self .iPos (iVar , iX ) * self .itemSize
630- self .MPI_WRITE_AT (offset , field [iVar , * iX ])
628+ for (iVar , * iBeg ) in itertools .product (range (self .nVar ), * [range (n ) for n in self .nLoc [:- 1 ]]):
629+ offset = offset0 + self .iPos (iVar , iBeg ) * self .itemSize
630+ self .MPI_WRITE_AT (offset , field [iVar , * iBeg ])
631631 self .MPI_FILE_CLOSE ()
632632
633633 def iPos (self , iVar , iX ):
634634 iPos = iVar * self .nDoF
635635 for axis in range (self .dim - 1 ):
636- iPos += (self .iLoc [axis ] + iX [axis ]) * np .prod (self .nX [axis + 1 :])
636+ iPos += (self .iLoc [axis ] + iX [axis ]) * np .prod (self .gridSizes [axis + 1 :])
637637 iPos += self .iLoc [- 1 ]
638638 return iPos
639639
640640 def readField (self , idx ):
641641 """
642642 Read one field stored in the binary file, corresponding to the given
643- time index, eventually in MPI mode .
643+ time index, using MPI in the eventuality of space parallel decomposition .
644644
645645 Parameters
646646 ----------
@@ -670,9 +670,9 @@ def readField(self, idx):
670670 field = np .empty ((self .nVar , * self .nLoc ), dtype = self .dtype )
671671
672672 self .MPI_FILE_OPEN (mode = "r" )
673- for (iVar , * iX ) in itertools .product (range (self .nVar ), * [range (nX ) for nX in self .nLoc [:- 1 ]]):
674- offset = offset0 + self .iPos (iVar , iX ) * self .itemSize
675- self .MPI_READ_AT (offset , field [iVar , * iX ])
673+ for (iVar , * iBeg ) in itertools .product (range (self .nVar ), * [range (n ) for n in self .nLoc [:- 1 ]]):
674+ offset = offset0 + self .iPos (iVar , iBeg ) * self .itemSize
675+ self .MPI_READ_AT (offset , field [iVar , * iBeg ])
676676 self .MPI_FILE_CLOSE ()
677677
678678 return t , field
@@ -691,8 +691,8 @@ def initGrid(nVar, gridSizes):
691691 return coords , u0
692692
693693
694- def writeFields_MPI (fileName , dtypeIdx , algo , nSteps , nVar , nX ):
695- coords , u0 = initGrid (nVar , nX )
694+ def writeFields_MPI (fileName , dtypeIdx , algo , nSteps , nVar , gridSizes ):
695+ coords , u0 = initGrid (nVar , gridSizes )
696696
697697 from mpi4py import MPI
698698 from pySDC .helpers .blocks import BlockDecomposition
@@ -702,7 +702,7 @@ def writeFields_MPI(fileName, dtypeIdx, algo, nSteps, nVar, nX):
702702 MPI_SIZE = comm .Get_size ()
703703 MPI_RANK = comm .Get_rank ()
704704
705- blocks = BlockDecomposition (MPI_SIZE , nX , algo , MPI_RANK )
705+ blocks = BlockDecomposition (MPI_SIZE , gridSizes , algo , MPI_RANK )
706706
707707 iLoc , nLoc = blocks .localBounds
708708 Rectilinear .setupMPI (comm , iLoc , nLoc )
0 commit comments