In [1]:
from dolfin import *
from IPython.display import Image
In [31]:
mesh = UnitSquareMesh(6, 6)
In [32]:
wiz = plot(mesh)
wiz.write_png("mesh")
Image("mesh.png")
Out[32]:
In [ ]:
V = FunctionSpace(mesh, 'Lagrange', 1)
In [43]:
u0 = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]')
In [35]:
def u0_boundary(x, on_boundary):
    return on_boundary
In [36]:
bc = DirichletBC(V, u0, u0_boundary)
In [37]:
u = TrialFunction(V)
v = TestFunction(V)
In [38]:
f = Constant(50.0)
a = inner(nabla_grad(u), nabla_grad(v))*dx
L = f*v*dx
In [ ]:
# Compute solution
u = Function(V)
solve(a == L, u, bc)
In [40]:
# Plot solution and mesh
wiz = plot(u)
wiz.write_png("u")
Image("u.png")
Out[40]:
In [44]:
dx?
In [ ]: