X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=doc%2Fsalome%2Fgui%2FSMESH%2Fconstructing_meshes.htm;h=a643f436f5807f11ea580dee480bc93a5d4e10fd;hp=6fa5dae03e8500523f1b8fd8ce356eb2d306929c;hb=9d11375af40826e967ab2c3bcb77d1f9d439c90c;hpb=57b43b4d010e2d0a1529d3c131bbb9d416e63258 diff --git a/doc/salome/gui/SMESH/constructing_meshes.htm b/doc/salome/gui/SMESH/constructing_meshes.htm index 6fa5dae03..a643f436f 100755 --- a/doc/salome/gui/SMESH/constructing_meshes.htm +++ b/doc/salome/gui/SMESH/constructing_meshes.htm @@ -1,727 +1,448 @@ - - - - -
-import salome
- -import geompy
- -import StdMeshers
- -smesh = salome.lcc.FindOrLoadComponent("FactoryServer", - "SMESH")
- -smeshgui = salome.ImportComponentGUI("SMESH")
- -smeshgui.Init(salome.myStudyId);
- -- -
# create a box
- -box = geompy.MakeBox(0., - 0., 0., 100., 200., 300.)
- -- -
# add box to the study
- -idbox = geompy.addToStudy(box, - "box")
- -- -
# create a hypothesis
- -print "-------------------------- - create Hypothesis"
- -print "-------------------------- - NumberOfSegments"
- -numberOfSegments - = 7
- -hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", - "libStdMeshersEngine.so")
- -hypNbSeg.SetNumberOfSegments(numberOfSegments)
- -print hypNbSeg.GetName()
- -print hypNbSeg.GetId()
- -print hypNbSeg.GetNumberOfSegments()
- -smeshgui.SetName(salome.ObjectToID(hypNbSeg), - "NumberOfSegments_10")
- -print "-------------------------- - MaxElementArea"
- -maxElementArea = - 800
- -hypArea = smesh.CreateHypothesis("MaxElementArea", - "libStdMeshersEngine.so")
- -hypArea.SetMaxElementArea(maxElementArea)
- -print hypArea.GetName()
- -print hypArea.GetId()
- -print hypArea.GetMaxElementArea()
- -smeshgui.SetName(salome.ObjectToID(hypArea), - "MaxElementArea_500")
- -print "-------------------------- - MaxElementVolume"
- -maxElementVolume - = 900
- -hypVolume = smesh.CreateHypothesis("MaxElementVolume", - "libStdMeshersEngine.so")
- -hypVolume.SetMaxElementVolume(maxElementVolume)
- -print hypVolume.GetName()
- -print hypVolume.GetId()
- -print hypVolume.GetMaxElementVolume()
- -smeshgui.SetName(salome.ObjectToID(hypVolume), - "MaxElementVolume_500")
- -- -
# create algorithms
- -print "-------------------------- - create Algorithms"
- -print "-------------------------- - Regular_1D"
- -regular1D = smesh.CreateHypothesis("Regular_1D", - "libStdMeshersEngine.so")
- -smeshgui.SetName(salome.ObjectToID(regular1D), - "Wire Discretisation")
- -print "-------------------------- - MEFISTO_2D"
- -mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", - "libStdMeshersEngine.so")
- -smeshgui.SetName(salome.ObjectToID(mefisto2D), - "MEFISTO_2D")
- -- -
# initialize a mesh with - the box
- -mesh = smesh.CreateMesh(box)
- -smeshgui.SetName(salome.ObjectToID(mesh), - "MeshBox")
- -- -
# add the hypothesis to - the box
- -print "-------------------------- - add hypothesis to the box"
- -mesh.AddHypothesis(box,hypNbSeg)
- -mesh.AddHypothesis(box,hypArea)
- -mesh.AddHypothesis(box,hypVolume)
- -mesh.AddHypothesis(box,regular1D)
- -mesh.AddHypothesis(box,mefisto2D)
- -- -
# compute the mesh
- -print "-------------------------- - compute the mesh of the box"
- -ret = smesh.Compute(mesh,box)
- -print ret
- -if ret == 0:
- -print - "probleme when computing the mesh"
- -salome.sg.updateObjBrowser(1)
- -- -
- -
from - geompy import *
- -import smesh
- -- -
# create vertices
- -Point111 = MakeVertex( 0, 0, - 0)
- -Point211 = MakeVertex(10, 0, - 0)
- -Point121 = MakeVertex( 0, 10, 0)
- -Point221 = MakeVertex(10, 10, 0)
- -Point112 = MakeVertex( 0, 0, - 10)
- -Point212 = MakeVertex(10, 0, - 10)
- -Point122 = MakeVertex( 0, 10, 10)
- -Point222 = MakeVertex(10, 10, 10)
- -- -
# create edges
- -EdgeX111 = MakeEdge(Point111, Point211)
- -EdgeX121 = MakeEdge(Point121, Point221)
- -EdgeX112 = MakeEdge(Point112, Point212)
- -EdgeX122 = MakeEdge(Point122, Point222)
- -EdgeY11 = MakeEdge(Point111, Point121)
- -EdgeY21 = MakeEdge(Point211, Point221)
- -EdgeY12 = MakeEdge(Point112, Point122)
- -EdgeY22 = MakeEdge(Point212, Point222)
- -EdgeZ111 = MakeEdge(Point111, Point112)
- -EdgeZ211 = MakeEdge(Point211, Point212)
- -EdgeZ121 = MakeEdge(Point121, Point122)
- -EdgeZ221 = MakeEdge(Point221, Point222)
- -- -
# create faces
- -FaceX11 = MakeQuad(EdgeY11, EdgeZ111, - EdgeY12, EdgeZ121)
- -FaceX21 = MakeQuad(EdgeY21, EdgeZ211, - EdgeY22, EdgeZ221)
- -FaceY111 = MakeQuad(EdgeX111, EdgeZ111, - EdgeX112, EdgeZ211)
- -FaceY121 = MakeQuad(EdgeX121, EdgeZ121, - EdgeX122, EdgeZ221)
- -FaceZ11 = MakeQuad(EdgeX111, EdgeY11, - EdgeX121, EdgeY21)
- -FaceZ12 = MakeQuad(EdgeX112, EdgeY12, - EdgeX122, EdgeY22)
- -- -
# create a solid
- -Block = MakeHexa(FaceX11, FaceX21, FaceY111, - FaceY121, FaceZ11, FaceZ12)
- -- -
# create a compound
- -box = MakeCompound([Block])
- -- -
# add in the study
- -box_id = addToStudy(box, "Box compound")
- -- -
# create hexahedral mesh - on the box
- -hexa = smesh.Mesh(box, "Box compound - : hexahedrical mesh")
- -algo = hexa.Segment()
- -- -
# define "NumberOfSegments" - hypothesis to cut the edge in a fixed number of segments
- -algo.NumberOfSegments(4)
- -- -
# creates a quadrangle - 2D algorithm for the faces
- -hexa.Quadrangle()
- -- -
# construct a submesh with - a local hypothesis
- -algo = hexa.Segment(EdgeX111)
- -- -
# define "Arithmetic1D" - hypothesis to cut an edge in several segments with increasing arithmetic - length
- -algo.Arithmetic1D(1, 4)
- -- -
# define "Propagation" - hypothesis that propagates all other hypothesis on all edges on the opposite - side in case of quadrangular faces
- -algo.Propagation()
- -- -
# compute the mesh
- -hexa.Compute()
- -- -
- -
import - salome
- -import geompy
- -import SMESH
- -import StdMeshers
- -- -
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", - "SMESH")
- -smesh.SetCurrentStudy(salome.myStudy)
- -- -
box = - geompy.MakeBox(0., 0., 0., 20., 20., 20.)
- -idbox = geompy.addToStudy(box, "box")
- -- -
subShapeList = geompy.SubShapeAll(box, - geompy.ShapeType["EDGE"])
- -edge = - subShapeList[0]
- -name = - geompy.SubShapeName(edge, box)
- -idedge = geompy.addToStudyInFather(box, - edge, name)
- -- -
box = - salome.IDToObject(idbox)
- -edge = salome.IDToObject(idedge)
- -- -
hyp1 = smesh.CreateHypothesis("NumberOfSegments", - "libStdMeshersEngine.so")
- -hyp1.SetNumberOfSegments(3)
- -hyp2 = smesh.CreateHypothesis("MaxElementArea", - "libStdMeshersEngine.so")
- -hyp2.SetMaxElementArea(10)
- -hyp3 = smesh.CreateHypothesis("Arithmetic1D", - "libStdMeshersEngine.so")
- -hyp3.SetLength(1,1)
- -hyp3.SetLength(6,0)
- -hyp4 = smesh.CreateHypothesis("Propagation", - "libStdMeshersEngine.so")
- -- -
algo1 = smesh.CreateHypothesis("Regular_1D", - "libStdMeshersEngine.so")
- -algo2 = smesh.CreateHypothesis("MEFISTO_2D", - "libStdMeshersEngine.so")
- -- -
mesh = smesh.CreateMesh(box)
- -mesh.AddHypothesis(box,hyp1)
- -mesh.AddHypothesis(box,hyp2)
- -mesh.AddHypothesis(box,algo1)
- -mesh.AddHypothesis(box,algo2)
- -mesh.AddHypothesis(edge,hyp3)
- -mesh.AddHypothesis(edge,hyp4)
- -mesh.AddHypothesis(edge,algo1)
- -- -
smesh.Compute(mesh,box)
- -salome.sg.updateObjBrowser(1)
- -- -
# remove a hypothesis
- -mesh.RemoveHypothesis(edge,hyp4)
- -- -
smesh.Compute(mesh,box)
- -salome.sg.updateObjBrowser(1)
- -- -
# change the value - of the hypothesis
- -hyp2.SetMaxElementArea(2)
- -mesh.AddHypothesis(box,hyp2)
- -- -
smesh.Compute(mesh,box)
- -salome.sg.updateObjBrowser(1)
- -- -
- -
import - salome
- -import geompy
- -import StdMeshers
- -smesh = salome.lcc.FindOrLoadComponent("FactoryServer", - "SMESH")
- -smeshgui = salome.ImportComponentGUI("SMESH")
- -smeshgui.Init(salome.myStudyId);
- -- -
# create a box
- -box = geompy.MakeBox(0., - 0., 0., 100., 200., 300.)
- -- -
# add the box to the study
- -idbox = geompy.addToStudy(box, - "box")
- -- -
# create a hypothesis
- -print "-------------------------- - create Hypothesis"
- -print "-------------------------- - NumberOfSegments"
- -numberOfSegments - = 7
- -hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", - "libStdMeshersEngine.so")
- -hypNbSeg.SetNumberOfSegments(numberOfSegments)
- -print hypNbSeg.GetName()
- -print hypNbSeg.GetId()
- -print hypNbSeg.GetNumberOfSegments()
- -smeshgui.SetName(salome.ObjectToID(hypNbSeg), - "NumberOfSegments_10")
- -print "-------------------------- - MaxElementArea"
- -maxElementArea = - 800
- -hypArea = smesh.CreateHypothesis("MaxElementArea", - "libStdMeshersEngine.so")
- -hypArea.SetMaxElementArea(maxElementArea)
- -print hypArea.GetName()
- -print hypArea.GetId()
- -print hypArea.GetMaxElementArea()
- -smeshgui.SetName(salome.ObjectToID(hypArea), - "MaxElementArea_500")
- -print "-------------------------- - MaxElementVolume"
- -maxElementVolume - = 900
- -hypVolume = smesh.CreateHypothesis("MaxElementVolume", - "libStdMeshersEngine.so")
- -hypVolume.SetMaxElementVolume(maxElementVolume)
- -print hypVolume.GetName()
- -print hypVolume.GetId()
- -print hypVolume.GetMaxElementVolume()
- -smeshgui.SetName(salome.ObjectToID(hypVolume), - "MaxElementVolume_500")
- -- -
# create algorithms
- -print "-------------------------- - create Algorithms"
- -print "-------------------------- - Regular_1D"
- -regular1D = smesh.CreateHypothesis("Regular_1D", - "libStdMeshersEngine.so")
- -smeshgui.SetName(salome.ObjectToID(regular1D), - "Wire Discretisation")
- -print "-------------------------- - MEFISTO_2D"
- -mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", - "libStdMeshersEngine.so")
- -smeshgui.SetName(salome.ObjectToID(mefisto2D), - "MEFISTO_2D")
- -- -
# initialize a mesh with - the box
- -mesh = smesh.CreateMesh(box)
- -smeshgui.SetName(salome.ObjectToID(mesh), - "MeshBox")
- -- -
# add the hypothesis to - the box
- -print "-------------------------- - add hypothesis to the box"
- -mesh.AddHypothesis(box,hypNbSeg)
- -mesh.AddHypothesis(box,hypArea)
- -mesh.AddHypothesis(box,hypVolume)
- -mesh.AddHypothesis(box,regular1D)
- -mesh.AddHypothesis(box,mefisto2D)
- -- -
# compute the mesh
- -print "-------------------------- - compute the mesh of the box"
- -ret = smesh.Compute(mesh,box)
- -print ret
- -if ret == 0:
- -print - "probleme when computing the mesh"
- -salome.sg.updateObjBrowser(1)
- -mesh.ExportMED("/tmp/meshMED.med",0)
- -- -
- - - - + + + + + +
First of all see Example + of 3d mesh generation, which is an example of good python script style + for Mesh module.
+ +Other examples of python + scripts will be also updated soon to use smesh package instead of direct + usage of idl interface.
+ +import + geompy
+ +import smesh
+ ++ +
# create a box
+ +box = geompy.MakeBox(0., + 0., 0., 100., 200., 300.)
+ +idbox = geompy.addToStudy(box, + "box")
+ ++ +
# create a mesh
+ +tetra = smesh.Mesh(box, + "MeshBox")
+ ++ +
algo1D = tetra.Segment()
+ +algo1D.NumberOfSegments(7)
+ ++ +
algo2D = tetra.Triangle()
+ +algo2D.MaxElementArea(800.)
+ ++ +
algo3D = tetra.Tetrahedron(smesh.NETGEN)
+ +algo3D.MaxElementVolume(900.)
+ ++ +
# compute the mesh
+ +ret = tetra.Compute()
+ +if ret == 0:
+ +print + "problem when computing the mesh"
+ +else:
+ +print + "mesh computed"
+ +pass +
+ ++ +
+ +
from + geompy import *
+ +import smesh
+ ++ +
# create a box
+ +box = MakeBoxDXDYDZ(10., 10., 10.)
+ +addToStudy(box, "Box")
+ ++ +
# select one edge of + the box for definition of a local hypothesis
+ +p5 = MakeVertex(5., 0., 0.)
+ +EdgeX = GetEdgeNearPoint(box, p5)
+ +addToStudyInFather(box, EdgeX, "Edge + [0,0,0 - 10,0,0]")
+ ++ +
# create a hexahedral + mesh on the box
+ +quadra = smesh.Mesh(box, "Box : quadrangle + 2D mesh")
+ ++ +
# create a regular + 1D algorithm for the faces
+ +algo1D = quadra.Segment()
+ ++ +
# define "NumberOfSegments" + hypothesis to cut
+ +# all the edges in + a fixed number of segments
+ +algo1D.NumberOfSegments(4)
+ ++ +
# create a quadrangle + 2D algorithm for the faces
+ +quadra.Quadrangle()
+ ++ +
# construct a submesh + on the edge with a local hypothesis
+ +algo_local = quadra.Segment(EdgeX)
+ ++ +
# define "Arithmetic1D" + hypothesis to cut the edge + in several segments with increasing arithmetic length
+ +algo_local.Arithmetic1D(1, 4)
+ ++ +
# define "Propagation" + hypothesis that propagates all other hypotheses
+ +# on all edges of the + opposite side in case of quadrangular faces
+ +algo_local.Propagation()
+ ++ +
# compute the mesh
+ +quadra.Compute()
+ ++ +
import + geompy
+ +import smesh
+ ++ +
def PrintMeshInfo(theMesh):
+ +aMesh + = theMesh.GetMesh()
+ +print + "Information about mesh:"
+ +print + "Number of nodes : + ", aMesh.NbNodes()
+ +print + "Number of edges : + ", aMesh.NbEdges()
+ +print + "Number of faces : + ", aMesh.NbFaces()
+ +print + "Number of volumes : + ", aMesh.NbVolumes()
+ +pass
+ ++ +
# create a box
+ +box = geompy.MakeBox(0., 0., 0., 20., + 20., 20.)
+ +geompy.addToStudy(box, "box")
+ ++ +
# select one edge of + the box for definition of a local hypothesis
+ +subShapeList = geompy.SubShapeAll(box, + geompy.ShapeType["EDGE"])
+ +edge = subShapeList[0]
+ +name = geompy.SubShapeName(edge, box)
+ +geompy.addToStudyInFather(box, edge, name)
+ ++ +
# create a mesh
+ +tria = smesh.Mesh(box, "Mesh 2D")
+ +algo1D = tria.Segment()
+ +hyp1 = algo1D.NumberOfSegments(3)
+ +algo2D = tria.Triangle()
+ +hyp2 = algo2D.MaxElementArea(10.)
+ ++ +
# create a sub-mesh
+ +algo_local = tria.Segment(edge)
+ +hyp3 = algo_local.Arithmetic1D(1, 6)
+ +hyp4 = algo_local.Propagation()
+ ++ +
# compute the mesh
+ +tria.Compute()
+ +PrintMeshInfo(tria)
+ ++ +
# remove a local hypothesis
+ +mesh = tria.GetMesh()
+ +mesh.RemoveHypothesis(edge, hyp4)
+ ++ +
# compute the mesh
+ +tria.Compute()
+ +PrintMeshInfo(tria)
+ ++ +
# change the value + of the 2D hypothesis
+ +hyp2.SetMaxElementArea(2.)
+ ++ +
# compute the mesh
+ +tria.Compute()
+ +PrintMeshInfo(tria)
+ ++ +
import geompy
+ +import smesh
+ ++ +
# create a box
+ +box = geompy.MakeBox(0., + 0., 0., 100., 200., 300.)
+ +idbox = geompy.addToStudy(box, + "box")
+ ++ +
# create a mesh
+ +tetra = smesh.Mesh(box, + "MeshBox")
+ ++ +
algo1D = tetra.Segment()
+ +algo1D.NumberOfSegments(7)
+ ++ +
algo2D = tetra.Triangle()
+ +algo2D.MaxElementArea(800.)
+ ++ +
algo3D = tetra.Tetrahedron(smesh.NETGEN)
+ +algo3D.MaxElementVolume(900.)
+ ++ +
# compute the mesh
+ +tetra.Compute()
+ ++ +
# export the mesh in a + MED file
+ +tetra.ExportMED("/tmp/meshMED.med", + 0)
+ + + +