source: development/stochastic_study/create_mesh.py @ 2984

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

Arbitrary working dir

File size: 6.6 KB
RevLine 
[2424]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 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.4, ybottom + (ytop-ybottom)/3-0.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                     
105    dict['segments'] = [[0,1], [1,2], [2,3], [3,4],
106                        [4,5], [5,6], [6,7], [7,0]]
107                       
108    dict['segment_tags'] = ['', '', '', '', '', '', '', '']
109
110
111    m.addVertsSegs(dict)   
112
113   
[2433]114    #res_1
115    #base_resolution = 1
116    #ocean = m.addRegionEN(xleft+.1, ybottom+.1)
117    #ocean.setMaxArea(0.1*base_resolution)
118    #mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
119    #mid.setMaxArea(0.0005*base_resolution)   
120    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
121    #inner.setMaxArea(0.00007*base_resolution)
[2424]122
[2433]123    #res_2 (try to improve by adding gulleys back in at a coarser res but coarsen inner and mid - this was OK) 
124    #base_resolution = 1
125    #ocean = m.addRegionEN(xleft+.1, ybottom+.1)
126    #ocean.setMaxArea(0.1*base_resolution)
127    #mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
128    #mid.setMaxArea(0.001*base_resolution)   
129    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
130    #inner.setMaxArea(0.0001*base_resolution)
131    #gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
132    ##gulleys.setMaxArea(0.00002*base_resolution)
133    #gulleys.setMaxArea(0.0005*base_resolution)           
[2424]134
[2433]135    #res_3 (Coarsen a bit more: mid and inner - shoulders got rounded. Lost one reflection) 
136    #base_resolution = 1
137    #ocean = m.addRegionEN(xleft+.1, ybottom+.1)
138    #ocean.setMaxArea(0.1*base_resolution)
139    #mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
140    #mid.setMaxArea(0.01*base_resolution)   
141    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
142    #inner.setMaxArea(0.0002*base_resolution)
143    #gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
144    #gulleys.setMaxArea(0.0005*base_resolution)           
[2424]145
[2433]146    #res_4 (Refined inner again - still rounded. Need mid to be finer) 
147    #base_resolution = 1
148    #ocean = m.addRegionEN(xleft+.1, ybottom+.1)
149    #ocean.setMaxArea(0.1*base_resolution)
150    #mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
151    #mid.setMaxArea(0.01*base_resolution)   
152    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
153    #inner.setMaxArea(0.0001*base_resolution)
154    #gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
155    #gulleys.setMaxArea(0.0005*base_resolution)
[2424]156
[2433]157    #res_5 (Refined mid again - coarsened inner 5 times - this almost OK)
158    #base_resolution = 1
159    #ocean = m.addRegionEN(xleft+.1, ybottom+.1)
160    #ocean.setMaxArea(0.1*base_resolution)
161    #mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
162    #mid.setMaxArea(0.001*base_resolution)   
163    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
164    #inner.setMaxArea(0.0005*base_resolution)
165    #gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
166    #gulleys.setMaxArea(0.0005*base_resolution)
[2424]167
[2433]168    #res_6 (Like 5 but with inner a little finer, ocean and mid a bit coarser -  no worse than 5)
169    #base_resolution = 1
170    #ocean = m.addRegionEN(xleft+.1, ybottom+.1)
171    #ocean.setMaxArea(0.2*base_resolution)
172    #mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
173    #mid.setMaxArea(0.002*base_resolution)   
174    #inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
175    #inner.setMaxArea(0.0004*base_resolution)
[2424]176    #gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
[2433]177    #gulleys.setMaxArea(0.0005*base_resolution)
178
179    #res_7 (Like 6 but with everything coarsened a tad -
180    #a bit smoothed but still OK)
181    base_resolution = 1
182    ocean = m.addRegionEN(xleft+.1, ybottom+.1)
183    ocean.setMaxArea(0.3*base_resolution)
184    mid = m.addRegionEN(point_mbottom[0]+.1, ybottom+.1)
185    mid.setMaxArea(0.003*base_resolution)   
186    inner = m.addRegionEN(island_3[0]+.1, island_3[1]+.1)
187    inner.setMaxArea(0.0007*base_resolution)
188    gulleys = m.addRegionEN(p0[0]+0.1, p0[1]+0.1)
189    gulleys.setMaxArea(0.0007*base_resolution)                       
190
[2424]191   
192    m.generateMesh('pzq28.0za1000000a')
193
194    import project
[2979]195    m.export_mesh_file(project.working_dir + project.mesh_filename)
[2424]196   
Note: See TracBrowser for help on using the repository browser.