source: development/momentum_sink/friction_block.py @ 2417

Last change on this file since 2417 was 2395, checked in by nicholas, 19 years ago

Updated compare_sww.py. Increased distance of rear boundary and changed to dirichlet

File size: 2.3 KB
Line 
1
2
3
4# add inundation dir to your pythonpath
5from pmesh.mesh import Mesh
6from coordinate_transforms.geo_reference import Geo_reference
7
8#test = 300
9def create_mesh(maximum_triangle_area,
10                mesh_file=None,
11                triangles_in_name = False):
12    """
13    triangles_in_name, if True is used to append the number of
14    triangles in the mesh to the mesh file name.
15    """
16    # create a mesh instance of class Mesh
17    m = Mesh()
18   
19    #print "test", test 
20    # Boundary of problem
21    WidtH = 200 # width of boudary in metres
22    #W = WidtH/8
23    #L = W
24    #outer_polygon = [[0,0],[2*WidtH,0],[2*WidtH,WidtH],[0,WidtH]]
25    #m.add_region_from_polygon(outer_polygon, tags={'wall':[0,1,2], 'wave':[3]})
26
27    #domain.set_region(Set_region('mound', 'elevation', 100, location='unique vertices'))
28
29    #Boundary
30    dict = {}
31    dict['points'] = [[0,0],[0.2*WidtH,0],[1.2*WidtH,0],[5*WidtH,0],[5*WidtH,WidtH] \
32                      ,[1.2*WidtH,WidtH],[0.2*WidtH,WidtH],[0,WidtH]]
33   
34    dict['segments'] = [[0,1], [1,2], [2,3], [3,4],
35                        [4,5], [5,6], [6,7], [7,0],[1,6],[2,5]] # the outer border
36    dict['segment_tags'] = ['wall',
37                            'wall',
38                            'wall',                           
39                            'wall',
40                            'back',
41                            'wall',
42                            'wall',
43                            'wave',
44                            '',                           
45                            '']
46    m.addVertsSegs(dict)
47
48    medium = m.add_region(0.51*WidtH,0.1)
49    medium.setTag('mound')
50   
51    m.generate_mesh(maximum_triangle_area=maximum_triangle_area)
52    triangle_count = m.get_triangle_count()
53 
54
55   
56    if mesh_file is None:   
57        return m, triangle_count, Width
58    else:
59        if triangles_in_name is True:
60            mesh_file = mesh_file[:-4] + '_' + str(triangle_count) \
61                        + mesh_file[-4:]
62        m.export_mesh_file(mesh_file)
63        return mesh_file, triangle_count
64
65#-------------------------------------------------------------
66if __name__ == "__main__":
67    _, triangle_count = create_mesh(10,mesh_file="test.tsh")
68    print "triangle_count",triangle_count
Note: See TracBrowser for help on using the repository browser.