[777] | 1 | """Simple example of shallow water wave equation using Pyvolution |
---|
| 2 | |
---|
[2772] | 3 | Water driven up a linear slope with a time varying boundary, |
---|
| 4 | similar to beach environment |
---|
[777] | 5 | |
---|
| 6 | """ |
---|
| 7 | |
---|
| 8 | ###################### |
---|
| 9 | # Module imports |
---|
[1853] | 10 | from pyvolution.mesh_factory import rectangular |
---|
| 11 | from pyvolution.shallow_water import Domain, Reflective_boundary,\ |
---|
[2156] | 12 | Dirichlet_boundary, Time_boundary, Transmissive_boundary |
---|
[777] | 13 | |
---|
[2288] | 14 | #Create basic triangular mesh |
---|
[2772] | 15 | points, vertices, boundary = rectangular(10, 10) |
---|
[777] | 16 | |
---|
| 17 | #Create shallow water domain |
---|
| 18 | domain = Domain(points, vertices, boundary) |
---|
[2288] | 19 | domain.set_name('bedslope') |
---|
[2320] | 20 | domain.set_datadir('.') #Use current directory for output |
---|
| 21 | domain.set_quantities_to_be_stored('stage') #See shallow_water.py |
---|
[777] | 22 | |
---|
[2582] | 23 | print domain.statistics() |
---|
[2288] | 24 | |
---|
[777] | 25 | ####################### |
---|
[2155] | 26 | # Initial conditions |
---|
[2156] | 27 | def f(x,y): |
---|
| 28 | return -x/2 |
---|
| 29 | |
---|
| 30 | domain.set_quantity('elevation', f) |
---|
[777] | 31 | domain.set_quantity('friction', 0.1) |
---|
| 32 | |
---|
[2772] | 33 | h = 0.00 # Constant depth over elevation |
---|
| 34 | domain.set_quantity('stage', -.4) |
---|
[777] | 35 | |
---|
[2155] | 36 | |
---|
[777] | 37 | ###################### |
---|
| 38 | # Boundary conditions |
---|
| 39 | from math import sin, pi |
---|
| 40 | Br = Reflective_boundary(domain) |
---|
| 41 | Bt = Transmissive_boundary(domain) |
---|
| 42 | Bd = Dirichlet_boundary([0.2,0.,0.]) |
---|
| 43 | Bw = Time_boundary(domain=domain, |
---|
[2772] | 44 | f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0]) |
---|
[777] | 45 | |
---|
[2155] | 46 | |
---|
[2320] | 47 | print 'Tags are ', domain.get_boundary_tags() |
---|
| 48 | |
---|
[2772] | 49 | domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br}) |
---|
[777] | 50 | |
---|
| 51 | |
---|
| 52 | ###################### |
---|
[2155] | 53 | #Evolution |
---|
[777] | 54 | domain.check_integrity() |
---|
| 55 | |
---|
[2772] | 56 | for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0): |
---|
[777] | 57 | domain.write_time() |
---|
| 58 | |
---|