示例#1
0
    def apply(self, pc, x, y):

        br = x.getSubVector(self.r_is)
        xr = br.duplicate()
        self.kspCGScalar.solve(br, xr)

        x2 = x.getSubVector(self.p_is)
        print x2.size
        y2 = x2.duplicate()
        y3 = x2.duplicate()
        xp = x2.duplicate()

        self.kspA.solve(x2, y2)
        self.Fp.mult(y2, y3)
        self.kspQ.solve(y3, xp)

        bb = x.getSubVector(self.b_is)
        xb, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.A, bb, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)

        bu1 = x.getSubVector(self.u_is)
        bu2 = self.Bt * xp
        bu4 = self.Ct * xb
        xu = bu1.duplicate()
        self.kspF.solve(bu1 - bu2 - bu4, xu)

        y.array = (np.concatenate([xu.array, xb.array, xp.array, xr.array]))
示例#2
0
    def apply(self, pc, x, y):

        br = x.getSubVector(self.r_is)
        xr = br.duplicate()
        self.kspScalar.solve(br, xr)

        # print self.D.size
        x2 = x.getSubVector(self.p_is)
        y2 = x2.duplicate()
        y3 = x2.duplicate()
        xp = x2.duplicate()
        self.kspA.solve(x2,y2)
        self.Fp.mult(y2,y3)
        self.kspQ.solve(y3,xp)


        # self.kspF.solve(bu1-bu4-bu2,xu)

        bb = x.getSubVector(self.b_is)
        bb = bb - self.Dt*xr
        xb = bb.duplicate()
        #self.kspMX.solve(bb,xb)
        xb, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(self.AA, bb, self.kspScalar, self.kspVector, self.G, self.P, self.tol)

        bu1 = x.getSubVector(self.u_is)
        bu2 = self.Bt*xp
        XX = bu1.duplicate()
        xu = XX.duplicate()
        self.kspF.solve(bu1-bu2,xu)
        #self.kspF.solve(bu1,xu)

        y.array = (np.concatenate([xu.array, xb.array,xp.array,xr.array]))
示例#3
0
    def apply(self, pc, x, y):

        x1 = x.getSubVector(self.b_is)
        yy1 = x1.duplicate()
        x2 = x.getSubVector(self.r_is)
        yy2 = x2.duplicate()
        # tic()
        yy1, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.A, x1, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        # print "Hiptmair time: ", toc()
        self.HiptmairIts += its
        tic()
        self.kspCGScalar.solve(x2, yy2)
        self.CGtime = toc()

        x1 = x.getSubVector(self.u_is)
        y1 = x1.duplicate()
        y11 = x1.duplicate()
        y111 = x1.duplicate()

        x2 = x.getSubVector(self.p_is)
        y2 = x2.duplicate()
        y3 = x2.duplicate()
        y4 = x2.duplicate()

        self.kspA.solve(x2, y2)
        self.Fp.mult(y2, y3)
        self.kspQ.solve(y3, y4)
        self.Bt.mult(y4, y11)
        self.C.mult(yy1, y111)
        self.kspF.solve(x1 - y11 - y111, y1)

        y.array = (np.concatenate([y1.array, y4.array, yy1.array, yy2.array]))
示例#4
0
文件: MHDprec.py 项目: daveb-dev/UBC
    def apply(self, pc, x, y):

        bu = x.getSubVector(self.u_is)
        invF = bu.duplicate()

        bp = x.getSubVector(self.p_is)
        outP = bp.duplicate()

        bb = x.getSubVector(self.b_is)
        invMX = bb.duplicate()

        br = x.getSubVector(self.r_is)
        invL = br.duplicate()

        if self.Schur == "Exact":
            self.kspS.solve(bp, outP)
        else:
            outP = FluidSchur([self.kspA, self.Fp, self.kspQ], bp)
        invMX, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.AA, bb, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        self.kspScalar.solve(br, invL)

        xb1 = invMX.duplicate()
        xb2 = invMX.duplicate()
        xb3 = invMX.duplicate()
        xb4 = invMX.duplicate()
        self.D.multTranspose(invL, xb1)
        xb2, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.AA, xb1, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        outB = -invMX - xb2

        xr1 = invL.duplicate()
        outR = invL.duplicate()
        self.D.mult(-invMX, xr1)
        self.kspScalar(xr1, outR)

        xu1 = bu.duplicate()
        xu2 = bu.duplicate()
        outU = bu.duplicate()
        self.B.multTranspose(outP, xu1)
        self.C.multTranspose(outB, xu2)
        self.kspF.solve(bu + xu1 - xu2, outU)

        y.array = (np.concatenate(
            [outU.array, -outP.array, outB.array, outR.array]))
示例#5
0
    def apply(self, pc, x, y):

        br = x.getSubVector(self.r_is)
        xr = br.duplicate()
        self.kspCGScalar.solve(br, xr)

        # print self.D.size
        bp1 = self.Dt * xr
        bp2, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.A, bp1, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        bp3 = self.Ct * bp2
        bp4 = bp3.duplicate()
        self.kspF.solve(bp3, bp4)
        bp5 = -self.B * bp4
        x2 = x.getSubVector(self.p_is)
        y2 = x2.duplicate()
        y3 = x2.duplicate()
        xp = x2.duplicate()
        self.kspA.solve(x2 - bp5, y2)
        self.Fp.mult(y2, y3)
        self.kspQ.solve(y3, xp)

        bb = x.getSubVector(self.b_is)
        xb, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.A, bb - self.Dt * xr, self.kspScalar, self.kspVector, self.G,
            self.P, self.tol)

        bu1 = x.getSubVector(self.u_is)
        bu2 = self.Bt * xp
        bu3, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.A, xb, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        bu4 = self.Ct * xb
        bu5 = bu4.duplicate()
        self.kspF.solve(bu4, bu5)
        xu = bu5.duplicate()
        self.kspF.solve(bu1 - bu4 - bu2, xu)
        y.array = (np.concatenate([xu.array, xb.array, xp.array, xr.array]))
示例#6
0
文件: MHDprec.py 项目: daveb-dev/UBC
    def apply(self, pc, x, y):

        br = x.getSubVector(self.r_is)
        xr = br.duplicate()
        self.kspScalar.solve(br, xr)

        # print self.D.size
        x2 = x.getSubVector(self.p_is)
        y2 = x2.duplicate()
        y3 = x2.duplicate()
        xp = x2.duplicate()
        self.kspA.solve(x2, y2)
        self.Fp.mult(y2, y3)
        self.kspQ.solve(y3, xp)

        # self.kspF.solve(bu1-bu4-bu2,xu)

        bb = x.getSubVector(self.b_is)
        xb = bb.duplicate()
        #self.kspMX.solve(bb,xb)
        xxr = bb.duplicate()
        # self.Dt.multTranspose(xr,xxr)
        xb, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.AA, bb - xxr, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)

        bu1 = x.getSubVector(self.u_is)
        bu2 = bu1.duplicate()
        bu4 = bu1.duplicate()
        # if self.A.type == 'python':
        #     bu = assemble(self.Bt) + assemble(self.Ct)

        #     self.BC.apply(bu)
        #     bu = IO.arrayToVec(bu.array())

        #     bu = bu.getSubVector(self.u_is)
        # else:
        #     self.Bt.multTranspose(xp,bu2)
        #     self.Ct.multTranspose(xb,bu4)
        XX = bu1.duplicate()
        xu = XX.duplicate()
        self.kspF.solve(bu1 - bu2 - bu4, xu)
        #self.kspF.solve(bu1,xu)

        y.array = (np.concatenate([xu.array, -xp.array, xb.array, xr.array]))
示例#7
0
    def apply(self, pc, x, y):
        # self.kspCurlCurl.setOperators(self.B)
        x1 = x.getSubVector(self.u_is)
        y1 = x1.duplicate()
        x2 = x.getSubVector(self.p_is)
        y2 = x2.duplicate()

        # tic()
        y1, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(self.A, x1, self.kspScalar, self.kspVector, self.G, self.P, self.tol)
        # print "Hiptmair time: ", toc()
        self.HiptmairIts += its
        tic()
        self.kspCGScalar.solve(x2, y2)
        self.CGtime = toc()
        # print "Laplacian, its ", self.kspCGScalar.its, "  time ",  self.CGtime

        # print "CG time: ", toc()
        # print "Laplacian inner iterations: ", self.kspCGScalar.its
        y.array = (np.concatenate([y1.array, y2.array]))
        self.CGits += self.kspCGScalar.its
示例#8
0
文件: MHDprec.py 项目: daveb-dev/UBC
    def apply(self, pc, x, y):

        bu = x.getSubVector(self.u_is)
        invF = bu.duplicate()

        bp = x.getSubVector(self.p_is)
        invS = bp.duplicate()

        bb = x.getSubVector(self.b_is)
        invMX = bb.duplicate()

        br = x.getSubVector(self.r_is)
        invL = br.duplicate()

        self.kspF.solve(bu, invF)
        if self.Schur == "True":
            self.kspS.solve(bp, invS)
        else:
            invS = FluidSchur([self.kspA, self.Fp, self.kspQ], bp)
        invMX, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.AA, bb, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        self.kspScalar.solve(br, invL)

        xp1 = invS.duplicate()
        barF = invS.duplicate()
        self.B.mult(invF, xp1)

        if self.Schur == "True":
            self.kspS.solve(xp1, barF)
        else:
            barF = FluidSchur([self.kspA, self.Fp, self.kspQ], xp1)

        xu1 = invF.duplicate()
        barS = invF.duplicate()
        self.B.multTranspose(invS, xu1)
        self.kspF.solve(xu1, barS)

        # outR = (L(D*invMx));
        xr1 = invL.duplicate()
        outR = invL.duplicate()
        self.D.mult(invMX, xr1)
        self.kspScalar(xr1, outR)

        # outB = (Mx(C*barS) + invMx + Mx(D'*invL));
        xb1 = invMX.duplicate()
        xb2 = invMX.duplicate()
        xb3 = invMX.duplicate()
        xb4 = invMX.duplicate()
        self.G.mult(invL, xb2)
        self.C.mult(barS, xb3)
        xb4, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
            self.AA, xb3, self.kspScalar, self.kspVector, self.G, self.P,
            self.tol)
        outB = xb4 + invMX + xb2

        # outP = barF - invS - Schur(B*F(C'*invMx));
        xp1 = invF.duplicate()
        xp2 = invF.duplicate()
        xp3 = invS.duplicate()
        xp4 = invS.duplicate()
        self.C.multTranspose(invMX, xp1)
        self.kspF.solve(xp1, xp2)
        self.B.mult(xp2, xp3)

        if self.Schur == "True":
            self.kspS.solve(xp3, xp4)
        else:
            xp4 = FluidSchur([self.kspA, self.Fp, self.kspQ], xp3)

        outP = barF - invS - xp4

        # outU = invF - F(B'*barF) + barS;
        xu1 = invF.duplicate()
        xu2 = invF.duplicate()
        self.B.multTranspose(barF, xu1)
        self.kspF.solve(xu1, xu2)
        outU = invF - xu2 + barS

        y.array = (np.concatenate(
            [outU.array, outP.array, outB.array, outR.array]))
示例#9
0
文件: MHDprec.py 项目: daveb-dev/UBC
    def apply(self, pc, x, y):
        if self.Options == 'BT':
            b = x.getSubVector(self.b_is)
            Mxb = b.duplicate()
            # self.kspMX.solve(b,Mxb)
            Mxb, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
                self.AA, b, self.kspScalar, self.kspVector, self.G, self.P,
                self.tol)

            r = x.getSubVector(self.r_is)
            Lr = r.duplicate()
            self.kspScalar.solve(r, Lr)

            DL = b.duplicate()
            self.Dt.multTranspose(Lr, DL)
            K = b.duplicate()
            K, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
                self.AA, DL, self.kspScalar, self.kspVector, self.G, self.P,
                self.tol)

            DM = r.duplicate()
            self.Dt.mult(Mxb, DM)
            E = r.duplicate()
            self.kspScalar.solve(DM, E)

            p = x.getSubVector(self.p_is)
            Sp2 = p.duplicate()
            Sp3 = p.duplicate()
            Sp = p.duplicate()
            self.kspA.solve(p, Sp2)
            self.Fp.mult(Sp2, Sp3)
            self.kspQ.solve(Sp3, Sp)

            u = x.getSubVector(self.u_is)
            Fu = u.duplicate()
            Cb = u.duplicate()
            Bp = u.duplicate()
            self.Ct.multTranspose(Mxb, Cb)
            self.Bt.multTranspose(Sp, Bp)
            self.kspF.solve(u - Cb + Bp, Fu)

            y.array = (np.concatenate(
                [Fu.array, -Sp.array, Mxb.array + K.array, E.array]))
        else:
            u = x.getSubVector(self.u_is)
            Fu = u.duplicate()
            self.kspF.solve(u, Fu)

            p = x.getSubVector(self.p_is)
            Sp2 = p.duplicate()
            Sp3 = p.duplicate()
            Sp = p.duplicate()
            self.kspA.solve(p, Sp2)
            self.Fp.mult(Sp2, Sp3)
            self.kspQ.solve(Sp3, Sp)

            b = x.getSubVector(self.b_is)
            Mxb = b.duplicate()
            Mxb, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
                self.AA, b, self.kspScalar, self.kspVector, self.G, self.P,
                self.tol)

            r = x.getSubVector(self.r_is)
            Lr = r.duplicate()
            self.kspScalar.solve(r, Lr)
            if self.Options == 'p4':
                Q = u.duplicate()
            else:
                Q1 = u.duplicate()
                self.Bt.multTranspose(Sp, Q1)
                Q = u.duplicate()
                self.kspF(Q1, Q)

            Y1 = u.duplicate()
            self.Ct.multTranspose(Mxb, Y1)
            Y = u.duplicate()
            self.kspF(Y1, Y)

            BF = p.duplicate()
            self.Bt.mult(Fu, BF)

            if self.Options == 'p3':
                H = p.duplicate()
            else:
                H1 = p.duplicate()
                H2 = p.duplicate()
                H = p.duplicate()
                self.kspA.solve(BF, H1)
                self.Fp.mult(H1, H2)
                self.kspQ.solve(H2, H)

            BY = p.duplicate()
            self.Bt.mult(Fu, BY)
            if self.Options == 'p3':
                J = p.duplicate()
            else:
                J1 = p.duplicate()
                J2 = p.duplicate()
                J = p.duplicate()
                self.kspA.solve(BY, J1)
                self.Fp.mult(J1, J2)
                self.kspQ.solve(J2, J)

            CF = b.duplicate()
            self.Ct.mult(Fu, CF)
            T, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
                self.AA, CF, self.kspScalar, self.kspVector, self.G, self.P,
                self.tol)

            if self.Options == 'p4':
                V = b.duplicate()
            else:
                CQ = b.duplicate()
                self.Ct.mult(Q, CQ)
                V, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
                    self.AA, CQ, self.kspScalar, self.kspVector, self.G,
                    self.P, self.tol)

            DL = b.duplicate()
            self.Dt.multTranspose(Lr, DL)
            K = b.duplicate()
            K, its, self.HiptmairTime = HiptmairSetup.HiptmairApply(
                self.AA, DL, self.kspScalar, self.kspVector, self.G, self.P,
                self.tol)

            DM = r.duplicate()
            self.Dt.mult(Mxb, DM)
            E = r.duplicate()
            self.kspScalar.solve(DM, E)

            y.array = (np.concatenate([
                Fu.array + Q.array - Y.array, H.array - Sp.array - J.array,
                T.array + V.array + Mxb.array + K.array, E.array
            ]))