source: anuga_core/source/anuga/examples/advection_waves.py @ 3740

Last change on this file since 3740 was 3560, checked in by ole, 18 years ago

Renamed pyvolution to abstract_2d_finite_volumes. This is
one step towards pulling pyvolution apart. More to follow.
All unit tests pass and most examples fixed up.




File size: 1.4 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
21domain.visualise = True
22
23#Boundaries
24T = Transmissive_boundary(domain)
25D = Dirichlet_boundary([0.1])
26
27from math import sin, pi
28T1 = Time_boundary(domain, f=lambda x: [0.2*(sin(2*x*pi)+1)/2])
29T2 = Time_boundary(domain, f=lambda x: [0.2*(sin(4*x*pi)+1)/3])
30T3 = Time_boundary(domain, f=lambda x: [0.2*(sin(6*x*pi)+1)/4])
31
32#Modify boundary tags
33domain.boundary[(7, 1)] = 't1'
34domain.boundary[(5, 2)] = 't2'
35domain.boundary[(3, 2)] = 't3'
36
37domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T,
38                      't1': T1, 't2': T2, 't3': T3} )
39domain.check_integrity()
40
41
42###################
43# Evolution
44for t in domain.evolve(yieldstep = 0.02, finaltime = None):
45    domain.write_time()
46
47
48
49
Note: See TracBrowser for help on using the repository browser.