Exemplo n.º 1
0
    def _faceCenters(self):

        XYcen = numerix.zeros((3, self.nx, self.ny, self.nz + 1), 'd')
        indices = numerix.indices((self.nx, self.ny, self.nz + 1))
        XYcen[0] = (indices[0] + 0.5) * self.dx
        XYcen[1] = (indices[1] + 0.5) * self.dy
        XYcen[2] = indices[2] * self.dz

        XZcen = numerix.zeros((3, self.nx, self.ny + 1, self.nz), 'd')
        indices = numerix.indices((self.nx, self.ny + 1, self.nz))
        XZcen[0] = (indices[0] + 0.5) * self.dx
        XZcen[1] = indices[1] * self.dy
        XZcen[2] = (indices[2] + 0.5) * self.dz

        YZcen = numerix.zeros((3, self.nx + 1, self.ny, self.nz), 'd')
        indices = numerix.indices((self.nx + 1, self.ny, self.nz))
        YZcen[0] = indices[0] * self.dx
        YZcen[1] = (indices[1] + 0.5) * self.dy
        YZcen[2] = (indices[2] + 0.5) * self.dz

        return numerix.concatenate(
            (numerix.reshape(XYcen.swapaxes(1, 3), (3, self.numberOfXYFaces)),
             numerix.reshape(XZcen.swapaxes(1, 3), (3, self.numberOfXZFaces)),
             numerix.reshape(YZcen.swapaxes(1, 3), (3, self.numberOfYZFaces))),
            axis=1) + self.origin
Exemplo n.º 2
0
        def _adjacentCellIDs(self):
            Hids = numerix.zeros((self.numberOfHorizontalRows, self.nx, 2),
                                 'l')
            indices = numerix.indices((self.numberOfHorizontalRows, self.nx))

            Hids[..., 1] = indices[1] + indices[0] * self.nx
            Hids[..., 0] = Hids[..., 1] - self.nx

            if self.numberOfHorizontalRows > 0:
                Hids[0, ..., 0] = Hids[0, ..., 1]
                Hids[0, ..., 1] = Hids[0, ..., 0]
                Hids[-1, ..., 1] = Hids[-1, ..., 0]

            Vids = numerix.zeros((self.ny, self.numberOfVerticalColumns, 2),
                                 'l')
            indices = numerix.indices((self.ny, self.numberOfVerticalColumns))
            Vids[..., 1] = indices[1] + indices[0] * self.nx
            Vids[..., 0] = Vids[..., 1] - 1

            if self.numberOfVerticalColumns > 0:
                Vids[..., 0, 0] = Vids[..., 0, 1]
                Vids[..., 0, 1] = Vids[..., 0, 0]
                Vids[..., -1, 1] = Vids[..., -1, 0]

            faceCellIDs = numerix.concatenate(
                (numerix.reshape(Hids, (self.numberOfHorizontalFaces, 2)),
                 numerix.reshape(
                     Vids,
                     (self.numberOfFaces - self.numberOfHorizontalFaces, 2))))

            return (faceCellIDs[:, 0], faceCellIDs[:, 1])
Exemplo n.º 3
0
        def faceCellIDs(self):
            Hids = numerix.zeros((2, self.nx, self.numberOfHorizontalRows),
                                 'l')
            indices = numerix.indices((self.nx, self.numberOfHorizontalRows))
            Hids[1] = indices[0] + indices[1] * self.nx
            Hids[0] = Hids[1] - self.nx
            if self.numberOfHorizontalRows > 0:
                Hids[0, ..., 0] = Hids[1, ..., 0]
                Hids[1, ..., 0] = -1
                Hids[1, ..., -1] = -1

            Vids = numerix.zeros((2, self.numberOfVerticalColumns, self.ny),
                                 'l')
            indices = numerix.indices((self.numberOfVerticalColumns, self.ny))
            Vids[1] = indices[0] + indices[1] * self.nx
            Vids[0] = Vids[1] - 1
            if self.numberOfVerticalColumns > 0:
                Vids[0, 0] = Vids[1, 0]
                Vids[1, 0] = -1
                Vids[1, -1] = -1

            return MA.masked_values(numerix.concatenate(
                (Hids.reshape(
                    (2, self.numberOfHorizontalFaces), order="FORTRAN"),
                 Vids.reshape(
                     (2, self.numberOfFaces - self.numberOfHorizontalFaces),
                     order="FORTRAN")),
                axis=1),
                                    value=-1)
Exemplo n.º 4
0
        def _adjacentCellIDs(self):
            Hids = numerix.zeros((self.numberOfHorizontalRows, self.nx, 2), 'l')
            indices = numerix.indices((self.numberOfHorizontalRows, self.nx))

            Hids[..., 1] = indices[1] + indices[0] * self.nx
            Hids[..., 0] = Hids[..., 1] - self.nx

            if self.numberOfHorizontalRows > 0:
                Hids[0, ..., 0] = Hids[0, ..., 1]
                Hids[0, ..., 1] = Hids[0, ..., 0]
                Hids[-1, ..., 1] = Hids[-1, ..., 0]

            Vids = numerix.zeros((self.ny, self.numberOfVerticalColumns, 2), 'l')
            indices = numerix.indices((self.ny, self.numberOfVerticalColumns))
            Vids[..., 1] = indices[1] + indices[0] * self.nx
            Vids[..., 0] = Vids[..., 1] - 1

            if self.numberOfVerticalColumns > 0:
                Vids[..., 0, 0] = Vids[..., 0, 1]
                Vids[..., 0, 1] = Vids[..., 0, 0]
                Vids[..., -1, 1] = Vids[..., -1, 0]

            faceCellIDs =  numerix.concatenate((numerix.reshape(Hids, (self.numberOfHorizontalFaces, 2)),
                                                numerix.reshape(Vids, (self.numberOfFaces - self.numberOfHorizontalFaces, 2))))

            return (faceCellIDs[:, 0], faceCellIDs[:, 1])
Exemplo n.º 5
0
    def faceCellIDs(self):
        XYids = MA.zeros((2, self.nx, self.ny, self.nz + 1), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz + 1))
        XYids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx
        XYids[0] = XYids[1] - self.nx * self.ny
        XYids[0,..., 0] = XYids[1,..., 0]
        XYids[1,..., 0] = MA.masked
        XYids[1,...,-1] = MA.masked

        XZids = MA.zeros((2, self.nx, self.ny + 1, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny + 1, self.nz))
        XZids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx
        XZids[0] = XZids[1] - self.nx
        XZids[0, :, 0, :] = XZids[1, :, 0, :]
        XZids[1, :, 0, :] = MA.masked
        XZids[1, :,-1, :] = MA.masked

        YZids = MA.zeros((2, self.nx + 1, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx + 1, self.ny, self.nz))
        YZids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx
        YZids[0] = YZids[1] - 1
        YZids[0, 0] = YZids[1, 0]
        YZids[1, 0] = MA.masked
        YZids[1,-1] = MA.masked

        return MA.concatenate((XYids.swapaxes(1,3).reshape((2, self.numberOfXYFaces)),
                               XZids.swapaxes(1,3).reshape((2, self.numberOfXZFaces)),
                               YZids.swapaxes(1,3).reshape((2, self.numberOfYZFaces))), axis=1)
Exemplo n.º 6
0
    def faceCellIDs(self):
        XYids = MA.zeros((2, self.nx, self.ny, self.nz + 1), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz + 1))
        XYids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx
        XYids[0] = XYids[1] - self.nx * self.ny
        XYids[0, ..., 0] = XYids[1, ..., 0]
        XYids[1, ..., 0] = MA.masked
        XYids[1, ..., -1] = MA.masked

        XZids = MA.zeros((2, self.nx, self.ny + 1, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny + 1, self.nz))
        XZids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx
        XZids[0] = XZids[1] - self.nx
        XZids[0,:, 0,:] = XZids[1,:, 0,:]
        XZids[1,:, 0,:] = MA.masked
        XZids[1,:, -1,:] = MA.masked

        YZids = MA.zeros((2, self.nx + 1, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx + 1, self.ny, self.nz))
        YZids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx
        YZids[0] = YZids[1] - 1
        YZids[0, 0] = YZids[1, 0]
        YZids[1, 0] = MA.masked
        YZids[1, -1] = MA.masked

        return MA.concatenate((XYids.swapaxes(1, 3).reshape((2, self.numberOfXYFaces)),
                               XZids.swapaxes(1, 3).reshape((2, self.numberOfXZFaces)),
                               YZids.swapaxes(1, 3).reshape((2, self.numberOfYZFaces))), axis=1)
Exemplo n.º 7
0
 def getFaceCenters(self):
     Hcen = numerix.zeros((2, self.nx, self.numberOfHorizontalRows), 'd')
     indices = numerix.indices((self.nx, self.numberOfHorizontalRows))
     Hcen[0,...] = (indices[0] + 0.5) * self.dx
     Hcen[1,...] = indices[1] * self.dy
     
     Vcen = numerix.zeros((2, self.numberOfVerticalColumns, self.ny), 'd')
     indices = numerix.indices((self.numberOfVerticalColumns, self.ny))
     Vcen[0,...] = indices[0] * self.dx
     Vcen[1,...] = (indices[1] + 0.5) * self.dy
     
     return numerix.concatenate((Hcen.reshape((2, self.numberOfHorizontalFaces), order="FORTRAN"),
                                 Vcen.reshape((2, self.numberOfVerticalFaces), order="FORTRAN")), axis=1) + self.origin
Exemplo n.º 8
0
    def _getFaceVertexIDs(self):
        Hids = numerix.zeros((2, self.nx, self.numberOfHorizontalRows))
        indices = numerix.indices((self.nx, self.numberOfHorizontalRows))
        Hids[0] = indices[0] + indices[1] * self.numberOfVerticalColumns
        Hids[1] = Hids[0] + 1

        Vids = numerix.zeros((2, self.numberOfVerticalColumns, self.ny))
        indices = numerix.indices((self.numberOfVerticalColumns, self.ny))
        Vids[0] = indices[0] + indices[1] * self.numberOfVerticalColumns
        Vids[1] = Vids[0] + self.numberOfVerticalColumns
        
        return numerix.concatenate((Hids.reshape((2, self.numberOfHorizontalFaces), order="FORTRAN"), 
                                    Vids.reshape((2, self.numberOfFaces - self.numberOfHorizontalFaces), order="FORTRAN")),
                                   axis=1)
Exemplo n.º 9
0
    def faceVertexIDs(self):
        Hids = numerix.zeros((2, self.nx, self.numberOfHorizontalRows), 'l')
        indices = numerix.indices((self.nx, self.numberOfHorizontalRows))
        Hids[0] = indices[0] + indices[1] * self.numberOfVerticalColumns
        Hids[1] = Hids[0] + 1

        Vids = numerix.zeros((2, self.numberOfVerticalColumns, self.ny), 'l')
        indices = numerix.indices((self.numberOfVerticalColumns, self.ny))
        Vids[0] = indices[0] + indices[1] * self.numberOfVerticalColumns
        Vids[1] = Vids[0] + self.numberOfVerticalColumns

        return numerix.concatenate((Hids.reshape((2, self.numberOfHorizontalFaces), order="FORTRAN"),
                                    Vids.reshape((2, self.numberOfFaces - self.numberOfHorizontalFaces),
                                                 order="FORTRAN")),
                                   axis=1)
Exemplo n.º 10
0
    def _faceCenters(self):
        Hcen = numerix.zeros((2, self.nx, self.numberOfHorizontalRows), 'd')
        indices = numerix.indices((self.nx, self.numberOfHorizontalRows))
        Hcen[0, ...] = (indices[0] + 0.5) * self.dx
        Hcen[1, ...] = indices[1] * self.dy

        Vcen = numerix.zeros((2, self.numberOfVerticalColumns, self.ny), 'd')
        indices = numerix.indices((self.numberOfVerticalColumns, self.ny))
        Vcen[0, ...] = indices[0] * self.dx
        Vcen[1, ...] = (indices[1] + 0.5) * self.dy

        return numerix.concatenate(
            (Hcen.reshape((2, self.numberOfHorizontalFaces), order="FORTRAN"),
             Vcen.reshape((2, self.numberOfVerticalFaces), order="FORTRAN")),
            axis=1) + self.origin
Exemplo n.º 11
0
 def _reshapeIDs(self, var, ids):
     shape = (self._vectorSize(var), self._vectorSize(var), ids.shape[-1])
     ids = numerix.resize(ids, shape)
     X, Y = numerix.indices(shape[:-1])
     X *= var.mesh.numberOfCells
     ids += X[..., numerix.newaxis]
     return ids
Exemplo n.º 12
0
 def _reshapeIDs(self, var, ids):
     shape = (self._vectorSize(var), self._vectorSize(var), ids.shape[-1])
     ids = numerix.resize(ids, shape)
     X, Y =  numerix.indices(shape[:-1])
     X *= var.mesh.numberOfCells
     ids += X[...,numerix.newaxis]
     return ids
Exemplo n.º 13
0
 def _cellCenters(self):
     centers = numerix.zeros((2, self.nx, self.ny), 'd')
     indices = numerix.indices((self.nx, self.ny))
     centers[0] = (indices[0] + 0.5) * self.dx
     centers[1] = (indices[1] + 0.5) * self.dy
     ccs = centers.reshape((2, self.numberOfCells),
                            order="FORTRAN") + self.origin
     return ccs
Exemplo n.º 14
0
 def _cellCenters(self):
     centers = numerix.zeros((2, self.nx, self.ny), 'd')
     indices = numerix.indices((self.nx, self.ny))
     centers[0] = (indices[0] + 0.5) * self.dx
     centers[1] = (indices[1] + 0.5) * self.dy
     ccs = centers.reshape(
         (2, self.numberOfCells), order="FORTRAN") + self.origin
     return ccs
Exemplo n.º 15
0
 def _cellCenters(self):
     centers = numerix.zeros((3, self.nx, self.ny, self.nz), 'd')
     indices = numerix.indices((self.nx, self.ny, self.nz))
     centers[0] = (indices[0] + 0.5) * self.dx
     centers[1] = (indices[1] + 0.5) * self.dy
     centers[2] = (indices[2] + 0.5) * self.dz
     ccs = numerix.reshape(centers.swapaxes(1, 3), (3, self.numberOfCells)) + self.origin
     return ccs
Exemplo n.º 16
0
 def _cellCenters(self):
     centers = numerix.zeros((3, self.nx, self.ny, self.nz), 'd')
     indices = numerix.indices((self.nx, self.ny, self.nz))
     centers[0] = (indices[0] + 0.5) * self.dx
     centers[1] = (indices[1] + 0.5) * self.dy
     centers[2] = (indices[2] + 0.5) * self.dz
     ccs = numerix.reshape(centers.swapaxes(1,3), (3, self.numberOfCells)) + self.origin
     return ccs
Exemplo n.º 17
0
 def _getCellVertexIDs(self):
     ids = numerix.zeros((4, self.nx, self.ny))
     indices = numerix.indices((self.nx, self.ny))
     ids[1] = indices[0] + (indices[1] + 1) * self.numberOfVerticalColumns
     ids[0] = ids[1] + 1
     ids[3] = indices[0] + indices[1] * self.numberOfVerticalColumns
     ids[2] = ids[3] + 1
     
     return numerix.reshape(ids, (4, self.numberOfCells))
Exemplo n.º 18
0
 def _getOrderedCellVertexIDs(self):
     ids = numerix.zeros((4, self.nx, self.ny))
     indices = numerix.indices((self.nx, self.ny))
     ids[2] = indices[0] + (indices[1] + 1) * self.numberOfVerticalColumns
     ids[1] = ids[2] + 1
     ids[3] = indices[0] + indices[1] * self.numberOfVerticalColumns
     ids[0] = ids[3] + 1
     
     return ids.reshape((4, self.numberOfCells), order="FORTRAN")
Exemplo n.º 19
0
    def _calcOrderedCellVertexIDs(self):
        """Correct ordering for VTK_PIXEL"""
        ids = numerix.zeros((4, self.nx, self.ny), 'l')
        indices = numerix.indices((self.nx, self.ny))
        ids[2] = indices[0] + (indices[1] + 1) * self.numberOfVerticalColumns
        ids[1] = ids[2] + 1
        ids[3] = indices[0] + indices[1] * self.numberOfVerticalColumns
        ids[0] = ids[3] + 1

        return ids.reshape((4, self.numberOfCells), order="FORTRAN")
Exemplo n.º 20
0
    def _calcOrderedCellVertexIDs(self):
        """Correct ordering for VTK_PIXEL"""
        ids = numerix.zeros((4, self.nx, self.ny), 'l')
        indices = numerix.indices((self.nx, self.ny))
        ids[2] = indices[0] + (indices[1] + 1) * self.numberOfVerticalColumns
        ids[1] = ids[2] + 1
        ids[3] = indices[0] + indices[1] * self.numberOfVerticalColumns
        ids[0] = ids[3] + 1

        return ids.reshape((4, self.numberOfCells), order="FORTRAN")
Exemplo n.º 21
0
        def faceCellIDs(self):
            Hids = numerix.zeros((2, self.nx, self.numberOfHorizontalRows), 'l')
            indices = numerix.indices((self.nx, self.numberOfHorizontalRows))
            Hids[1] = indices[0] + indices[1] * self.nx
            Hids[0] = Hids[1] - self.nx
            if self.numberOfHorizontalRows > 0:
                Hids[0, ..., 0] = Hids[1, ..., 0]
                Hids[1, ..., 0] = -1
                Hids[1, ..., -1] = -1

            Vids = numerix.zeros((2, self.numberOfVerticalColumns, self.ny), 'l')
            indices = numerix.indices((self.numberOfVerticalColumns, self.ny))
            Vids[1] = indices[0] + indices[1] * self.nx
            Vids[0] = Vids[1] - 1
            if self.numberOfVerticalColumns > 0:
                Vids[0, 0] = Vids[1, 0]
                Vids[1, 0] = -1
                Vids[1, -1] = -1

            return MA.masked_values(numerix.concatenate((Hids.reshape((2, self.numberOfHorizontalFaces), order="FORTRAN"),
                                                         Vids.reshape((2, self.numberOfFaces - self.numberOfHorizontalFaces), order="FORTRAN")), axis=1), value = -1)
Exemplo n.º 22
0
    def _calcOrderedCellVertexIDs(self):
        """Correct ordering for VTK_VOXEL"""
        ids = numerix.zeros((8, self.nx, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz))
        ids[1] = indices[0] + (indices[1] + (indices[2] + 1) * (self.ny + 1) + 1) * (self.nx + 1)
        ids[0] = ids[1] + 1
        ids[3] = indices[0] + (indices[1] + (indices[2] + 1) * (self.ny + 1)) * (self.nx + 1)
        ids[2] = ids[3] + 1
        ids[5] = indices[0] + (indices[1] + indices[2] * (self.ny + 1) + 1) * (self.nx + 1)
        ids[4] = ids[5] + 1
        ids[7] = indices[0] + (indices[1] + indices[2] * (self.ny + 1)) * (self.nx + 1)
        ids[6] = ids[7] + 1

        return numerix.reshape(ids.swapaxes(1, 3), (8, self.numberOfCells))
Exemplo n.º 23
0
    def _calcOrderedCellVertexIDs(self):
        """Correct ordering for VTK_VOXEL"""
        ids = numerix.zeros((8, self.nx, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz))
        ids[1] = indices[0] + (indices[1] + (indices[2] + 1) * (self.ny + 1) + 1) * (self.nx + 1)
        ids[0] = ids[1] + 1
        ids[3] = indices[0] + (indices[1] + (indices[2] + 1) * (self.ny + 1)) * (self.nx + 1)
        ids[2] = ids[3] + 1
        ids[5] = indices[0] + (indices[1] + indices[2] * (self.ny + 1) + 1) * (self.nx + 1)
        ids[4] = ids[5] + 1
        ids[7] = indices[0] + (indices[1] + indices[2] * (self.ny + 1)) * (self.nx + 1)
        ids[6] = ids[7] + 1

        return numerix.reshape(ids.swapaxes(1,3), (8, self.numberOfCells))
Exemplo n.º 24
0
    def _faceCenters(self):

        XYcen = numerix.zeros((3, self.nx, self.ny, self.nz + 1), 'd')
        indices = numerix.indices((self.nx, self.ny, self.nz + 1))
        XYcen[0] = (indices[0] + 0.5) * self.dx
        XYcen[1] = (indices[1] + 0.5) * self.dy
        XYcen[2] = indices[2] * self.dz

        XZcen = numerix.zeros((3, self.nx, self.ny + 1, self.nz), 'd')
        indices = numerix.indices((self.nx, self.ny + 1, self.nz))
        XZcen[0] = (indices[0] + 0.5) * self.dx
        XZcen[1] = indices[1] * self.dy
        XZcen[2] = (indices[2] + 0.5) * self.dz

        YZcen = numerix.zeros((3, self.nx + 1, self.ny, self.nz), 'd')
        indices = numerix.indices((self.nx + 1, self.ny, self.nz))
        YZcen[0] = indices[0] * self.dx
        YZcen[1] = (indices[1] + 0.5) * self.dy
        YZcen[2] = (indices[2] + 0.5) * self.dz

        return numerix.concatenate((numerix.reshape(XYcen.swapaxes(1, 3), (3, self.numberOfXYFaces)),
                                    numerix.reshape(XZcen.swapaxes(1, 3), (3, self.numberOfXZFaces)),
                                    numerix.reshape(YZcen.swapaxes(1, 3), (3, self.numberOfYZFaces))), axis=1) + self.origin
Exemplo n.º 25
0
    def _cellToCellIDs(self):
        ids = MA.zeros((4, self.nx, self.ny), 'l')
        indices = numerix.indices((self.nx, self.ny))
        ids[0] = indices[0] + (indices[1] - 1) * self.nx
        ids[1] = (indices[0] + 1) + indices[1] * self.nx
        ids[2] = indices[0] + (indices[1] + 1) * self.nx
        ids[3] = (indices[0] - 1) + indices[1] * self.nx

        if self.ny > 0:
            ids[0, ..., 0] = MA.masked
            ids[2, ..., -1] = MA.masked
        if self.nx > 0:
            ids[1, -1, ...] = MA.masked
            ids[3, 0, ...] = MA.masked

        return MA.reshape(ids.swapaxes(1, 2), (4, self.numberOfCells))
Exemplo n.º 26
0
    def _cellToCellIDs(self):
        ids = MA.zeros((4, self.nx, self.ny), 'l')
        indices = numerix.indices((self.nx, self.ny))
        ids[0] = indices[0] + (indices[1] - 1) * self.nx
        ids[1] = (indices[0] + 1) + indices[1] * self.nx
        ids[2] = indices[0] + (indices[1] + 1) * self.nx
        ids[3] = (indices[0] - 1) + indices[1] * self.nx

        if self.ny > 0:
            ids[0, ..., 0] = MA.masked
            ids[2, ..., -1] = MA.masked
        if self.nx > 0:
            ids[1, -1, ...] = MA.masked
            ids[3, 0, ...] = MA.masked

        return MA.reshape(ids.swapaxes(1, 2), (4, self.numberOfCells))
Exemplo n.º 27
0
    def _cellToCellIDs(self):
        ids = MA.zeros((6, self.nx, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz))
        ids[0] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx - 1
        ids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx + 1
        ids[2] = indices[0] + (indices[1] + indices[2] * self.ny - self.nz) * self.nx
        ids[3] = indices[0] + (indices[1] + indices[2] * self.ny + self.nz) * self.nx
        ids[4] = indices[0] + (indices[1] + (indices[2] - 1) * self.ny) * self.nx
        ids[5] = indices[0] + (indices[1] + (indices[2] + 1) * self.ny) * self.nx
        
        ids[0, 0,    ...] = MA.masked
        ids[1,-1,    ...] = MA.masked
        ids[2,..., 0,...] = MA.masked
        ids[3,...,-1,...] = MA.masked
        ids[4,...,     0] = MA.masked
        ids[5,...,    -1] = MA.masked

        return MA.reshape(ids.swapaxes(1,3), (6, self.numberOfCells))
Exemplo n.º 28
0
    def _cellToCellIDs(self):
        ids = MA.zeros((6, self.nx, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz))
        nxy = self.nx * self.ny
        same = indices[0] + indices[1] * self.nx + indices[2] * nxy

        ids[0] = same - 1
        ids[1] = same + 1
        ids[2] = same - self.nx
        ids[3] = same + self.nx
        ids[4] = same - nxy
        ids[5] = same + nxy

        if self.nx > 0:
            ids[0, 0,  ...] = MA.masked
            ids[1, -1,  ...] = MA.masked
        if self.ny > 0:
            ids[2,:, 0,:] = MA.masked
            ids[3,:, -1,:] = MA.masked
        if self.nz > 0:
            ids[4, ...,  0] = MA.masked
            ids[5, ..., -1] = MA.masked

        return MA.reshape(ids.swapaxes(1, 3), (6, self.numberOfCells))
Exemplo n.º 29
0
    def _cellToCellIDs(self):
        ids = MA.zeros((6, self.nx, self.ny, self.nz), 'l')
        indices = numerix.indices((self.nx, self.ny, self.nz))
        nxy = self.nx * self.ny
        same = indices[0] + indices[1] * self.nx + indices[2] * nxy

        ids[0] = same - 1
        ids[1] = same + 1
        ids[2] = same - self.nx
        ids[3] = same + self.nx
        ids[4] = same - nxy
        ids[5] = same + nxy

        if self.nx > 0:
            ids[0, 0,  ...] = MA.masked
            ids[1,-1,  ...] = MA.masked
        if self.ny > 0:
            ids[2, :, 0, :] = MA.masked
            ids[3, :,-1, :] = MA.masked
        if self.nz > 0:
            ids[4, ...,  0] = MA.masked
            ids[5, ..., -1] = MA.masked

        return MA.reshape(ids.swapaxes(1,3), (6, self.numberOfCells))
Exemplo n.º 30
0
 def _cellIDsToLocalColIDs(self, IDs):
     M = self.numberOfVariables
     N = len(IDs)
     return (numerix.vstack([IDs] * M) + numerix.indices(
         (M, N))[0] * self.mesh.numberOfCells).flatten()
Exemplo n.º 31
0
 def getNumpyArray(self):
     shape = self._getShape()
     indices = numerix.indices(shape)
     numMatrix = self.take(indices[0].ravel(), indices[1].ravel())
     return numerix.reshape(numMatrix, shape)
Exemplo n.º 32
0
 def numpyArray(self):
     shape = self._shape
     indices = numerix.indices(shape)
     numMatrix = self.take(indices[0].ravel(), indices[1].ravel())
     return numerix.reshape(numMatrix, shape)
Exemplo n.º 33
0
 def _cellIDsToGlobalIDs(IDs, M, L):
     N = len(IDs)
     return (numerix.vstack([IDs] * M) + numerix.indices(
         (M, N))[0] * L).flatten()
Exemplo n.º 34
0
 def _cellIDsToGlobalColIDs(self, IDs):
     N = len(IDs)
     M = self.numberOfVariables
     return (numerix.vstack([IDs] * M) + numerix.indices(
         (M, N))[0] * self.mesh.globalNumberOfCells).flatten()