Viewing Meshes

Viewing Mesh Infos

Attention! This script was written using old approach, based on direct usage of SMESH idl interface. To be updated for version 3.2.1 to use smesh package.
 

import salome

import geompy

import SMESH

import StdMeshers

 

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")

smesh.SetCurrentStudy(salome.myStudy)

 

box   = geompy.MakeBox(0., 0., 0., 20., 20., 20.)

idbox = geompy.addToStudy(box, "box")

 

subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])

edge   = subShapeList[0]

name   = geompy.SubShapeName(edge, box)

idedge = geompy.addToStudyInFather(box, edge, name)

 

box  = salome.IDToObject(idbox)

edge = salome.IDToObject(idedge)

 

hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")

hyp1.SetNumberOfSegments(3)

hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")

hyp2.SetMaxElementArea(10)

hyp3 = smesh.CreateHypothesis("Arithmetic1D", "libStdMeshersEngine.so")

hyp3.SetLength(1,1)

hyp3.SetLength(6,0)

hyp4 = smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so")

 

algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")

algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")

mesh = smesh.CreateMesh(box)

 

mesh.AddHypothesis(box,hyp1)

mesh.AddHypothesis(box,hyp2)

mesh.AddHypothesis(box,algo1)

mesh.AddHypothesis(box,algo2)

mesh.AddHypothesis(edge,hyp3)

mesh.AddHypothesis(edge,hyp4)

mesh.AddHypothesis(edge,algo1)

smesh.Compute(mesh,box)

salome.sg.updateObjBrowser(1)

 

# remove one hypothesis

mesh.RemoveHypothesis(edge,hyp4)

smesh.Compute(mesh,box)

salome.sg.updateObjBrowser(1)

 

# change the value of the hypothesis

hyp2.SetMaxElementArea(2)

mesh.AddHypothesis(box,hyp2)

smesh.Compute(mesh,box)

print "Information about mesh:"

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 polygons    : ", mesh.NbPolygons()

print "Number of volumes     : ", mesh.NbVolumes()

print "Number of tetrahedrons: ", mesh.NbTetras()

print "Number of hexahedrons : ", mesh.NbHexas()

print "Number of prisms      : ", mesh.NbPrisms()

print "Number of pyramids    : ", mesh.NbPyramids()

print "Number of polyhedrons : ", mesh.NbPolyhedrons()

salome.sg.updateObjBrowser(1)