Exemplo n.º 1
0
 def __init__(self, N, a0, alfa, beta, quad="GL"):
     self.quad = quad
     self.shape = (N - 4, N - 4)
     SB = bases.ShenBiharmonicBasis(N, quad)
     self.S = inner_product((SB, 0), (SB, 4))
     self.B = inner_product((SB, 0), (SB, 0))
     self.A = inner_product((SB, 0), (SB, 2))
     self.a0 = a0
     self.alfa = alfa
     self.beta = beta
Exemplo n.º 2
0
    def __init__(self, N, a0, alfa, beta, quad="GL", solver="cython"):
        self.quad = quad
        self.solver = solver
        k = arange(N)
        SB = bases.ShenBiharmonicBasis(N, quad=quad)
        self.S = S = inner_product((SB, 0), (SB, 4))
        self.B = B = inner_product((SB, 0), (SB, 0))
        self.A = A = inner_product((SB, 0), (SB, 2))
        self.a0 = a0
        self.alfa = alfa
        self.beta = beta
        if not solver == "scipy":
            sii, siu, siuu = S[0], S[2], S[4]
            ail, aii, aiu = A[-2], A[0], A[2]
            bill, bil, bii, biu, biuu = B[-4], B[-2], B[0], B[2], B[4]
            M = sii[::2].shape[0]

        if hasattr(beta, "__len__"):
            Ny, Nz = beta.shape
            if solver == "scipy":
                self.Le = Le = []
                self.Lo = Lo = []
                #self.AA = []
                for i in range(Ny):
                    Lej = []
                    Loj = []
                    #AA = []
                    for j in range(Nz):
                        AA = a0*S.diags().toarray() + alfa[i, j]*A.diags().toarray() + beta[i, j]*B.diags().toarray()
                        Ae = AA[::2, ::2]
                        Ao = AA[1::2, 1::2]
                        Lej.append(lu_factor(Ae))
                        Loj.append(lu_factor(Ao))
                        #AA.append((a0*S + alfa*A + beta*B).diags('csr'))
                    Le.append(Lej)
                    Lo.append(Loj)
                    #self.AA.append(AA)
            else:
                self.u0 = zeros((2, M, Ny, Nz))
                self.u1 = zeros((2, M, Ny, Nz))
                self.u2 = zeros((2, M, Ny, Nz))
                self.l0 = zeros((2, M, Ny, Nz))
                self.l1 = zeros((2, M, Ny, Nz))
                self.ak = zeros((2, M, Ny, Nz))
                self.bk = zeros((2, M, Ny, Nz))
                LUsolve.LU_Biharmonic_3D_n(a0, alfa, beta, sii, siu, siuu, ail, aii, aiu, bill, bil, bii, biu, biuu, self.u0, self.u1, self.u2, self.l0, self.l1)
                LUsolve.Biharmonic_factor_pr_3D(self.ak, self.bk, self.l0, self.l1)

        else:
            if solver == "scipy":
                #AA = a0*S.diags().toarray() + alfa*A.diags().toarray() + beta*B.diags().toarray()
                #Ae = AA[::2, ::2]
                #Ao = AA[1::2, 1::2]
                #self.Le = lu_factor(Ae)
                #self.Lo = lu_factor(Ao)
                self.AA = (a0*S + alfa*A + beta*B).diags('csr')
            else:
                self.u0 = zeros((2, M))
                self.u1 = zeros((2, M))
                self.u2 = zeros((2, M))
                self.l0 = zeros((2, M))
                self.l1 = zeros((2, M))
                self.ak = zeros((2, M))
                self.bk = zeros((2, M))
                LUsolve.LU_Biharmonic_1D(a0, alfa, beta, sii, siu, siuu, ail, aii, aiu, bill, bil, bii, biu, biuu, self.u0, self.u1, self.u2, self.l0, self.l1)
                LUsolve.Biharmonic_factor_pr(self.ak, self.bk, self.l0, self.l1)