# 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],[5*WidtH,0],[5*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,0],[1,6],[2,5]] # the outer border dict['segment_tags'] = ['wall', 'wall', 'wall', 'wall', 'back', # defines direchet boundary for back of test area 'wall', 'wall', 'wave', # defines the wave boundary '', ''] m.addVertsSegs(dict) medium = m.add_region(0.51*WidtH,0.1) medium.setTag('mound') 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] + '_' + 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