source: inundation/debug/mesh_error_reporting/create_mesh.py @ 1878

Last change on this file since 1878 was 1878, checked in by ole, 19 years ago

Code revealing error in ticket:9

File size: 3.8 KB
Line 
1"""Create mesh for lwru2 validation of the Oshiri island tsunami
2"""
3
4#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5# Assume that the root AnuGA dir is included in your pythonpath
6#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7
8from pmesh.mesh import *
9from pyvolution.coordinate_transforms.geo_reference import Geo_reference
10
11#-------------------------------------------------------------
12if __name__ == "__main__":
13
14
15    #Basic geometry
16   
17    xleft   = 0
18    xright  = 5.448
19    ybottom = 0
20    ytop    = 3.402
21
22    #Outline
23    point_sw = [xleft, ybottom]
24    point_se = [xright, ybottom]
25    point_nw = [xleft, ytop]   
26    point_ne = [xright, ytop]
27
28    #Midway points (left)
29    point_mtop = [xleft + (xright-xleft)/3+1, ytop]
30    point_mbottom = [xleft + (xright-xleft)/3+1, ybottom]
31
32
33    geo = Geo_reference(xllcorner = xleft,
34                        yllcorner = ybottom)
35   
36                       
37    print "***********************"
38    print "geo ref", geo
39    print "***********************"
40   
41    m = Mesh(geo_reference=geo)
42
43    #Boundary
44    dict = {}
45    dict['points'] = [point_se,   #se
46                      point_ne,
47                      point_mtop,
48                      point_nw,
49                      point_sw,
50                      point_mbottom]
51
52   
53    dict['segments'] = [[0,1], [1,2], [2,3], [3,4],
54                        [4,5], [5,0],  #The outer border
55                        [2,5]]         #Separator
56   
57    dict['segment_tags'] = ['wall',
58                            'wall',
59                            'wall',
60                            'wave',
61                            'wall',
62                            'wall',
63                            '']           #Interior
64
65       
66    m.addVertsSegs(dict)
67
68
69
70
71
72    #Localised refined area for gulleys
73    dict = {}
74    xl = 4.8
75    xr = 5.3
76    yb = 1.6
77    yt = 2.3
78    p0 = [xl, yb]
79    p1 = [xr, yb]
80    p2 = [xr, yt]
81    p3 = [xl, yt]
82   
83    dict['points'] = [p0, p1, p2, p3]
84    dict['segments'] = [[0,1], [1,2], [2,3], [3,0]]
85    dict['segment_tags'] = ['', '', '', '']
86    m.addVertsSegs(dict)   
87
88    #Island area
89    island_0 = [xleft + 2*(xright-xleft)/3+1.2, ytop-0.5]
90    island_1 = [xleft + 2*(xright-xleft)/3+0.5, ybottom + 2*(ytop-ybottom)/3]
91    island_2 = [xleft + (xright-xleft)/2+0.3, ybottom + 2*(ytop-ybottom)/3-0.3]
92    island_3 = [xleft + (xright-xleft)/2+0.3, ybottom + (ytop-ybottom)/3+0.3]
93    island_4 = [xleft + 2*(xright-xleft)/3+0.5, ybottom + (ytop-ybottom)/3] 
94    island_5 = [xleft + 2*(xright-xleft)/3+1.2, ybottom+0.2]
95    island_6 = [xl-.01, yb]  #OK
96    island_7 = [xl-.01, yt]  #OK     
97   
98
99    dict['points'] = [island_0, island_1, island_2,
100                      island_3, island_4, island_5,
101                      p0, p3]
102                      #island_6, island_7]
103
104    #Both versions fail
105    #dict['segments'] = [[0,1], [1,2], [2,3], [3,4],
106    #                    [4,5], [5,6], [7,0]]
107    #dict['segment_tags'] = ['', '', '', '', '', '', '']   
108
109    dict['segments'] = [[0,1], [1,2], [2,3], [3,4],
110                        [4,5], [5,6], [6,7], [7,0]]   
111    dict['segment_tags'] = ['', '', '', '', '', '', '', '']
112
113    #ALso try having list of segment_tags the wrong length
114
115
116    m.addVertsSegs(dict)   
117   
118#
119   
120    base_resolution = 1000
121
122    ocean = m.addRegionEN(xleft+.1, ybottom+.1)
123    ocean.setMaxArea(0.1*base_resolution)
124
125    mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
126    mid.setMaxArea(0.05*base_resolution)
127   
128
129    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
130    #inner.setMaxArea(0.0005*base_resolution)
131
132
133    gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
134    gulleys.setMaxArea(0.00002*base_resolution)   
135   
136   
137    m.generateMesh('pzq28.0za1000000a')
138
139    import filenames
140    m.export_mesh_file(filenames.mesh_filename)
141   
Note: See TracBrowser for help on using the repository browser.