1
"""This demo illustrates how to set boundary conditions for meshes
2
that include boundary indicators. The mesh used in this demo was
3
generated with VMTK (http://villacamozzi.marionegri.it/~luca/vmtk/)."""
5
__author__ = "Anders Logg (logg@simula.no)"
6
__date__ = "2008-05-23 -- 2008-05-23"
7
__copyright__ = "Copyright (C) 2008 Anders Logg"
8
__license__ = "GNU LGPL Version 2.1"
12
# Create mesh and finite element
13
mesh = Mesh("../../../../data/meshes/aneurysm.xml.gz")
14
element = FiniteElement("Lagrange", "tetrahedron", 1)
16
# Define variational problem
17
v = TestFunction(element)
18
u = TrialFunction(element)
19
f = Function(element, mesh, 0.0)
20
a = dot(grad(v), grad(u))*dx
23
# Define boundary condition values
24
u0 = Function(mesh, 0.0)
25
u1 = Function(mesh, 1.0)
26
u2 = Function(mesh, 2.0)
27
u3 = Function(mesh, 3.0)
29
# Define boundary conditions
30
bc0 = DirichletBC(u0, mesh, 0)
31
bc1 = DirichletBC(u1, mesh, 1)
32
bc2 = DirichletBC(u2, mesh, 2)
33
bc3 = DirichletBC(u3, mesh, 3)
35
# Solve PDE and plot solution
36
pde = LinearPDE(a, L, mesh, [bc0, bc1, bc2, bc3])
38
plot(u, interactive=True)