当前位置: 首页>>代码示例>>Python>>正文


Python MA.where方法代码示例

本文整理汇总了Python中fipy.tools.numerix.MA.where方法的典型用法代码示例。如果您正苦于以下问题:Python MA.where方法的具体用法?Python MA.where怎么用?Python MA.where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fipy.tools.numerix.MA的用法示例。


在下文中一共展示了MA.where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _cellInterfaceNormals

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _cellInterfaceNormals(self):
        """
        
        Returns the interface normals over the cells.

           >>> from fipy.meshes import Grid2D
           >>> from fipy.variables.cellVariable import CellVariable
           >>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2)
           >>> distanceVariable = DistanceVariable(mesh = mesh, 
           ...                                     value = (-0.5, 0.5, 0.5, 1.5))
           >>> v = 1 / numerix.sqrt(2)
           >>> answer = CellVariable(mesh=mesh,
           ...                       value=(((0, 0, v, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, v, 0, 0)),
           ...                              ((0, 0, v, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, v, 0, 0))))
           >>> print numerix.allclose(distanceVariable._cellInterfaceNormals, answer)
           True
           
        """

        dim = self.mesh.dim

        valueOverFaces = numerix.repeat(self._cellValueOverFaces[numerix.newaxis, ...], dim, axis=0)
        cellFaceIDs = self.mesh.cellFaceIDs
        if cellFaceIDs.shape[-1] > 0:
            interfaceNormals = self._interfaceNormals[...,cellFaceIDs]
        else:
            interfaceNormals = 0

        return MA.where(valueOverFaces < 0, 0, interfaceNormals)
开发者ID:LWhitson2,项目名称:fipy,代码行数:37,代码来源:distanceVariable.py

示例2: deleteIslands

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def deleteIslands(self):
     cellToCellIDs = self.mesh._cellToCellIDs
     adjVals = numerix.take(self.value, cellToCellIDs)
     adjInterfaceValues = MA.masked_array(adjVals, mask = (adjVals * self.value) > 0)
     masksum = numerix.sum(numerix.logical_not(MA.getmask(adjInterfaceValues)), 0)
     tmp = MA.logical_and(masksum == 4, self.value > 0)
     self.value = numerix.array(MA.where(tmp, -1, self.value))
开发者ID:wd15,项目名称:extremefill2D,代码行数:9,代码来源:variables.py

示例3: _buildMatrix

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _buildMatrix(self, var, SparseMatrix, boundaryConditions=(), dt=None, equation=None, transientGeomCoeff=None, diffusionGeomCoeff=None):

        oldArray = var.old

        mesh = var.mesh
        NCells = mesh.numberOfCells
        NCellFaces = mesh._maxFacesPerCell

        cellValues = numerix.repeat(oldArray[numerix.newaxis, ...], NCellFaces, axis = 0)

        cellIDs = numerix.repeat(numerix.arange(NCells)[numerix.newaxis, ...], NCellFaces, axis = 0)
        cellToCellIDs = mesh._cellToCellIDs

        if NCells > 0:
            cellToCellIDs = MA.where(MA.getmask(cellToCellIDs), cellIDs, cellToCellIDs)

            adjacentValues = numerix.take(oldArray, cellToCellIDs)

            differences = self._getDifferences(adjacentValues, cellValues, oldArray, cellToCellIDs, mesh)
            differences = MA.filled(differences, 0)

            minsq = numerix.sqrt(numerix.sum(numerix.minimum(differences, numerix.zeros((NCellFaces, NCells), 'l'))**2, axis=0))
            maxsq = numerix.sqrt(numerix.sum(numerix.maximum(differences, numerix.zeros((NCellFaces, NCells), 'l'))**2, axis=0))

            coeff = numerix.array(self._getGeomCoeff(var))

            coeffXdifferences = coeff * ((coeff > 0.) * minsq + (coeff < 0.) * maxsq)
        else:
            coeffXdifferences = 0.

        return (var, SparseMatrix(mesh=var.mesh), -coeffXdifferences * mesh.cellVolumes)
开发者ID:usnistgov,项目名称:fipy,代码行数:33,代码来源:firstOrderAdvectionTerm.py

示例4: _buildMatrix

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _buildMatrix(self, var, SparseMatrix, boundaryCondtions=(), dt=None, equation=None):

        oldArray = var.getOld()

        mesh = var.getMesh()
        NCells = mesh.getNumberOfCells()
        NCellFaces = mesh._getMaxFacesPerCell()

        cellValues = numerix.repeat(oldArray[numerix.newaxis, ...], NCellFaces, axis = 0)
        
        cellIDs = numerix.repeat(numerix.arange(NCells)[numerix.newaxis, ...], NCellFaces, axis = 0)
        cellToCellIDs = mesh._getCellToCellIDs()

        if NCells > 0:
            cellToCellIDs = MA.where(MA.getmask(cellToCellIDs), cellIDs, cellToCellIDs) 

            adjacentValues = numerix.take(oldArray, cellToCellIDs)

            differences = self._getDifferences(adjacentValues, cellValues, oldArray, cellToCellIDs, mesh)
            differences = MA.filled(differences, 0)
            
            minsq = numerix.sqrt(numerix.sum(numerix.minimum(differences, numerix.zeros((NCellFaces, NCells)))**2, axis=0))
            maxsq = numerix.sqrt(numerix.sum(numerix.maximum(differences, numerix.zeros((NCellFaces, NCells)))**2, axis=0))

            coeff = numerix.array(self._getGeomCoeff(mesh))

            coeffXdiffereneces = coeff * ((coeff > 0.) * minsq + (coeff < 0.) * maxsq)
        else:
            coeffXdiffereneces = 0.

        return (SparseMatrix(mesh=var.getMesh()), -coeffXdiffereneces * mesh.getCellVolumes())
开发者ID:calbaker,项目名称:FiPy-2.1.3,代码行数:33,代码来源:advectionTerm.py

示例5: _calcCellDistAndVec

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def _calcCellDistAndVec(self):
     tmp = numerix.take(self._cellCenters, self.faceCellIDs, axis=1)
     tmp = tmp[...,1,:] - tmp[...,0,:]
     tmp = MA.filled(MA.where(MA.getmaskarray(tmp), self._cellToFaceDistanceVectors[:,0], tmp))
     cellDistanceVectors = tmp
     cellDistances = MA.filled(MA.sqrt(MA.sum(tmp * tmp, 0)))
     return cellDistances, cellDistanceVectors
开发者ID:LWhitson2,项目名称:fipy,代码行数:9,代码来源:mesh.py

示例6: _calcOrderedCellVertexIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _calcOrderedCellVertexIDs(self):
        from fipy.tools.numerix import take
        NFac = self._maxFacesPerCell

        # numpy 1.1's MA.take doesn't like FlatIter. Call ravel() instead.
        cellVertexIDs0 = take(self.faceVertexIDs[0], self.cellFaceIDs.ravel())
        cellVertexIDs1 = take(self.faceVertexIDs[1], self.cellFaceIDs.ravel())
        cellVertexIDs = MA.where(self._cellToFaceOrientations.ravel() > 0,
                             cellVertexIDs0, cellVertexIDs1)

        cellVertexIDs = numerix.reshape(cellVertexIDs, (NFac, -1))
        return cellVertexIDs
开发者ID:LWhitson2,项目名称:fipy,代码行数:14,代码来源:mesh2D.py

示例7: _getCellInterfaceNormals

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _getCellInterfaceNormals(self):
        """
        
        Returns the interface normals over the cells.

           >>> from fipy.meshes.grid2D import Grid2D
           >>> from fipy.variables.cellVariable import CellVariable
           >>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2)
           >>> distanceVariable = DistanceVariable(mesh = mesh, 
           ...                                     value = (-0.5, 0.5, 0.5, 1.5))
           >>> v = 1 / numerix.sqrt(2)
           >>> answer = CellVariable(mesh=mesh,
           ...                       value=(((0, 0, v, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, v, 0, 0)),
           ...                              ((0, 0, v, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, 0, 0, 0),
           ...                               (0, v, 0, 0))))
           >>> print numerix.allclose(distanceVariable._getCellInterfaceNormals(), answer)
           True
           
        """

        N = self.mesh.getNumberOfCells()
        M = self.mesh._getMaxFacesPerCell()
        dim = self.mesh.getDim()

        valueOverFaces = numerix.repeat(self._getCellValueOverFaces()[numerix.newaxis, ...], dim, axis=0)
        if self.cellFaceIDs.shape[-1] > 0:
            interfaceNormals = self._getInterfaceNormals()[...,self.cellFaceIDs]
        else:
            interfaceNormals = 0
        from fipy.tools.numerix import MA
        return MA.where(valueOverFaces < 0, 0, interfaceNormals)
开发者ID:regmi,项目名称:fipy,代码行数:38,代码来源:distanceVariable.py

示例8: _cellToCellIDsFilled

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def _cellToCellIDsFilled(self):
     N = self.numberOfCells
     M = self._maxFacesPerCell
     cellIDs = numerix.repeat(numerix.arange(N)[numerix.newaxis, ...], M, axis=0)
     cellToCellIDs = self._cellToCellIDs
     return MA.where(MA.getmaskarray(cellToCellIDs), cellIDs, cellToCellIDs)
开发者ID:usnistgov,项目名称:fipy,代码行数:8,代码来源:uniformGrid3D.py

示例9: _adjacentCellIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def _adjacentCellIDs(self):
     faceCellIDs = self.faceCellIDs
     return (MA.where(MA.getmaskarray(faceCellIDs[0]), faceCellIDs[1], faceCellIDs[0]).filled(),
             MA.where(MA.getmaskarray(faceCellIDs[1]), faceCellIDs[0], faceCellIDs[1]).filled())
开发者ID:usnistgov,项目名称:fipy,代码行数:6,代码来源:uniformGrid3D.py

示例10: _calcCellToCellIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def _calcCellToCellIDs(self):    
     cellToCellIDs = numerix.take(self.faceCellIDs, self.cellFaceIDs, axis=1)
     cellToCellIDs = MA.where(self._cellToFaceOrientations == 1, 
                              cellToCellIDs[1], cellToCellIDs[0])
     return cellToCellIDs 
开发者ID:LWhitson2,项目名称:fipy,代码行数:7,代码来源:mesh.py

示例11: _calcAdjacentCellIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def _calcAdjacentCellIDs(self):
     return (MA.filled(self.faceCellIDs[0]), 
                       MA.filled(MA.where(MA.getmaskarray(self.faceCellIDs[1]), 
                           self.faceCellIDs[0], 
                                          self.faceCellIDs[1])))
开发者ID:LWhitson2,项目名称:fipy,代码行数:7,代码来源:mesh.py

示例12: _connectFaces

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _connectFaces(self, faces0, faces1):
        """
        
        Merge faces on the same mesh. This is used to create periodic
        meshes. The first list of faces, `faces1`, will be the faces
        that are used to add to the matrix diagonals. The faces in
        `faces2` will not be used. They aren't deleted but their
        adjacent cells are made to point at `faces1`. The list
        `faces2` are not altered, they still remain as members of
        exterior faces.

           >>> from fipy.meshes.numMesh.grid2D import Grid2D
           >>> mesh = Grid2D(nx = 2, ny = 2, dx = 1., dy = 1.)

           >>> from fipy.tools import parallel
           >>> print parallel.procID != 0 or (mesh._getCellFaceIDs() == [[0, 1, 2, 3],
           ...                                                           [7, 8, 10, 11],
           ...                                                           [2, 3, 4, 5],
           ...                                                           [6, 7, 9, 10]]).flatten().all()
           True

           >>> mesh._connectFaces(numerix.nonzero(mesh.getFacesLeft()), numerix.nonzero(mesh.getFacesRight()))

           >>> print parallel.procID != 0 or (mesh._getCellFaceIDs() == [[0, 1, 2, 3],
           ...                                                           [7, 6, 10, 9],
           ...                                                           [2, 3, 4, 5],
           ...                                                           [6, 7, 9, 10]]).flatten().all()
           True

        """

        ## check for errors

        ## check that faces are members of exterior faces
        from fipy.variables.faceVariable import FaceVariable
        faces = FaceVariable(mesh=self, value=False)
        faces[faces0] = True
        faces[faces1] = True
        assert (faces | self.getExteriorFaces() == self.getExteriorFaces()).all()

        ## following assert checks number of faces are equal, normals are opposite and areas are the same
        assert numerix.alltrue(numerix.take(self.areaProjections, faces0, axis=1) 
                               == numerix.take(-self.areaProjections, faces1, axis=1))

        ## extract the adjacent cells for both sets of faces
        faceCellIDs0 = self.faceCellIDs[0]
        faceCellIDs1 = self.faceCellIDs[1]
        ## set the new adjacent cells for `faces0`
        MA.put(faceCellIDs1, faces0, MA.take(faceCellIDs0, faces0))
        MA.put(faceCellIDs0, faces0, MA.take(faceCellIDs0, faces1))
        self.faceCellIDs[0] = faceCellIDs0
        self.faceCellIDs[1] = faceCellIDs1
        
        ## extract the face to cell distances for both sets of faces
        faceToCellDistances0 = self.faceToCellDistances[0]
        faceToCellDistances1 = self.faceToCellDistances[1]
        ## set the new faceToCellDistances for `faces0`
        MA.put(faceToCellDistances1, faces0, MA.take(faceToCellDistances0, faces0))
        MA.put(faceToCellDistances0, faces0, MA.take(faceToCellDistances0, faces1))
        self.faceToCellDistances[0] = faceToCellDistances0
        self.faceToCellDistances[1] = faceToCellDistances1

        ## calculate new cell distances and add them to faces0
        numerix.put(self.cellDistances, faces0, MA.take(faceToCellDistances0 + faceToCellDistances1, faces0))

        ## change the direction of the face normals for faces0
        for dim in range(self.getDim()):
            faceNormals = self.faceNormals[dim].copy()
            numerix.put(faceNormals, faces0, MA.take(faceNormals, faces1))
            self.faceNormals[dim] = faceNormals

        ## Cells that are adjacent to faces1 are changed to point at faces0
        ## get the cells adjacent to faces1
        faceCellIDs = MA.take(self.faceCellIDs[0], faces1)
        ## get all the adjacent faces for those particular cells
        cellFaceIDs = numerix.take(self.cellFaceIDs, faceCellIDs, axis=1)
        for i in range(cellFaceIDs.shape[0]):
            ## if the faces is a member of faces1 then change the face to point at
            ## faces0
            cellFaceIDs[i] = MA.where(cellFaceIDs[i] == faces1,
                                      faces0,
                                      cellFaceIDs[i])
            ## add those faces back to the main self.cellFaceIDs
            tmp = self.cellFaceIDs[i]
            numerix.put(tmp, faceCellIDs, cellFaceIDs[i])
            self.cellFaceIDs[i] = tmp

        ## calculate new topology
        _CommonMesh._calcTopology(self)

        ## calculate new geometry
        self._calcFaceToCellDistanceRatio()
        self._calcCellToCellDistances()
        self._calcScaledGeometry()
        self._calcFaceAspectRatios()
开发者ID:regmi,项目名称:fipy,代码行数:97,代码来源:mesh.py

示例13: _calcDistanceFunction

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _calcDistanceFunction(self, extensionVariable = None, narrowBandWidth = None, deleteIslands = False):

        if narrowBandWidth == None:
            narrowBandWidth = self.narrowBandWidth

        ## calculate interface values

        cellToCellIDs = self.mesh._getCellToCellIDs()

        if deleteIslands:
            adjVals = numerix.take(self.value, cellToCellIDs)
            adjInterfaceValues = MA.masked_array(adjVals, mask = (adjVals * self.value) > 0)
            masksum = numerix.sum(numerix.logical_not(MA.getmask(adjInterfaceValues)), 0)
            tmp = MA.logical_and(masksum == 4, self.value > 0)
            self.value = MA.where(tmp, -1, self.value)

        adjVals = numerix.take(self.value, cellToCellIDs)
        adjInterfaceValues = MA.masked_array(adjVals, mask = (adjVals * self.value) > 0)
        dAP = self.mesh._getCellToCellDistances()
        distances = abs(self.value * dAP / (self.value - adjInterfaceValues))
        indices = MA.argsort(distances, 0)
        sign = (self.value > 0) * 2 - 1

        s = distances[indices[0], numerix.arange(indices.shape[1])]

        if self.mesh.getDim() == 2:

            t = distances[indices[1], numerix.arange(indices.shape[1])]
            u = distances[indices[2], numerix.arange(indices.shape[1])]

            if indices.shape[1] > 0:
                ns = self.cellNormals[..., indices[0], numerix.arange(indices.shape[1])]
                nt = self.cellNormals[..., indices[1], numerix.arange(indices.shape[1])]
            else:
                ns = MA.zeros(self.cellNormals.shape[:-1] + (0,))
                nt = MA.zeros(self.cellNormals.shape[:-1] + (0,))

            signedDistance = MA.where(MA.getmask(s),
                                      self.value,
                                      MA.where(MA.getmask(t),
                                               sign * s,
                                               MA.where(abs(numerix.dot(ns,nt)) < 0.9,
                                                        sign * s * t / MA.sqrt(s**2 + t**2),
                                                        MA.where(MA.getmask(u),
                                                                 sign * s,
                                                                 sign * s * u / MA.sqrt(s**2 + u**2)
                                                                 )
                                                        )
                                               )
                                      )
        else:
            signedDistance = MA.where(MA.getmask(s),
                                      self.value,
                                      sign * s)
            

        self.value = signedDistance

        ## calculate interface flag
        masksum = numerix.sum(numerix.logical_not(MA.getmask(distances)), 0)
        interfaceFlag = (masksum > 0).astype('l')

        ## spread the extensionVariable to the whole interface
        flag = True
        if extensionVariable is None:
            extensionVariable = numerix.zeros(self.mesh.getNumberOfCells(), 'd')
            flag = False
            
        ext = numerix.zeros(self.mesh.getNumberOfCells(), 'd')

        positiveInterfaceFlag = numerix.where(self.value > 0, interfaceFlag, 0)
        negativeInterfaceIDs = numerix.nonzero(numerix.where(self.value < 0, interfaceFlag, 0))[0]

        for id in negativeInterfaceIDs:
            tmp, extensionVariable[...,id] = self._calcTrialValue(id, positiveInterfaceFlag, extensionVariable)

        if flag:
            self.value = self.tmpValue.copy()

        ## evaluate the trialIDs
        adjInterfaceFlag = numerix.take(interfaceFlag, cellToCellIDs)
        hasAdjInterface = (numerix.sum(MA.filled(adjInterfaceFlag, 0), 0) > 0).astype('l')

        trialFlag = numerix.logical_and(numerix.logical_not(interfaceFlag), hasAdjInterface).astype('l')

        trialIDs = list(numerix.nonzero(trialFlag)[0])
        evaluatedFlag = interfaceFlag


        for id in trialIDs:
            self.value[...,id], extensionVariable[id] = self._calcTrialValue(id, evaluatedFlag, extensionVariable)

        while len(trialIDs):

            id = trialIDs[numerix.argmin(abs(numerix.take(self.value, trialIDs)))]

            if abs(self.value[...,id]) > narrowBandWidth / 2:
                break

            trialIDs.remove(id)
#.........这里部分代码省略.........
开发者ID:regmi,项目名称:fipy,代码行数:103,代码来源:distanceVariable.py

示例14: _connectFaces

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
    def _connectFaces(self, faces0, faces1):
        """

        Merge faces on the same mesh. This is used to create periodic
        meshes. The first list of faces, `faces1`, will be the faces
        that are used to add to the matrix diagonals. The faces in
        `faces2` will not be used. They aren't deleted but their
        adjacent cells are made to point at `faces1`. The list
        `faces2` are not altered, they still remain as members of
        exterior faces.

           >>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D
           >>> mesh = NonUniformGrid2D(nx = 2, ny = 2, dx = 1., dy = 1.)

           >>> print((mesh.cellFaceIDs == [[0, 1, 2, 3],
           ...                             [7, 8, 10, 11],
           ...                             [2, 3, 4, 5],
           ...                             [6, 7, 9, 10]]).flatten().all()) # doctest: +PROCESSOR_0
           True

           >>> mesh._connectFaces(numerix.nonzero(mesh.facesLeft), numerix.nonzero(mesh.facesRight))

           >>> print((mesh.cellFaceIDs == [[0, 1, 2, 3],
           ...                             [7, 6, 10, 9],
           ...                             [2, 3, 4, 5],
           ...                             [6, 7, 9, 10]]).flatten().all()) # doctest: +PROCESSOR_0
           True

        """
        ## check for errors

        ## check that faces are members of exterior faces
        from fipy.variables.faceVariable import FaceVariable
        faces = FaceVariable(mesh=self, value=False)
        faces[faces0] = True
        faces[faces1] = True

        assert (faces | self.exteriorFaces == self.exteriorFaces).all()

        ## following assert checks number of faces are equal, normals are opposite and areas are the same
        assert numerix.allclose(numerix.take(self._areaProjections, faces0, axis=1),
                               numerix.take(-self._areaProjections, faces1, axis=1))

        ## extract the adjacent cells for both sets of faces
        faceCellIDs0 = self.faceCellIDs[0]
        faceCellIDs1 = self.faceCellIDs[1]
        ## set the new adjacent cells for `faces0`
        MA.put(faceCellIDs1, faces0, MA.take(faceCellIDs0, faces0))
        MA.put(faceCellIDs0, faces0, MA.take(faceCellIDs0, faces1))
        self.faceCellIDs[0] = faceCellIDs0
        self.faceCellIDs[1] = faceCellIDs1

        ## extract the face to cell distances for both sets of faces
        faceToCellDistances0 = self._faceToCellDistances[0]
        faceToCellDistances1 = self._faceToCellDistances[1]
        ## set the new faceToCellDistances for `faces0`
        MA.put(faceToCellDistances1, faces0, MA.take(faceToCellDistances0, faces0))
        MA.put(faceToCellDistances0, faces0, MA.take(faceToCellDistances0, faces1))

        self._faceToCellDistances[0] = faceToCellDistances0
        self._faceToCellDistances[1] = faceToCellDistances1

        ## calculate new cell distances and add them to faces0
        numerix.put(self._cellDistances, faces0, MA.take(faceToCellDistances0 + faceToCellDistances1, faces0))

        ## change the direction of the face normals for faces0
        for dim in range(self.dim):
            faceNormals = self.faceNormals[dim].copy()
            numerix.put(faceNormals, faces0, MA.take(faceNormals, faces1))
            self.faceNormals[dim] = faceNormals

        ## Cells that are adjacent to faces1 are changed to point at faces0
        ## get the cells adjacent to faces1
        faceCellIDs = MA.take(self.faceCellIDs[0], faces1)
        ## get all the adjacent faces for those particular cells
        cellFaceIDs = numerix.take(self.cellFaceIDs, faceCellIDs, axis=1)
        for i in range(cellFaceIDs.shape[0]):
            ## if the faces is a member of faces1 then change the face to point at
            ## faces0
            cellFaceIDs[i] = MA.where(cellFaceIDs[i] == faces1,
                                      faces0,
                                      cellFaceIDs[i])
            ## add those faces back to the main self.cellFaceIDs
            numerix.put(self.cellFaceIDs[i], faceCellIDs, cellFaceIDs[i])

        ## calculate new topology
        self._setTopology()

        ## calculate new geometry
        self._handleFaceConnection()

        self.scale = self.scale['length']
开发者ID:usnistgov,项目名称:fipy,代码行数:94,代码来源:abstractMesh.py

示例15: _calcCellToCellIDsFilled

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import where [as 别名]
 def _calcCellToCellIDsFilled(self):
     N = self.getNumberOfCells()
     M = self._getMaxFacesPerCell()
     cellIDs = numerix.repeat(numerix.arange(N)[numerix.newaxis, ...], M, axis=0)
     cellToCellIDs = self._getCellToCellIDs()
     self.cellToCellIDsFilled = MA.where(MA.getmaskarray(cellToCellIDs), cellIDs, cellToCellIDs)
开发者ID:regmi,项目名称:fipy,代码行数:8,代码来源:mesh.py


注:本文中的fipy.tools.numerix.MA.where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。