# -*- coding: utf-8 -*- """ Created on Tue Oct 28 09:50:33 2014 @author: hans-werner """ from dolfin import * # # Mesh # mesh = Mesh("potential_flow_domain01.xml") V = FunctionSpace(mesh,"CG",1) # # Specify different parts of the boundary # potential_left = Constant(0.0) def boundary_left(x,on_boundary): return abs(x[0]) < DOLFIN_EPS and on_boundary bc_left = DirichletBC(V,potential_left,boundary_left) potential_right = Constant(10.0) def boundary_right(x,on_boundary): return abs(x[0] - 10.0) < DOLFIN_EPS and \ x[1] >= -1.0 and \ x[1] <= 0.0 and \ on_boundary bc_right = DirichletBC(V,potential_right,boundary_right) bc = [bc_left,bc_right] # # Set up the bilinear form # u = TrialFunction(V) v = TestFunction(V) a = inner(grad(u),grad(v))*dx L = Constant(0.0)*v*dx u = Function(V) solve(a == L, u, bc) u_vel = grad(u) plot(u) plot(u_vel) interactive() file = File('potential_flow_01.pvd') file << u