source: anuga_work/development/demos/advection_waves.py @ 5741

Last change on this file since 5741 was 4713, checked in by steve, 18 years ago

Implemented 2nd and 3rd order timestepping via the domain.set_timestepping_method method

File size: 1.3 KB
Line 
1"""Example using the module for solving the advection equation
2
3
4Initial condition is zero, boundary conditions are transmissive everywhere except
5for three segments where three different time dependent conditions are applied.
6"""
7import sys
8from os import sep
9sys.path.append('..'+sep+'abstract_2d_finite_volumes')
10
11from mesh_factory import rectangular
12from advection import Domain, Transmissive_boundary, Dirichlet_boundary, Time_boundary
13
14#Create basic mesh
15points, vertices, boundary = rectangular(20, 4)
16
17#Create advection domain
18# - Initial condition is zero by default
19domain = Domain(points, vertices, boundary, velocity=[1.0, -0.8])
20#domain.smooth = False
21
22#Boundaries
23T = Transmissive_boundary(domain)
24D = Dirichlet_boundary([0.1])
25
26from math import sin, pi
27T1 = Time_boundary(domain, f=lambda x: [0.2*(sin(2*x*pi)+1)/2])
28T2 = Time_boundary(domain, f=lambda x: [0.2*(sin(4*x*pi)+1)/3])
29T3 = Time_boundary(domain, f=lambda x: [0.2*(sin(6*x*pi)+1)/4])
30
31#Modify boundary tags
32domain.boundary[(7, 1)] = 't1'
33domain.boundary[(5, 2)] = 't2'
34domain.boundary[(3, 2)] = 't3'
35
36domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T,
37                      't1': T1, 't2': T2, 't3': T3} )
38domain.check_integrity()
39
40
41###################
42# Evolution
43for t in domain.evolve(yieldstep = 0.02, finaltime = None):
44    domain.write_time()
45
46
47
48
Note: See TracBrowser for help on using the repository browser.