From: msv Date: Thu, 27 Apr 2006 06:33:13 +0000 (+0000) Subject: Update SMESH module to accomodate new features of NETGEN plugin based on X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1e17309dab392b1bb4d42db2fb37b656af077429;p=modules%2Fsmesh.git Update SMESH module to accomodate new features of NETGEN plugin based on Netgen ver.4.5 --- diff --git a/Makefile.in b/Makefile.in index 1f0723b45..1b3bc2ca6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -76,11 +76,15 @@ mesh_tree_algo.png \ mesh_tree_algo_quad.png \ mesh_tree_algo_regular.png \ mesh_tree_algo_tetra.png \ +mesh_tree_algo_netgen_2d3d.png \ +mesh_tree_algo_netgen_2d.png \ mesh_tree_hypo_area.png \ mesh_tree_hypo_length.png \ mesh_tree_hypo.png \ mesh_tree_hypo_segment.png \ mesh_tree_hypo_volume.png \ +mesh_tree_hypo_netgen.png \ +mesh_tree_hypo_netgen_2d.png \ mesh_tree_mesh.png \ mesh_tree_importedmesh.png \ mesh_tree_mesh_warn.png \ diff --git a/resources/mesh_tree_algo_netgen_2d.png b/resources/mesh_tree_algo_netgen_2d.png new file mode 100755 index 000000000..092eae3c0 Binary files /dev/null and b/resources/mesh_tree_algo_netgen_2d.png differ diff --git a/resources/mesh_tree_algo_netgen_2d3d.png b/resources/mesh_tree_algo_netgen_2d3d.png new file mode 100644 index 000000000..eeaf98afe Binary files /dev/null and b/resources/mesh_tree_algo_netgen_2d3d.png differ diff --git a/resources/mesh_tree_hypo_netgen.png b/resources/mesh_tree_hypo_netgen.png new file mode 100644 index 000000000..ad5e9f3c4 Binary files /dev/null and b/resources/mesh_tree_hypo_netgen.png differ diff --git a/resources/mesh_tree_hypo_netgen_2d.png b/resources/mesh_tree_hypo_netgen_2d.png new file mode 100644 index 000000000..cd813c86a Binary files /dev/null and b/resources/mesh_tree_hypo_netgen_2d.png differ diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in index df7e19a17..f0ba6eec1 100644 --- a/src/SMESH_SWIG/Makefile.in +++ b/src/SMESH_SWIG/Makefile.in @@ -72,9 +72,11 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \ SMESH_mechanic.py \ SMESH_mechanic_tetra.py \ SMESH_mechanic_editor.py \ + SMESH_mechanic_netgen.py \ SMESH_fixation.py \ SMESH_fixation_hexa.py \ SMESH_fixation_tetra.py \ + SMESH_fixation_netgen.py \ SMESH_box_tetra.py \ SMESH_box2_tetra.py \ SMESH_box3_tetra.py \ diff --git a/src/SMESH_SWIG/SMESH_fixation_netgen.py b/src/SMESH_SWIG/SMESH_fixation_netgen.py new file mode 100644 index 000000000..ccc679c43 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_fixation_netgen.py @@ -0,0 +1,56 @@ +# +# Tetrahedrization of the geometry generated by the Python script +# SMESH_fixation.py +# The new Netgen algorithm is used that discretizes baoundaries itself +# + +import StdMeshers +import NETGENPlugin +import SMESH_fixation +import smesh + +compshell = SMESH_fixation.compshell +idcomp = SMESH_fixation.idcomp +geompy = SMESH_fixation.geompy +salome = SMESH_fixation.salome + +print "Analysis of the geometry to be meshed :" +subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) + +print "number of Shells in compshell : ", len(subShellList) +print "number of Faces in compshell : ", len(subFaceList) +print "number of Edges in compshell : ", len(subEdgeList) + +status = geompy.CheckShape(compshell) +print " check status ", status + +### ---------------------------- SMESH -------------------------------------- + +print "-------------------------- create Mesh, algorithm, hypothesis" + +mesh = smesh.Mesh(compshell, "MeshcompShel"); +netgen = mesh.Netgen(1) +hyp = netgen.Parameters() +hyp.SetMaxSize( 50 ) +#hyp.SetSecondOrder( 0 ) +hyp.SetFineness( 3 ) +#hyp.SetOptimize( 1 ) + +salome.sg.updateObjBrowser(1) + +print "-------------------------- compute mesh" +ret = mesh.Compute() +print ret +if ret != 0: + print "Information about the MeshcompShel:" + print "Number of nodes : ", mesh.GetMesh().NbNodes() + print "Number of edges : ", mesh.GetMesh().NbEdges() + print "Number of faces : ", mesh.GetMesh().NbFaces() + print "Number of triangles : ", mesh.GetMesh().NbTriangles() + print "Number of volumes : ", mesh.GetMesh().NbVolumes() + print "Number of tetrahedrons : ", mesh.GetMesh().NbTetras() + +else: + print "problem when computing the mesh" diff --git a/src/SMESH_SWIG/SMESH_mechanic_netgen.py b/src/SMESH_SWIG/SMESH_mechanic_netgen.py new file mode 100644 index 000000000..b711bc495 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_mechanic_netgen.py @@ -0,0 +1,117 @@ +# +# Quadrangulation of the geometry generated by the Python script +# SMESH_mechanic.py +# The new Netgen algorithm is used that discretizes baoundaries itself +# + +import salome +import geompy + +geom = geompy.geom + +import StdMeshers +import NETGENPlugin +import smesh + +# ---------------------------- GEOM -------------------------------------- + +# ---- define contigous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) + +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) + +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) + +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) + +# ---- define a closed wire with arcs and segment +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) + +# ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) + +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1") + +# ---- create two cylinders + +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) +radius = 20.0 +height = 180.0 +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) + +# ---- Analysis of the geometry + +print "Analysis of the geometry mechanic :" + +subShellList = geompy.SubShapeAll(mechanic,geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(mechanic,geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(mechanic,geompy.ShapeType["EDGE"]) + +print "number of Shells in mechanic : ",len(subShellList) +print "number of Faces in mechanic : ",len(subFaceList) +print "number of Edges in mechanic : ",len(subEdgeList) + +### ---------------------------- SMESH -------------------------------------- + +print "-------------------------- create Mesh, algorithm, hypothesis" + +mesh = smesh.Mesh(mechanic, "Mesh_mechanic"); +netgen = mesh.Netgen(0) +hyp = netgen.Parameters() +hyp.SetMaxSize( 50 ) +#hyp.SetSecondOrder( 0 ) +hyp.SetFineness( 3 ) +hyp.SetQuadAllowed( 1 ) +#hyp.SetOptimize( 1 ) + +salome.sg.updateObjBrowser(1) + +print "-------------------------- compute mesh" +ret = mesh.Compute() +print ret +if ret != 0: + print "Information about the MeshcompShel:" + print "Number of nodes : ", mesh.GetMesh().NbNodes() + print "Number of edges : ", mesh.GetMesh().NbEdges() + print "Number of faces : ", mesh.GetMesh().NbFaces() + print "Number of triangles : ", mesh.GetMesh().NbTriangles() + print "Number of quadrangles : ", mesh.GetMesh().NbQuadrangles() + print "Number of volumes : ", mesh.GetMesh().NbVolumes() + print "Number of tetrahedrons : ", mesh.GetMesh().NbTetras() + +else: + print "problem when computing the mesh" diff --git a/src/SMESH_SWIG/smesh.py b/src/SMESH_SWIG/smesh.py index 5e37242dc..bf7fed011 100644 --- a/src/SMESH_SWIG/smesh.py +++ b/src/SMESH_SWIG/smesh.py @@ -383,6 +383,37 @@ class Mesh_Hexahedron(Mesh_Algorithm): """ self.Create(mesh, geom, "Hexa_3D") +# Public class: Mesh_Netgen +# ------------------------------ + +class Mesh_Netgen(Mesh_Algorithm): + """ + Class to define a NETGEN-based 2D or 3D algorithm + that need no discrete boundary (i.e. independent) + """ + + is3D = 0 + + def __init__(self, mesh, is3D, geom=0): + """ + Private constructor + """ + self.is3D = is3D + if is3D: + self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so") + else: + self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so") + + def Parameters(self): + """ + Define hypothesis containing parameters of the algorithm + """ + if self.is3D: + hyp = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so") + else: + hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so") + return hyp + # Public class: Mesh # ================== @@ -499,6 +530,17 @@ class Mesh: """ return Mesh_Hexahedron(self, geom) + def Netgen(self, is3D, geom=0): + """ + Creates a NETGEN-based 2D or 3D independent algorithm (i.e. needs no + discrete boundary). + If the optional \a geom parameter is not sets, this algorithm is global. + Otherwise, this algorithm defines a submesh based on \a geom subshape. + \param is3D If 0 then algorithm is 2D, otherwise 3D + \param geom If defined, subshape to be meshed + """ + return Mesh_Netgen(self, is3D, geom) + def Compute(self): """ Compute the mesh and return the status of the computation