Exemplo n.º 1
0
    def precomp(self):
        """precompute jacobi iteration matrices"""
        #precompute merged metric operations
        D1P1 = util.dia_simple(self.geometry.D1P1)
        P0D2 = util.dia_simple(self.geometry.P0D2)
        D21 = self.topology.D21
        P10 = self.topology.P10
        L = util.coo_matrix(D21 * D1P1 * P10 * P0D2)
        od = L.row != L.col
        self.off_diagonal = util.csr_matrix(
            (L.data[od], (L.row[od], L.col[od])),
            shape=(self.topology.P0, self.topology.P0))

        self._laplace_d2 = util.csr_matrix(L)

        self.inverse_diagonal = 1.0 / (L.data[od==False][:, None])
Exemplo n.º 2
0
    def transfer_operators(self):
        """
        generate transfer operators for the given layer, assuming the given conventions
        interpolation is identity concatted with averaging matrix

        how to organize mg?
        maintain complex hierarchy? this is the only place we truely need it no?
        otoh, with geometry all required info is first available no?
        """
        vertex_vertex = util.coo_matrix( util.dia_simple(np.ones(self.P0)))
        edge_vertex   = util.coo_matrix( self.edge_mid)
        edge_vertex   = util.coo_shift( edge_vertex,self.P0, 0)

        self.interpolation = util.coo_append(vertex_vertex, edge_vertex)
        self.restriction   = self.interpolation.T
        #redution of operator
        self.weighting     = self.restriction * np.ones(self.P0+self.P1)
        self.interpolation_weighting     = self.interpolation * np.ones(self.P0)