コード例 #1
0
ファイル: pysparseMatrix.py プロジェクト: yuanyuansjtu/fipy
    def asTrilinosMeshMatrix(self):
        """Transforms a Pysparse matrix into a Trilinos matrix

        Maintains the Trilinos matrix as an attribute.

        Returns
        -------
        ~fipy.matrices.trilinosMatrix._TrilinosMatrix
        """
        A = self.matrix.copy()
        values, irow, jcol = A.find()

        if not hasattr(self, 'trilinosMatrix'):
            if A.shape[0] == 0:
                bandwidth = 0
            else:
                bandwidth = int(numerix.ceil(float(len(values)) / float(A.shape[0])))
            bandwidth = 1
            from fipy.matrices.trilinosMatrix import _TrilinosMeshMatrixKeepStencil
            tmp = _TrilinosMeshMatrixKeepStencil(mesh=self.mesh, bandwidth=bandwidth,
                                                 numberOfVariables=self.numberOfVariables,
                                                 numberOfEquations=self.numberOfEquations)
            self.trilinosMatrix = tmp

        self.trilinosMatrix.addAt(values, irow, jcol)
        self.trilinosMatrix.finalize()

        return self.trilinosMatrix
コード例 #2
0
ファイル: pysparseMatrix.py プロジェクト: usnistgov/fipy
    def asTrilinosMeshMatrix(self):
        """Transforms a pysparse matrix into a trilinos matrix and maintains the
        trilinos matrix as an attribute.

        :Returns:
          The trilinos matrix.

        """
        A = self.matrix.copy()
        values, irow, jcol = A.find()

        if not hasattr(self, 'trilinosMatrix'):
            if A.shape[0] == 0:
                bandwidth = 0
            else:
                bandwidth = int(numerix.ceil(float(len(values)) / float(A.shape[0])))
            bandwidth = 1
            from fipy.matrices.trilinosMatrix import _TrilinosMeshMatrixKeepStencil
            self.trilinosMatrix = _TrilinosMeshMatrixKeepStencil(mesh=self.mesh, bandwidth=bandwidth,
                                                                 numberOfVariables=self.numberOfVariables,
                                                                 numberOfEquations=self.numberOfEquations)

        self.trilinosMatrix.addAt(values, irow, jcol)
        self.trilinosMatrix.finalize()

        return self.trilinosMatrix