Exemplo n.º 1
0
    rs.solve_system(sln_fine)
    
    # Either solve on coarse mesh or project the fine mesh solution 
    # on the coarse mesh.   
    if SOLVE_ON_COARSE_MESH:
        ls.assemble()
        ls.solve_system(sln_coarse)
    else:
        ls.project_global(sln_fine, sln_coarse)
    
    # View the solution and mesh
    sview.show(sln_coarse);
    mesh.plot(space=space)
        
    # Calculate error estimate wrt. fine mesh solution
    hp = H1Adapt(ls)
    hp.set_solutions([sln_coarse], [sln_fine])
    err_est = hp.calc_error() * 100
    print("Error estimate: %d" % err_est)

    # If err_est too large, adapt the mesh
    if (err_est < ERR_STOP):
        done = True
    else:
        done = hp.adapt(selector, THRESHOLD, STRATEGY, MESH_REGULARITY)
        if (ls.get_num_dofs() >= NDOF_STOP):
            done = True

# Show the fine solution - the final result
sview.show(sln_fine)
Exemplo n.º 2
0
    rs.assemble()
    rs.solve_system(sln_fine)
    
    # Either solve on coarse mesh or project the fine mesh solution 
    # on the coarse mesh.   
    if SOLVE_ON_COARSE_MESH:
        ls.assemble()
        ls.solve_system(sln_coarse)
    else:
        ls.project_global(sln_fine, sln_coarse)
        
    # View the solution and mesh
    sview.show(sln_coarse);
    mesh.plot(space=space)

    # Calculate error estimate wrt. fine mesh solution
    hp = H1Adapt(ls)
    hp.set_solutions([sln_coarse], [sln_fine])
    err_est = hp.calc_error() * 100
    print("Error estimate: %d" % err_est)

    # If err_est too large, adapt the mesh
    if (err_est < ERR_STOP):
        done = True
    else:
        done = hp.adapt(selector, THRESHOLD, STRATEGY, MESH_REGULARITY)
        if (ls.get_num_dofs() >= NDOF_STOP):
            done = True

sview.show(sln_fine)
Exemplo n.º 3
0
    else:
        ls.project_global()

    # View the solution and meshes
    uview.show(u_sln_coarse)
    vview.show(v_sln_coarse)
    umesh.plot(space=uspace)
    vmesh.plot(space=vspace)

    # Calculate element errors and total error estimate
    hp = H1Adapt(ls)
    hp.set_solutions([u_sln_coarse, v_sln_coarse], [u_sln_fine, v_sln_fine]);
    set_hp_forms(hp)
    err_est = hp.calc_error() * 100

    print("Error estimate: %s" % err_est)

    # If err_est too large, adapt the mesh
    if err_est < ERR_STOP:
        done = True
    else:
        MULTI = False if MULTI == True else True
        hp.adapt(selector, THRESHOLD, STRATEGY, MESH_REGULARITY, MULTI) 
        if ls.get_num_dofs() >= NDOF_STOP:
            done = True
    

# Show the fine solution - this is the final result
uview.show(u_sln_fine)
vview.show(v_sln_fine)