~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to demo/pde/bcs/python/demo.py

  • Committer: Anders Logg
  • Date: 2008-05-18 20:10:23 UTC
  • mto: (2668.7.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2670.
  • Revision ID: logg@simula.no-20080518201023-q5sec18uepjnjw4f
Add new function DirichletBC::setSubSystem(), allowing modification
of the sub system for which a BC has been set.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/)."""
4
 
 
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"
9
 
 
10
 
from dolfin import *
11
 
 
12
 
# Create mesh and finite element
13
 
mesh = Mesh("../../../../data/meshes/aneurysm.xml.gz")
14
 
element = FiniteElement("Lagrange", "tetrahedron", 1)
15
 
 
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
21
 
L = v*f*dx
22
 
 
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)
28
 
 
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)
34
 
 
35
 
# Solve PDE and plot solution
36
 
pde = LinearPDE(a, L, mesh, [bc0, bc1, bc2, bc3])
37
 
u = pde.solve()
38
 
plot(u, interactive=True)