Exemple #1
0
def smoother_local(Ah, bh, ugh, Acor, poordof):
    '''
    Local correction smoother. Ah is the whole matrix,
    bh is the whole rhs, ugh is the initial guess or input.
    Also need a vector B which contains the indices of all bad nodes.
    fixa is the submatrix, fixr is the corresponding residual part and
    fixu is the error obtained.
    '''
    rh = bh - Ah * ugh
    badpet = PETSc.IS()
    badpet.createGeneral(poordof)
    rcor = Vec()
    rh.getSubVector(badpet, rcor)
    nb = rcor.getSize()
    ecor = direct(Acor, rcor)
    for i in range(nb):
        row = poordof[i]
        ugh[row] += ecor.getValue(i)

    return ugh
Exemple #2
0
def local_correction(Ah, bh, ugh, Acc, btt, bset):
    '''
    Local correction smoother. Ah is the whole matrix,
    bh is the whole rhs, ugh is the initial guess or input.
    Also need a vector B which contains the indices of all bad nodes.
    fixa is the submatrix, fixr is the corresponding residual part and
    fixu is the error obtained.
    '''
    rh = bh - Ah * ugh
    bcc = Vec()
    #ucc = Vec()
    rh.getSubVector(btt, bcc)
    nb = bcc.getSize()
    #ugh.getSubVector(btt,ucc)
    #ucc = cg(Acc,bcc,10)
    ucc = direct(Acc, bcc)
    for i in range(nb):
        row = bset[i]
        ugh[row] += ucc.getValue(i)

    return ugh