Esempio n. 1
0
def test4():
    print "TEST 4"
    mis = (Multiindex(), Multiindex([1]), Multiindex([0, 1]), Multiindex([1, 1]))
    mv = MultiVectorWithProjection()
    V1 = FEniCSBasis(FunctionSpace(UnitSquare(5, 5), 'CG', 1))
    V2, _, _ = V1.refine()
    V3, _, _ = V2.refine()
    V4 = V1.refine_maxh(1 / 30, uniform=True)
    print "mesh1", V1.mesh, "maxh,minh=", V1.maxh, V1.minh
    print "mesh2", V2.mesh, "maxh,minh=", V2.maxh, V2.minh
    print "mesh3", V3.mesh, "maxh,minh=", V3.maxh, V3.minh
    print "mesh4", V4.mesh, "maxh,minh=", V4.maxh, V4.minh
    F2 = FEniCSVector.from_basis(V2)
    F3 = FEniCSVector.from_basis(V3)
    F4 = FEniCSVector.from_basis(V4)
    mv[mis[0]] = FEniCSVector.from_basis(V1)
    mv[mis[1]] = F2
    mv[mis[2]] = F3
    mv[mis[3]] = F4
    for j, ex in enumerate(EX):
        print "ex[", j, "] =================="
        for degree in range(1, 4):
            print "\t=== degree ", degree, "==="
            F2.interpolate(ex)
            F3.interpolate(ex)
            F4.interpolate(ex)
            err1 = mv.get_projection_error_function(mis[1], mis[0], degree, refine_mesh=False)
            err2 = mv.get_projection_error_function(mis[2], mis[0], degree, refine_mesh=False)
            err3 = mv.get_projection_error_function(mis[3], mis[0], degree, refine_mesh=False)
            print "\t[NO DESTINATION MESH REFINEMENT]"
            print "\t\tV2 L2", norm(err1._fefunc, 'L2'), "H1", norm(err1._fefunc, 'H1')
            print "\t\tV3 L2", norm(err2._fefunc, 'L2'), "H1", norm(err2._fefunc, 'H1')
            print "\t\tV4 L2", norm(err3._fefunc, 'L2'), "H1", norm(err3._fefunc, 'H1')
            err1 = mv.get_projection_error_function(mis[1], mis[0], degree, refine_mesh=True)
            err2 = mv.get_projection_error_function(mis[2], mis[0], degree, refine_mesh=True)
            err3 = mv.get_projection_error_function(mis[3], mis[0], degree, refine_mesh=True)
            print "\t[WITH DESTINATION MESH REFINEMENT]"
            print "\t\tV2 L2", norm(err1._fefunc, 'L2'), "H1", norm(err1._fefunc, 'H1')
            print "\t\tV3 L2", norm(err2._fefunc, 'L2'), "H1", norm(err2._fefunc, 'H1')
            print "\t\tV4 L2", norm(err3._fefunc, 'L2'), "H1", norm(err3._fefunc, 'H1')