예제 #1
0
 def __init__(self, var, name=''):
     CellVariable.__init__(self,
                           mesh=var.mesh,
                           name=name,
                           elementshape=(var.mesh.dim, ) + var.shape[:-1])
     self.var = self._requires(var)
     self.faceGradientContributions = _FaceGradContributions(self.var)
예제 #2
0
    def __init__(self, faceVariable, mesh = None):
        if not mesh:
            mesh = faceVariable.getMesh()

        CellVariable.__init__(self, mesh, hasOld = 0)
    
        self.faceVariable = self._requires(faceVariable)
예제 #3
0
    def __init__(self, mesh, name = '', value = 0., unit = None, hasOld = 0, narrowBandWidth = 1e+10):
        """
        Creates a `distanceVariable` object.

        :Parameters:
          - `mesh`: The mesh that defines the geometry of this variable.
          - `name`: The name of the variable.
	  - `value`: The initial value.
	  - `unit`: the physical units of the variable
          - `hasOld`: Whether the variable maintains an old value.
          - `narrowBandWidth`: The width of the region about the zero level set
            within which the distance function is evaluated.

        """
        CellVariable.__init__(self, mesh, name = name, value = value, unit = unit, hasOld = hasOld)
        self._markStale()
        self.narrowBandWidth = narrowBandWidth

        self.cellToCellDistances = MA.filled(self.mesh._getCellToCellDistances(), 0)
        self.cellNormals = MA.filled(self.mesh._getCellNormals(), 0)      
        self.cellAreas = MA.filled(self.mesh._getCellAreas(), 0)
##         self.cellToCellDistances = numerix.array(MA.array(self.mesh._getCellToCellDistances()).filled(0))
##         self.cellNormals = numerix.array(MA.array(self.mesh._getCellNormals()).filled(0))       
##         self.cellAreas = numerix.array(MA.array(self.mesh._getCellAreas()).filled(0))
        self.cellToCellIDs = numerix.array(self.mesh._getCellToCellIDsFilled())
        self.adjacentCellIDs = self.mesh._getAdjacentCellIDs()
        self.exteriorFaces = self.mesh.getExteriorFaces()
        self.cellFaceIDs = self.mesh._getCellFaceIDs()
예제 #4
0
    def __init__(self, distanceVar, bulkVar, rateConstant):
        CellVariable.__init__(self, mesh = distanceVar.getMesh())

        self.distanceVar = self._requires(distanceVar)
        self.bulkVar = self._requires(bulkVar)
        self.rateConstant = rateConstant
        self.dt = 0
예제 #5
0
    def __init__(self, value = 0., distanceVar = None, name = 'surfactant variable', hasOld=False):
        """

        A simple 1D test:

           >>> from fipy.meshes.grid1D import Grid1D
           >>> mesh = Grid1D(dx = 1., nx = 4)
           >>> from fipy.models.levelSet.distanceFunction.distanceVariable \\
           ...     import DistanceVariable
           >>> distanceVariable = DistanceVariable(mesh = mesh, 
           ...                                     value = (-1.5, -0.5, 0.5, 941.5))
           >>> surfactantVariable = SurfactantVariable(value = 1, 
           ...                                         distanceVar = distanceVariable)
           >>> print numerix.allclose(surfactantVariable, (0, 0., 1., 0))
           1

        A 2D test case:

           >>> from fipy.meshes.grid2D import Grid2D
           >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3)
           >>> distanceVariable = DistanceVariable(mesh = mesh,
           ...                                     value = (1.5, 0.5, 1.5,
           ...                                              0.5,-0.5, 0.5,
           ...                                              1.5, 0.5, 1.5))
           >>> surfactantVariable = SurfactantVariable(value = 1, 
           ...                                         distanceVar = distanceVariable)
           >>> print numerix.allclose(surfactantVariable, (0, 1, 0, 1, 0, 1, 0, 1, 0))
           1

        Another 2D test case:

           >>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2)
           >>> distanceVariable = DistanceVariable(mesh = mesh, 
           ...                                     value = (-0.5, 0.5, 0.5, 1.5))
           >>> surfactantVariable = SurfactantVariable(value = 1, 
           ...                                         distanceVar = distanceVariable)
           >>> print numerix.allclose(surfactantVariable, 
           ...                  (0, numerix.sqrt(2), numerix.sqrt(2), 0))
           1

        :Parameters:
          - `value`: The initial value.
          - `distanceVar`: A `DistanceVariable` object.
          - `name`: The name of the variable.
          
        """


        CellVariable.__init__(self, mesh = distanceVar.getMesh(), name = name, hasOld=False)

        self.distanceVar = self._requires(distanceVar)
        self.value = distanceVar.getCellInterfaceAreas() * value / self.mesh.getCellVolumes()

        if hasOld:
            self.old = self.copy()
        else:
            self.old = None

        self.interfaceSurfactantVariable = None
    def __init__(self, faceVariable, mesh=None):
        if not mesh:
            mesh = faceVariable.mesh

        CellVariable.__init__(self,
                              mesh,
                              hasOld=0,
                              elementshape=faceVariable.shape[:-1])
        self.faceVariable = self._requires(faceVariable)
예제 #7
0
    def __init__(self, distanceVar):
        """
        Creates an `_InterfaceAreaVariable` object.

        Parameters
        ----------
        distanceVar : ~fipy.variables.distanceVariable.DistanceVariable
        """
        CellVariable.__init__(self, distanceVar.mesh, hasOld=False)
        self.distanceVar = self._requires(distanceVar)
예제 #8
0
    def __init__(self, distanceVar):
        """
        Creates an `_InterfaceAreaVariable` object.

        :Parameters:
          - `distanceVar` : A `DistanceVariable` object.

        """
        CellVariable.__init__(self, distanceVar.mesh, hasOld=False)
        self.distanceVar = self._requires(distanceVar)
예제 #9
0
    def __init__(self, distanceVar):
        """
        Creates an `_InterfaceFlagVariable` object.

        :Parameters:
          - `distanceVar` : A `DistanceVariable` object.

        """
        CellVariable.__init__(self, distanceVar.mesh, hasOld=False)
        self.distanceVar = self._requires(distanceVar)
 def __init__(self, distribution, dx = 1., nx = None, offset = 0.):
     r"""
     Produces a histogram of the values of the supplied distribution.
     
     :Parameters:
         
         - `distribution`: The collection of values to sample.
         - `dx`: the bin size
         - `nx`: the number of bins
         - `offset`: the position of the first bin
     """
     CellVariable.__init__(self, mesh = Grid1D(dx = dx, nx = nx) + (offset,))
     self.distribution = self._requires(distribution)
예제 #11
0
    def __init__(self, mesh, name = '', value = 0., unit = None, hasOld = 0):
        """
        Creates a `distanceVariable` object.

        :Parameters:
          - `mesh`: The mesh that defines the geometry of this variable.
          - `name`: The name of the variable.
	  - `value`: The initial value.
	  - `unit`: the physical units of the variable
          - `hasOld`: Whether the variable maintains an old value.

        """
        CellVariable.__init__(self, mesh, name = name, value = value, unit = unit, hasOld = hasOld)
        self._markStale()
예제 #12
0
    def __init__(self, mesh, name = '', value = 0., unit = None, hasOld = 0):
        """
        Creates a `distanceVariable` object.

        :Parameters:
          - `mesh`: The mesh that defines the geometry of this variable.
          - `name`: The name of the variable.
	  - `value`: The initial value.
	  - `unit`: the physical units of the variable
          - `hasOld`: Whether the variable maintains an old value.

        """
        CellVariable.__init__(self, mesh, name = name, value = value, unit = unit, hasOld = hasOld)
        self._markStale()
예제 #13
0
    def __init__(self, ionVar = None, distanceVar = None, depositionRate = None, metalIonMolarVolume = None):
        """
        Creates a `_MetalIonSourceVariable` object.

        :Parameters:
          - `ionVar` : The metal ion concentration.
          - `distanceVar` : A `DistanceVariable` object.
          - `depositionRate` : The deposition rate.
          - `metalIonMolarVolume` : Molar volume of the metal ions.
       
        """
        
        CellVariable.__init__(self, distanceVar.getMesh(), hasOld = 0)
        self.ionVar = self._requires(ionVar)
        self.distanceVar = self._requires(distanceVar)
        self.depositionRate = self._requires(depositionRate)
        self.metalIonMolarVolume = metalIonMolarVolume
예제 #14
0
    def __init__(self, distribution, dx=1., nx=None, offset=0.):
        r"""
        Produces a histogram of the values of the supplied distribution.

        Parameters
        ----------
        distribution : array_like or ~fipy.variables.Variable
            The collection of values to sample.
        dx : float
            The bin size
        nx : int
            The number of bins
        offset : float
            The position of the first bin
        """
        CellVariable.__init__(self, mesh=Grid1D(dx=dx, nx=nx) + (offset, ))
        self.distribution = self._requires(distribution)
예제 #15
0
    def __init__(self, mesh, name = '', value = 0., unit = None, hasOld = 0):
        """
        Creates a `distanceVariable` object.

        Parameters
        ----------
        mesh : ~fipy.meshes.mesh.Mesh
            The mesh that defines the geometry of this variable.
        name : str
            The name of the variable.
        value : float or array_like
            The initial value.
        unit : str or ~fipy.tools.dimensions.physicalField.PhysicalUnit
            The physical units of the variable
        hasOld : bool
            Whether the variable maintains an old value.

        """
        CellVariable.__init__(self, mesh, name = name, value = value, unit = unit, hasOld = hasOld)
        self._markStale()
 def __init__(self, var, name = ''):
     CellVariable.__init__(self, mesh=var.getMesh(), name=name, rank=var.getRank() + 1)
     self.var = self._requires(var)
예제 #17
0
 def __init__(self, modVar):
     CellVariable.__init__(self, mesh = modVar.getMesh())
     self.modVar = self._requires(modVar)
예제 #18
0
 def __init__(self, modVar):
     CellVariable.__init__(self, mesh=modVar.mesh)
     self.modVar = self._requires(modVar)
 def __init__(self, rateConstant = None, distanceVar = None):
     CellVariable.__init__(self, mesh = distanceVar.getMesh())
     self.distanceVar = self._requires(distanceVar)
     self.rateConstant = rateConstant
예제 #20
0
 def __init__(self, var, name=''):
     CellVariable.__init__(self, mesh=var.mesh, name=name, elementshape=(var.mesh.dim,) + var.shape[:-1])
     self.var = self._requires(var)
     self.faceGradientContributions = _FaceGradContributions(self.var)
예제 #21
0
    def __init__(self, faceVariable, mesh = None):
        if not mesh:
            mesh = faceVariable.mesh

        CellVariable.__init__(self, mesh, hasOld = 0, elementshape=faceVariable.shape[:-1])
        self.faceVariable = self._requires(faceVariable)
예제 #22
0
 def __init__(self, var, name = ''):
     CellVariable.__init__(self, mesh=var.mesh, name=name, rank=var.rank + 1)
     self.var = self._requires(var)
예제 #23
0
 def __init__(self, surfactantVar):
     CellVariable.__init__(self, name = surfactantVar.name + "_interface", mesh = surfactantVar.mesh)
     self.surfactantVar = self._requires(surfactantVar)
예제 #24
0
    def __init__(self, mesh, name='', hasOld=0):
        if self.__class__ is NoiseVariable:
            raise NotImplementedError, "can't instantiate abstract base class"

        CellVariable.__init__(self, mesh=mesh, name=name, hasOld=hasOld)
        self.scramble()
예제 #25
0
파일: inputGold.py 프로젝트: ghorn/Eg
 def __init__(self, var = None, name = ''):
     CellVariable.__init__(self, mesh = mesh.getFineMesh(), name = name)
     self.var = self._requires(var)
예제 #26
0
파일: noiseVariable.py 프로젝트: regmi/fipy
 def __init__(self, mesh, name = '', hasOld = 0):
     if self.__class__ is NoiseVariable:
         raise NotImplementedError, "can't instantiate abstract base class"
         
     CellVariable.__init__(self, mesh = mesh, name = name, hasOld = hasOld)
     self.scramble()
예제 #27
0
 def __init__(self, surfactantVar):
     CellVariable.__init__(self,
                           name=surfactantVar.name + "_interface",
                           mesh=surfactantVar.mesh)
     self.surfactantVar = self._requires(surfactantVar)
예제 #28
0
 def __init__(self, var, name=""):
     CellVariable.__init__(self, mesh=var.mesh, name=name, rank=var.rank + 1)
     self.var = self._requires(var)
예제 #29
0
    def __init__(self,
                 value=0.,
                 distanceVar=None,
                 name='surfactant variable',
                 hasOld=False):
        """

        A simple 1D test:

        >>> from fipy.meshes import Grid1D
        >>> mesh = Grid1D(dx = 1., nx = 4)
        >>> from fipy.variables.distanceVariable import DistanceVariable
        >>> distanceVariable = DistanceVariable(mesh = mesh,
        ...                                     value = (-1.5, -0.5, 0.5, 941.5))
        >>> surfactantVariable = SurfactantVariable(value = 1,
        ...                                         distanceVar = distanceVariable)
        >>> print(numerix.allclose(surfactantVariable, (0, 0., 1., 0)))
        1

        A 2D test case:

        >>> from fipy.meshes import Grid2D
        >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3)
        >>> distanceVariable = DistanceVariable(mesh = mesh,
        ...                                     value = (1.5, 0.5, 1.5,
        ...                                              0.5, -0.5, 0.5,
        ...                                              1.5, 0.5, 1.5))
        >>> surfactantVariable = SurfactantVariable(value = 1,
        ...                                         distanceVar = distanceVariable)
        >>> print(numerix.allclose(surfactantVariable, (0, 1, 0, 1, 0, 1, 0, 1, 0)))
        1

        Another 2D test case:

        >>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2)
        >>> distanceVariable = DistanceVariable(mesh = mesh,
        ...                                     value = (-0.5, 0.5, 0.5, 1.5))
        >>> surfactantVariable = SurfactantVariable(value = 1,
        ...                                         distanceVar = distanceVariable)
        >>> print(numerix.allclose(surfactantVariable,
        ...                  (0, numerix.sqrt(2), numerix.sqrt(2), 0)))
        1

        :Parameters:
          - `value`: The initial value.
          - `distanceVar`: A `DistanceVariable` object.
          - `name`: The name of the variable.

        """

        CellVariable.__init__(self,
                              mesh=distanceVar.mesh,
                              name=name,
                              hasOld=False)

        self.distanceVar = self._requires(distanceVar)
        self._value = numerix.array(
            distanceVar.cellInterfaceAreas) * value / self.mesh.cellVolumes

        if hasOld:
            self._old = self.copy()
        else:
            self._old = None

        self.interfaceSurfactantVariable = None
예제 #30
0
파일: inputGold.py 프로젝트: ghorn/Eg
 def __init__(self, var=None, name=''):
     CellVariable.__init__(self,
                           mesh=mesh.getFineMesh(),
                           name=name)
     self.var = self._requires(var)
예제 #31
0
 def __init__(self, var, name=""):
     CellVariable.__init__(self, mesh=var.getMesh(), name=name, rank=var.getRank() + 1)
     self.var = self._requires(var)
     self.faceGradientContributions = _FaceGradContributions(self.var)
예제 #32
0
 def __init__(self, distanceVar, vars = ()):
     CellVariable.__init__(self, mesh = distanceVar.getMesh())
     self.vars = vars
     for var in self.vars:
         self._requires(var)
     self.distanceVar = self._requires(distanceVar)