source: development/momentum_sink/scripts/two_friction_block.py @ 3295

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

final update of all relavent data

File size: 2.4 KB
RevLine 
[2927]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],[2.2*WidtH,0],[5*WidtH,0],[5*WidtH,WidtH] \
25                      ,[2.2*WidtH,WidtH],[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,8],[8,9],[9,0],[1,8],[2,7],[3,6]] # 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                            'wall',
37                            'wall',
38                            'wave', # defines the wave boundary
39                            '',                           
40                            '',                           
41                            '']
42    m.addVertsSegs(dict)
43
44    roughness_first = m.add_region(0.21*WidtH,0.1)
45    roughness_first.setTag('first_block')
46    roughness_second = m.add_region(1.21*WidtH,0.1)
47    roughness_second.setTag('second_block')
48   
49    m.generate_mesh(maximum_triangle_area=maximum_triangle_area)
50    triangle_count = m.get_triangle_count()
51   
52    if mesh_file is None:   
53        return m, triangle_count, Width
54    else:
55        if triangles_in_name is True:
56            mesh_file = mesh_file[:-4] + 'fric_Dbl_' + str(triangle_count) \
57                        + mesh_file[-4:]
58        m.export_mesh_file(mesh_file)
59        return mesh_file, triangle_count
60
61#-------------------------------------------------------------
62if __name__ == "__main__":
63    _, triangle_count = create_mesh(10,mesh_file="test.tsh")
64    print "triangle_count",triangle_count
Note: See TracBrowser for help on using the repository browser.