The gmsh input is shown below and this is the first text to put into the structured_ex.geo file. To create the square, four points are speficied and these are connected by four lines. For this tutorial, a square shape is first created. The shape to be meshed will be created by specifying points and then connecting these points with lines. The first step in creating a mesh is to create some shape that will be meshed. write ( save_path ) # Save and close gmsh. write ( filename + ".geo_unrolled" ) replace ( filename + ".geo_unrolled", filename + file_extension ) else : gmsh. synchronize () filename, file_extension = splitext ( save_path ) if file_extension = ".geo" : gmsh. setPhysicalName ( 3, 1, "rotor" ) # Generate the 3D mesh factory. setPhysicalName ( 3, 1, "stator" ) else : model. addPhysicalGroup ( 3, list ( range ( 1, Zs + 1 )), 1 ) if lamination. extrude (, 0, 0, L, numElements =, recombine = False ) model. extrude (, 0, 0, L, numElements =, recombine = True ) else : ov = factory. setPhysicalName ( 2, 2, "Lamination" ) # Extrude the lamination for surf in surf_list : if is_rect = True : ov = factory. addPhysicalGroup ( 2, surf_list, 2 ) gmsh. setTransfiniteCurve ( ii + 1, mesh_dict + 1, "Progression" ) # Copy/Rotate all the tooth to get the 2D lamination surf_list = for ii in range ( Zs ): ov = factory. If numElements is not empty, also extrude the mesh: the entries in. update ( user_mesh_dict ) # Apply the number of element on each line of the surface for ii, line in enumerate ( tooth_surf. By design, the Gmsh C API is purely functional, and only uses elementary types. comp_mesh_dict ( element_size = mesh_size ) # Overwrite basic mesh dict with user one mesh_dict. setRecombine ( 2, 1 ) # Change the mesh size for each line if user_mesh_dict is not None : # Compute basic mesh_dict mesh_dict = tooth_surf. setPhysicalName ( 2, 1, "Tooth" ) # convert triangle mesh to rectangle mesh if is_rect : factory. addCurveLoop ( list ( range ( 1, NLine + 1 )), 1 ) gmsh. addLine ( NLine, NLine + 1, NLine ) # Create the Tooth surface gmsh. addCircleArc ( NLine, NPoint, NLine + 1, NLine ) else : factory. imag, - L / 2, mesh_size, NPoint ) factory. addLine ( NLine, 1, NLine ) else : if isinstance ( line, Arc ): Zc = line. addCircleArc ( NLine, NPoint - 1, 1, NLine ) else : factory. get_lines ()): if isinstance ( line, Arc ): Zc = line. get_lines (): NLine += 1 if NLine = len ( tooth_surf. imag, - L / 2, mesh_size, NPoint ) # Draw all the lines of the tooth NLine = 0 # Number of line created for line in tooth_surf. add ( "Pyleecan" ) # Create all the points of the tooth NPoint = 0 # Number of point created for line in tooth_surf. setNumber ( "Geometry.CopyMeshingMethod", 1 ) model. setNumber ( "General.Terminal", int ( display )) gmsh. L1 # Lamination length # Start a new model gmsh. The 1st and 3rd section > should be identical. > Part of my geometry includes a simple extrusion of a circle 3 times, > with different length and layer distribution. The extrude command in GMSH lets you easily make an extrusion were all the layers are the same height, but making the layer vary in size was the problem. build_geometry ( sym = sym ) Zs = sym # For readibility model = gmsh. The script is not clean, and probably not very efficient, but > it works. I was faced with the following problem: I have a nice unstructured mesh 2D mesh in GMSH, and I want to extrude this mesh with a certain growth ratio to a 3D mesh. get_Zs () else : tooth_surf = lamination. Def gen_3D_mesh ( lamination, save_path = "Lamination.msh", sym =- 1, mesh_size = 5e-3, user_mesh_dict = None, is_rect = False, Nlayer = 20, display = True, ): """Draw 3D mesh of the lamination Parameters - lamination: LamSlot Lamintation with slot to draw save_path: str Path to save the msh result file sym : int Number of symmetry to apply mesh_size : float Size of the mesh user_mesh_dict : dict To enforce the number of elements on the lines is_rect : bool To use rectangular elements Nlayer : int Number of mesh layer on Z axis display : bool To display gmsh logs Returns - None """ # The defaut symmetry is Zs => We draw only one tooth if sym = - 1 : tooth_surf = lamination.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |