[8199] | 1 | """Simple water flow example using ANUGA |
---|
| 2 | |
---|
| 3 | Water driven up a linear slope and time varying boundary, |
---|
| 4 | similar to a beach environment |
---|
| 5 | """ |
---|
| 6 | |
---|
| 7 | #------------------------------------------------------------------------------ |
---|
| 8 | # Import necessary modules |
---|
| 9 | #------------------------------------------------------------------------------ |
---|
| 10 | import sys |
---|
| 11 | import anuga |
---|
| 12 | from math import cos |
---|
| 13 | from numpy import zeros, float |
---|
| 14 | from time import localtime, strftime, gmtime |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #------------------------------------------------------------------------------- |
---|
| 19 | # Copy scripts to time stamped output directory and capture screen |
---|
| 20 | # output to file |
---|
| 21 | #------------------------------------------------------------------------------- |
---|
| 22 | time = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
| 23 | |
---|
| 24 | output_dir = 'circular_dam_break_'+time |
---|
| 25 | output_file = 'circular_dam_break' |
---|
| 26 | |
---|
[8212] | 27 | #anuga.copy_code_files(output_dir,__file__) |
---|
[8199] | 28 | #start_screen_catcher(output_dir+'_') |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | #------------------------------------------------------------------------------ |
---|
| 32 | # Setup domain |
---|
| 33 | #------------------------------------------------------------------------------ |
---|
| 34 | dx = 1. |
---|
| 35 | dy = dx |
---|
| 36 | L = 100. |
---|
| 37 | W = L |
---|
| 38 | |
---|
| 39 | # structured mesh |
---|
| 40 | points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (-L/2.0, -W/2.0)) |
---|
| 41 | |
---|
| 42 | domain = anuga.Domain(points, vertices, boundary) |
---|
| 43 | |
---|
| 44 | domain.set_name(output_file) |
---|
| 45 | domain.set_datadir(output_dir) |
---|
| 46 | |
---|
| 47 | #------------------------------------------------------------------------------ |
---|
| 48 | # Setup Algorithm |
---|
| 49 | #------------------------------------------------------------------------------ |
---|
| 50 | domain.set_timestepping_method('rk2') |
---|
| 51 | domain.set_default_order(2) |
---|
| 52 | |
---|
| 53 | print domain.get_timestepping_method() |
---|
| 54 | |
---|
| 55 | #------------------------------------------------------------------------------ |
---|
| 56 | # Setup initial conditions |
---|
| 57 | #------------------------------------------------------------------------------ |
---|
| 58 | domain.set_quantity('elevation',0.0) |
---|
| 59 | domain.set_quantity('friction', 0.0) |
---|
| 60 | |
---|
| 61 | h0 = 10.0 |
---|
| 62 | h1 = 1.0 |
---|
| 63 | radius = 10.0 |
---|
| 64 | |
---|
| 65 | def height(x,y): |
---|
| 66 | z = zeros(len(x), float) |
---|
| 67 | r2 = radius**2 |
---|
| 68 | for i in range(len(x)): |
---|
| 69 | rad2 = x[i]**2 + y[i]**2 |
---|
| 70 | |
---|
| 71 | if rad2 <= r2: |
---|
| 72 | z[i] = h0 |
---|
| 73 | else: |
---|
| 74 | z[i] = h1 |
---|
| 75 | return z |
---|
| 76 | |
---|
| 77 | domain.set_quantity('stage', height) |
---|
| 78 | |
---|
| 79 | #----------------------------------------------------------------------------- |
---|
| 80 | # Setup boundary conditions |
---|
| 81 | #------------------------------------------------------------------------------ |
---|
| 82 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | # Associate boundary tags with boundary objects |
---|
| 87 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | #=============================================================================== |
---|
[8212] | 91 | ##from anuga.visualiser import RealtimeVisualiser |
---|
| 92 | ##vis = RealtimeVisualiser(domain) |
---|
| 93 | ##vis.render_quantity_height("stage", zScale =h0, dynamic=True) |
---|
| 94 | ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0)) |
---|
| 95 | ##vis.start() |
---|
[8199] | 96 | #=============================================================================== |
---|
[8212] | 97 | print "Evolving...." |
---|
[8199] | 98 | |
---|
| 99 | #------------------------------------------------------------------------------ |
---|
| 100 | # Evolve system through time |
---|
| 101 | #------------------------------------------------------------------------------ |
---|
| 102 | |
---|
[8212] | 103 | for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0): |
---|
[8199] | 104 | #print domain.timestepping_statistics(track_speeds=True) |
---|
| 105 | print domain.timestepping_statistics() |
---|
[8212] | 106 | ## vis.update() |
---|
[8199] | 107 | |
---|
| 108 | |
---|
| 109 | #test against know data |
---|
| 110 | |
---|
[8212] | 111 | ##vis.evolveFinished() |
---|
[8199] | 112 | |
---|