[5163] | 1 | """ This Script shows how a bad mesh can be generated causing |
---|
| 2 | excessive values for stage and momentum. |
---|
| 3 | |
---|
| 4 | """ |
---|
| 5 | |
---|
| 6 | #------------------------------------------------------------------------------ |
---|
| 7 | # Import necessary modules |
---|
| 8 | #------------------------------------------------------------------------------ |
---|
| 9 | |
---|
| 10 | # Standard modules |
---|
| 11 | import os |
---|
| 12 | import time |
---|
| 13 | import sys |
---|
| 14 | |
---|
| 15 | # Related major packages |
---|
| 16 | from anuga.shallow_water import Domain |
---|
| 17 | from anuga.shallow_water import Dirichlet_boundary |
---|
| 18 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
| 19 | from anuga.utilities.polygon import read_polygon, plot_polygons |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #------------------------------------------------------------------------------ |
---|
| 24 | # Filenames |
---|
| 25 | #------------------------------------------------------------------------------ |
---|
| 26 | |
---|
| 27 | outname ='bad_mesh' |
---|
| 28 | meshname ='bad_mesh.msh' |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | #------------------------------------------------------------------------------ |
---|
| 32 | # Create the triangular mesh based on overall clipping polygon with a tagged |
---|
| 33 | # boundary and interior regions defined in project.py along with |
---|
| 34 | # resolutions (maximal area of per triangle) for each polygon |
---|
| 35 | #------------------------------------------------------------------------------ |
---|
| 36 | |
---|
| 37 | W=304180.0 |
---|
| 38 | S=6185270.0 |
---|
| 39 | E=307650.0 |
---|
| 40 | N=6189040.0 |
---|
| 41 | |
---|
| 42 | bounding_polygon = [[W, S], [E, S], [E, N], [W, N]] |
---|
| 43 | |
---|
| 44 | # Below is assigning the name for each polygon (roughness values added below) |
---|
| 45 | Refine_Read_Polygon1 = read_polygon('Catchment_Bdy.csv') |
---|
| 46 | Refine_Read_Polygon2 = read_polygon('OuterHarbour.csv') |
---|
| 47 | |
---|
| 48 | # Bad |
---|
[5164] | 49 | # interior_regions = [[Refine_Read_Polygon1, 10],[Refine_Read_Polygon2, 50]] |
---|
[5163] | 50 | |
---|
[5165] | 51 | # Bad (simpler) - Polygon 2 is warped |
---|
[5164] | 52 | interior_regions = [[Refine_Read_Polygon2, 50]] |
---|
| 53 | |
---|
[5163] | 54 | # OK |
---|
| 55 | #interior_regions = [[Refine_Read_Polygon1, 10]] |
---|
| 56 | |
---|
| 57 | # Output plot of polygons to file |
---|
| 58 | #plot_polygons([bounding_polygon, |
---|
| 59 | # Refine_Read_Polygon1, |
---|
| 60 | # Refine_Read_Polygon2], |
---|
| 61 | # figname='milevsky') |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | create_mesh_from_regions(bounding_polygon, |
---|
| 66 | boundary_tags={'south': [0], |
---|
| 67 | 'east': [1], |
---|
| 68 | 'north': [2], |
---|
| 69 | 'west': [3]}, |
---|
| 70 | maximum_triangle_area=10000, #background mesh size |
---|
| 71 | interior_regions=interior_regions, |
---|
| 72 | filename=meshname, |
---|
| 73 | use_cache=False, |
---|
| 74 | verbose=True) |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | #------------------------------------------------------------------------------ |
---|
| 78 | # Setup computational domain |
---|
| 79 | #------------------------------------------------------------------------------ |
---|
| 80 | |
---|
| 81 | domain = Domain(meshname, use_cache=False, verbose=True) |
---|
| 82 | domain.set_name(outname) |
---|
| 83 | print domain.statistics() |
---|
| 84 | |
---|
| 85 | #------------------------------------------------------------------------------ |
---|
| 86 | # Setup initial conditions |
---|
| 87 | #------------------------------------------------------------------------------ |
---|
| 88 | # Setting up initial conditions for a Flood model includes: |
---|
| 89 | # Setting A Base topography over the model domain |
---|
| 90 | # Setting the variation of Roughness over the terrain, which may be |
---|
| 91 | # varied dependent on depth say |
---|
| 92 | # Setting initial water levels at BOundaries and in Lakes and Water Bodies. |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | tide = 1.5 # 100yr tidal level as per WCC drainage design code |
---|
| 96 | base_friction = 0.015 |
---|
| 97 | |
---|
| 98 | domain.set_quantity('friction', base_friction) |
---|
| 99 | domain.set_quantity('stage', tide) |
---|
| 100 | domain.set_quantity('elevation', 0) |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | #------------------------------------------------------------------------------ |
---|
| 104 | # Setup boundary conditions |
---|
| 105 | #------------------------------------------------------------------------------ |
---|
| 106 | |
---|
| 107 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
| 108 | |
---|
| 109 | Bd = Dirichlet_boundary([tide,0,0]) |
---|
| 110 | |
---|
| 111 | # Boundary conditions |
---|
| 112 | domain.set_boundary({'west': Bd, |
---|
| 113 | 'south': Bd, |
---|
| 114 | 'north': Bd, |
---|
| 115 | 'east': Bd}) |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | #------------------------------------------------------------------------------ |
---|
| 119 | # Evolve system through time |
---|
| 120 | #------------------------------------------------------------------------------ |
---|
| 121 | |
---|
| 122 | import time |
---|
| 123 | t0 = time.time() |
---|
| 124 | |
---|
| 125 | for t in domain.evolve(yieldstep = 1, finaltime = 2): |
---|
| 126 | print domain.timestepping_statistics() |
---|
| 127 | |
---|
| 128 | print 'Finished' |
---|
| 129 | |
---|