Changeset 3229
- Timestamp:
- 08/14/09 15:43:49 (8 months ago)
- Location:
- branches/parallel/fipy
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/parallel/fipy/meshes/cylindricalGrid2D.py
r2781 r3229 33 33 ## 34 34 35 from fipy.tools import parallel 35 36 36 def CylindricalGrid2D(dr=None, dz=None, nr=None, nz=None, dx=1., dy=1., nx=None, ny=None ):37 def CylindricalGrid2D(dr=None, dz=None, nr=None, nz=None, dx=1., dy=1., nx=None, ny=None, parallelModule=parallel): 37 38 from numMesh import cylindricalUniformGrid2D 38 39 from numMesh import cylindricalGrid2D … … 55 56 56 57 if numerix.getShape(dx) == () and numerix.getShape(dy) == (): 57 return cylindricalUniformGrid2D.CylindricalUniformGrid2D(dx=dx, dy=dy, nx=nx or 1, ny=ny or 1 )58 return cylindricalUniformGrid2D.CylindricalUniformGrid2D(dx=dx, dy=dy, nx=nx or 1, ny=ny or 1, parallelModule=parallelModule) 58 59 else: 59 return cylindricalGrid2D.CylindricalGrid2D(dx=dx, dy=dy, nx=nx, ny=ny )60 return cylindricalGrid2D.CylindricalGrid2D(dx=dx, dy=dy, nx=nx, ny=ny, parallelModule=parallelModule) -
branches/parallel/fipy/meshes/numMesh/cylindricalGrid2D.py
r3156 r3229 43 43 from fipy.meshes.numMesh.grid2D import Grid2D 44 44 from fipy.tools.dimensions.physicalField import PhysicalField 45 from fipy.tools import parallel 45 46 46 47 class CylindricalGrid2D(Grid2D): … … 49 50 first and then vertical faces. 50 51 """ 51 def __init__(self, dx=1., dy=1., nx=None, ny=None, origin=((0.,), (0.,)), overlap=2 ):52 def __init__(self, dx=1., dy=1., nx=None, ny=None, origin=((0.,), (0.,)), overlap=2, parallelModule=parallel): 52 53 scale = PhysicalField(value=1, unit=PhysicalField(value=dx).getUnit()) 53 54 self.origin = PhysicalField(value=origin) 54 55 self.origin /= scale 55 56 56 Grid2D.__init__(self, dx=dx, dy=dy, nx=nx, ny=ny, overlap=overlap )57 Grid2D.__init__(self, dx=dx, dy=dy, nx=nx, ny=ny, overlap=overlap, parallelModule=parallelModule) 57 58 58 59 -
branches/parallel/fipy/meshes/numMesh/cylindricalUniformGrid2D.py
r3154 r3229 40 40 from fipy import numerix 41 41 from fipy.meshes.numMesh.uniformGrid2D import UniformGrid2D 42 from fipy.tools import parallel 42 43 43 44 class CylindricalUniformGrid2D(UniformGrid2D): … … 46 47 appropriate for axial symmetry. 47 48 """ 48 def __init__(self, dx=1., dy=1., nx=1, ny=1, origin=((0,),(0,)), overlap=2 ):49 UniformGrid2D.__init__(self, dx=dx, dy=dy, nx=nx, ny=ny, origin=origin, overlap=overlap )49 def __init__(self, dx=1., dy=1., nx=1, ny=1, origin=((0,),(0,)), overlap=2, parallelModule=parallel): 50 UniformGrid2D.__init__(self, dx=dx, dy=dy, nx=nx, ny=ny, origin=origin, overlap=overlap, parallelModule=parallelModule) 50 51 51 52 def _getAreaProjections(self): -
branches/parallel/fipy/meshes/numMesh/grid1D.py
r3147 r3229 92 92 93 93 def _calcParallelGridInfo(self, nx, overlap): 94 from fipy.tools.parallel import procID, Nproc 94 from fipy.tools import parallel 95 procID = parallel.procID 96 Nproc = parallel.Nproc 95 97 96 98 overlap = min(overlap, nx) -
branches/parallel/fipy/meshes/numMesh/grid2D.py
r3216 r3229 43 43 from fipy.tools import vector 44 44 from fipy.tools.dimensions.physicalField import PhysicalField 45 from fipy.tools import parallel 45 46 46 47 class Grid2D(Mesh2D): … … 49 50 first and then vertical faces. 50 51 """ 51 def __init__(self, dx=1., dy=1., nx=None, ny=None, overlap=2): 52 def __init__(self, dx=1., dy=1., nx=None, ny=None, overlap=2, parallelModule=parallel): 53 52 54 self.args = { 53 55 'dx': dx, … … 55 57 'nx': nx, 56 58 'ny': ny, 57 'overlap': overlap 59 'overlap': overlap, 60 'parallelModule': parallelModule 58 61 } 59 62 60 63 self.dx = PhysicalField(value = dx) 61 64 scale = PhysicalField(value=1, unit=self.dx.getUnit()) … … 75 78 self.ny, 76 79 self.overlap, 77 self.offset) = self._calcParallelGridInfo(nx, ny, overlap )80 self.offset) = self._calcParallelGridInfo(nx, ny, overlap, parallelModule) 78 81 79 82 if numerix.getShape(self.dx) is not (): … … 104 107 self.setScale(value = scale) 105 108 106 def _getParallelInfo(self): 107 from fipy.tools.parallel import procID, Nproc 108 return procID, Nproc 109 110 def _calcParallelGridInfo(self, nx, ny, overlap): 111 procID, Nproc = self._getParallelInfo() 112 109 def _calcParallelGridInfo(self, nx, ny, overlap, parallelModule): 110 111 procID = parallelModule.procID 112 Nproc = parallelModule.Nproc 113 113 114 overlap = min(overlap, ny) 114 115 cellsPerNode = max(int(ny / Nproc), overlap) -
branches/parallel/fipy/meshes/numMesh/uniformGrid2D.py
r3216 r3229 43 43 from fipy.tools.dimensions.physicalField import PhysicalField 44 44 from fipy.tools import inline 45 from fipy.tools import parallel 45 46 46 47 class UniformGrid2D(Grid2D): … … 49 50 first and then vertical faces. 50 51 """ 51 def __init__(self, dx=1., dy=1., nx=1, ny=1, origin=((0,),(0,)), overlap=2 ):52 def __init__(self, dx=1., dy=1., nx=1, ny=1, origin=((0,),(0,)), overlap=2, parallelModule=parallel): 52 53 self.args = { 53 54 'dx': dx, … … 56 57 'ny': ny, 57 58 'origin': origin, 58 'overlap': overlap 59 'overlap': overlap, 60 'parallelModule': parallelModule 59 61 } 60 62 61 63 self.dim = 2 62 64 … … 78 80 self.ny, 79 81 self.overlap, 80 self.offset) = self._calcParallelGridInfo(nx, ny, overlap )82 self.offset) = self._calcParallelGridInfo(nx, ny, overlap, parallelModule) 81 83 82 84 self.origin = PhysicalField(value = origin) … … 115 117 return self.__class__(dx = self.dx, nx = self.nx, 116 118 dy = self.dy, ny = self.ny, 117 origin = self.origin + vector) 119 origin = self.origin + vector, 120 parallelModule=self.args['parallelModule']) 118 121 119 122 def __mul__(self, factor): -
branches/parallel/fipy/models/levelSet/electroChem/gapFillMesh.py
r3216 r3229 95 95 96 96 ## Build the fine region mesh. 97 from fipy. meshes.numMesh.serialUniformGrid2D import SerialUniformGrid2D98 self.fineMesh = SerialUniformGrid2D(nx = nx, ny = ny, dx = cellSize, dy = cellSize)97 from fipy.tools import serial 98 self.fineMesh = Grid2D(nx = nx, ny = ny, dx = cellSize, dy = cellSize, parallelModule=serial) 99 99 100 100 ## Build the transition mesh and displace. … … 103 103 ## Build the boundary layer mesh. 104 104 105 boundaryLayerMesh = SerialUniformGrid2D(dx = actualDomainWidth,106 107 108 ny = numberOfBoundaryLayerCells) + ((0,), (self.actualFineRegionHeight + transitionRegionHeight,))109 110 105 boundaryLayerMesh = Grid2D(dx = actualDomainWidth, 106 dy = actualDomainWidth, 107 nx = 1, 108 ny = numberOfBoundaryLayerCells, 109 parallelModule=serial) + ((0,), (self.actualFineRegionHeight + transitionRegionHeight,),) 110 111 111 ## Add the meshes together. 112 112 mesh = self.fineMesh._concatenate(transitionMesh, self.epsilon) -
branches/parallel/fipy/terms/diffusionTerm.py
r3130 r3229 364 364 >>> from fipy.meshes.grid1D import Grid1D 365 365 >>> from fipy.tools.pysparseMatrix import _PysparseMatrix as SparseMatrix 366 >>> from fipy.tools.parallel import procID 366 >>> from fipy.tools import parallel 367 >>> procID = parallel.procID 367 368 >>> mesh = Grid1D(dx = 1., nx = 2) 368 369 >>> term = DiffusionTerm(coeff = (1,)) -
branches/parallel/fipy/tools/__init__.py
r3113 r3229 1 class Parallel: 2 try: 3 4 try: 5 import scipy 6 except: 7 pass 8 9 from PyTrilinos import Epetra 10 11 procID = Epetra.PyComm().MyPID() 12 Nproc = Epetra.PyComm().NumProc() 13 except ImportError: 14 procID = 0 15 Nproc = 1 16 17 class Serial: 18 procID = 0 19 Nproc = 1 20 21 parallel = Parallel() 22 serial = Serial() 1 23 import dump 2 24 import numerix 3 import parallel4 25 import vector 5 26 from dimensions.physicalField import PhysicalField 6 27 from numerix import * 7