示例#1
0
    xx, niter, res, tt = my_gmres("\nGmres restart={0} maxiter={1}",
                                   M, b, tol, restart, maxiter)

    ecald = checker('Calderon ', A, J, xx)
    etrans = checker('Transmission ', J, X, xx, b)

    Ecald.append(ecald)
    Etrans.append(etrans)

    print('')
    print('STF classic', '[{}]'.format(int(M.shape[0] / 2)))
    print('')

    stf = STF(xtf)
    M_stf = stf.get()
    b_stf = stf.rhs()

    print(M_stf.shape)

    zz_stf, niter_stf, res_stf, tt_stf = my_gmres("\nGmres restart={0} maxiter={1}",
                                                  M_stf, b_stf, tol, restart, maxiter)

    n, = zz_stf.shape
    n = int(n/2)
    sold_stf, soln_stf = zz_stf[:n], zz_stf[n:]

    gui = bem.GridFunction(stf.space, fun=uinc)
    uicoeffs = gui.coefficients

    fui = bem.GridFunction(stf.space, fun=dnuinc)
示例#2
0
    xx, niter, res, tt = my_gmres("\nGmres restart={0} maxiter={1}", M, b, tol,
                                  restart, maxiter)

    ecald = checker('Calderon ', A, J, xx)
    etrans = checker('Transmission ', J, X, xx, b)

    Ecald.append(ecald)
    Etrans.append(etrans)

    print('')
    print('STF classic', '[{}]'.format(int(M.shape[0] / 2)))
    print('')

    stf = STF(xtf)
    M_stf = stf.get()
    b_stf = stf.rhs()

    print(M_stf.shape)

    zz_stf, niter_stf, res_stf, tt_stf = my_gmres(
        "\nGmres restart={0} maxiter={1}", M_stf, b_stf, tol, restart, maxiter)

    n, = zz_stf.shape
    n = int(n / 2)
    sold_stf, soln_stf = zz_stf[:n], zz_stf[n:]

    gui = bem.GridFunction(stf.space, fun=uinc)
    uicoeffs = gui.coefficients

    fui = bem.GridFunction(stf.space, fun=dnuinc)
示例#3
0
def neu_data(x, normal, dom_ind, result):
    result[0] = -1j * normal[1] * kRef * np.exp(1j * kRef * x[1])


xtf = xTF(kRef, n)
xtf.setRHS(dir_data, neu_data)

space = xtf.space
shape = xtf.shape
fd, fn = xtf.getDir(), xtf.getNeu()
fdir, fneu = xtf.getGFdir(), xtf.getGFneu()

STF, MTF = STF(xtf), MTF(xtf)

stf, rhs_stf = STF.get(), STF.rhs()
mtf, rhs_mtf = MTF.get(), MTF.rhs()

x_stf = solve(stf, rhs_stf)
xd_stf, xn_stf = x_stf[0:shape], x_stf[shape:]

x_mtf = solve(mtf, rhs_mtf)
xd_mtf, xn_mtf = x_mtf[0:shape], x_mtf[shape:2 * shape]
yd_mtf, yn_mtf = x_mtf[2 * shape:3 * shape], x_mtf[3 * shape:4 * shape]

print('')
print('l2 norm (relative)')
print(la.norm(xd_mtf - xd_stf), la.norm(xn_mtf - xn_stf))
print(
    la.norm(xd_mtf - yd_mtf - fd) / la.norm(xd_mtf),
    la.norm(-xn_mtf - yn_mtf - fn) / la.norm(xn_mtf))
示例#4
0
文件: eg-2.py 项目: zimoun/mtf
def neu_data(x, normal, dom_ind, result):
    result[0] = -1j * normal[1] * kRef * np.exp( 1j * kRef * x[1])


xtf = xTF(kRef, n)
xtf.setRHS(dir_data, neu_data)

space = xtf.space
shape = xtf.shape
fd, fn = xtf.getDir(), xtf.getNeu()
fdir, fneu = xtf.getGFdir(), xtf.getGFneu()

STF, MTF = STF(xtf), MTF(xtf)

stf, rhs_stf = STF.get(), STF.rhs()
mtf, rhs_mtf = MTF.get(), MTF.rhs()



rescaleRes = lambda res, P, rhs: res / la.norm(P(rhs))

print('\nSTF restart={0} maxiter={1}'.format(restart, maxiter), flush=True)
Mat, b = stf, rhs_stf
print('size: ', stf.shape, 2*shape)
del res
res = []
tt = time()
x_stf, info = gmres(Mat, b,
                 orthog='mgs',
                 tol=tol,