# add inundation dir to your pythonpath from pmesh.mesh import Mesh from coordinate_transforms.geo_reference import Geo_reference def create_mesh(maximum_triangle_area, mesh_file=None, triangles_in_name = False): """ triangles_in_name, if True is used to append the number of triangles in the mesh to the mesh file name. """ # create a mesh instance of class Mesh m = Mesh() # Boundary of problem WidtH = 200 # width of boudary in metres #Boundary dict = {} dict['points'] = [[0,0],[0.2*WidtH,0],[1.2*WidtH,0],[2.2*WidtH,0],[5*WidtH,0],[5*WidtH,WidtH] \ ,[2.2*WidtH,WidtH],[1.2*WidtH,WidtH],[0.2*WidtH,WidtH],[0,WidtH]] dict['segments'] = [[0,1], [1,2], [2,3], [3,4], [4,5], [5,6], [6,7], [7,8],[8,9],[9,0],[1,8],[2,7],[3,6]] # the outer border dict['segment_tags'] = ['wall', 'wall', 'wall', 'wall', 'back', # defines direchet boundary for back of test area 'wall', 'wall', 'wall', 'wall', 'wave', # defines the wave boundary '', '', ''] m.addVertsSegs(dict) roughness_first = m.add_region(0.21*WidtH,0.1) roughness_first.setTag('first_block') roughness_second = m.add_region(1.21*WidtH,0.1) roughness_second.setTag('second_block') m.generate_mesh(maximum_triangle_area=maximum_triangle_area) triangle_count = m.get_triangle_count() if mesh_file is None: return m, triangle_count, Width else: if triangles_in_name is True: mesh_file = mesh_file[:-4] + 'fric_Dbl_' + str(triangle_count) \ + mesh_file[-4:] m.export_mesh_file(mesh_file) return mesh_file, triangle_count #------------------------------------------------------------- if __name__ == "__main__": _, triangle_count = create_mesh(10,mesh_file="test.tsh") print "triangle_count",triangle_count