# View the mesh mview = MeshView("Example 7", 100, 100, 500, 500) mview.show(mesh, lib="mpl", method="orders", notebook=False) # Solve the fine mesh problem rs = RefSystem(ls) rs.assemble() rs.solve_system(sln_fine) # Calculate element errors and total error estimate hp = H1OrthoHP(space); err_est = hp.calc_error(sln_coarse, sln_fine) * 100 print("Error estimate: %d" % err_est) # If err_est too large, adapt the mesh if (err_est < ERR_STOP): done = True else: hp.adapt(THRESHOLD, STRATEGY, ADAPT_TYPE)#, ISO_ONLY, MESH_REGULARITY) ndofs = space.assign_dofs() if (ndofs >= NDOF_STOP): done = True print ("Total running time: %d sec" % cpu) # Show the fine solution - this is the final result sview.show(sln_fine, lib="mayavi") gview.show(sln_fine, sln_fine, EPS_HIGH)
# initialize the discrete problem wf = WeakForm(3) set_forms(wf, xprev, yprev) # visualize the solution vview = VectorView("velocity [m/s]", 0, 0, 1200, 350) pview = ScalarView("pressure [Pa]", 0, 500, 1200, 350) vview.set_min_max_range(0, 1.9) vview.show_scale(False) pview.show_scale(False) pview.show_mesh(False) solver = DummySolver() sys = LinSystem(wf, solver) sys.set_spaces(xvel, yvel, press) sys.set_pss(pss) #dp.set_external_fns(xprev, yprev) EPS_LOW = 0.0014 for i in range(1000): print "*** Iteration %d ***" % i psln = Solution() sys.assemble() sys.solve_system(xprev, yprev, psln) vview.show(xprev, yprev, 2*EPS_LOW) pview.show(psln) vview.wait()