Skip to content

Commit

Permalink
Fixing ticket:491, renaming parallel and serial communicators.
Browse files Browse the repository at this point in the history
The names `parallel` and `serial` for the communicator instances are
not descriptive enough. Renamed to `parallelComm` and `serialComm`.

 * Maintaining `serial` and `parallel` for backwards
   compatibility. These are not deprecated as they are not functions
   or classes, but just instances.
  • Loading branch information
wd15 committed Jan 22, 2013
1 parent a729768 commit 28de7a8
Show file tree
Hide file tree
Showing 46 changed files with 204 additions and 201 deletions.
2 changes: 1 addition & 1 deletion examples/diffusion/anisotropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
Import a mesh previously created using :term:`Gmsh`.
>>> import os
>>> mesh = Gmsh2D(os.path.splitext(__file__)[0] + '.msh', communicator=serial) # doctest: +GMSH
>>> mesh = Gmsh2D(os.path.splitext(__file__)[0] + '.msh', communicator=serialComm) # doctest: +GMSH
Set the centermost cell to have a value.
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/advection/mesh1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
.. index:: Grid1D
>>> from fipy.tools import serial
>>> mesh = Grid1D(dx=dx, nx=nx, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid1D(dx=dx, nx=nx, communicator=serialComm)
Construct a `distanceVariable` object.
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/advection/trench.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
>>> timeStepDuration = cfl * dx / velocity
>>> steps = 200
>>> from fipy.tools import serial
>>> mesh = Grid2D(dx = dx, dy = dx, nx = nx, ny = ny, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid2D(dx = dx, dy = dx, nx = nx, ny = ny, communicator=serialComm)
>>> var = DistanceVariable(name = 'level set variable',
... mesh = mesh,
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/distanceFunction/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
.. index:: Grid2D
>>> from fipy.tools import serial
>>> mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny, communicator=serialComm)
Construct a `distanceVariable` object.
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/distanceFunction/interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
Lx = nx * dx
Ly = ny * dy

from fipy.tools import serial
mesh = Grid2D(dx = dx, dy = dy, nx = nx, ny = ny, communicator=serial)
from fipy.tools import serialComm
mesh = Grid2D(dx = dx, dy = dy, nx = nx, ny = ny, communicator=serialComm)

var = DistanceVariable(
name = 'level set variable',
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/distanceFunction/mesh1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
.. index:: Grid2D
>>> from fipy.tools import serial
>>> mesh = Grid1D(dx=dx, nx=nx, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid1D(dx=dx, nx=nx, communicator=serialComm)
Construct a `distanceVariable` object.
Expand Down
8 changes: 4 additions & 4 deletions examples/levelSet/electroChem/adsorbingSurfactantEquation.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class AdsorbingSurfactantEquation():
>>> c = 0.2
>>> from fipy.meshes import Grid2D
>>> from fipy import serial
>>> mesh = Grid2D(dx = dx, dy = dy, nx = 5, ny = 1, communicator=serial)
>>> from fipy import serialComm
>>> mesh = Grid2D(dx = dx, dy = dy, nx = 5, ny = 1, communicator=serialComm)
>>> distanceVar = DistanceVariable(mesh = mesh,
... value = (-dx*3/2, -dx/2, dx/2,
... 3*dx/2, 5*dx/2),
Expand Down Expand Up @@ -121,7 +121,7 @@ class AdsorbingSurfactantEquation():
>>> c0 = 1.
>>> c1 = 1.
>>> totalSteps = 10
>>> mesh = Grid2D(dx = dx, dy = dy, nx = 5, ny = 1, communicator=serial)
>>> mesh = Grid2D(dx = dx, dy = dy, nx = 5, ny = 1, communicator=serialComm)
>>> distanceVar = DistanceVariable(mesh = mesh,
... value = dx * (numerix.arange(5) - 1.5),
... hasOld = 1)
Expand Down Expand Up @@ -196,7 +196,7 @@ class AdsorbingSurfactantEquation():
>>> ny = 5
>>> dx = 1.
>>> dy = 1.
>>> mesh = Grid2D(dx=dx, dy=dy, nx = nx, ny = ny, communicator=serial)
>>> mesh = Grid2D(dx=dx, dy=dy, nx = nx, ny = ny, communicator=serialComm)
>>> x, y = mesh.cellCenters
>>> disVar = DistanceVariable(mesh=mesh, value=1., hasOld=True)
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/electroChem/adsorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
## build the mesh

dx = L / (nx - 1.5)
from fipy.tools import serial
mesh = Grid1D(nx = nx, dx = dx, communicator=serial)
from fipy.tools import serialComm
mesh = Grid1D(nx = nx, dx = dx, communicator=serialComm)

## build the distance variable

Expand Down
10 changes: 5 additions & 5 deletions examples/levelSet/electroChem/gapFillMesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

from fipy.meshes import Gmsh2D
from fipy.meshes import Grid2D
from fipy.tools import serial
from fipy.tools import parallel
from fipy.tools import serialComm
from fipy.tools import parallelComm

class GapFillMesh(Gmsh2D):
"""
Expand All @@ -64,7 +64,7 @@ class GapFillMesh(Gmsh2D):
>>> import fipy.tools.dump as dump
>>> (f, filename) = dump.write(mesh) # doctest: +GMSH
>>> if parallel.Nproc == 1:
>>> if parallelComm.Nproc == 1:
... mesh = dump.read(filename, f) # doctest: +GMSH
>>> print 136 < mesh.globalNumberOfCells < 300 # doctest: +GMSH
Expand Down Expand Up @@ -104,7 +104,7 @@ def __init__(self,
desiredDomainHeight=None,
desiredFineRegionHeight=None,
transitionRegionHeight=None,
communicator=parallel):
communicator=parallelComm):

"""
Arguments:
Expand Down Expand Up @@ -133,7 +133,7 @@ def __init__(self,
numberOfBoundaryLayerCells = int(boundaryLayerHeight / actualDomainWidth)

# Build the fine region mesh.
self.fineMesh = Grid2D(nx=nx, ny=ny, dx=cellSize, dy=cellSize, communicator=serial)
self.fineMesh = Grid2D(nx=nx, ny=ny, dx=cellSize, dy=cellSize, communicator=serialComm)

eps = cellSize / nx / 10

Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/electroChem/howToWriteAScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@
>>> from metalIonDiffusionEquation import buildMetalIonDiffusionEquation
>>> from adsorbingSurfactantEquation import AdsorbingSurfactantEquation
>>> from fipy import serial
>>> from fipy import serialComm
>>> mesh = Grid2D(dx=cellSize,
... dy=cellSize,
... nx=xCells,
... ny=yCells,
... communicator=serial)
... communicator=serialComm)
A ``distanceVariable`` object,
:math:`\phi`, is required to store the position of the interface.
Expand Down
8 changes: 4 additions & 4 deletions examples/levelSet/electroChem/metalIonDiffusionEquation.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def buildMetalIonDiffusionEquation(ionVar = None,
>>> from fipy.meshes import Grid1D
>>> nx = 11
>>> dx = 1.
>>> from fipy.tools import serial
>>> mesh = Grid1D(nx = nx, dx = dx, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid1D(nx = nx, dx = dx, communicator=serialComm)
>>> x, = mesh.cellCenters
>>> from fipy.variables.cellVariable import CellVariable
>>> ionVar = CellVariable(mesh = mesh, value = 1.)
Expand Down Expand Up @@ -131,8 +131,8 @@ def buildMetalIonDiffusionEquation(ionVar = None,
Testing the interface source term
>>> from fipy.meshes import Grid2D
>>> from fipy import numerix, serial
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2, communicator=serial)
>>> from fipy import numerix, serialComm
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2, communicator=serialComm)
>>> from fipy.variables.distanceVariable import DistanceVariable
>>> distance = DistanceVariable(mesh = mesh, value = (-.5, .5, .5, 1.5))
>>> ionVar = CellVariable(mesh = mesh, value = (1, 1, 1, 1))
Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/electroChem/simpleTrenchSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ def runSimpleTrenchSystem(faradaysConstant=9.6e4,

xCells = int(trenchSpacing / 2 / cellSize)

from fipy.tools import serial
from fipy.tools import serialComm
mesh = Grid2D(dx = cellSize,
dy = cellSize,
nx = xCells,
ny = yCells,
communicator=serial)
communicator=serialComm)

narrowBandWidth = numberOfCellsInNarrowBand * cellSize

Expand Down
8 changes: 4 additions & 4 deletions examples/levelSet/electroChem/trenchMesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

from fipy.tools import numerix
from fipy.variables.cellVariable import CellVariable
from fipy.tools import parallel
from fipy.tools import parallelComm
from gapFillMesh import GapFillMesh

class TrenchMesh(GapFillMesh):
Expand All @@ -58,7 +58,7 @@ class TrenchMesh(GapFillMesh):
>>> import fipy.tools.dump as dump
>>> (f, filename) = dump.write(mesh) # doctest: +GMSH
>>> if parallel.Nproc == 1:
>>> if parallelComm.Nproc == 1:
... mesh = dump.read(filename, f) # doctest: +GMSH
>>> print mesh.globalNumberOfCells - len(numerix.nonzero(mesh.electrolyteMask)[0]) # doctest: +GMSH, +SERIAL
150
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(self,
cellSize=None,
aspectRatio=None,
angle=0.,
communicator=parallel):
communicator=parallelComm):
"""
`trenchDepth` - Depth of the trench.
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self,
desiredDomainHeight=domainHeight,
desiredFineRegionHeight=fineRegionHeight,
transitionRegionHeight=transitionHeight,
communicator=parallel)
communicator=parallelComm)

trenchWidth = trenchDepth / aspectRatio

Expand Down
4 changes: 2 additions & 2 deletions examples/levelSet/surfactant/expandingCircle.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
dx = L / nx
steps = 20

from fipy.tools import serial
mesh = Grid2D(dx = dx, dy = dx, nx = nx, ny = nx, communicator=serial)
from fipy.tools import serialComm
mesh = Grid2D(dx = dx, dy = dx, nx = nx, ny = nx, communicator=serialComm)

x, y = mesh.cellCenters
distanceVariable = DistanceVariable(
Expand Down
6 changes: 3 additions & 3 deletions examples/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
trilinos_info = "PyTrilinos: processor %d of %d" % (epcomm.MyPID(),
epcomm.NumProc())

from fipy import parallel, Grid1D
from fipy import parallelComm, Grid1D

mesh = Grid1D(nx=10)

fipy_info = "FiPy: %d cells on processor %d of %d" % (mesh.numberOfCells,
parallel.procID,
parallel.Nproc)
parallelComm.procID,
parallelComm.Nproc)

print " :: ".join((mpi4py_info, trilinos_info, fipy_info))

20 changes: 10 additions & 10 deletions fipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def _getVersion():
input = input
input_original = input

if parallel.Nproc > 1:
if parallelComm.Nproc > 1:
def mpi_input(prompt=""):
parallel.Barrier()
parallelComm.Barrier()
sys.stdout.flush()
if parallel.procID == 0:
if parallelComm.procID == 0:
sys.stdout.write(prompt)
sys.stdout.flush()
return sys.stdin.readline()
Expand All @@ -85,11 +85,11 @@ def mpi_input(prompt=""):
raw_input = raw_input
raw_input_original = raw_input

if parallel.Nproc > 1:
if parallelComm.Nproc > 1:
def mpi_raw_input(prompt=""):
parallel.Barrier()
parallelComm.Barrier()
sys.stdout.flush()
if parallel.procID == 0:
if parallelComm.procID == 0:
sys.stdout.write(prompt)
sys.stdout.flush()
return sys.stdin.readline()
Expand All @@ -115,14 +115,14 @@ def doctest_raw_input(prompt):
This routine attempts to be savvy about running in parallel.
"""
try:
from fipy.tools import parallel
parallel.Barrier()
from fipy.tools import parallelComm
parallelComm.Barrier()
_saved_stdout.flush()
if parallel.procID == 0:
if parallelComm.procID == 0:
txt = _serial_doctest_raw_input(prompt)
else:
txt = ""
parallel.Barrier()
parallelComm.Barrier()
except ImportError:
txt = _serial_doctest_raw_input(prompt)
# return txt
Expand Down
4 changes: 2 additions & 2 deletions fipy/boundaryConditions/boundaryCondition.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class in this manner. This is merely a test.
>>> from fipy.meshes import Grid1D
>>> mesh = Grid1D(nx = 2)
>>> from fipy.tools import parallel
>>> if parallel.procID == 0:
>>> from fipy.tools import parallelComm
>>> if parallelComm.procID == 0:
... bc = __BoundaryCondition(mesh.interiorFaces, 0)
... else:
... raise IndexError("Face list has interior faces")
Expand Down
8 changes: 4 additions & 4 deletions fipy/matrices/pysparseMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ def asTrilinosMeshMatrix(self):

@property
def numpyArray(self):
from fipy.tools import parallel
if parallel.Nproc == 1:
from fipy.tools import parallelComm
if parallelComm.Nproc == 1:
return super(_PysparseMeshMatrix, self).numpyArray
else:
return self.asTrilinosMeshMatrix().numpyArray
Expand Down Expand Up @@ -417,8 +417,8 @@ def __init__(self, mesh):
"""Create a sparse matrix associated with a `Mesh` with '1' in the diagonal
>>> from fipy import Grid1D
>>> from fipy.tools import serial
>>> mesh = Grid1D(nx=3, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid1D(nx=3, communicator=serialComm)
>>> print _PysparseIdentityMeshMatrix(mesh=mesh)
1.000000 --- ---
--- 1.000000 ---
Expand Down
4 changes: 2 additions & 2 deletions fipy/matrices/scipyMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ def __init__(self, mesh):
Create a sparse matrix associated with a `Mesh` with '1' in the diagonal
>>> from fipy import Grid1D
>>> from fipy.tools import serial
>>> mesh = Grid1D(nx=3, communicator=serial)
>>> from fipy.tools import serialComm
>>> mesh = Grid1D(nx=3, communicator=serialComm)
>>> print _ScipyIdentityMeshMatrix(mesh=mesh)
1.000000 --- ---
--- 1.000000 ---
Expand Down
Loading

0 comments on commit 28de7a8

Please sign in to comment.