1 | """Create a mesh of the Gippsland Lakes coast based on 100m |
---|
2 | bathymetric data. |
---|
3 | """ |
---|
4 | |
---|
5 | import os, sys |
---|
6 | sys.path.append('..') |
---|
7 | |
---|
8 | # add storm_surge dir to your pythonpath |
---|
9 | from pmesh.mesh import * |
---|
10 | from coordinate_transforms.geo_reference import Geo_reference |
---|
11 | |
---|
12 | def create_mesh(max_area, mesh_file=None): |
---|
13 | #Lower left corner |
---|
14 | xllcorner = 570066 |
---|
15 | yllcorner = 5773910 |
---|
16 | |
---|
17 | #Upper left corner |
---|
18 | xulcorner = 553571 |
---|
19 | yulcorner = 5796228 |
---|
20 | |
---|
21 | #Upper right corner |
---|
22 | xurcorner = 583675 |
---|
23 | yurcorner = 5820018 |
---|
24 | |
---|
25 | #Lower right corner |
---|
26 | xlrcorner = 601018 |
---|
27 | ylrcorner = 5797629 |
---|
28 | |
---|
29 | |
---|
30 | #create geo reference object for use with mesh |
---|
31 | geo = Geo_reference(xllcorner = xllcorner, |
---|
32 | yllcorner = yllcorner, |
---|
33 | zone = 56) |
---|
34 | print "***********************" |
---|
35 | print "geo ref", geo |
---|
36 | print "***********************" |
---|
37 | |
---|
38 | m = Mesh(geo_reference=geo) |
---|
39 | |
---|
40 | #Boundary |
---|
41 | dict = {} |
---|
42 | dict['points'] = [[xllcorner, yllcorner], #sw |
---|
43 | [xulcorner, yulcorner], |
---|
44 | [xurcorner, yurcorner], |
---|
45 | [xlrcorner, ylrcorner]] |
---|
46 | |
---|
47 | dict['segments'] = [[0,1], [1,2], [2,3], [3,0]] # the outer border |
---|
48 | dict['segment_tags'] = ['side', |
---|
49 | 'back', |
---|
50 | 'side', |
---|
51 | 'ocean'] |
---|
52 | m.addVertsSegs(dict) |
---|
53 | |
---|
54 | m.generateMesh('q28.0z', maxArea = max_area) |
---|
55 | if mesh_file is None: |
---|
56 | return m, len(m.getTriangulation()) |
---|
57 | else: |
---|
58 | m.export_mesh_file(mesh_file) |
---|
59 | return len(m.getTriangulation()) |
---|
60 | |
---|
61 | |
---|
62 | #------------------------------------------------------------- |
---|
63 | if __name__ == "__main__": |
---|
64 | _, triangle_count = create_mesh(1000000) |
---|
65 | print "triangle_count",triangle_count |
---|