Exemple #1
0
 def _concatenableMesh(self):
     from fipy.meshes.nonUniformGrid3D import NonUniformGrid3D
     args = self.args.copy()
     origin = args['origin']
     from fipy.tools import serialComm
     args['communicator'] = serialComm
     del args['origin']
     return NonUniformGrid3D(**args) + origin
Exemple #2
0
def Grid3D(dx=1., dy=1., dz=1.,
           nx=None, ny=None, nz=None,
           Lx=None, Ly=None, Lz=None,
           overlap=2, communicator=parallelComm):

    r""" Factory function to select between UniformGrid3D and
    NonUniformGrid3D.  If `Lx` is specified the length of the domain
    is always `Lx` regardless of `dx`.

    :Parameters:

      - `dx`: grid spacing in the horizontal direction
      - `dy`: grid spacing in the vertical direction
      - `dz`: grid spacing in the z-direction
      - `nx`: number of cells in the horizontal direction
      - `ny`: number of cells in the vertical direction
      - `nz`: number of cells in the z-direction
      - `Lx`: the domain length in the horizontal direction
      - `Ly`: the domain length in the vertical direction
      - `Lz`: the domain length in the z-direction
      - `overlap`: the number of overlapping cells for parallel
        simulations. Generally 2 is adequate. Higher order equations or
        discretizations require more.
      - `communicator`: either `fipy.tools.parallelComm` or
        `fipy.tools.serialComm`. Select `fipy.tools.serialComm` to create a
        serial mesh when running in parallel. Mostly used for test
        purposes.

    """

    if numerix.getShape(dx) == () \
      and numerix.getShape(dy) == () \
      and numerix.getShape(dz) == ():

        dx, nx = _dnl(dx, nx, Lx)
        dy, ny = _dnl(dy, ny, Ly)
        dz, nz = _dnl(dz, nz, Lz)
        from fipy.meshes.uniformGrid3D import UniformGrid3D
        return UniformGrid3D(dx = dx, dy = dy, dz = dz,
                             nx = nx or 1, ny = ny or 1, nz = nz or 1,
                             overlap=overlap, communicator=communicator)
    else:
        from fipy.meshes.nonUniformGrid3D import NonUniformGrid3D
        return NonUniformGrid3D(dx = dx, dy = dy, dz = dz, nx = nx, ny = ny, nz = nz,
                                overlap=overlap, communicator=communicator)
Exemple #3
0
def Grid3D(dx=1.,
           dy=1.,
           dz=1.,
           nx=None,
           ny=None,
           nz=None,
           Lx=None,
           Ly=None,
           Lz=None,
           overlap=2,
           communicator=parallelComm):
    r""" Factory function to select between `UniformGrid3D` and
    `NonUniformGrid3D`. If `L{x,y,z}` is specified, the length of the domain
    is always `L{x,y,z}` regardless of `d{x,y,z}`, unless `d{x,y,z}` is a
    list of spacings, in which case `L{x,y,z}` will be the sum of
    `d{x,y,z}` and `n{x,y,z}` will be the count of `d{x,y,z}`.

    Parameters
    ----------
    dx : float
        Grid spacing in the horizontal direction
    dy : float
        Grid spacing in the vertical direction
    dz : float
        Grid spacing in the depth direction
    nx : int
        Number of cells in the horizontal direction
    ny : int
        Number of cells in the vertical direction
    nz : int
        Number of cells in the depth direction
    Lx : float
        Domain length in the horizontal direction
    Ly : float
        Domain length in the vertical direction
    Lz : float
        Domain length in the depth direction
    overlap : int
        Number of overlapping cells for parallel simulations.  Generally 2
        is adequate.  Higher order equations or discretizations require
        more.
    communicator : ~fipy.tools.comms.commWrapper.CommWrapper
        Generally, `fipy.tools.serialComm` or `fipy.tools.parallelComm`.
        Select `~fipy.tools.serialComm` to create a serial mesh when
        running in parallel; mostly used for test purposes.
    """

    if numerix.getShape(dx) == () \
      and numerix.getShape(dy) == () \
      and numerix.getShape(dz) == ():

        dx, nx = _dnl(dx, nx, Lx)
        dy, ny = _dnl(dy, ny, Ly)
        dz, nz = _dnl(dz, nz, Lz)
        from fipy.meshes.uniformGrid3D import UniformGrid3D
        return UniformGrid3D(dx=dx,
                             dy=dy,
                             dz=dz,
                             nx=nx or 1,
                             ny=ny or 1,
                             nz=nz or 1,
                             overlap=overlap,
                             communicator=communicator)
    else:
        from fipy.meshes.nonUniformGrid3D import NonUniformGrid3D
        return NonUniformGrid3D(dx=dx,
                                dy=dy,
                                dz=dz,
                                nx=nx,
                                ny=ny,
                                nz=nz,
                                overlap=overlap,
                                communicator=communicator)