--- /dev/null
+# -*- coding: utf-8 -*-\r
+from __future__ import print_function, division\r
+from math import sqrt\r
+from salome.geom import geomBuilder\r
+from salome.smesh import smeshBuilder\r
+\r
+geompy = geomBuilder.New()\r
+smesh = smeshBuilder.New()\r
+\r
+def create_group_near(name, mother_shape, pos, list_grp, type, add=True):\r
+ shapes = [geompy.GetShapesNearPoint(mother_shape, P, geompy.ShapeType[type]) for P in pos]\r
+ new = create_group_from(name, mother_shape, shapes, type)\r
+ if add:\r
+ list_grp.append(new)\r
+ return new, list_grp\r
+\r
+def create_group_from(name, mother_shape, list_elem, type="EDGE"):\r
+ new = geompy.CreateGroup(mother_shape, geompy.ShapeType[type])\r
+ geompy.UnionList(new, list_elem)\r
+ new.SetName(name)\r
+ geompy.addToStudyInFather(mother_shape, new, name)\r
+ return new\r
+\r
+def yt(t, x, c, finite):\r
+ a4 = 0.1015 if finite else 0.1036\r
+ return t / 0.2 * (0.2969 * sqrt(x / c) - 0.1260 * (x / c) - 0.3516 * (x / c)**2 + 0.2843 * (x / c)**3 - a4 * (x / c) ** 4)\r
+\r
+# ------------------------------------------- #\r
+# parametres geometriques\r
+\r
+c = 1. # corde\r
+t = 0.12 # episseur max (fraction de corde)\r
+nx = 1000 # discretisation de la forme\r
+\r
+# taille du domaine\r
+hx, hy = 10.0 * c, 5.0 * c\r
+\r
+# parametres du maillage\r
+NumberOfSegments = 10\r
+dx_mesh = c / NumberOfSegments\r
+angle_mesh = 8.\r
+# ------------------------------------------- #\r
+\r
+dx = c / nx\r
+xC = [i * dx for i in range(nx + 1)]\r
+yU = [ yt(t, x, c, False) for x in xC]\r
+yD = [-yt(t, x, c, False) for x in xC]\r
+\r
+profile = [geompy.MakeVertex(x, y, 0) for x, y in zip(reversed(xC), reversed(yU))]\r
+profile += [geompy.MakeVertex(x, y, 0) for x, y in zip(xC[1:], yD[1:])]\r
+\r
+profile_boundary = geompy.MakeWire([geompy.MakeInterpol(profile)])\r
+profile = geompy.MakeFace(profile_boundary, 1)\r
+geompy.addToStudy(profile, "Profile")\r
+\r
+domain = geompy.MakeFaceHW(hx, hy, 1)\r
+domain = geompy.MakeCut(domain, profile)\r
+\r
+geompy.addToStudy(domain, "Domain")\r
+group = create_group_from("Airfoil_boundary", domain, [geompy.GetInPlace(domain, profile_boundary, 1)])\r
+groups = [group]\r
+new, groups = create_group_near("Inlet" , domain, [geompy.MakeVertex(-hx / 2., 0., 0.)], groups, "EDGE")\r
+new, groups = create_group_near("Outlet", domain, [geompy.MakeVertex( hx / 2., 0., 0.)], groups, "EDGE")\r
+new, groups = create_group_near("Top" , domain, [geompy.MakeVertex(0., hy / 2., 0.)], groups, "EDGE")\r
+new, groups = create_group_near("Bottom", domain, [geompy.MakeVertex(0., -hy / 2., 0.)], groups, "EDGE")\r
+\r
+# maillage\r
+mesh = smesh.Mesh(domain, "MeshFlow")\r
+for g in groups: mesh.Group(g)\r
+msurf = mesh.Triangle(algo=smeshBuilder.NETGEN_1D2D)\r
+NETGEN_2D_Simple_Parameters_1 = msurf.Parameters(smeshBuilder.SIMPLE)\r
+NETGEN_2D_Simple_Parameters_1.SetNumberOfSegments( NumberOfSegments )\r
+mesh.Compute()\r
+\r
+mesh.ExportMED("naca"+str(NumberOfSegments)+".med")\r