1 | """Create mesh for near shore PMD |
---|
2 | """ |
---|
3 | |
---|
4 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
5 | from anuga.coordinate_transforms.geo_reference import Geo_reference |
---|
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 | xleft = 8000 # looking at the first 2 km of wave travel |
---|
16 | xright = 10000 # wave generated here |
---|
17 | if thinner: |
---|
18 | ytop = 10 |
---|
19 | ybottom = -ytop |
---|
20 | else: |
---|
21 | ytop = 2000 |
---|
22 | ybottom = -ytop |
---|
23 | |
---|
24 | |
---|
25 | point_sw = [xleft, ybottom] |
---|
26 | point_se = [xright, ybottom] |
---|
27 | point_nw = [xleft, ytop] |
---|
28 | point_ne = [xright, ytop] |
---|
29 | |
---|
30 | bounding_polygon = [point_se, |
---|
31 | point_ne, |
---|
32 | point_nw, |
---|
33 | point_sw] |
---|
34 | |
---|
35 | # local refinement |
---|
36 | xleft = -80 |
---|
37 | xright = 2000 |
---|
38 | if thinner: |
---|
39 | ytop = 450 |
---|
40 | ybottom = -450 |
---|
41 | else: |
---|
42 | ytop = 1000 |
---|
43 | ybottom = -1000 |
---|
44 | |
---|
45 | point_sw = [xleft, ybottom] |
---|
46 | point_se = [xright, ybottom] |
---|
47 | point_nw = [xleft, ytop] |
---|
48 | point_ne = [xright, ytop] |
---|
49 | |
---|
50 | polygon_2 = [point_se, |
---|
51 | point_ne, |
---|
52 | point_nw, |
---|
53 | point_sw] |
---|
54 | |
---|
55 | interior_regions = [[polygon_2, maximum_triangle_area/2.]] |
---|
56 | |
---|
57 | m = create_mesh_from_regions(bounding_polygon, |
---|
58 | boundary_tags={'wall': [1, 2, 3], |
---|
59 | 'wave': [0]}, |
---|
60 | maximum_triangle_area=maximum_triangle_area, |
---|
61 | #interior_regions=interior_regions, |
---|
62 | mesh_geo_reference=Geo_reference(), |
---|
63 | filename=mesh_filename, |
---|
64 | verbose=True) |
---|
65 | print "mesh created" |
---|
66 | |
---|
67 | |
---|
68 | def generate_structured(): |
---|
69 | """ |
---|
70 | """ |
---|
71 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
72 | from anuga.shallow_water import Domain |
---|
73 | #------------------------------------------------------------------------------ |
---|
74 | # Setup domain |
---|
75 | #------------------------------------------------------------------------------ |
---|
76 | dx = 10. |
---|
77 | dy = dx |
---|
78 | L = 2080. |
---|
79 | W = dx |
---|
80 | |
---|
81 | # structured mesh |
---|
82 | points, vertices, boundary = rectangular_cross(int(L/dx), int(W/dy), L, W, (-80.0, -W*0.5)) |
---|
83 | |
---|
84 | domain = Domain(points, vertices, boundary) |
---|
85 | |
---|
86 | print "domain created" |
---|
87 | return domain |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | #------------------------------------------------------------- |
---|
92 | if __name__ == "__main__": |
---|
93 | generate("aa.tsh", thinner=True) |
---|