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

« back to all changes in this revision

Viewing changes to sandbox/misc/python/test.py

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2008-09-16 08:41:20 UTC
  • Revision ID: james.westby@ubuntu.com-20080916084120-i8k3u6lhx3mw3py3
Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from dolfin import *
 
2
 
 
3
def test1():
 
4
    "Test time-stepping with initial data expression."
 
5
 
 
6
    # Initializations
 
7
    mesh = UnitSquare(32, 32)
 
8
    V = FunctionSpace(mesh, "Lagrange", 1)
 
9
    u0 = Function(V, "sin(x[0])")
 
10
    u1 = Function(V)
 
11
 
 
12
    # Time stepping
 
13
    for i in range(10):
 
14
 
 
15
        print i
 
16
 
 
17
        # Solve for u1
 
18
        u1.vector()
 
19
 
 
20
        # Assign u0 = u1 (works fine)
 
21
        u0.assign(u1)
 
22
 
 
23
def test2():
 
24
    "Test time-stepping with time-dependent coefficient expression."
 
25
 
 
26
    # Initializations
 
27
    mesh = UnitSquare(32, 32)
 
28
    V = FunctionSpace(mesh, "Lagrange", 1)
 
29
    w0 = Function(V)
 
30
    w1 = Function(V, "sin(t*x[0])")
 
31
 
 
32
    # Time stepping
 
33
    for i in range(10):
 
34
 
 
35
        print i
 
36
 
 
37
        # Update w1
 
38
        w1.t = float(i)
 
39
        
 
40
        # Solve for u
 
41
 
 
42
        # One of these needed
 
43
 
 
44
        # Assign w0 = w1 (does not work)
 
45
        w0.assign(w1)
 
46
        #w0 = interpolate(w1, V)
 
47
        #w0 = project(w1, V)
 
48
 
 
49
test1()
 
50
test2()