1
"""This demo demonstrates how to compute functionals (or forms in
2
general) over subsets of the mesh. The two functionals lift and
3
drag are computed for the pressure field around a dolphin. Here, we
4
use the pressure field obtained from solving the Stokes equations
5
(see demo program in the sub directory
6
src/demo/pde/stokes/taylor-hood).
8
The calculation only includes the pressure contribution (not shear
12
__author__ = "Kristian B. Oelgaard (k.b.oelgaard@tudelft.nl)"
13
__date__ = "2007-11-14 -- 2008-12-27"
14
__copyright__ = "Copyright (C) 2007 Kristian B. Oelgaard"
15
__license__ = "GNU LGPL Version 2.1"
17
# Modified by Anders Logg, 2008.
18
# Modified by Garth N. Wells, 2009.
22
# Read the mesh from file
23
mesh = Mesh("../mesh.xml.gz")
25
# Create FunctionSpace for pressure field
26
Vp = FunctionSpace(mesh, "CG", 1)
28
p = Function(Vp, "../pressure.xml.gz")
30
# Define sub domain for the dolphin
31
class Fish(SubDomain):
32
def inside(self, x, on_boundary):
33
return x[0] > DOLFIN_EPS and x[0] < (1.0 - DOLFIN_EPS) and \
34
x[1] > DOLFIN_EPS and x[1] < (1.0 - DOLFIN_EPS)
36
# Define functionals for drag and lift
41
# Assemble functionals over sub domain
43
drag = assemble(D, exterior_facet_domains = fish)
44
lift = assemble(L, exterior_facet_domains = fish)
46
print "Lift: %f" %lift
47
print "Drag: %f" %drag