~ubuntu-branches/ubuntu/maverick/dolfin/maverick

« back to all changes in this revision

Viewing changes to demo/function/projection-interpolation/python/demo.py

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2009-10-12 14:13:18 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012141318-hkbxl0sq555vqv7d
Tags: 0.9.4-1
* New upstream release. This version cleans up the design of the
  function class by adding a new abstraction for user-defined
  functions called Expression. A number of minor bugfixes and
  improvements have also been made.
* debian/watch: Update for new flat directory structure.
* Update debian/copyright.
* debian/rules: Use explicit paths to PETSc 3.0.0 and SLEPc 3.0.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
between different finite element spaces."""
3
3
 
4
4
__author__ = "Anders Logg (logg@simula.no)"
5
 
__date__ = "2008-10-06 -- 2008-12-12"
 
5
__date__ = "2008-10-06 -- 2009-10-06"
6
6
__copyright__ = "Copyright (C) 2008 Anders Logg"
7
7
__license__  = "GNU LGPL Version 2.1"
8
8
 
14
14
P2 = FunctionSpace(mesh, "CG", 2)
15
15
 
16
16
# Define function
17
 
v = Function(P2, "sin(10.0*x[0])*sin(10.0*x[1])")
 
17
v = Expression("sin(10.0*x[0])*sin(10.0*x[1])", V = P2)
18
18
 
19
19
# Compute projection (L2-projection)
20
20
Pv = project(v, P1)
21
21
 
22
22
# Compute interpolation (evaluating dofs)
23
 
PIv = interpolate(v, P1)
 
23
PIv = Function(P1)
 
24
PIv.interpolate(v)
24
25
 
25
26
# Plot functions
26
 
plot(v,   title="v")
 
27
#plot(v,   title="v")
27
28
plot(Pv,  title="Pv")
28
29
plot(PIv, title="PI v")
29
30
interactive()