source: development/momentum_sink/scripts/friction_block.py @ 3322

Last change on this file since 3322 was 2927, checked in by nicholas, 19 years ago

final update of all relavent data

File size: 2.0 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
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    # Boundary of problem
20    WidtH = 200 # width of boudary in metres
21
22    #Boundary
23    dict = {}
24    dict['points'] = [[0,0],[0.2*WidtH,0],[1.2*WidtH,0],[5*WidtH,0],[5*WidtH,WidtH] \
25                      ,[1.2*WidtH,WidtH],[0.2*WidtH,WidtH],[0,WidtH]]
26   
27    dict['segments'] = [[0,1], [1,2], [2,3], [3,4],
28                        [4,5], [5,6], [6,7], [7,0],[1,6],[2,5]] # the outer border
29    dict['segment_tags'] = ['wall',
30                            'wall',
31                            'wall',                           
32                            'wall',
33                            'back', # defines direchet boundary for back of test area
34                            'wall',
35                            'wall',
36                            'wave', # defines the wave boundary
37                            '',                           
38                            '']
39    m.addVertsSegs(dict)
40
41    medium = m.add_region(0.51*WidtH,0.1)
42    medium.setTag('mound')
43   
44    m.generate_mesh(maximum_triangle_area=maximum_triangle_area)
45    triangle_count = m.get_triangle_count()
46   
47    if mesh_file is None:   
48        return m, triangle_count, Width
49    else:
50        if triangles_in_name is True:
51            mesh_file = mesh_file[:-4] + '_' + str(triangle_count) \
52                        + mesh_file[-4:]
53        m.export_mesh_file(mesh_file)
54        return mesh_file, triangle_count
55
56#-------------------------------------------------------------
57if __name__ == "__main__":
58    _, triangle_count = create_mesh(10,mesh_file="test.tsh")
59    print "triangle_count",triangle_count
Note: See TracBrowser for help on using the repository browser.