[5180] | 1 | """Simple water flow example using ANUGA |
---|
| 2 | |
---|
| 3 | Will Powers example of a simple sinusoidal wave which showed diffusive effects of |
---|
| 4 | thefirst order and standard second order method. Problem resolved if "rk2" timestepping |
---|
| 5 | and higher beta = 2 limiter used. Also new edge limiter with rk2 resolves problem |
---|
| 6 | """ |
---|
| 7 | |
---|
| 8 | #------------------------------------------------------------------------------ |
---|
| 9 | # Import necessary modules |
---|
| 10 | #------------------------------------------------------------------------------ |
---|
| 11 | |
---|
| 12 | import sys |
---|
| 13 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
| 14 | from anuga.shallow_water import Domain |
---|
| 15 | from anuga.shallow_water import Reflective_boundary |
---|
| 16 | from anuga.shallow_water import Dirichlet_boundary |
---|
| 17 | from anuga.shallow_water import Time_boundary |
---|
| 18 | from anuga.shallow_water import Transmissive_boundary |
---|
| 19 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
| 20 | from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files |
---|
| 21 | |
---|
| 22 | from math import cos |
---|
| 23 | from Numeric import zeros, Float |
---|
| 24 | from time import localtime, strftime, gmtime |
---|
| 25 | from os import sep |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | #------------------------------------------------------------------------------- |
---|
| 30 | # Copy scripts to time stamped output directory and capture screen |
---|
| 31 | # output to file |
---|
| 32 | #------------------------------------------------------------------------------- |
---|
| 33 | model_name = 'tilted' |
---|
| 34 | |
---|
| 35 | time = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
| 36 | output_dir = model_name + '_'+time |
---|
| 37 | output_file = model_name |
---|
| 38 | copy_code_files(output_dir,__file__) |
---|
| 39 | #start_screen_catcher(output_dir+sep) |
---|
| 40 | |
---|
| 41 | #------------------------------------------------------------------------------ |
---|
| 42 | # Setup domain |
---|
| 43 | #------------------------------------------------------------------------------ |
---|
| 44 | dx = 6.0*0.01 |
---|
| 45 | dy = dx |
---|
| 46 | L = 600*0.01 |
---|
| 47 | W = 10*dx |
---|
| 48 | |
---|
| 49 | # structured mesh |
---|
| 50 | points, vertices, boundary = rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, -W/2)) |
---|
| 51 | |
---|
| 52 | domain = Domain(points, vertices, boundary) |
---|
| 53 | |
---|
| 54 | domain.set_name(output_file) |
---|
| 55 | domain.set_datadir(output_dir) |
---|
| 56 | |
---|
| 57 | #------------------------------------------------------------------------------ |
---|
| 58 | # Setup Algorithm |
---|
| 59 | #------------------------------------------------------------------------------ |
---|
| 60 | domain.set_timestepping_method('rk2') |
---|
| 61 | domain.set_default_order(2) |
---|
| 62 | |
---|
| 63 | print domain.get_timestepping_method() |
---|
| 64 | |
---|
| 65 | domain.use_edge_limiter = True |
---|
| 66 | domain.tight_slope_limiters = True |
---|
| 67 | |
---|
| 68 | domain.CFL = 1.0 |
---|
| 69 | |
---|
| 70 | domain.beta_w = 0.6 |
---|
| 71 | domain.beta_w_dry = 0.0 |
---|
| 72 | domain.beta_uh = 0.6 |
---|
| 73 | domain.beta_uh_dry = 0.0 |
---|
| 74 | domain.beta_vh = 0.6 |
---|
| 75 | domain.beta_vh_dry = 0.0 |
---|
| 76 | |
---|
[5442] | 77 | |
---|
[5180] | 78 | interactive_visualisation = True |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | #------------------------------------------------------------------------------ |
---|
| 82 | # Setup initial conditions |
---|
| 83 | #------------------------------------------------------------------------------ |
---|
| 84 | domain.set_quantity('elevation',0.0) |
---|
| 85 | domain.set_quantity('friction', 0.00) |
---|
| 86 | domain.set_quantity('stage', lambda x,y : 14.0*0.01 + x/(600.0*0.01)*14.0*0.01 ) |
---|
| 87 | |
---|
| 88 | #----------------------------------------------------------------------------- |
---|
| 89 | # Setup boundary conditions |
---|
| 90 | #------------------------------------------------------------------------------ |
---|
| 91 | from math import sin, pi, exp |
---|
| 92 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
| 93 | |
---|
| 94 | # Associate boundary tags with boundary objects |
---|
| 95 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | #=============================================================================== |
---|
| 99 | if interactive_visualisation: |
---|
| 100 | from anuga.visualiser import RealtimeVisualiser |
---|
| 101 | vis = RealtimeVisualiser(domain) |
---|
| 102 | vis.render_quantity_height("stage", zScale =1, dynamic=True) |
---|
| 103 | vis.colour_height_quantity('stage', (1.0, 0.5, 0.5)) |
---|
| 104 | vis.start() |
---|
| 105 | #=============================================================================== |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | #------------------------------------------------------------------------------ |
---|
| 109 | # Evolve system through time |
---|
| 110 | #------------------------------------------------------------------------------ |
---|
| 111 | |
---|
| 112 | for t in domain.evolve(yieldstep = 0.5, finaltime = 60.0): |
---|
| 113 | domain.write_time() |
---|
| 114 | if interactive_visualisation: |
---|
| 115 | vis.update() |
---|
| 116 | |
---|
| 117 | if interactive_visualisation: |
---|
| 118 | vis.evolveFinished() |
---|
| 119 | |
---|