thklm = 200.0 bm2 = DataFactory.get_bedmap2(thklm) bedmap2 = DataInput(bm2) # Load the domain coordinates domain_coordinates = loadtxt('domain_coordinates1.out') mesh_name = 'ant_mesh' # Create a contour for the domain #======================================================= # Create a mesh file in the current directory m = MeshGenerator(bedmap2, mesh_name, '') # Manually set the countour instead of calculating it automatically m.set_contour(domain_coordinates) # Write the contour points to the mesh file m.write_gmsh_contour(100000, boundary_extend = False) # Extrude the flat mesh 10,000 meters in the z dimension. The height of the # mesh can be automatically scaled to the proper height by the model object m.extrude(10000, 14) # We're finished with the flat mesh! m.close_file() # Refine the mesh based on ice thickness #======================================================= ref_bm = MeshRefiner(bedmap2, 'H', gmsh_file_name = mesh_name) # Refine the mesh based on the refinement radius a, aid = ref_bm.add_static_attractor(1.5) ref_bm.set_background_field(aid)
# plot to check : #db2.data['mask'][db2.data['mask'] == 1] = 0 #imshow(db2.data['mask'][::-1,:]) #colorbar() #tight_layout() #show() imshow(db2.data['B'][::-1]) colorbar() #show() print db2.data['B'].max() # generate the contour : m = MeshGenerator(db2, 'mesh', '') # Manually create a circular contour angles = linspace(0, 1, 1000)*2*pi xs = 2999000*cos(angles) ys = 2999000*sin(angles) contour = array(zip(xs, ys)) m.set_contour(contour) m.write_gmsh_contour(1000, boundary_extend=False) m.add_edge_attractor(1) #field, ifield, lcMin, lcMax, distMin, distMax m.add_threshold(2, 1, 5000, 5000, 1, 100000) m.finish(4) m.close_file()
[xmin, 100000] ]) # Name of refined mesh mesh_name = 'transect_mesh' # Get the Antarctica data sets bedmap2 = DataFactory.get_bedmap2(thklim=200) # Load in a DataInput object. We won't use it, but we need to pass a DataInput # to the MeshGenerator, and we have to fake it out. db2 = DataInput(None, bedmap2) # Create a mesh file in the current directory m = MeshGenerator(db2, mesh_name, '') # Manually set the countour instead of calculating it automatically m.set_contour(cont) # Write the contour points to the mesh file m.write_gmsh_contour(100000, boundary_extend = False) # Extrude the flat mesh 10,000 meters in the z dimension. The height of the # mesh can be automatically scaled to the proper height by the model object m.extrude(20000, 10) # We're finished with the flat mesh! m.close_file() # Refine the mesh based on thickness # Wrap the bed spline in a function that takes two arguments def bed(x,y) : return bed_spline(x)