def temporal_hook(q_, u_, tstep, V, uv, p_, plot_interval, omega, ds, save_step, mesh, nu, Umean, D, n, **NS_namespace): if tstep % plot_interval == 0: uv() plt.figure(1) plot(uv, title='Velocity') plt.figure(2) plot(p_, title='Pressure') plt.figure(3) plot(q_['alfa'], title='alfa') plt.show() R = VectorFunctionSpace(mesh, 'R', 0) c = TestFunction(R) tau = -p_ * Identity(2) + nu * (grad(u_) + grad(u_).T) forces = assemble( dot(dot(tau, n), c) * ds(1)).get_local() * 2 / Umean**2 / D print("Cd = {}, CL = {}".format(*forces)) if tstep % save_step == 0: try: from fenicstools import StreamFunction omega.assign(StreamFunction(u_, [])) except: omega.assign( project(curl(u_), V, solver_type='cg', bcs=[DirichletBC(V, 0, DomainBoundary())]))
def theend_hook(u_, p_, mesh, **NS_namespace): plot(u_, title='Velocity') plot(p_, title='Pressure') try: from fenicstools import StreamFunction psi = StreamFunction(u_, [], mesh, use_strong_bc=True) plot(psi, title='Streamfunction', interactive=True) except: pass
def theend_hook(u_, p_, mesh, **NS_namespace): plot(u_, title='Velocity') plot(p_, title='Pressure') try: from fenicstools import StreamFunction import matplotlib.pyplot as plt psi = StreamFunction(u_, [], mesh, use_strong_bc=True) plot(psi, title='Streamfunction') plt.show() except: pass
def theend_hook(u_, p_, uv, mesh, testing, **NS_namespace): if not testing: assign(uv.sub(0), u_[0]) assign(uv.sub(1), u_[1]) plot(uv, title='Velocity') plot(p_, title='Pressure') u_norm = norm(u_[0].vector()) if MPI.rank(mpi_comm_world()) == 0 and testing: print "Velocity norm = {0:2.6e}".format(u_norm) if not testing: try: from fenicstools import StreamFunction psi = StreamFunction(uv, [], mesh, use_strong_bc=True) plot(psi, title='Streamfunction', interactive=True) except: pass