source: storm_surge/examples/advection_waves.py @ 1

Last change on this file since 1 was 1, checked in by duncan, 20 years ago

initial import

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+'pyvolution')
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.