1 | """Create mesh for near shore PMD |
---|
2 | """ |
---|
3 | |
---|
4 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
5 | |
---|
6 | |
---|
7 | xslope = 5.0 # Distance between the boundary ande the start of the slope |
---|
8 | |
---|
9 | |
---|
10 | def generate(mesh_filename, maximum_triangle_area=300000, thinner=False): |
---|
11 | """ |
---|
12 | """ |
---|
13 | # Basic geometry and bounding polygon |
---|
14 | xleft = -100 # Beach |
---|
15 | xright = 10000 # wave generated here |
---|
16 | if thinner: |
---|
17 | ytop = 1000 |
---|
18 | ybottom = -1000 |
---|
19 | else: |
---|
20 | ytop = 2000 |
---|
21 | ybottom = -2000 |
---|
22 | |
---|
23 | |
---|
24 | point_sw = [xleft, ybottom] |
---|
25 | point_se = [xright, ybottom] |
---|
26 | point_nw = [xleft, ytop] |
---|
27 | point_ne = [xright, ytop] |
---|
28 | |
---|
29 | bounding_polygon = [point_se, |
---|
30 | point_ne, |
---|
31 | point_nw, |
---|
32 | point_sw] |
---|
33 | |
---|
34 | # local refinement |
---|
35 | xleft = -80 |
---|
36 | xright = 2000 |
---|
37 | if thinner: |
---|
38 | ytop = 900 |
---|
39 | ybottom = -900 |
---|
40 | else: |
---|
41 | ytop = 1000 |
---|
42 | ybottom = -1000 |
---|
43 | |
---|
44 | point_sw = [xleft, ybottom] |
---|
45 | point_se = [xright, ybottom] |
---|
46 | point_nw = [xleft, ytop] |
---|
47 | point_ne = [xright, ytop] |
---|
48 | |
---|
49 | polygon_2 = [point_se, |
---|
50 | point_ne, |
---|
51 | point_nw, |
---|
52 | point_sw] |
---|
53 | |
---|
54 | interior_regions = [[polygon_2, maximum_triangle_area/2.]] |
---|
55 | |
---|
56 | m = create_mesh_from_regions(bounding_polygon, |
---|
57 | boundary_tags={'wall': [1, 2, 3], |
---|
58 | 'wave': [0]}, |
---|
59 | maximum_triangle_area=maximum_triangle_area, |
---|
60 | interior_regions=interior_regions, |
---|
61 | filename=mesh_filename, |
---|
62 | verbose=True) |
---|
63 | print "mesh created" |
---|
64 | |
---|
65 | |
---|
66 | #------------------------------------------------------------- |
---|
67 | if __name__ == "__main__": |
---|
68 | generate("aa.tsh", thinner=True) |
---|