mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-28 08:30:33 +05:00
Scripts update concerninig the smesh.py interface redesign.
This commit is contained in:
parent
0c56d66286
commit
c5b7bbe381
@ -17,10 +17,10 @@
|
||||
#
|
||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
#
|
||||
import geompy
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
|
||||
#-----------------------------GEOM----------------------------------------
|
||||
|
||||
@ -51,72 +51,48 @@ Id_face1 = geompy.addToStudy(face1,"Face1")
|
||||
|
||||
|
||||
#-----------------------------SMESH-------------------------------------------
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
# -- Init --
|
||||
|
||||
# -- Init mesh --
|
||||
plane_mesh = salome.IDToObject( Id_face1)
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
mesh = smesh.CreateMesh(plane_mesh)
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
id_mesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName( id_mesh, "Mesh_1")
|
||||
|
||||
|
||||
print"---------------------Hypothesis"
|
||||
mesh = smesh.Mesh(plane_mesh, "Mesh_1")
|
||||
|
||||
print"---------------------Hypothesis and Algorithms"
|
||||
|
||||
#---------------- NumberOfSegments
|
||||
|
||||
numberOfSegment = 9
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
|
||||
hypNbSeg.SetNumberOfSegments( numberOfSegment )
|
||||
algoWireDes = mesh.Segment()
|
||||
listHyp = algoWireDes.GetCompatibleHypothesis()
|
||||
print algoWireDes.GetName()
|
||||
algoWireDes.SetName("Ware descritisation")
|
||||
|
||||
hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "Nb. Segments")
|
||||
smesh.SetName(hypNbSeg, "Nb. Segments")
|
||||
|
||||
|
||||
#--------------------------Max. Element Area
|
||||
maxElementArea = 200
|
||||
|
||||
hypArea200 = smesh.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so")
|
||||
hypArea200.SetMaxElementArea( maxElementArea )
|
||||
algoMef = mesh.Triangle()
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
print algoMef.GetName()
|
||||
algoMef.SetName("Triangle (Mefisto)")
|
||||
|
||||
hypArea200 = algoMef.MaxElementArea(maxElementArea)
|
||||
print hypArea200.GetName()
|
||||
print hypArea200.GetMaxElementArea()
|
||||
smesh.SetName(hypArea200, "Max. Element Area")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea200), "Max. Element Area")
|
||||
|
||||
print"---------------------Algorithms"
|
||||
|
||||
#----------------------------Wire discretisation
|
||||
algoWireDes = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoWireDes.GetCompatibleHypothesis()
|
||||
|
||||
print algoWireDes.GetName()
|
||||
smeshgui.SetName(salome.ObjectToID(algoWireDes), "Ware descritisation")
|
||||
|
||||
#----------------------------Triangle (Mefisto)
|
||||
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
|
||||
print algoMef.GetName()
|
||||
|
||||
#----------------------------Add hipothesis to the plane
|
||||
mesh.AddHypothesis( plane_mesh, hypNbSeg ) # nb segments
|
||||
mesh.AddHypothesis( plane_mesh, hypArea200 ) # max area
|
||||
|
||||
mesh.AddHypothesis( plane_mesh, algoWireDes ) # Regular 1D/wire discretisation
|
||||
mesh.AddHypothesis( plane_mesh, algoMef ) # MEFISTO 2D
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
|
||||
|
||||
print "---------------------Compute the mesh"
|
||||
|
||||
smesh.Compute(mesh, plane_mesh)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import SMESH
|
||||
import StdMeshers
|
||||
import smesh
|
||||
|
||||
|
||||
#----------------------------------GEOM
|
||||
|
||||
@ -51,51 +51,25 @@ id_ellipse2 = geompy.addToStudy(ellipse2, "Ellips 2")
|
||||
|
||||
|
||||
#---------------------------------SMESH
|
||||
# get smesh engine
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# get SMESH GUI
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
# create hypoteses
|
||||
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg1.SetNumberOfSegments(18)
|
||||
id_hypNbSeg1 = salome.ObjectToID(hypNbSeg1)
|
||||
smeshgui.SetName(id_hypNbSeg1, "NumberOfSegments 1");
|
||||
|
||||
hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg2.SetNumberOfSegments(34)
|
||||
id_hypNbSeg2 = salome.ObjectToID(hypNbSeg2)
|
||||
smeshgui.SetName(id_hypNbSeg2, "NumberOfSegments 2");
|
||||
|
||||
# create algorithmes
|
||||
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
id_algoReg = salome.ObjectToID(algoReg)
|
||||
smeshgui.SetName(id_algoReg, "Regular_1D");
|
||||
|
||||
# create the path mesh
|
||||
mesh1 = smesh.CreateMesh(ellipse1)
|
||||
id_mesh1 = salome.ObjectToID(mesh1)
|
||||
smeshgui.SetName(id_mesh1, "Path Mesh");
|
||||
mesh1 = smesh.Mesh(ellipse1, "Path Mesh")
|
||||
|
||||
# set hypotheses and algos
|
||||
mesh1.AddHypothesis(ellipse1,algoReg)
|
||||
mesh1.AddHypothesis(ellipse1,hypNbSeg1)
|
||||
algoReg1 = mesh1.Segment()
|
||||
algoReg1.SetName("Regular_1D")
|
||||
hypNbSeg1 = algoReg1.NumberOfSegments(18)
|
||||
smesh.SetName(hypNbSeg1, "NumberOfSegments 1")
|
||||
|
||||
# create the tool mesh
|
||||
mesh2 = smesh.CreateMesh(ellipse2)
|
||||
id_mesh2 = salome.ObjectToID(mesh2)
|
||||
smeshgui.SetName(id_mesh2, "Tool Mesh");
|
||||
|
||||
# set hypotheses and algos
|
||||
mesh2.AddHypothesis(ellipse2,algoReg)
|
||||
mesh2.AddHypothesis(ellipse2,hypNbSeg2)
|
||||
mesh2 = smesh.Mesh(ellipse2, "Tool Mesh")
|
||||
algoReg2 = mesh2.Segment()
|
||||
algoReg2.SetName("Regular_1D")
|
||||
hypNbSeg2 = algoReg2.NumberOfSegments(34)
|
||||
smesh.SetName(hypNbSeg2, "NumberOfSegments 2")
|
||||
|
||||
# compute meshes
|
||||
smesh.Compute(mesh1,ellipse1)
|
||||
smesh.Compute(mesh2,ellipse2)
|
||||
mesh1.Compute()
|
||||
mesh2.Compute()
|
||||
|
||||
|
||||
# ---- udate object browser
|
||||
|
@ -25,12 +25,8 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import SMESH
|
||||
import StdMeshers
|
||||
import smesh
|
||||
|
||||
# get smesh engine
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# create points to build two circles
|
||||
p1 = geompy.MakeVertex(0, 100, 0)
|
||||
@ -52,53 +48,39 @@ face = geompy.MakeFace(wire, 1)
|
||||
idcircle = geompy.addToStudy(circle, "Circle")
|
||||
idface = geompy.addToStudy(face, "Circular face")
|
||||
|
||||
# get SMESH GUI
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
# create hypoteses
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(12)
|
||||
idseg = salome.ObjectToID(hypNbSeg)
|
||||
smeshgui.SetName(idseg, "NumberOfSegments_10");
|
||||
|
||||
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea.SetMaxElementArea(30)
|
||||
idarea = salome.ObjectToID(hypArea)
|
||||
smeshgui.SetName(idarea, "MaxElementArea_20");
|
||||
|
||||
# create algorithmes
|
||||
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
idreg = salome.ObjectToID(algoReg)
|
||||
smeshgui.SetName(idreg, "Regular_1D");
|
||||
|
||||
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
idmef = salome.ObjectToID(algoMef)
|
||||
smeshgui.SetName(idmef, "MEFISTO_2D");
|
||||
|
||||
# init a Mesh with the circular face
|
||||
mesh1 = smesh.CreateMesh(face)
|
||||
idmesh1 = salome.ObjectToID(mesh1)
|
||||
smeshgui.SetName(idmesh1, "Mesh on circular face");
|
||||
mesh1 = smesh.Mesh(face, "Mesh on circular face")
|
||||
|
||||
# set hypotheses and algos to the first mesh
|
||||
numberOfSegments1 = 12
|
||||
algoReg1 = mesh1.Segment()
|
||||
algoReg1.SetName("Regular_1D")
|
||||
hypNbSeg1 = algoReg1.NumberOfSegments(numberOfSegments1)
|
||||
smesh.SetName(hypNbSeg1, "NumberOfSegments_" + str(numberOfSegments1))
|
||||
|
||||
maxElementArea = 30
|
||||
|
||||
algoMef = mesh1.Triangle()
|
||||
algoMef.SetName("MEFISTO_2D")
|
||||
hypArea = algoMef.MaxElementArea(maxElementArea)
|
||||
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
# set hypotheses and algos
|
||||
mesh1.AddHypothesis(face,algoReg)
|
||||
mesh1.AddHypothesis(face,hypNbSeg)
|
||||
mesh1.AddHypothesis(face,algoMef)
|
||||
mesh1.AddHypothesis(face,hypArea)
|
||||
|
||||
# init a Mesh with the second circle
|
||||
mesh2 = smesh.CreateMesh(circle)
|
||||
idmesh2 = salome.ObjectToID(mesh2)
|
||||
smeshgui.SetName(idmesh2, "Mesh on circular edge");
|
||||
mesh2 = smesh.Mesh(circle, "Mesh on circular edge")
|
||||
|
||||
numberOfSegments2 = 12
|
||||
algoReg2 = mesh2.Segment()
|
||||
algoReg2.SetName("Regular_1D")
|
||||
hypNbSeg2 = algoReg2.NumberOfSegments(numberOfSegments2)
|
||||
smesh.SetName(hypNbSeg2, "NumberOfSegments_" + str(numberOfSegments2))
|
||||
|
||||
# set hypotheses and algos
|
||||
mesh2.AddHypothesis(circle,algoReg)
|
||||
mesh2.AddHypothesis(circle,hypNbSeg)
|
||||
|
||||
# compute meshes
|
||||
smesh.Compute(mesh1,face)
|
||||
smesh.Compute(mesh2,circle)
|
||||
mesh1.Compute()
|
||||
mesh2.Compute()
|
||||
|
||||
# ---- udate object browser
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
@ -18,7 +18,6 @@
|
||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
#
|
||||
import smesh
|
||||
import SMESH
|
||||
import math
|
||||
|
||||
def GetNewNodes(mesh,Elems,OldNodes):
|
||||
@ -51,45 +50,44 @@ def GetNewNodes(mesh,Elems,OldNodes):
|
||||
|
||||
|
||||
# create empty mesh
|
||||
mesh = smesh.smesh.CreateEmptyMesh()
|
||||
mesh = smesh.Mesh()
|
||||
|
||||
ed = mesh.GetMeshEditor()
|
||||
tol = 0.001
|
||||
|
||||
# create a cross from quadrangle faces
|
||||
# 1. create first edge and make extrusion along 0x
|
||||
n1 = ed.AddNode(55,-5,0)
|
||||
n2 = ed.AddNode(55,5,0)
|
||||
e1 = ed.AddEdge([n1,n2])
|
||||
dir1 = SMESH.DirStruct(SMESH.PointStruct(-10,0,0))
|
||||
ed.ExtrusionSweep([e1],dir1,11)
|
||||
n1 = mesh.AddNode(55,-5,0)
|
||||
n2 = mesh.AddNode(55,5,0)
|
||||
e1 = mesh.AddEdge([n1,n2])
|
||||
dir1 = smesh.DirStruct(smesh.PointStruct(-10,0,0))
|
||||
mesh.ExtrusionSweep([e1],dir1,11)
|
||||
# 2. create second edge and make extrusion along 0y
|
||||
n3 = ed.AddNode(-5,-55,0)
|
||||
n4 = ed.AddNode(5,-55,0)
|
||||
e2 = ed.AddEdge([n3,n4])
|
||||
dir2 = SMESH.DirStruct(SMESH.PointStruct(0,10,0))
|
||||
ed.ExtrusionSweep([e2],dir2,11)
|
||||
n3 = mesh.AddNode(-5,-55,0)
|
||||
n4 = mesh.AddNode(5,-55,0)
|
||||
e2 = mesh.AddEdge([n3,n4])
|
||||
dir2 = smesh.DirStruct(smesh.PointStruct(0,10,0))
|
||||
mesh.ExtrusionSweep([e2],dir2,11)
|
||||
|
||||
# since result has coincident nodes and faces
|
||||
# we have to make merge
|
||||
nodes = ed.FindCoincidentNodes(0.001)
|
||||
ed.MergeNodes(nodes)
|
||||
ed.MergeEqualElements()
|
||||
nodes = mesh.FindCoincidentNodes(0.001)
|
||||
mesh.MergeNodes(nodes)
|
||||
mesh.MergeEqualElements()
|
||||
|
||||
# make extrusion faces along 0z
|
||||
faces = mesh.GetElementsByType(SMESH.FACE)
|
||||
faces = mesh.GetElementsByType(smesh.FACE)
|
||||
nbf = len(faces)
|
||||
maxang = 2.0
|
||||
zstep = 5
|
||||
nbzsteps = 50
|
||||
dir3 = SMESH.DirStruct(SMESH.PointStruct(0,0,zstep))
|
||||
dir3 = smesh.DirStruct(smesh.PointStruct(0,0,zstep))
|
||||
newfaces = [] # list for keeping created top faces
|
||||
# during extrusion
|
||||
|
||||
for i in range(0,nbzsteps):
|
||||
ed.ExtrusionSweep(faces,dir3,1)
|
||||
mesh.ExtrusionSweep(faces,dir3,1)
|
||||
# find top faces after each extrusion and keep them
|
||||
res = ed.GetLastCreatedElems()
|
||||
res = mesh.GetLastCreatedElems()
|
||||
nbr = len(res)
|
||||
nfaces = []
|
||||
for j in res:
|
||||
@ -115,23 +113,23 @@ for i in range(0,nbzsteps):
|
||||
pass
|
||||
|
||||
# rotate faces from newfaces
|
||||
axisr1 = SMESH.AxisStruct(0,0,0,0,0,1)
|
||||
axisr1 = smesh.AxisStruct(0,0,0,0,0,1)
|
||||
for i in range(0,nbzsteps):
|
||||
ang = maxang*(1-math.cos((i+1)*math.pi/nbzsteps))
|
||||
ed.Rotate(newfaces[i],axisr1,ang,0)
|
||||
mesh.Rotate(newfaces[i],axisr1,ang,0)
|
||||
|
||||
|
||||
# create circles
|
||||
# create two edges and rotate them for creation
|
||||
# full circle
|
||||
n5 = ed.AddNode(65,0,0)
|
||||
n6 = ed.AddNode(67.5,0,0)
|
||||
n7 = ed.AddNode(70,0,0)
|
||||
e56 = ed.AddEdge([n5,n6])
|
||||
e67 = ed.AddEdge([n6,n7])
|
||||
axisr2 = SMESH.AxisStruct(65,0,0,0,1,0)
|
||||
ed.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
|
||||
res = ed.GetLastCreatedElems()
|
||||
n5 = mesh.AddNode(65,0,0)
|
||||
n6 = mesh.AddNode(67.5,0,0)
|
||||
n7 = mesh.AddNode(70,0,0)
|
||||
e56 = mesh.AddEdge([n5,n6])
|
||||
e67 = mesh.AddEdge([n6,n7])
|
||||
axisr2 = smesh.AxisStruct(65,0,0,0,1,0)
|
||||
mesh.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
|
||||
res = mesh.GetLastCreatedElems()
|
||||
faces1 = []
|
||||
for i in res:
|
||||
nbn = mesh.GetElemNbNodes(i)
|
||||
@ -141,14 +139,14 @@ nbf1 = len(faces1)
|
||||
|
||||
# create other two edges and rotate them for creation
|
||||
# other full circle
|
||||
n8 = ed.AddNode(-65,0,0)
|
||||
n9 = ed.AddNode(-67.5,0,0)
|
||||
n10 = ed.AddNode(-70,0,0)
|
||||
e8 = ed.AddEdge([n8,n9])
|
||||
e9 = ed.AddEdge([n9,n10])
|
||||
axisr3 = SMESH.AxisStruct(-65,0,0,0,-1,0)
|
||||
ed.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
|
||||
res = ed.GetLastCreatedElems()
|
||||
n8 = mesh.AddNode(-65,0,0)
|
||||
n9 = mesh.AddNode(-67.5,0,0)
|
||||
n10 = mesh.AddNode(-70,0,0)
|
||||
e8 = mesh.AddEdge([n8,n9])
|
||||
e9 = mesh.AddEdge([n9,n10])
|
||||
axisr3 = smesh.AxisStruct(-65,0,0,0,-1,0)
|
||||
mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
|
||||
res = mesh.GetLastCreatedElems()
|
||||
faces2 = []
|
||||
for i in res:
|
||||
nbn = mesh.GetElemNbNodes(i)
|
||||
@ -158,8 +156,8 @@ nbf2 = len(faces2)
|
||||
|
||||
# there are coincident nodes after rotation
|
||||
# therefore we have to merge nodes
|
||||
nodes = ed.FindCoincidentNodes(0.001)
|
||||
ed.MergeNodes(nodes)
|
||||
nodes = mesh.FindCoincidentNodes(0.001)
|
||||
mesh.MergeNodes(nodes)
|
||||
|
||||
nbcircs = 2
|
||||
nbrsteps = 24
|
||||
@ -172,8 +170,8 @@ newnodes = GetNewNodes(mesh,faces1,oldnodes)
|
||||
oldnodes = newnodes
|
||||
|
||||
nodes = []
|
||||
ed.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol)
|
||||
res = ed.GetLastCreatedElems()
|
||||
mesh.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol)
|
||||
res = mesh.GetLastCreatedElems()
|
||||
|
||||
for i in range(0,nbrs):
|
||||
volumes = []
|
||||
@ -181,7 +179,7 @@ for i in range(0,nbrs):
|
||||
newnodes = GetNewNodes(mesh,volumes,oldnodes)
|
||||
for j in newnodes:
|
||||
xyz = mesh.GetNodeXYZ(j)
|
||||
ed.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
|
||||
mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
|
||||
pass
|
||||
oldnodes = newnodes
|
||||
pass
|
||||
@ -192,8 +190,8 @@ newnodes = GetNewNodes(mesh,faces2,oldnodes)
|
||||
oldnodes = newnodes
|
||||
|
||||
nodes = []
|
||||
ed.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol)
|
||||
res = ed.GetLastCreatedElems()
|
||||
mesh.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol)
|
||||
res = mesh.GetLastCreatedElems()
|
||||
|
||||
for i in range(0,nbrs):
|
||||
volumes = []
|
||||
@ -201,9 +199,9 @@ for i in range(0,nbrs):
|
||||
newnodes = GetNewNodes(mesh,volumes,oldnodes)
|
||||
for j in newnodes:
|
||||
xyz = mesh.GetNodeXYZ(j)
|
||||
ed.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
|
||||
mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
|
||||
pass
|
||||
oldnodes = newnodes
|
||||
pass
|
||||
|
||||
|
||||
smesh.salome.sg.updateObjBrowser(1)
|
||||
|
@ -17,10 +17,11 @@
|
||||
#
|
||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
#
|
||||
import SMESH
|
||||
|
||||
from SMESH_test1 import *
|
||||
|
||||
def CheckBelongToGeomFilter(theMeshGen, theMesh, theShape, theSubShape, theElemType):
|
||||
## Old style
|
||||
def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType):
|
||||
import geompy
|
||||
if theShape != theSubShape:
|
||||
aName = str(theSubShape)
|
||||
@ -38,10 +39,26 @@ def CheckBelongToGeomFilter(theMeshGen, theMesh, theShape, theSubShape, theElemT
|
||||
aFilter.SetPredicate(aBelongToGeom)
|
||||
return aFilter.GetElementsId(theMesh)
|
||||
|
||||
anElemType = SMESH.ALL;
|
||||
## Current style
|
||||
def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType):
|
||||
import geompy
|
||||
if theShape != theSubShape:
|
||||
aName = str(theSubShape)
|
||||
geompy.addToStudyInFather(theShape,theSubShape,aName)
|
||||
|
||||
theMesh.Compute()
|
||||
aFilter = theMesh.GetFilter(theElemType, smesh.FT_BelongToGeom, theSubShape)
|
||||
return aFilter.GetElementsId(theMesh.GetMesh())
|
||||
|
||||
|
||||
anElemType = smesh.FACE;
|
||||
print "anElemType =", anElemType
|
||||
#anIds = CheckBelongToGeomFilter(smesh,mesh,box,subShapeList[1],SMESH.FACE)
|
||||
anIds = CheckBelongToGeomFilter(smesh,mesh,box,box,SMESH.FACE)
|
||||
#anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType)
|
||||
anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType)
|
||||
print "Number of ids = ", len(anIds)
|
||||
print "anIds = ", anIds
|
||||
## Check old version
|
||||
#anIds = CheckBelongToGeomFilterOld(smesh.smesh,mesh.GetMesh(),box,box,anElemType)
|
||||
#print "anIds = ", anIds
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
@ -23,11 +23,10 @@
|
||||
# Module : SMESH
|
||||
|
||||
from SMESH_test1 import *
|
||||
import SMESH
|
||||
|
||||
# Compute the mesh created in SMESH_test1
|
||||
|
||||
smesh.Compute(mesh, box)
|
||||
mesh.Compute()
|
||||
|
||||
# Create geometry groups on plane:
|
||||
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
|
||||
@ -43,7 +42,7 @@ geompy.AddObject(aGeomGroup2, 10)
|
||||
geompy.addToStudy(aGeomGroup1, "Group on Faces")
|
||||
geompy.addToStudy(aGeomGroup2, "Group on Edges")
|
||||
|
||||
aSmeshGroup1 = mesh.CreateGroupFromGEOM(SMESH.FACE, "SMESHGroup1", aGeomGroup1)
|
||||
aSmeshGroup2 = mesh.CreateGroupFromGEOM(SMESH.EDGE, "SMESHGroup2", aGeomGroup2)
|
||||
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE)
|
||||
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE)
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
@ -25,11 +25,11 @@
|
||||
# Project : PAL/SALOME
|
||||
#==============================================================================
|
||||
from SMESH_test1 import *
|
||||
import SMESH
|
||||
|
||||
|
||||
# Compute the mesh created in SMESH_test1
|
||||
|
||||
smesh.Compute(mesh, box)
|
||||
mesh.Compute()
|
||||
|
||||
# Create geometry groups on plane:
|
||||
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
|
||||
@ -45,11 +45,11 @@ geompy.AddObject(aGeomGroup2, 10)
|
||||
geompy.addToStudy(aGeomGroup1, "Group on Faces")
|
||||
geompy.addToStudy(aGeomGroup2, "Group on Edges")
|
||||
|
||||
aSmeshGroup1 = mesh.CreateGroupFromGEOM(SMESH.FACE, "SMESHGroup1", aGeomGroup1)
|
||||
aSmeshGroup2 = mesh.CreateGroupFromGEOM(SMESH.EDGE, "SMESHGroup2", aGeomGroup2)
|
||||
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE)
|
||||
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE)
|
||||
|
||||
print "Create aGroupOnShell - a group linked to a shell"
|
||||
aGroupOnShell = mesh.CreateGroupFromGEOM(SMESH.EDGE, "GroupOnShell", shell)
|
||||
aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", smesh.EDGE)
|
||||
print "aGroupOnShell type =", aGroupOnShell.GetType()
|
||||
print "aGroupOnShell size =", aGroupOnShell.Size()
|
||||
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
|
||||
@ -65,7 +65,7 @@ print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
|
||||
print " "
|
||||
|
||||
print "Re-compute mesh, contents of aGroupOnShell changes again:"
|
||||
smesh.Compute(mesh, box)
|
||||
mesh.Compute()
|
||||
print "aGroupOnShell size =", aGroupOnShell.Size()
|
||||
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
#
|
||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
#
|
||||
from smesh import *
|
||||
import smesh
|
||||
|
||||
def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
|
||||
aFilterMgr = smesh.CreateFilterManager()
|
||||
aFilterMgr = smesh.smesh.CreateFilterManager()
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
|
||||
aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
|
||||
@ -36,7 +36,12 @@ def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
|
||||
#Example
|
||||
from SMESH_test1 import *
|
||||
|
||||
smesh.Compute(mesh, box)
|
||||
BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )
|
||||
mesh.Compute()
|
||||
|
||||
# First way
|
||||
BuildGroupLyingOn(mesh.GetMesh(), smesh.FACE, "Group of faces lying on edge #1", edge )
|
||||
|
||||
# Second way
|
||||
mesh.MakeGroup("Group of faces lying on edge #2", smesh.FACE, smesh.FT_LyingOnGeom, edge)
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
@ -24,10 +24,9 @@
|
||||
|
||||
import geompy
|
||||
import salome
|
||||
import smesh
|
||||
import os
|
||||
import math
|
||||
import StdMeshers
|
||||
import SMESH
|
||||
|
||||
#Sketcher_1 creation
|
||||
print "Sketcher creation..."
|
||||
@ -94,79 +93,43 @@ Cut_1 = geompy.MakeBoolean(Chamfer_2, theShapeForCut, 2)
|
||||
Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
|
||||
|
||||
#Mesh creation
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
# -- Init --
|
||||
shape_mesh = salome.IDToObject( Cut_1_ID )
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
idmesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName( idmesh, "Nut" )
|
||||
|
||||
mesh = smesh.Mesh(shape_mesh, "Nut")
|
||||
|
||||
#HYPOTHESIS CREATION
|
||||
print "-------------------------- Average length"
|
||||
theAverageLength = 5
|
||||
hAvLength = smesh.CreateHypothesis( "LocalLength", "libStdMeshersEngine.so" )
|
||||
hAvLength.SetLength( theAverageLength )
|
||||
algoReg1D = mesh.Segment()
|
||||
hAvLength = algoReg1D.LocalLength(theAverageLength)
|
||||
print hAvLength.GetName()
|
||||
print hAvLength.GetId()
|
||||
smeshgui.SetName(salome.ObjectToID(hAvLength), "AverageLength_5")
|
||||
print hAvLength.GetLength()
|
||||
smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength))
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
theMaxElementArea = 20
|
||||
hArea20 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
|
||||
hArea20.SetMaxElementArea( theMaxElementArea )
|
||||
print hArea20.GetName()
|
||||
print hArea20.GetId()
|
||||
print hArea20.GetMaxElementArea()
|
||||
smeshgui.SetName(salome.ObjectToID(hArea20), "MaxElementArea_20")
|
||||
algoMef = mesh.Triangle(smesh.MEFISTO)
|
||||
hArea = algoMef.MaxElementArea( theMaxElementArea )
|
||||
print hArea.GetName()
|
||||
print hArea.GetId()
|
||||
print hArea.GetMaxElementArea()
|
||||
smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea))
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
theMaxElementVolume = 150
|
||||
hVolume150 = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
|
||||
hVolume150.SetMaxElementVolume( theMaxElementVolume )
|
||||
print hVolume150.GetName()
|
||||
print hVolume150.GetId()
|
||||
print hVolume150.GetMaxElementVolume()
|
||||
smeshgui.SetName(salome.ObjectToID(hVolume150), "MaxElementVolume_150")
|
||||
algoNg = mesh.Tetrahedron(smesh.NETGEN)
|
||||
hVolume = algoNg.MaxElementVolume( theMaxElementVolume )
|
||||
print hVolume.GetName()
|
||||
print hVolume.GetId()
|
||||
print hVolume.GetMaxElementVolume()
|
||||
smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume))
|
||||
|
||||
mesh.AddHypothesis(shape_mesh, hAvLength)
|
||||
mesh.AddHypothesis(shape_mesh, hArea20)
|
||||
mesh.AddHypothesis(shape_mesh, hVolume150)
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoReg1D.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoReg1D.GetName()
|
||||
print algoReg1D.GetId()
|
||||
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Wire discretisation")
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoMef.GetName()
|
||||
print algoMef.GetId()
|
||||
smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
|
||||
print algoNg.GetName()
|
||||
print algoNg.GetId()
|
||||
smeshgui.SetName(salome.ObjectToID(algoNg), "Tetrahedron (NETGEN)")
|
||||
mesh.AddHypothesis(shape_mesh, algoReg1D)
|
||||
mesh.AddHypothesis(shape_mesh, algoMef)
|
||||
mesh.AddHypothesis(shape_mesh, algoNg)
|
||||
|
||||
print "-------------------------- compute the mesh of the mechanic piece"
|
||||
smesh.Compute(mesh,shape_mesh)
|
||||
mesh.Compute()
|
||||
|
||||
print "Information about the Nut:"
|
||||
print "Number of nodes : ", mesh.NbNodes()
|
||||
|
@ -26,16 +26,9 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
from math import sqrt
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
@ -125,82 +118,48 @@ print " check status ", status
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
# ---- init a Mesh with the alveole
|
||||
shape_mesh = salome.IDToObject( idalveole )
|
||||
|
||||
mesh = smesh.Mesh(shape_mesh, "MeshAlveole")
|
||||
|
||||
print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
regular1D = mesh.Segment()
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 0.1
|
||||
|
||||
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea.SetMaxElementArea(maxElementArea)
|
||||
mefisto2D = mesh.Triangle()
|
||||
hypArea = mefisto2D.MaxElementArea(maxElementArea)
|
||||
print hypArea.GetName()
|
||||
print hypArea.GetId()
|
||||
print hypArea.GetMaxElementArea()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_0.1")
|
||||
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 0.5
|
||||
|
||||
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
|
||||
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5")
|
||||
|
||||
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")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the alveole
|
||||
shape_mesh = salome.IDToObject( idalveole )
|
||||
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole")
|
||||
|
||||
# ---- add hypothesis to alveole
|
||||
|
||||
print "-------------------------- add hypothesis to alveole"
|
||||
|
||||
mesh.AddHypothesis(shape_mesh,regular1D)
|
||||
mesh.AddHypothesis(shape_mesh,hypNbSeg)
|
||||
|
||||
mesh.AddHypothesis(shape_mesh,mefisto2D)
|
||||
mesh.AddHypothesis(shape_mesh,hypArea)
|
||||
|
||||
mesh.AddHypothesis(shape_mesh,netgen3D)
|
||||
mesh.AddHypothesis(shape_mesh,hypVolume)
|
||||
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
|
||||
|
||||
print "-------------------------- compute the mesh of alveole "
|
||||
ret = smesh.Compute(mesh,shape_mesh)
|
||||
ret = mesh.Compute()
|
||||
|
||||
if ret != 0:
|
||||
log=mesh.GetLog(0) # no erase trace
|
||||
|
@ -28,16 +28,14 @@
|
||||
import salome
|
||||
import geompy
|
||||
import math
|
||||
import smesh
|
||||
|
||||
import GEOM_Spanner
|
||||
|
||||
isBlocksTest = 0 # False
|
||||
isMeshTest = 1 # True
|
||||
hasGUI = 1 # True
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
GEOM_Spanner.MakeSpanner(salome, geompy, math, isBlocksTest, isMeshTest, smesh, hasGUI)
|
||||
GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh)
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
@ -30,63 +30,41 @@
|
||||
import salome
|
||||
from salome import sg
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
|
||||
# ---- launch GEOM
|
||||
|
||||
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
|
||||
meshgenerator = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
###geom.GetCurrentStudy(salome.myStudy._get_StudyId())
|
||||
meshgenerator.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# Plate
|
||||
|
||||
box = geompy.MakeBox(0.,0.,0.,1.,1.,1.)
|
||||
boxId = geompy.addToStudy(box,"box")
|
||||
|
||||
# ---- launch SMESH
|
||||
# ---- SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
# meshgenerator=smeshpy.smeshpy()
|
||||
|
||||
|
||||
# Hypothesis
|
||||
|
||||
hypL1=meshgenerator.CreateHypothesis("LocalLength","libStdMeshersEngine.so")
|
||||
hypL1.SetLength(0.25)
|
||||
hypL1Id = salome.ObjectToID(hypL1)
|
||||
smeshgui.SetName(hypL1Id, "LocalLength")
|
||||
|
||||
# Algorithm
|
||||
|
||||
alg1D=meshgenerator.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
alg1DId = salome.ObjectToID(alg1D)
|
||||
smeshgui.SetName(alg1DId, "algo1D")
|
||||
|
||||
alg2D=meshgenerator.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
|
||||
alg2DId = salome.ObjectToID(alg2D)
|
||||
smeshgui.SetName(alg2DId, "algo2D")
|
||||
|
||||
alg3D=meshgenerator.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
|
||||
alg3DId = salome.ObjectToID(alg3D)
|
||||
smeshgui.SetName(alg3DId, "algo3D")
|
||||
|
||||
# ---- init a Mesh
|
||||
|
||||
box_mesh=meshgenerator.CreateMesh(box)
|
||||
box_meshId = salome.ObjectToID(box_mesh)
|
||||
smeshgui.SetName(box_meshId, "box_mesh")
|
||||
box_mesh=smesh.Mesh(box, "box_mesh")
|
||||
|
||||
# ---- set Hypothesis & Algorithm
|
||||
# set Hypothesis and Algorithm
|
||||
|
||||
box_mesh.AddHypothesis(box,alg1D)
|
||||
box_mesh.AddHypothesis(box,alg2D)
|
||||
box_mesh.AddHypothesis(box,alg3D)
|
||||
box_mesh.AddHypothesis(box,hypL1)
|
||||
alg1D = box_mesh.Segment()
|
||||
alg1D.SetName("algo1D")
|
||||
hypL1 = alg1D.LocalLength(0.25)
|
||||
smesh.SetName(hypL1, "LocalLength")
|
||||
|
||||
alg2D = box_mesh.Quadrangle()
|
||||
alg2D.SetName("algo2D")
|
||||
|
||||
meshgenerator.Compute(box_mesh,box)
|
||||
alg3D = box_mesh.Hexahedron()
|
||||
alg3D.SetName("algo3D")
|
||||
|
||||
# compute mesh
|
||||
|
||||
box_mesh.Compute()
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
@ -24,14 +24,8 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId);
|
||||
|
||||
# ---- define 2 boxes box1 and box2
|
||||
|
||||
@ -79,90 +73,51 @@ print "number of Edges in shell : ", len(subEdgeList)
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
|
||||
# ---- create Hypothesis
|
||||
# ---- init a Mesh with the shell
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
mesh = smesh.Mesh(shell, "MeshBox2")
|
||||
|
||||
|
||||
# ---- set Hypothesis and Algorithm
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
|
||||
regular1D = mesh.Segment()
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 500
|
||||
|
||||
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea.SetMaxElementArea(maxElementArea)
|
||||
|
||||
mefisto2D = mesh.Triangle()
|
||||
hypArea = mefisto2D.MaxElementArea(maxElementArea)
|
||||
print hypArea.GetName()
|
||||
print hypArea.GetId()
|
||||
print hypArea.GetMaxElementArea()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
|
||||
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 500
|
||||
|
||||
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
|
||||
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
|
||||
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
|
||||
|
||||
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")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the shell
|
||||
|
||||
mesh = smesh.CreateMesh(shell)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox2")
|
||||
|
||||
# ---- add hypothesis to shell
|
||||
|
||||
print "-------------------------- add hypothesis to shell"
|
||||
|
||||
mesh.AddHypothesis(shell,regular1D)
|
||||
mesh.AddHypothesis(shell,hypNbSeg)
|
||||
|
||||
mesh.AddHypothesis(shell,mefisto2D)
|
||||
mesh.AddHypothesis(shell,hypArea)
|
||||
|
||||
mesh.AddHypothesis(shell,netgen3D)
|
||||
mesh.AddHypothesis(shell,hypVolume)
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute shell"
|
||||
ret = smesh.Compute(mesh,shell)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
if ret != 0:
|
||||
log = mesh.GetLog(0) # no erase trace
|
||||
|
@ -25,14 +25,8 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId);
|
||||
|
||||
# ---- define 3 boxes box1, box2 and box3
|
||||
|
||||
@ -90,90 +84,52 @@ print "number of Edges in shell : ", len(subEdgeList)
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
|
||||
# ---- create Hypothesis
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
# ---- init a Mesh with the shell
|
||||
|
||||
mesh = smesh.Mesh(shell, "MeshBox3")
|
||||
|
||||
|
||||
# ---- set Hypothesis and Algorithm
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
|
||||
regular1D = mesh.Segment()
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 500
|
||||
|
||||
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea.SetMaxElementArea(maxElementArea)
|
||||
|
||||
mefisto2D = mesh.Triangle()
|
||||
hypArea = mefisto2D.MaxElementArea(maxElementArea)
|
||||
print hypArea.GetName()
|
||||
print hypArea.GetId()
|
||||
print hypArea.GetMaxElementArea()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
|
||||
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 500
|
||||
|
||||
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
|
||||
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
|
||||
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
|
||||
|
||||
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")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the shell
|
||||
|
||||
mesh = smesh.CreateMesh(shell)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
|
||||
|
||||
# ---- add hypothesis to shell
|
||||
|
||||
print "-------------------------- add hypothesis to shell"
|
||||
|
||||
mesh.AddHypothesis(shell,regular1D)
|
||||
mesh.AddHypothesis(shell,hypNbSeg)
|
||||
|
||||
mesh.AddHypothesis(shell,mefisto2D)
|
||||
mesh.AddHypothesis(shell,hypArea)
|
||||
|
||||
mesh.AddHypothesis(shell,netgen3D)
|
||||
mesh.AddHypothesis(shell,hypVolume)
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute shell"
|
||||
ret = smesh.Compute(mesh,shell)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
if ret != 0:
|
||||
log = mesh.GetLog(0) # no erase trace
|
||||
|
@ -24,14 +24,8 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId);
|
||||
|
||||
# ---- define a boxe
|
||||
|
||||
@ -51,90 +45,48 @@ print "number of Edges in box : ", len(subEdgeList)
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
|
||||
# ---- create Hypothesis
|
||||
# ---- init a Mesh with the boxe
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
mesh = smesh.Mesh(box, "MeshBox")
|
||||
|
||||
# ---- set Hypothesis and Algorithm
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
|
||||
regular1D = mesh.Segment()
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 500
|
||||
|
||||
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea.SetMaxElementArea(maxElementArea)
|
||||
|
||||
mefisto2D = mesh.Triangle()
|
||||
hypArea = mefisto2D.MaxElementArea(maxElementArea)
|
||||
print hypArea.GetName()
|
||||
print hypArea.GetId()
|
||||
print hypArea.GetMaxElementArea()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
|
||||
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 500
|
||||
|
||||
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
|
||||
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
|
||||
hypVolume = netgen3D.MaxElementVolume(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")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the boxe
|
||||
|
||||
mesh = smesh.CreateMesh(box)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
|
||||
|
||||
# ---- add hypothesis to the boxe
|
||||
|
||||
print "-------------------------- add hypothesis to the box"
|
||||
|
||||
mesh.AddHypothesis(box,regular1D)
|
||||
mesh.AddHypothesis(box,hypNbSeg)
|
||||
|
||||
mesh.AddHypothesis(box,mefisto2D)
|
||||
mesh.AddHypothesis(box,hypArea)
|
||||
|
||||
mesh.AddHypothesis(box,netgen3D)
|
||||
mesh.AddHypothesis(box,hypVolume)
|
||||
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute the mesh of the boxe"
|
||||
ret = smesh.Compute(mesh,box)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
if ret != 0:
|
||||
log = mesh.GetLog(0) # no erase trace
|
||||
|
@ -24,186 +24,107 @@
|
||||
# Module : SMESH
|
||||
|
||||
|
||||
import SMESH
|
||||
import smesh
|
||||
import SMESH_mechanic
|
||||
|
||||
smesh = SMESH_mechanic.smesh
|
||||
salome = smesh.salome
|
||||
mesh = SMESH_mechanic.mesh
|
||||
salome = SMESH_mechanic.salome
|
||||
|
||||
|
||||
aFilterMgr = smesh.CreateFilterManager()
|
||||
# ---- Criterion : AREA > 100
|
||||
|
||||
# Criterion : AREA > 100
|
||||
|
||||
aFunctor = aFilterMgr.CreateArea()
|
||||
aPredicate = aFilterMgr.CreateMoreThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 100 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
# create group
|
||||
aGroup = mesh.MakeGroup("Area > 100", smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100)
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Area > 100 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
|
||||
# ---- Criterion : Taper > 3e-15
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
|
||||
# Criterion : Taper > 3e-15
|
||||
|
||||
aFunctor = aFilterMgr.CreateTaper()
|
||||
aPredicate = aFilterMgr.CreateMoreThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 3e-15 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
aGroup = mesh.MakeGroup("Taper > 3e-15", smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, 3e-15)
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Taper > 3e-15 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
|
||||
# ---- Criterion : ASPECT RATIO > 1.3
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-15" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
|
||||
# Criterion : ASPECT RATIO > 1.3
|
||||
|
||||
aFunctor = aFilterMgr.CreateAspectRatio()
|
||||
aPredicate = aFilterMgr.CreateMoreThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 1.3 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
aGroup = mesh.MakeGroup("Aspect Ratio > 1.3", smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 1.3)
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
|
||||
# ---- Criterion : MINIMUM ANGLE < 30
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
|
||||
# Criterion : MINIMUM ANGLE < 30
|
||||
|
||||
aFunctor = aFilterMgr.CreateMinimumAngle()
|
||||
aPredicate = aFilterMgr.CreateLessThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 30 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
aGroup = mesh.MakeGroup("Minimum Angle < 30", smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, 30)
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Minimum Angle < 30 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
|
||||
# ---- Criterion : Warp > 2e-13
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 30" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
# Criterion : Warp > 2e-13
|
||||
|
||||
aFunctor = aFilterMgr.CreateWarping()
|
||||
aPredicate = aFilterMgr.CreateMoreThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 2e-13 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
aGroup = mesh.MakeGroup("Warp > 2e-13", smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, 2e-13 )
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Warp > 2e-13 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
|
||||
# ---- Criterion : Skew > 18
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 2e-13" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
# Criterion : Skew > 18
|
||||
|
||||
aFunctor = aFilterMgr.CreateSkew()
|
||||
aPredicate = aFilterMgr.CreateMoreThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 18 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
aGroup = mesh.MakeGroup("Skew > 18", smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 18 )
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Skew > 18 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
# Criterion : Length > 10
|
||||
|
||||
aFunctor = aFilterMgr.CreateLength()
|
||||
aPredicate = aFilterMgr.CreateMoreThan()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 10 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
# create group
|
||||
aGroup = mesh.MakeGroup("Length > 10", smesh.FACE, smesh.FT_Length, smesh.FT_MoreThan, 10 )
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Length > 10 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.EDGE, "Length > 10" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
# Criterion : Borders at multi-connections = 2
|
||||
|
||||
aFunctor = aFilterMgr.CreateMultiConnection()
|
||||
aPredicate = aFilterMgr.CreateEqualTo()
|
||||
aPredicate.SetNumFunctor( aFunctor )
|
||||
aPredicate.SetMargin( 2 )
|
||||
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
# create group
|
||||
aGroup = mesh.MakeGroup("Borders at multi-connections = 2", smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, 2)
|
||||
|
||||
# print result
|
||||
anIds = aGroup.GetIDs()
|
||||
print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )
|
||||
#for i in range( len( anIds ) ):
|
||||
#print anIds[ i ]
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections = 2" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
@ -31,18 +31,11 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
|
||||
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId);
|
||||
import smesh
|
||||
|
||||
import math
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
ShapeTypeShell = 3
|
||||
@ -130,86 +123,54 @@ for i in range(8):
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
|
||||
# ---- create Hypothesis
|
||||
# ---- init a Mesh with the volume
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
mesh = smesh.Mesh(vol, "meshVolume")
|
||||
|
||||
# ---- set Hypothesis and Algorithm to main shape
|
||||
|
||||
print "-------------------------- NumberOfSegments the global one"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypNbSeg=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
hypNbSegID = hypNbSeg.GetId()
|
||||
regular1D = mesh.Segment()
|
||||
regular1D.SetName("Wire Discretisation")
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSegID
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments")
|
||||
|
||||
|
||||
print "-------------------------- Quadrangle_2D"
|
||||
|
||||
quad2D=mesh.Quadrangle()
|
||||
quad2D.SetName("Quadrangle_2D")
|
||||
|
||||
print "-------------------------- Hexa_3D"
|
||||
|
||||
hexa3D=mesh.Hexahedron()
|
||||
hexa3D.SetName("Hexa_3D")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments")
|
||||
|
||||
print "-------------------------- NumberOfSegments in the Z direction"
|
||||
|
||||
numberOfSegmentsZ = 40
|
||||
|
||||
hypNbSegZ=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
|
||||
hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
|
||||
hypNbSegZID = hypNbSegZ.GetId()
|
||||
print hypNbSegZ.GetName()
|
||||
print hypNbSegZID
|
||||
print hypNbSegZ.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSegZ), "NumberOfSegmentsZ")
|
||||
|
||||
# ---- create Algorithms
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
|
||||
|
||||
print "-------------------------- Quadrangle_2D"
|
||||
|
||||
quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
|
||||
|
||||
print "-------------------------- Hexa_3D"
|
||||
|
||||
hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
|
||||
|
||||
# ---- init a Mesh with the volume
|
||||
|
||||
mesh = smesh.CreateMesh(vol)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "meshVolume")
|
||||
|
||||
# ---- add hypothesis to the volume
|
||||
|
||||
print "-------------------------- add hypothesis to the volume"
|
||||
|
||||
ret=mesh.AddHypothesis(vol,regular1D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,hypNbSeg)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,quad2D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,hexa3D)
|
||||
print ret
|
||||
|
||||
for i in range(8):
|
||||
print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
|
||||
|
||||
subMeshEdgeZ = mesh.GetSubMesh(edgeZ[i],"SubMeshEdgeZ_"+str(i+1))
|
||||
|
||||
retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
|
||||
print " add hyp Z ", retZ
|
||||
algo = mesh.Segment(edgeZ[i])
|
||||
hyp = algo.NumberOfSegments(numberOfSegmentsZ)
|
||||
smesh.SetName(hyp, "NumberOfSegmentsZ")
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
|
||||
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute the mesh of the volume"
|
||||
|
||||
ret=smesh.Compute(mesh,vol)
|
||||
ret=mesh.Compute()
|
||||
|
||||
print ret
|
||||
if ret != 0:
|
||||
|
@ -24,8 +24,7 @@
|
||||
#
|
||||
|
||||
import SMESH_fixation
|
||||
|
||||
import StdMeshers
|
||||
import smesh
|
||||
|
||||
compshell = SMESH_fixation.compshell
|
||||
idcomp = SMESH_fixation.idcomp
|
||||
@ -45,65 +44,42 @@ status = geompy.CheckShape(compshell)
|
||||
print " check status ", status
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
# ---- init a Mesh with the compshell
|
||||
shape_mesh = salome.IDToObject( idcomp )
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
mesh = smesh.Mesh(shape_mesh, "MeshCompShell")
|
||||
|
||||
|
||||
# ---- set Hypothesis and Algorithm
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 5
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
|
||||
regular1D = mesh.Segment()
|
||||
regular1D.SetName("Wire Discretisation")
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
|
||||
|
||||
print "-------------------------- Quadrangle_2D"
|
||||
|
||||
quad2D = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
|
||||
quad2D = mesh.Quadrangle()
|
||||
quad2D.SetName("Quadrangle_2D")
|
||||
|
||||
print "-------------------------- Hexa_3D"
|
||||
|
||||
hexa3D = smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
|
||||
hexa3D = mesh.Hexahedron()
|
||||
hexa3D.SetName("Hexa_3D")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
|
||||
|
||||
# ---- init a Mesh with the compshell
|
||||
shape_mesh = salome.IDToObject( idcomp )
|
||||
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell")
|
||||
|
||||
|
||||
print "-------------------------- add hypothesis to compshell"
|
||||
|
||||
mesh.AddHypothesis(shape_mesh,regular1D)
|
||||
mesh.AddHypothesis(shape_mesh,hypNbSeg)
|
||||
|
||||
mesh.AddHypothesis(shape_mesh,quad2D)
|
||||
mesh.AddHypothesis(shape_mesh,hexa3D)
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute compshell"
|
||||
ret = smesh.Compute(mesh, shape_mesh)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
if ret != 0:
|
||||
log = mesh.GetLog(0) # no erase trace
|
||||
|
@ -23,8 +23,6 @@
|
||||
# The new Netgen algorithm is used that discretizes baoundaries itself
|
||||
#
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
import SMESH_fixation
|
||||
import smesh
|
||||
|
||||
@ -50,12 +48,11 @@ print " check status ", status
|
||||
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 )
|
||||
netgen = mesh.Tetrahedron(smesh.FULL_NETGEN)
|
||||
netgen.SetMaxSize( 50 )
|
||||
#netgen.SetSecondOrder( 0 )
|
||||
netgen.SetFineness( smesh.Fine )
|
||||
#netgen.SetOptimize( 1 )
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
|
@ -23,9 +23,8 @@
|
||||
# Hypothesis and algorithms for the mesh generation are global
|
||||
#
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
import SMESH_fixation
|
||||
import smesh
|
||||
|
||||
compshell = SMESH_fixation.compshell
|
||||
idcomp = SMESH_fixation.idcomp
|
||||
@ -45,94 +44,65 @@ status = geompy.CheckShape(compshell)
|
||||
print " check status ", status
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
# ---- init a Mesh with the compshell
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
mesh = smesh.Mesh(compshell, "MeshcompShell")
|
||||
|
||||
|
||||
# ---- set Hypothesis and Algorithm
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 5
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
|
||||
regular1D = mesh.Segment()
|
||||
regular1D.SetName("Wire Discretisation")
|
||||
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
## print "-------------------------- MaxElementArea"
|
||||
|
||||
## maxElementArea = 80
|
||||
|
||||
## hypArea=smesh.CreateHypothesis("MaxElementArea")
|
||||
## hypArea.SetMaxElementArea(maxElementArea)
|
||||
## mefisto2D = mesh.Triangle()
|
||||
## mefisto2D.SetName("MEFISTO_2D")
|
||||
## hypArea = mefisto2D.MaxElementArea(maxElementArea)
|
||||
## print hypArea.GetName()
|
||||
## print hypArea.GetId()
|
||||
## print hypArea.GetMaxElementArea()
|
||||
## smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_160")
|
||||
## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
|
||||
smeshgui.SetName(salome.ObjectToID(hypLengthFromEdges), "LengthFromEdges")
|
||||
print "-------------------------- LengthFromEdges"
|
||||
|
||||
mefisto2D = mesh.Triangle()
|
||||
mefisto2D.SetName("MEFISTO_2D")
|
||||
hypLengthFromEdges = mefisto2D.LengthFromEdges()
|
||||
print hypLengthFromEdges.GetName()
|
||||
print hypLengthFromEdges.GetId()
|
||||
smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
|
||||
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 1000
|
||||
|
||||
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
|
||||
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
|
||||
netgen3D.SetName("NETGEN_3D")
|
||||
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_1000")
|
||||
|
||||
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")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the compshell
|
||||
|
||||
mesh = smesh.CreateMesh(compshell)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshcompShel")
|
||||
|
||||
print "-------------------------- add hypothesis to compshell"
|
||||
|
||||
mesh.AddHypothesis(compshell,regular1D)
|
||||
mesh.AddHypothesis(compshell,hypNbSeg)
|
||||
|
||||
mesh.AddHypothesis(compshell,mefisto2D)
|
||||
mesh.AddHypothesis(compshell,hypLengthFromEdges)
|
||||
|
||||
mesh.AddHypothesis(compshell,netgen3D)
|
||||
mesh.AddHypothesis(compshell,hypVolume)
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute compshell"
|
||||
ret = smesh.Compute(mesh,compshell)
|
||||
ret = mesh.Compute(mesh)
|
||||
print ret
|
||||
if ret != 0:
|
||||
log = mesh.GetLog(0) # no erase trace
|
||||
|
@ -26,12 +26,7 @@
|
||||
import os
|
||||
import salome
|
||||
import geompy
|
||||
import StdMeshers
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
import smesh
|
||||
|
||||
|
||||
# ---------------------------- GEOM --------------------------------------
|
||||
@ -61,64 +56,39 @@ print "number of Edges in flight : ", len(subEdgeList)
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
# ---- init a Mesh with the shell
|
||||
shape_mesh = salome.IDToObject( idShape )
|
||||
|
||||
mesh = smesh.Mesh(shape_mesh, "MeshFlight")
|
||||
|
||||
|
||||
# ---- set Hypothesis and Algorithm
|
||||
|
||||
print "-------------------------- LocalLength"
|
||||
|
||||
lengthOfSegments = 0.3
|
||||
|
||||
hypLength = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
|
||||
hypLength.SetLength(lengthOfSegments)
|
||||
|
||||
regular1D = mesh.Segment()
|
||||
hypLength = regular1D.LocalLength(lengthOfSegments)
|
||||
print hypLength.GetName()
|
||||
print hypLength.GetId()
|
||||
print hypLength.GetLength()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
|
||||
smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments))
|
||||
|
||||
print "-------------------------- LengthFromEdges"
|
||||
|
||||
hypLengthFromEdge = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
|
||||
|
||||
mefisto2D = mesh.Triangle()
|
||||
hypLengthFromEdge = mefisto2D.LengthFromEdges()
|
||||
print hypLengthFromEdge.GetName()
|
||||
print hypLengthFromEdge.GetId()
|
||||
smesh.SetName(hypLengthFromEdge,"LengthFromEdge")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
|
||||
|
||||
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")
|
||||
|
||||
# ---- init a Mesh with the shell
|
||||
shape_mesh = salome.IDToObject( idShape )
|
||||
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
|
||||
|
||||
# ---- add hypothesis to flight
|
||||
|
||||
print "-------------------------- add hypothesis to flight"
|
||||
|
||||
mesh.AddHypothesis(shape_mesh,regular1D)
|
||||
mesh.AddHypothesis(shape_mesh,hypLength)
|
||||
mesh.AddHypothesis(shape_mesh,mefisto2D)
|
||||
mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
|
||||
print "-------------------------- compute the skin flight"
|
||||
ret = smesh.Compute(mesh,shape_mesh)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
if ret != 0:
|
||||
log = mesh.GetLog(0) # no erase trace
|
||||
|
@ -17,69 +17,51 @@
|
||||
#
|
||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
#
|
||||
import salome
|
||||
import geompy
|
||||
import SMESH
|
||||
import StdMeshers
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# Create box without one plane
|
||||
|
||||
box = geompy.MakeBox(0., 0., 0., 10., 20., 30.)
|
||||
subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
|
||||
|
||||
FaceList = []
|
||||
for i in range( 5 ):
|
||||
FaceList.append( subShapeList[ i ] )
|
||||
|
||||
aComp = geompy.MakeCompound( FaceList )
|
||||
aBox = geompy.Sew( aComp, 1. )
|
||||
idbox = geompy.addToStudy( aBox, "box" )
|
||||
|
||||
aBox = salome.IDToObject( idbox )
|
||||
|
||||
# Create mesh
|
||||
|
||||
hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hyp1.SetNumberOfSegments(5)
|
||||
hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hyp2.SetMaxElementArea(20)
|
||||
hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hyp3.SetMaxElementArea(50)
|
||||
|
||||
algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
|
||||
mesh = smesh.CreateMesh(aBox)
|
||||
mesh.AddHypothesis(aBox,hyp1)
|
||||
mesh.AddHypothesis(aBox,hyp2)
|
||||
mesh.AddHypothesis(aBox,algo1)
|
||||
mesh.AddHypothesis(aBox,algo2)
|
||||
|
||||
smesh.Compute(mesh,aBox)
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId);
|
||||
smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_freebord" );
|
||||
|
||||
# Criterion : Free edges
|
||||
aFilterMgr = smesh.CreateFilterManager()
|
||||
aPredicate = aFilterMgr.CreateFreeBorders()
|
||||
aFilter = aFilterMgr.CreateFilter()
|
||||
aFilter.SetPredicate( aPredicate )
|
||||
|
||||
anIds = aFilter.GetElementsId( mesh )
|
||||
|
||||
# print result
|
||||
print "Criterion: Free edges Nb = ", len( anIds )
|
||||
for i in range( len( anIds ) ):
|
||||
print anIds[ i ]
|
||||
|
||||
# create group
|
||||
aGroup = mesh.CreateGroup( SMESH.EDGE, "Free edges" )
|
||||
aGroup.Add( anIds )
|
||||
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
|
||||
# Create box without one plane
|
||||
|
||||
box = geompy.MakeBox(0., 0., 0., 10., 20., 30.)
|
||||
subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
|
||||
|
||||
FaceList = []
|
||||
for i in range( 5 ):
|
||||
FaceList.append( subShapeList[ i ] )
|
||||
|
||||
aComp = geompy.MakeCompound( FaceList )
|
||||
aBox = geompy.Sew( aComp, 1. )
|
||||
idbox = geompy.addToStudy( aBox, "box" )
|
||||
|
||||
aBox = salome.IDToObject( idbox )
|
||||
|
||||
# Create mesh
|
||||
|
||||
mesh = smesh.Mesh(aBox, "Mesh_freebord")
|
||||
|
||||
algoReg = mesh.Segment()
|
||||
hypNbSeg = algoReg.NumberOfSegments(5)
|
||||
|
||||
algoMef = mesh.Triangle()
|
||||
hypArea = algoMef.MaxElementArea(20)
|
||||
|
||||
|
||||
mesh.Compute()
|
||||
|
||||
|
||||
# Criterion : Free edges. Create group.
|
||||
|
||||
aCriterion = smesh.GetCriterion(smesh.EDGE, smesh.FT_FreeEdges)
|
||||
|
||||
aGroup = mesh.MakeGroupByCriterion("Free edges", aCriterion)
|
||||
|
||||
anIds = aGroup.GetIDs()
|
||||
|
||||
# print result
|
||||
print "Criterion: Free edges Nb = ", len( anIds )
|
||||
for i in range( len( anIds ) ):
|
||||
print anIds[ i ]
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
@ -26,9 +26,8 @@
|
||||
#==============================================================================
|
||||
|
||||
import salome
|
||||
from salome import sg
|
||||
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import math
|
||||
|
||||
@ -37,7 +36,6 @@ import math
|
||||
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
|
||||
myBuilder = salome.myStudy.NewBuilder()
|
||||
gg = salome.ImportComponentGUI("GEOM")
|
||||
from salome import sg
|
||||
|
||||
ShapeTypeCompSolid = 1
|
||||
ShapeTypeSolid = 2
|
||||
@ -95,72 +93,67 @@ salome.sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- mesh"
|
||||
|
||||
import SMESH
|
||||
import StdMeshers
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# ---- create Hypothesis
|
||||
print "-------------------------- create Hypothesis"
|
||||
numberOfSegments = 4
|
||||
hypNbSegA=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSegA.SetNumberOfSegments(numberOfSegments)
|
||||
numberOfSegments = 10
|
||||
hypNbSegB=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSegB.SetNumberOfSegments(numberOfSegments)
|
||||
numberOfSegments = 15
|
||||
hypNbSegC=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSegC.SetNumberOfSegments(numberOfSegments)
|
||||
|
||||
# ---- create Algorithms
|
||||
print "-------------------------- create Algorithms"
|
||||
regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
|
||||
hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
|
||||
|
||||
# ---- init a Mesh with the geom shape
|
||||
shape_mesh = blob
|
||||
myMesh=smesh.CreateMesh(shape_mesh)
|
||||
mesh=smesh.Mesh(shape_mesh, "MeshBlob")
|
||||
|
||||
# ---- add hypothesis and algorithms to mesh
|
||||
print "-------------------------- add hypothesis to mesh"
|
||||
myMesh.AddHypothesis(shape_mesh,regular1D)
|
||||
myMesh.AddHypothesis(shape_mesh,quad2D)
|
||||
myMesh.AddHypothesis(shape_mesh,hexa3D)
|
||||
algo1 = mesh.Segment()
|
||||
algo2 = mesh.Quadrangle()
|
||||
algo3 = mesh.Hexahedron()
|
||||
|
||||
#myMesh.AddHypothesis(shape_mesh,hypNbSeg)
|
||||
numberOfSegmentsA = 4
|
||||
|
||||
myMesh.AddHypothesis(aretes[0],hypNbSegA)
|
||||
myMesh.AddHypothesis(aretes[2],hypNbSegA)
|
||||
myMesh.AddHypothesis(aretes[8],hypNbSegA)
|
||||
myMesh.AddHypothesis(aretes[10],hypNbSegA)
|
||||
algo = mesh.Segment(aretes[0])
|
||||
algo.NumberOfSegments(numberOfSegmentsA)
|
||||
algo = mesh.Segment(aretes[2])
|
||||
algo.NumberOfSegments(numberOfSegmentsA)
|
||||
algo = mesh.Segment(aretes[8])
|
||||
algo.NumberOfSegments(numberOfSegmentsA)
|
||||
algo = mesh.Segment(aretes[10])
|
||||
algo.NumberOfSegments(numberOfSegmentsA)
|
||||
|
||||
myMesh.AddHypothesis(aretes[1],hypNbSegC)
|
||||
myMesh.AddHypothesis(aretes[3],hypNbSegC)
|
||||
myMesh.AddHypothesis(aretes[9],hypNbSegC)
|
||||
myMesh.AddHypothesis(aretes[11],hypNbSegC)
|
||||
|
||||
myMesh.AddHypothesis(aretes[4],hypNbSegB)
|
||||
myMesh.AddHypothesis(aretes[5],hypNbSegB)
|
||||
myMesh.AddHypothesis(aretes[6],hypNbSegB)
|
||||
myMesh.AddHypothesis(aretes[7],hypNbSegB)
|
||||
numberOfSegmentsC = 15
|
||||
|
||||
algo = mesh.Segment(aretes[1])
|
||||
algo.NumberOfSegments(numberOfSegmentsC)
|
||||
algo = mesh.Segment(aretes[3])
|
||||
algo.NumberOfSegments(numberOfSegmentsC)
|
||||
algo = mesh.Segment(aretes[9])
|
||||
algo.NumberOfSegments(numberOfSegmentsC)
|
||||
algo = mesh.Segment(aretes[11])
|
||||
algo.NumberOfSegments(numberOfSegmentsC)
|
||||
|
||||
|
||||
numberOfSegmentsB = 10
|
||||
algo = mesh.Segment(aretes[4])
|
||||
algo.NumberOfSegments(numberOfSegmentsB)
|
||||
algo = mesh.Segment(aretes[5])
|
||||
algo.NumberOfSegments(numberOfSegmentsB)
|
||||
algo = mesh.Segment(aretes[6])
|
||||
algo.NumberOfSegments(numberOfSegmentsB)
|
||||
algo = mesh.Segment(aretes[7])
|
||||
algo.NumberOfSegments(numberOfSegmentsB)
|
||||
|
||||
|
||||
# ---- compute mesh
|
||||
|
||||
print "-------------------------- compute mesh"
|
||||
ret=smesh.Compute(myMesh, shape_mesh)
|
||||
ret=mesh.Compute()
|
||||
print ret
|
||||
if ret != 0:
|
||||
#log=myMesh.GetLog(0) # no erase trace
|
||||
#log=mesh.GetLog(0) # no erase trace
|
||||
#for linelog in log:
|
||||
# print linelog
|
||||
print "Information about the Mesh:"
|
||||
print "Number of nodes : ", myMesh.NbNodes()
|
||||
print "Number of edges : ", myMesh.NbEdges()
|
||||
print "Number of faces : ", myMesh.NbFaces()
|
||||
print "Number of quadrangles : ", myMesh.NbQuadrangles()
|
||||
print "Number of volumes : ", myMesh.NbVolumes()
|
||||
print "Number of hexahedrons : ", myMesh.NbHexas()
|
||||
print "Number of nodes : ", mesh.NbNodes()
|
||||
print "Number of edges : ", mesh.NbEdges()
|
||||
print "Number of faces : ", mesh.NbFaces()
|
||||
print "Number of quadrangles : ", mesh.NbQuadrangles()
|
||||
print "Number of volumes : ", mesh.NbVolumes()
|
||||
print "Number of hexahedrons : ", mesh.NbHexas()
|
||||
else:
|
||||
print "problem when Computing the mesh"
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
|
||||
@ -120,130 +121,55 @@ Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name )
|
||||
|
||||
# ---------------------------- SMESH --------------------------------------
|
||||
|
||||
# ---- launch SMESH, init a Mesh with shape 'mechanic'
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
# -- Init --
|
||||
shape_mesh = salome.IDToObject( Id_mechanic )
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
idmesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName( idmesh, "Mesh_mechanic" )
|
||||
mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic")
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegment = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
|
||||
hypNbSeg.SetNumberOfSegments( numberOfSegment )
|
||||
algo = mesh.Segment()
|
||||
hypNbSeg = algo.NumberOfSegments(numberOfSegment)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_10")
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 25
|
||||
|
||||
hypArea25 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
|
||||
hypArea25.SetMaxElementArea( maxElementArea )
|
||||
algo = mesh.Triangle()
|
||||
hypArea25 = algo.MaxElementArea(maxElementArea)
|
||||
print hypArea25.GetName()
|
||||
print hypArea25.GetId()
|
||||
print hypArea25.GetMaxElementArea()
|
||||
smesh.SetName(hypArea25, "MaxElementArea_25")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea25), "MaxElementArea_25")
|
||||
# Create submesh on sub_face1 - sub_face4
|
||||
# ---------------------------------------
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
# Set 2D algorithm to submesh on sub_face1
|
||||
algo = mesh.Quadrangle(sub_face1)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace1")
|
||||
|
||||
maxElementArea = 35
|
||||
# Set 2D algorithm to submesh on sub_face2
|
||||
algo = mesh.Quadrangle(sub_face2)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace2")
|
||||
|
||||
hypArea35 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
|
||||
hypArea35.SetMaxElementArea( maxElementArea )
|
||||
print hypArea35.GetName()
|
||||
print hypArea35.GetId()
|
||||
print hypArea35.GetMaxElementArea()
|
||||
# Set 2D algorithm to submesh on sub_face3
|
||||
algo = mesh.Quadrangle(sub_face3)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace3")
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea35), "MaxElementArea_35")
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoReg1D.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoReg1D.GetName()
|
||||
print algoReg1D.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D")
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
|
||||
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoMef.GetName()
|
||||
print algoMef.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D")
|
||||
|
||||
print "-------------------------- SMESH_Quadrangle_2D"
|
||||
|
||||
algoQuad = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoQuad.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoQuad.GetName()
|
||||
print algoQuad.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoQuad), "SMESH_Quadrangle_2D")
|
||||
|
||||
print "-------------------------- add hypothesis to main shape"
|
||||
|
||||
mesh.AddHypothesis( shape_mesh, hypNbSeg ) # nb segments
|
||||
mesh.AddHypothesis( shape_mesh, hypArea25 ) # max area
|
||||
|
||||
mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation
|
||||
mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D
|
||||
|
||||
print "-------------------------- add hypothesis and algorithm to sub face 1"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1")
|
||||
|
||||
mesh.AddHypothesis( sub_face1, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face1, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- add hypothesis and algorithm to sub face 2"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
|
||||
|
||||
mesh.AddHypothesis( sub_face2, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face2, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- add hypothesis and algorith to sub face 3"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3")
|
||||
|
||||
mesh.AddHypothesis( sub_face3, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face3, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- add hypothesis and algorith to sub face 4"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4")
|
||||
|
||||
mesh.AddHypothesis( sub_face4, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face4, hypArea35 ) # max area
|
||||
# Set 2D algorithm to submesh on sub_face4
|
||||
algo = mesh.Quadrangle(sub_face4)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace4")
|
||||
|
||||
print "-------------------------- compute the mesh of the mechanic piece"
|
||||
|
||||
smesh.Compute(mesh, shape_mesh)
|
||||
mesh.Compute()
|
||||
|
||||
print "Information about the Mesh_mechanic:"
|
||||
print "Number of nodes : ", mesh.NbNodes()
|
||||
|
@ -28,10 +28,7 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
|
||||
import StdMeshers
|
||||
|
||||
import SMESH
|
||||
import smesh
|
||||
|
||||
# ---------------------------- GEOM --------------------------------------
|
||||
|
||||
@ -122,130 +119,62 @@ Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name )
|
||||
|
||||
# ---------------------------- SMESH --------------------------------------
|
||||
|
||||
# ---- launch SMESH, init a Mesh with shape 'mechanic'
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
|
||||
# -- Init --
|
||||
shape_mesh = salome.IDToObject( Id_mechanic )
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
idmesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName( idmesh, "Mesh_mechanic" )
|
||||
mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic")
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegment = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
|
||||
hypNbSeg.SetNumberOfSegments( numberOfSegment )
|
||||
algo = mesh.Segment()
|
||||
hypNbSeg = algo.NumberOfSegments(numberOfSegment)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment))
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 25
|
||||
|
||||
hypArea25 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
|
||||
hypArea25.SetMaxElementArea( maxElementArea )
|
||||
algo = mesh.Triangle()
|
||||
hypArea25 = algo.MaxElementArea(maxElementArea)
|
||||
print hypArea25.GetName()
|
||||
print hypArea25.GetId()
|
||||
print hypArea25.GetMaxElementArea()
|
||||
smesh.SetName(hypArea25, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea25), "MaxElementArea_25")
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
# Create submesh on sub_face1 - sub_face4
|
||||
# ---------------------------------------
|
||||
|
||||
maxElementArea = 35
|
||||
# Set 2D algorithm to submesh on sub_face1
|
||||
algo = mesh.Quadrangle(sub_face1)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace1")
|
||||
submesh1 = algo.GetSubMesh()
|
||||
|
||||
hypArea35 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
|
||||
hypArea35.SetMaxElementArea( maxElementArea )
|
||||
print hypArea35.GetName()
|
||||
print hypArea35.GetId()
|
||||
print hypArea35.GetMaxElementArea()
|
||||
# Set 2D algorithm to submesh on sub_face2
|
||||
algo = mesh.Quadrangle(sub_face2)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace2")
|
||||
submesh2 = algo.GetSubMesh()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea35), "MaxElementArea_35")
|
||||
# Set 2D algorithm to submesh on sub_face3
|
||||
algo = mesh.Quadrangle(sub_face3)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace3")
|
||||
submesh3 = algo.GetSubMesh()
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
# Set 2D algorithm to submesh on sub_face4
|
||||
algo = mesh.Quadrangle(sub_face4)
|
||||
smesh.SetName(algo.GetSubMesh(), "SubMeshFace4")
|
||||
submesh4 = algo.GetSubMesh()
|
||||
|
||||
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoReg1D.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoReg1D.GetName()
|
||||
print algoReg1D.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D")
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
|
||||
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoMef.GetName()
|
||||
print algoMef.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D")
|
||||
|
||||
print "-------------------------- SMESH_Quadrangle_2D"
|
||||
|
||||
algoQuad = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoQuad.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoQuad.GetName()
|
||||
print algoQuad.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoQuad), "SMESH_Quadrangle_2D")
|
||||
|
||||
print "-------------------------- add hypothesis to main shape"
|
||||
|
||||
mesh.AddHypothesis( shape_mesh, hypNbSeg ) # nb segments
|
||||
mesh.AddHypothesis( shape_mesh, hypArea25 ) # max area
|
||||
|
||||
mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation
|
||||
mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D
|
||||
|
||||
print "-------------------------- add hypothesis and algorithm to sub face 1"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1")
|
||||
|
||||
mesh.AddHypothesis( sub_face1, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face1, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- add hypothesis and algorithm to sub face 2"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
|
||||
|
||||
mesh.AddHypothesis( sub_face2, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face2, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- add hypothesis and algorith to sub face 3"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3")
|
||||
|
||||
mesh.AddHypothesis( sub_face3, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face3, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- add hypothesis and algorith to sub face 4"
|
||||
|
||||
submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4")
|
||||
|
||||
mesh.AddHypothesis( sub_face4, algoQuad ) # Quadrangle 2D
|
||||
mesh.AddHypothesis( sub_face4, hypArea35 ) # max area
|
||||
|
||||
print "-------------------------- compute the mesh of the mechanic piece"
|
||||
|
||||
smesh.Compute(mesh, shape_mesh)
|
||||
mesh.Compute()
|
||||
|
||||
print "Information about the Mesh_mechanic:"
|
||||
print "Number of nodes : ", mesh.NbNodes()
|
||||
@ -257,52 +186,45 @@ print "Number of volumes : ", mesh.NbVolumes()
|
||||
print "Number of tetrahedrons: ", mesh.NbTetras()
|
||||
|
||||
|
||||
MeshEditor = mesh.GetMeshEditor()
|
||||
|
||||
#1 cutting of quadrangles of the 'SubMeshFace2' submesh
|
||||
submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
|
||||
MeshEditor.SplitQuadObject(submesh, 1)
|
||||
mesh.SplitQuadObject(submesh2, 1)
|
||||
|
||||
#2 cutting of triangles of the group
|
||||
FacesTriToQuad = [2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422]
|
||||
GroupTriToQuad = mesh.CreateGroup(SMESH.FACE,"Group of faces (quad)")
|
||||
GroupTriToQuad.Add(FacesTriToQuad)
|
||||
MeshEditor.TriToQuadObject(GroupTriToQuad, None , 1.57)
|
||||
GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", smesh.FACE, FacesTriToQuad)
|
||||
mesh.TriToQuadObject(GroupTriToQuad, None , 1.57)
|
||||
|
||||
#3 extrusion of the group
|
||||
point = SMESH.PointStruct(0, 0, 5)
|
||||
vector = SMESH.DirStruct(point)
|
||||
MeshEditor.ExtrusionSweepObject(GroupTriToQuad, vector, 5)
|
||||
point = smesh.PointStruct(0, 0, 5)
|
||||
vector = smesh.DirStruct(point)
|
||||
mesh.ExtrusionSweepObject(GroupTriToQuad, vector, 5)
|
||||
|
||||
#4 mirror object
|
||||
MeshEditor.MirrorObject(mesh, SMESH.AxisStruct(0, 0, 0, 0, 0, 0), SMESH.SMESH_MeshEditor.POINT, 0)
|
||||
mesh.Mirror([], smesh.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0)
|
||||
|
||||
#5 mesh translation
|
||||
point = SMESH.PointStruct(10, 10, 10)
|
||||
vector = SMESH.DirStruct(point)
|
||||
MeshEditor.TranslateObject(mesh, vector, 0)
|
||||
point = smesh.PointStruct(10, 10, 10)
|
||||
vector = smesh.DirStruct(point)
|
||||
mesh.Translate([], vector, 0)
|
||||
|
||||
#6 mesh rotation
|
||||
axisXYZ = SMESH.AxisStruct(0, 0, 0, 10, 10, 10)
|
||||
axisXYZ = smesh.AxisStruct(0, 0, 0, 10, 10, 10)
|
||||
angle180 = 180*3.141/180
|
||||
MeshEditor.RotateObject(mesh, axisXYZ, angle180, 0)
|
||||
mesh.Rotate([], axisXYZ, angle180, 0)
|
||||
|
||||
#7 group smoothing
|
||||
FacesSmooth = [864, 933, 941, 950, 1005, 1013]
|
||||
GroupSmooth = mesh.CreateGroup(SMESH.FACE,"Group of faces (smooth)")
|
||||
GroupSmooth.Add(FacesSmooth)
|
||||
MeshEditor.SmoothObject(GroupSmooth, [], 20, 2, SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH)
|
||||
GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", smesh.FACE, FacesSmooth)
|
||||
mesh.SmoothObject(GroupSmooth, [], 20, 2, smesh.CENTROIDAL_SMOOTH)
|
||||
|
||||
#8 rotation sweep object
|
||||
FacesRotate = [492, 493, 502, 503]
|
||||
GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group of faces (rotate)")
|
||||
GroupRotate.Add(FacesRotate)
|
||||
GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", smesh.FACE, FacesRotate)
|
||||
angle45 = 45*3.141/180
|
||||
axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632)
|
||||
MeshEditor.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
|
||||
axisXYZ = smesh.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632)
|
||||
mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
|
||||
|
||||
#9 reorientation of the whole mesh
|
||||
submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1")
|
||||
MeshEditor.ReorientObject(submesh)
|
||||
#9 reorientation of the submesh1
|
||||
mesh.ReorientObject(submesh1)
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
@ -28,8 +28,6 @@ import geompy
|
||||
|
||||
geom = geompy.geom
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
import smesh
|
||||
|
||||
# ---------------------------- GEOM --------------------------------------
|
||||
@ -109,13 +107,12 @@ print "number of Edges in mechanic : ",len(subEdgeList)
|
||||
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 )
|
||||
netgen = mesh.Triangle(smesh.NETGEN)
|
||||
netgen.SetMaxSize( 50 )
|
||||
#netgen.SetSecondOrder( 0 )
|
||||
netgen.SetFineness( smesh.Fine )
|
||||
netgen.SetQuadAllowed( 1 )
|
||||
#netgen.SetOptimize( 1 )
|
||||
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
||||
@ -124,13 +121,13 @@ 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()
|
||||
print "Number of nodes : ", mesh.NbNodes()
|
||||
print "Number of edges : ", mesh.NbEdges()
|
||||
print "Number of faces : ", mesh.NbFaces()
|
||||
print "Number of triangles : ", mesh.NbTriangles()
|
||||
print "Number of quadrangles : ", mesh.NbQuadrangles()
|
||||
print "Number of volumes : ", mesh.NbVolumes()
|
||||
print "Number of tetrahedrons : ", mesh.NbTetras()
|
||||
|
||||
else:
|
||||
print "problem when computing the mesh"
|
||||
|
@ -26,16 +26,9 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
geom = geompy.geom
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
import StdMeshers
|
||||
import NETGENPlugin
|
||||
|
||||
# ---------------------------- GEOM --------------------------------------
|
||||
|
||||
@ -111,94 +104,44 @@ print "number of Edges in mechanic : ",len(subEdgeList)
|
||||
|
||||
### ---------------------------- SMESH --------------------------------------
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
shape_mesh = salome.IDToObject( Id_mechanic )
|
||||
|
||||
numberOfSegment = 10
|
||||
|
||||
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
|
||||
hypNbSeg.SetNumberOfSegments( numberOfSegment )
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
maxElementArea = 20
|
||||
|
||||
hypArea = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
|
||||
hypArea.SetMaxElementArea( maxElementArea )
|
||||
print hypArea.GetName()
|
||||
print hypArea.GetId()
|
||||
print hypArea.GetMaxElementArea()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_20")
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 20
|
||||
|
||||
hypVolume = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
|
||||
hypVolume.SetMaxElementVolume( maxElementVolume )
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_20")
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
|
||||
listHyp =algoReg1D.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoReg1D.GetName()
|
||||
print algoReg1D.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D")
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
|
||||
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoMef.GetName()
|
||||
print algoMef.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
|
||||
listHyp = algoNg.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoNg.GetName()
|
||||
print algoNg.GetId()
|
||||
|
||||
smeshgui.SetName(salome.ObjectToID(algoNg), "NETGEN_3D")
|
||||
mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic_tetra")
|
||||
|
||||
print "-------------------------- add hypothesis to main mechanic"
|
||||
|
||||
shape_mesh = salome.IDToObject( Id_mechanic )
|
||||
numberOfSegment = 10
|
||||
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
algo1 = mesh.Segment()
|
||||
hypNbSeg = algo1.NumberOfSegments(numberOfSegment)
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSeg.GetId()
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment))
|
||||
|
||||
idmesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName( idmesh, "Mesh_mechanic_tetra" )
|
||||
|
||||
mesh.AddHypothesis( shape_mesh, hypNbSeg ) # nb segments
|
||||
mesh.AddHypothesis( shape_mesh, hypArea ) # max area
|
||||
mesh.AddHypothesis( shape_mesh, hypVolume ) # max volume
|
||||
maxElementArea = 20
|
||||
|
||||
algo2 = mesh.Triangle(smesh.MEFISTO)
|
||||
hypArea = algo2.MaxElementArea(maxElementArea)
|
||||
print hypArea.GetName()
|
||||
print hypArea.GetId()
|
||||
print hypArea.GetMaxElementArea()
|
||||
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
|
||||
|
||||
|
||||
maxElementVolume = 20
|
||||
|
||||
algo3 = mesh.Tetrahedron(smesh.NETGEN)
|
||||
hypVolume = algo3.MaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
smesh.SetName(hypVolume, "maxElementVolume_" + str(maxElementVolume))
|
||||
|
||||
mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation
|
||||
mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D
|
||||
mesh.AddHypothesis( shape_mesh, algoNg ) # NETGEN 3D
|
||||
|
||||
print "-------------------------- compute the mesh of the mechanic piece"
|
||||
smesh.Compute(mesh,shape_mesh)
|
||||
mesh.Compute()
|
||||
|
||||
print "Information about the Mesh_mechanic_tetra:"
|
||||
print "Number of nodes : ", mesh.NbNodes()
|
||||
|
@ -24,11 +24,10 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# ---- define a box
|
||||
print "Define box"
|
||||
@ -60,124 +59,53 @@ smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- LocalLength"
|
||||
hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
|
||||
hypLen1.SetLength(100)
|
||||
print hypLen1.GetName()
|
||||
print hypLen1.GetId()
|
||||
print hypLen1.GetLength()
|
||||
|
||||
idlength = salome.ObjectToID(hypLen1)
|
||||
smeshgui.SetName(idlength, "Local_Length_100");
|
||||
|
||||
hypNbSeg = []
|
||||
print "-------------------------- NumberOfSegments"
|
||||
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg1.SetDistrType(0)
|
||||
hypNbSeg1.SetNumberOfSegments(7)
|
||||
print hypNbSeg1.GetName()
|
||||
print hypNbSeg1.GetId()
|
||||
print hypNbSeg1.GetNumberOfSegments()
|
||||
idseg1 = salome.ObjectToID(hypNbSeg1)
|
||||
smeshgui.SetName(idseg1, "NumberOfSegmentsReg");
|
||||
hypNbSeg.append(hypNbSeg1)
|
||||
|
||||
hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg2.SetDistrType(1)
|
||||
hypNbSeg2.SetNumberOfSegments(7)
|
||||
hypNbSeg2.SetScaleFactor(2)
|
||||
print hypNbSeg2.GetName()
|
||||
print hypNbSeg2.GetId()
|
||||
print hypNbSeg2.GetNumberOfSegments()
|
||||
idseg2 = salome.ObjectToID(hypNbSeg2)
|
||||
smeshgui.SetName(idseg2, "NumberOfSegmentsScale");
|
||||
hypNbSeg.append(hypNbSeg2)
|
||||
|
||||
hypNbSeg3 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg3.SetDistrType(2)
|
||||
hypNbSeg3.SetNumberOfSegments(7)
|
||||
hypNbSeg3.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
|
||||
hypNbSeg3.SetConversionMode(0)
|
||||
print hypNbSeg3.GetName()
|
||||
print hypNbSeg3.GetId()
|
||||
print hypNbSeg3.GetNumberOfSegments()
|
||||
idseg3 = salome.ObjectToID(hypNbSeg3)
|
||||
smeshgui.SetName(idseg3, "NumberOfSegmentsTable");
|
||||
hypNbSeg.append(hypNbSeg3)
|
||||
|
||||
hypNbSeg4 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg4.SetDistrType(3)
|
||||
hypNbSeg4.SetNumberOfSegments(10)
|
||||
hypNbSeg4.SetExpressionFunction("sin(3*t)")
|
||||
hypNbSeg4.SetConversionMode(1)
|
||||
print hypNbSeg4.GetName()
|
||||
print hypNbSeg4.GetId()
|
||||
print hypNbSeg4.GetNumberOfSegments()
|
||||
idseg4 = salome.ObjectToID(hypNbSeg4)
|
||||
smeshgui.SetName(idseg4, "NumberOfSegmentsExpr");
|
||||
hypNbSeg.append(hypNbSeg4)
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea1.SetMaxElementArea(2500)
|
||||
print hypArea1.GetName()
|
||||
print hypArea1.GetId()
|
||||
print hypArea1.GetMaxElementArea()
|
||||
|
||||
idarea1 = salome.ObjectToID(hypArea1)
|
||||
smeshgui.SetName(idarea1, "MaxElementArea_2500");
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea2.SetMaxElementArea(500)
|
||||
print hypArea2.GetName()
|
||||
print hypArea2.GetId()
|
||||
print hypArea2.GetMaxElementArea()
|
||||
|
||||
idarea2 = salome.ObjectToID(hypArea2)
|
||||
smeshgui.SetName(idarea2, "MaxElementArea_500");
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
listHyp = algoReg.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoReg.GetName()
|
||||
print algoReg.GetId()
|
||||
|
||||
idreg = salome.ObjectToID(algoReg)
|
||||
smeshgui.SetName(idreg, "Regular_1D");
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoMef.GetName()
|
||||
print algoMef.GetId()
|
||||
|
||||
idmef = salome.ObjectToID(algoMef)
|
||||
smeshgui.SetName(idmef, "MEFISTO_2D");
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
||||
# ---- Init a Mesh with the box
|
||||
# ---- Creating meshes
|
||||
|
||||
box = salome.IDToObject(idbox)
|
||||
names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ];
|
||||
j = 0
|
||||
for i in range(4):
|
||||
mesh = smesh.CreateMesh(box)
|
||||
idmesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName(idmesh, names[j]);
|
||||
print "-------------------------- add hypothesis to box"
|
||||
mesh.AddHypothesis(box,algoReg)
|
||||
mesh.AddHypothesis(box,hypNbSeg[j])
|
||||
mesh.AddHypothesis(box,algoMef)
|
||||
mesh.AddHypothesis(box,hypArea1)
|
||||
j=j+1
|
||||
names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ]
|
||||
|
||||
|
||||
print "-------------------------- Create ", names[0], " mesh"
|
||||
mesh = smesh.Mesh(box, names[0])
|
||||
algo = mesh.Segment()
|
||||
hyp = algo.NumberOfSegments(7)
|
||||
hyp.SetDistrType(0)
|
||||
smesh.SetName(hyp, "NumberOfSegmentsReg")
|
||||
algo = mesh.Triangle()
|
||||
algo.MaxElementArea(2500)
|
||||
|
||||
print "-------------------------- Create ", names[1], " mesh"
|
||||
mesh = smesh.Mesh(box, names[1])
|
||||
algo = mesh.Segment()
|
||||
hyp = algo.NumberOfSegments(7)
|
||||
hyp.SetDistrType(1)
|
||||
hyp.SetScaleFactor(2)
|
||||
smesh.SetName(hyp, "NumberOfSegmentsScale")
|
||||
algo = mesh.Triangle()
|
||||
algo.MaxElementArea(2500)
|
||||
|
||||
print "-------------------------- Create ", names[2], " mesh"
|
||||
mesh = smesh.Mesh(box,names[2])
|
||||
algo = mesh.Segment()
|
||||
hyp = algo.NumberOfSegments(7)
|
||||
hyp.SetDistrType(2)
|
||||
hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
|
||||
hyp.SetConversionMode(0)
|
||||
smesh.SetName(hyp, "NumberOfSegmentsTable")
|
||||
algo = mesh.Triangle()
|
||||
algo.MaxElementArea(2500)
|
||||
|
||||
print "-------------------------- Create ", names[3], " mesh"
|
||||
mesh = smesh.Mesh(box, names[3])
|
||||
algo = mesh.Segment()
|
||||
hyp = algo.NumberOfSegments(10)
|
||||
hyp.SetDistrType(3)
|
||||
hyp.SetExpressionFunction("sin(3*t)")
|
||||
hyp.SetConversionMode(1)
|
||||
smesh.SetName(hyp, "NumberOfSegmentsExpr")
|
||||
algo = mesh.Triangle()
|
||||
algo.MaxElementArea(2500)
|
||||
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
||||
|
@ -26,10 +26,7 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smeshpy
|
||||
|
||||
import SMESH
|
||||
import StdMeshers
|
||||
import smesh
|
||||
|
||||
# ---- define a box
|
||||
|
||||
@ -57,94 +54,46 @@ edge = edgeList[0];
|
||||
name = geompy.SubShapeName(edge, face)
|
||||
ide = geompy.addToStudyInFather(face, edge, name)
|
||||
|
||||
# ---- launch SMESH, init a Mesh with the box
|
||||
# ---- SMESH
|
||||
|
||||
gen = smeshpy.smeshpy()
|
||||
mesh = gen.CreateMesh(idb)
|
||||
box = salome.IDToObject(idb)
|
||||
mesh = smesh.Mesh(box, "Meshbox")
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
print "-------------------------- add hypothesis to box"
|
||||
|
||||
print "-------------------------- LocalLength"
|
||||
algo_1 = mesh.Segment(box)
|
||||
hyp = algo_1.LocalLength(100)
|
||||
print hyp.GetName()
|
||||
print hyp.GetId()
|
||||
print hyp.GetLength()
|
||||
|
||||
hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
|
||||
print hypo1.GetName()
|
||||
print hypo1.GetId()
|
||||
print hypo1.GetLength()
|
||||
hypo1.SetLength(100)
|
||||
print hypo1.GetLength()
|
||||
algo_2 = mesh.Triangle(smesh.MEFISTO, box)
|
||||
hyp = algo_2.MaxElementArea(5000)
|
||||
print hyp.GetName()
|
||||
print hyp.GetId()
|
||||
print hyp.GetMaxElementArea()
|
||||
|
||||
print "-------------------------- bidon"
|
||||
smesh.SetName(algo_2.GetSubMesh(), "SubMeshBox")
|
||||
|
||||
hyp3 = gen.CreateHypothesis("bidon", "")
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypo3.SetNumberOfSegments(7)
|
||||
print hypo3.GetName()
|
||||
print hypo3.GetNumberOfSegments()
|
||||
print hypo3.GetId()
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
|
||||
hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypo4.SetMaxElementArea(5000)
|
||||
print hypo4.GetName()
|
||||
print hypo4.GetMaxElementArea()
|
||||
print hypo4.GetId()
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
print algo_1.GetName()
|
||||
print algo_1.GetId()
|
||||
listHyp = algo_1.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algo_1.GetId()
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
|
||||
algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
print algo_2.GetName()
|
||||
print algo_2.GetId()
|
||||
listHyp = algo_2.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algo_2.GetId()
|
||||
|
||||
print "-------------------------- add hypothesis to edge"
|
||||
|
||||
edge = salome.IDToObject(ide)
|
||||
submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
|
||||
ret = mesh.AddHypothesis(edge,algo_1)
|
||||
print ret
|
||||
ret = mesh.AddHypothesis(edge,hypo1)
|
||||
print ret
|
||||
|
||||
##print "-------------------------- compute edge"
|
||||
##ret=gen.Compute(mesh,ide)
|
||||
##print ret
|
||||
##log=mesh.GetLog(1);
|
||||
##for a in log:
|
||||
## print a
|
||||
algo_3 = mesh.Segment(edge)
|
||||
hyp = algo_3.LocalLength(100)
|
||||
print hyp.GetName()
|
||||
print hyp.GetId()
|
||||
print hyp.GetLength()
|
||||
|
||||
print "-------------------------- add hypothesis to box"
|
||||
smesh.SetName(algo_3.GetSubMesh(), "SubMeshEdge")
|
||||
|
||||
box = salome.IDToObject(idb)
|
||||
submesh = mesh.GetSubMesh(box, "SubMeshBox")
|
||||
ret = mesh.AddHypothesis(box,algo_1)
|
||||
print ret
|
||||
ret = mesh.AddHypothesis(box,hypo1)
|
||||
print ret
|
||||
ret = mesh.AddHypothesis(box,algo_2)
|
||||
print ret
|
||||
ret = mesh.AddHypothesis(box,hypo4)
|
||||
print ret
|
||||
|
||||
print "-------------------------- compute face"
|
||||
|
||||
ret = gen.Compute(mesh,idf)
|
||||
face = salome.IDToObject(idf)
|
||||
|
||||
ret = mesh.Compute(face)
|
||||
print ret
|
||||
log = mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after
|
||||
for a in log:
|
||||
@ -183,18 +132,3 @@ for a in log:
|
||||
i3 = a.indexes[ii]
|
||||
ii = ii+1
|
||||
print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
|
||||
|
||||
##print "-------------------------- compute box"
|
||||
##ret=gen.Compute(mesh,idb)
|
||||
##print ret
|
||||
##log=mesh.GetLog(1);
|
||||
##print log
|
||||
|
||||
##shell=salome.IDToObject(ids)
|
||||
##submesh=mesh.GetElementsOnShape(shell)
|
||||
##ret=mesh.AddHypothesis(shell,algo_1)
|
||||
##print ret
|
||||
##ret=mesh.AddHypothesis(shell,hypo1)
|
||||
##print ret
|
||||
##ret=gen.Compute(mesh,ids)
|
||||
##print ret
|
||||
|
@ -26,7 +26,6 @@ import salome
|
||||
import geompy
|
||||
from geompy import geom
|
||||
|
||||
import SMESH
|
||||
|
||||
myBuilder = salome.myStudy.NewBuilder()
|
||||
|
||||
|
@ -24,11 +24,8 @@
|
||||
|
||||
import salome
|
||||
import geompy
|
||||
import smesh
|
||||
|
||||
import StdMeshers
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# ---- define a box
|
||||
|
||||
@ -59,99 +56,51 @@ name = geompy.SubShapeName(edge, face)
|
||||
print name
|
||||
idedge = geompy.addToStudyInFather(face, edge, name)
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- LocalLength"
|
||||
hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
|
||||
hypLen1.SetLength(100)
|
||||
print hypLen1.GetName()
|
||||
print hypLen1.GetId()
|
||||
print hypLen1.GetLength()
|
||||
|
||||
idlength = salome.ObjectToID(hypLen1)
|
||||
smeshgui.SetName(idlength, "Local_Length_100");
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg1.SetNumberOfSegments(7)
|
||||
print hypNbSeg1.GetName()
|
||||
print hypNbSeg1.GetId()
|
||||
print hypNbSeg1.GetNumberOfSegments()
|
||||
|
||||
idseg = salome.ObjectToID(hypNbSeg1)
|
||||
smeshgui.SetName(idseg, "NumberOfSegments_7");
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea1.SetMaxElementArea(2500)
|
||||
print hypArea1.GetName()
|
||||
print hypArea1.GetId()
|
||||
print hypArea1.GetMaxElementArea()
|
||||
|
||||
idarea1 = salome.ObjectToID(hypArea1)
|
||||
smeshgui.SetName(idarea1, "MaxElementArea_2500");
|
||||
|
||||
print "-------------------------- MaxElementArea"
|
||||
hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea2.SetMaxElementArea(500)
|
||||
print hypArea2.GetName()
|
||||
print hypArea2.GetId()
|
||||
print hypArea2.GetMaxElementArea()
|
||||
|
||||
idarea2 = salome.ObjectToID(hypArea2)
|
||||
smeshgui.SetName(idarea2, "MaxElementArea_500");
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
listHyp = algoReg.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoReg.GetName()
|
||||
print algoReg.GetId()
|
||||
|
||||
idreg = salome.ObjectToID(algoReg)
|
||||
smeshgui.SetName(idreg, "Regular_1D");
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
print algoMef.GetName()
|
||||
print algoMef.GetId()
|
||||
|
||||
idmef = salome.ObjectToID(algoMef)
|
||||
smeshgui.SetName(idmef, "MEFISTO_2D");
|
||||
# ---- SMESH
|
||||
|
||||
# ---- Init a Mesh with the box
|
||||
|
||||
box = salome.IDToObject(idbox)
|
||||
mesh = smesh.CreateMesh(box)
|
||||
idmesh = salome.ObjectToID(mesh)
|
||||
smeshgui.SetName(idmesh, "Meshbox");
|
||||
mesh = smesh.Mesh(box, "Meshbox")
|
||||
|
||||
print "-------------------------- add hypothesis to box"
|
||||
mesh.AddHypothesis(box,algoReg)
|
||||
mesh.AddHypothesis(box,hypNbSeg1)
|
||||
mesh.AddHypothesis(box,algoMef)
|
||||
mesh.AddHypothesis(box,hypArea1)
|
||||
algoReg1 = mesh.Segment()
|
||||
hypNbSeg1 = algoReg1.NumberOfSegments(7)
|
||||
print hypNbSeg1.GetName()
|
||||
print hypNbSeg1.GetId()
|
||||
print hypNbSeg1.GetNumberOfSegments()
|
||||
smesh.SetName(hypNbSeg1, "NumberOfSegments_7")
|
||||
|
||||
algoMef1 = mesh.Triangle()
|
||||
hypArea1 = algoMef1.MaxElementArea(2500)
|
||||
print hypArea1.GetName()
|
||||
print hypArea1.GetId()
|
||||
print hypArea1.GetMaxElementArea()
|
||||
smesh.SetName(hypArea1, "MaxElementArea_2500")
|
||||
|
||||
# ---- add hypothesis to edge
|
||||
|
||||
print "-------------------------- add hypothesis to edge"
|
||||
edge = salome.IDToObject(idedge)
|
||||
submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
|
||||
mesh.AddHypothesis(edge, algoReg)
|
||||
mesh.AddHypothesis(edge, hypLen1)
|
||||
|
||||
algoReg2 = mesh.Segment(edge)
|
||||
hypLen1 = algoReg2.LocalLength(100)
|
||||
smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
|
||||
print hypLen1.GetName()
|
||||
print hypLen1.GetId()
|
||||
print hypLen1.GetLength()
|
||||
smesh.SetName(hypLen1, "Local_Length_100")
|
||||
|
||||
# ---- add hypothesis to face
|
||||
print "-------------------------- add hypothesis to face"
|
||||
face = salome.IDToObject(idface)
|
||||
submesh = mesh.GetSubMesh(face, "SubMeshFace")
|
||||
mesh.AddHypothesis(face, hypArea2)
|
||||
|
||||
algoMef2 = mesh.Triangle(face)
|
||||
hypArea2 = algoMef2.MaxElementArea(500)
|
||||
smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace")
|
||||
print hypArea2.GetName()
|
||||
print hypArea2.GetId()
|
||||
print hypArea2.GetMaxElementArea()
|
||||
smesh.SetName(hypArea2, "MaxElementArea_500")
|
||||
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
@ -27,39 +27,10 @@ from SMESH_test1 import *
|
||||
# ---- compute box
|
||||
|
||||
print "-------------------------- compute box"
|
||||
ret = smesh.Compute(mesh,box)
|
||||
ret = mesh.Compute()
|
||||
print ret
|
||||
log = mesh.GetLog(0); # no erase trace
|
||||
for linelog in log:
|
||||
print linelog
|
||||
|
||||
salome.sg.updateObjBrowser(1);
|
||||
|
||||
# ---- compute edge
|
||||
|
||||
##print "-------------------------- compute edge"
|
||||
##ret=gen.Compute(mesh,idedge)
|
||||
##print ret
|
||||
##log=mesh.GetLog(1);
|
||||
##for a in log:
|
||||
## print a
|
||||
|
||||
# ---- add hypothesis to face
|
||||
|
||||
# ---- compute face
|
||||
|
||||
#print "-------------------------- compute face"
|
||||
#ret=gen.Compute(mesh,idface)
|
||||
#print ret
|
||||
#log=mesh.GetLog(1);
|
||||
#for a in log:
|
||||
# print a
|
||||
|
||||
##shell=salome.IDToObject(ids)
|
||||
##submesh=mesh.GetElementsOnShape(shell)
|
||||
##ret=mesh.AddHypothesis(shell,algoReg)
|
||||
##print ret
|
||||
##ret=mesh.AddHypothesis(shell,hypLen1)
|
||||
##print ret
|
||||
##ret=gen.Compute(mesh,ids)
|
||||
##print ret
|
||||
salome.sg.updateObjBrowser(1)
|
||||
|
@ -19,11 +19,10 @@
|
||||
#
|
||||
import salome
|
||||
import geompy
|
||||
import SMESH
|
||||
import StdMeshers
|
||||
import smesh
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
|
||||
# ---- GEOM
|
||||
|
||||
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
|
||||
idbox = geompy.addToStudy(box, "box")
|
||||
@ -36,35 +35,34 @@ idface = geompy.addToStudyInFather(box, face, name)
|
||||
box = salome.IDToObject(idbox)
|
||||
face = salome.IDToObject(idface)
|
||||
|
||||
hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hyp1.SetNumberOfSegments(10)
|
||||
hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hyp2.SetMaxElementArea(10)
|
||||
hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hyp3.SetMaxElementArea(100)
|
||||
# ---- SMESH
|
||||
|
||||
algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
mesh = smesh.Mesh(box, "Meshbox")
|
||||
|
||||
mesh = smesh.CreateMesh(box)
|
||||
mesh.AddHypothesis(box,hyp1)
|
||||
mesh.AddHypothesis(box,hyp2)
|
||||
mesh.AddHypothesis(box,algo1)
|
||||
mesh.AddHypothesis(box,algo2)
|
||||
# Set 1D algorithm/hypotheses to mesh
|
||||
algo1 = mesh.Segment()
|
||||
algo1.NumberOfSegments(10)
|
||||
|
||||
submesh = mesh.GetSubMesh(face, "SubMeshFace")
|
||||
mesh.AddHypothesis(face,hyp1)
|
||||
mesh.AddHypothesis(face,hyp3)
|
||||
mesh.AddHypothesis(face,algo1)
|
||||
mesh.AddHypothesis(face,algo2)
|
||||
# Set 2D algorithm/hypotheses to mesh
|
||||
algo2 = mesh.Triangle(smesh.MEFISTO)
|
||||
algo2.MaxElementArea(10)
|
||||
|
||||
smesh.Compute(mesh,box)
|
||||
# Create submesh on face
|
||||
algo3 = mesh.Segment(face)
|
||||
algo3.NumberOfSegments(10)
|
||||
algo4 = mesh.Triangle(smesh.MEFISTO, face)
|
||||
algo4.MaxElementArea(100)
|
||||
submesh = algo4.GetSubMesh()
|
||||
smesh.SetName(submesh, "SubMeshFace")
|
||||
|
||||
faces = submesh.GetElementsByType(SMESH.FACE)
|
||||
|
||||
mesh.Compute()
|
||||
|
||||
faces = submesh.GetElementsByType(smesh.FACE)
|
||||
if len(faces) > 1:
|
||||
print len(faces), len(faces)/2
|
||||
group1 = mesh.CreateGroup(SMESH.FACE,"Group of faces")
|
||||
group2 = mesh.CreateGroup(SMESH.FACE,"Another group of faces")
|
||||
group1 = mesh.CreateEmptyGroup(smesh.FACE,"Group of faces")
|
||||
group2 = mesh.CreateEmptyGroup(smesh.FACE,"Another group of faces")
|
||||
group1.Add(faces[:int(len(faces)/2)])
|
||||
group2.Add(faces[int(len(faces)/2):])
|
||||
|
||||
|
@ -19,11 +19,11 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
# File : SMESH_test1.py
|
||||
# File : SMESH_test5.py
|
||||
# Module : SMESH
|
||||
|
||||
import salome
|
||||
import SMESH
|
||||
import smesh
|
||||
import SALOMEDS
|
||||
import CORBA
|
||||
import os
|
||||
@ -43,26 +43,21 @@ def ConvertMED2UNV(thePath,theFile) :
|
||||
|
||||
for iMesh in range(len(aMeshes)) :
|
||||
aMesh = aMeshes[iMesh]
|
||||
anSObj = salome.ObjectToSObject(aMesh)
|
||||
print anSObj.GetName(),
|
||||
print aMesh.GetName(),
|
||||
aFileName = anInitFileName
|
||||
aFileName = os.path.basename(aFileName)
|
||||
SetSObjName(anSObj,aFileName)
|
||||
print anSObj.GetName()
|
||||
aMesh.SetName(aFileName)
|
||||
print aMesh.GetName()
|
||||
|
||||
aOutPath = '/tmp/'
|
||||
aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv"
|
||||
aMesh.ExportUNV(aFileName)
|
||||
aMesh = smesh.CreateMeshesFromUNV(aFileName)
|
||||
anSObj = salome.ObjectToSObject(aMesh)
|
||||
print anSObj.GetName(),
|
||||
print aMesh.GetName(),
|
||||
os.remove(aFileName)
|
||||
aFileName = os.path.basename(aFileName)
|
||||
SetSObjName(anSObj,aFileName)
|
||||
print anSObj.GetName()
|
||||
|
||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||
smesh.SetCurrentStudy(salome.myStudy)
|
||||
aMesh.SetName(aFileName)
|
||||
print aMesh.GetName()
|
||||
|
||||
aPath = os.getenv('DATA_DIR') + '/MedFiles/'
|
||||
aListDir = os.listdir(aPath)
|
||||
|
@ -49,44 +49,44 @@ def CreateMesh (theFileName, area, len = None, nbseg = None):
|
||||
|
||||
|
||||
# ---- SMESH
|
||||
print "-------------------------- create mesh"
|
||||
mesh = smesh.Mesh(shape_mesh)
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
if (len is not None):
|
||||
print "-------------------------- LocalLength"
|
||||
hypLength1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
|
||||
hypLength1.SetLength(len)
|
||||
algoReg = mesh.Segment()
|
||||
hypLength1 = algoReg.LocalLength(len)
|
||||
print "Hypothesis type : ", hypLength1.GetName()
|
||||
print "Hypothesis ID : ", hypLength1.GetId()
|
||||
print "Hypothesis Value: ", hypLength1.GetLength()
|
||||
|
||||
if (nbseg is not None):
|
||||
print "-------------------------- NumberOfSegments"
|
||||
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
||||
hypNbSeg1.SetNumberOfSegments(nbseg)
|
||||
algoReg = mesh.Segment()
|
||||
hypNbSeg1 = algoReg.NumberOfSegments(nbseg)
|
||||
print "Hypothesis type : ", hypNbSeg1.GetName()
|
||||
print "Hypothesis ID : ", hypNbSeg1.GetId()
|
||||
print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments()
|
||||
|
||||
if (area == "LengthFromEdges"):
|
||||
print "-------------------------- LengthFromEdges"
|
||||
hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
|
||||
hypLengthFromEdges.SetMode(1)
|
||||
algoMef = mesh.Triangle()
|
||||
hypLengthFromEdges = algoMef.LengthFromEdges(1)
|
||||
print "Hypothesis type : ", hypLengthFromEdges.GetName()
|
||||
print "Hypothesis ID : ", hypLengthFromEdges.GetId()
|
||||
print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode()
|
||||
|
||||
else:
|
||||
print "-------------------------- MaxElementArea"
|
||||
hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
|
||||
hypArea1.SetMaxElementArea(area)
|
||||
algoMef = mesh.Triangle()
|
||||
hypArea1 = algoMef.MaxElementArea(area)
|
||||
print "Hypothesis type : ", hypArea1.GetName()
|
||||
print "Hypothesis ID : ", hypArea1.GetId()
|
||||
print "Hypothesis Value: ", hypArea1.GetMaxElementArea()
|
||||
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
||||
|
||||
listHyp = algoReg.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
@ -95,8 +95,6 @@ def CreateMesh (theFileName, area, len = None, nbseg = None):
|
||||
print "Algo ID : ", algoReg.GetId()
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
|
||||
|
||||
listHyp = algoMef.GetCompatibleHypothesis()
|
||||
for hyp in listHyp:
|
||||
print hyp
|
||||
@ -107,38 +105,8 @@ def CreateMesh (theFileName, area, len = None, nbseg = None):
|
||||
|
||||
# ---- add hypothesis to shape
|
||||
|
||||
print "-------------------------- add hypothesis to shape"
|
||||
mesh = smesh.CreateMesh(shape_mesh)
|
||||
|
||||
ret = mesh.AddHypothesis(shape_mesh, algoReg)
|
||||
print "Add Regular_1D algo .... ",
|
||||
print ret
|
||||
|
||||
if (nbseg is not None):
|
||||
ret = mesh.AddHypothesis(shape_mesh, hypNbSeg1)
|
||||
print "Add Number Of Segements algo .... ",
|
||||
print ret
|
||||
|
||||
if (len is not None):
|
||||
ret = mesh.AddHypothesis(shape_mesh,hypLength1)
|
||||
print "Add Local Length algo .... ",
|
||||
print ret
|
||||
|
||||
ret = mesh.AddHypothesis(shape_mesh, algoMef)
|
||||
print "Add MEFISTO_2D algo....",
|
||||
print ret
|
||||
|
||||
if (area == "LengthFromEdges"):
|
||||
ret = mesh.AddHypothesis( shape_mesh, hypLengthFromEdges) # length from edge
|
||||
print "Add Length From Edges algo .... ",
|
||||
print ret
|
||||
else:
|
||||
ret = mesh.AddHypothesis(shape_mesh, hypArea1)
|
||||
print "Add Max Triangle Area algo .... ",
|
||||
print ret
|
||||
|
||||
print "-------------------------- compute mesh"
|
||||
ret = smesh.Compute(mesh,shape_mesh)
|
||||
ret = mesh.Compute()
|
||||
print "Compute Mesh .... ",
|
||||
print ret
|
||||
log = mesh.GetLog(0); # no erase trace
|
||||
|
Loading…
Reference in New Issue
Block a user