+++ /dev/null
-# 3d mesh generation and mesh exploration
-
-import salome
-salome.salome_init_without_session()
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH
-from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-
-###
-# Geometry: an assembly of a box, a cylinder and a truncated cone
-# to be meshed with tetrahedra
-###
-
-# Define values
-name = "ex21_lamp"
-cote = 60
-section = 20
-size = 200
-radius_1 = 80
-radius_2 = 40
-height = 100
-
-# Build a box
-box = geompy.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
-
-# Build a cylinder
-pt1 = geompy.MakeVertex(0, 0, cote/3)
-di1 = geompy.MakeVectorDXDYDZ(0, 0, 1)
-cyl = geompy.MakeCylinder(pt1, di1, section, size)
-
-# Build a truncated cone
-pt2 = geompy.MakeVertex(0, 0, size)
-cone = geompy.MakeCone(pt2, di1, radius_1, radius_2, height)
-
-# Fuse
-box_cyl = geompy.MakeFuse(box, cyl)
-piece = geompy.MakeFuse(box_cyl, cone)
-
-# Add to the study
-geompy.addToStudy(piece, name)
-
-# Create a group of faces
-faces_group = geompy.CreateGroup(piece, geompy.ShapeType["FACE"])
-group_name = name + "_grp"
-geompy.addToStudy(faces_group, group_name)
-faces_group.SetName(group_name)
-
-# Add faces to the group
-faces = geompy.SubShapeAllIDs(piece, geompy.ShapeType["FACE"])
-geompy.UnionIDs(faces_group, faces)
-
-###
-# Create a mesh
-###
-
-# Define a mesh on a geometry
-tetra = smesh.Mesh(piece, name)
-
-# Define 1D algorithm and hypothesis
-algo1d = tetra.Segment()
-algo1d.LocalLength(10)
-
-# Define 2D algorithm and hypothesis
-algo2d = tetra.Triangle()
-algo2d.LengthFromEdges()
-
-# Define 3D algorithm and hypothesis
-algo3d = tetra.Tetrahedron()
-algo3d.MaxElementVolume(100)
-
-# Compute the mesh
-tetra.Compute()
-
-# Create a mesh group of all triangles generated on geom faces present in faces_group
-group = tetra.Group(faces_group)
-
-###
-# Explore the mesh
-###
-
-# Retrieve coordinates of nodes
-coordStr = ""
-for node in tetra.GetNodesId():
- x,y,z = tetra.GetNodeXYZ( node )
- coordStr += "%s (%s, %s, %s) " % ( node, x,y,z )
- pass
-
-# Retrieve nodal connectivity of triangles
-triaStr = ""
-for tria in tetra.GetElementsByType( SMESH.FACE ):
- nodes = tetra.GetElemNodes( tria )
- triaStr += "%s (%s, %s, %s) " % ( tria, nodes[0], nodes[1], nodes[2] )
-
-# Retrieve group contents
-groupStr = ""
-for group in tetra.GetGroups():
- ids = group.GetIDs()
- name = group.GetName()
- eType = group.GetType()
- groupStr += "'%s' %s: %s \n" % ( name, eType, ids )
-
IF(SALOME_BUILD_TESTS OR SALOME_BUILD_DOC)
INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${EXAMPLES_INSTALL_DIRECTORY})
+ INSTALL(FILES mechanic.py DESTINATION ${SALOME_INSTALL_BINS})
INSTALL(DIRECTORY data DESTINATION ${EXAMPLES_INSTALL_DIRECTORY})
ENDIF()
# Usage of Body Fitting algorithm
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a sphere
-sphere = geompy.MakeSphereR( 50 )
+sphere = geom_builder.MakeSphereR( 50 )
# cut the sphere by a box
-box = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
-partition = geompy.MakePartition([ sphere ], [ box ], theName="partition")
+box = geom_builder.MakeBoxDXDYDZ( 100, 100, 100 )
+partition = geom_builder.MakePartition([ sphere ], [ box ], theName="partition")
# create a mesh and assign a "Body Fitting" algo
-mesh = smesh.Mesh( partition )
+mesh = smesh_builder.Mesh( partition )
cartAlgo = mesh.BodyFitted()
# define a cartesian grid using Coordinates
# Example of customization of dirtections of the grid axes
# make a box with non-orthogonal edges
-xDir = geompy.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" )
-yDir = geompy.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" )
-zDir = geompy.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" )
-face = geompy.MakePrismVecH( xDir, yDir, 1.0 )
-box = geompy.MakePrismVecH( face, zDir, 1.0, theName="box" )
+xDir = geom_builder.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" )
+yDir = geom_builder.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" )
+zDir = geom_builder.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" )
+face = geom_builder.MakePrismVecH( xDir, yDir, 1.0 )
+box = geom_builder.MakePrismVecH( face, zDir, 1.0, theName="box" )
spc = "0.1" # spacing
# default axes
-mesh = smesh.Mesh( box, "custom axes")
+mesh = smesh_builder.Mesh( box, "custom axes")
algo = mesh.BodyFitted()
algo.SetGrid( spc, spc, spc, 10000 )
mesh.Compute()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
+tetra = smesh_builder.Mesh(box, "MeshBox")
algo1D = tetra.Segment()
algo1D.NumberOfSegments(7)
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
+box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
+geom_builder.addToStudy(box, "Box")
# select one edge of the box for definition of a local hypothesis
-p5 = geompy.MakeVertex(5., 0., 0.)
-EdgeX = geompy.GetEdgeNearPoint(box, p5)
-geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+p5 = geom_builder.MakeVertex(5., 0., 0.)
+EdgeX = geom_builder.GetEdgeNearPoint(box, p5)
+geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
-mesh = smesh.Mesh(box, "Box : hexahedral 3D mesh")
+mesh = smesh_builder.Mesh(box, "Box : hexahedral 3D mesh")
# create a Regular_1D algorithm for discretization of edges
algo1D = mesh.Segment()
# assign a hexahedral algorithm
mesh.Hexahedron()
-
# any sub-shape can be meshed individually --
# compute mesh on two surfaces using different methods
# get surfaces
-surfaces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+surfaces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
# method 1: no sub-mesh is created
mesh.Compute( surfaces[0] )
submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" )
submesh.Compute()
-
-
# compute the whole mesh
mesh.Compute()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
-[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
+[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geom_builder.SubShapeAllSorted(Box_1, geom_builder.ShapeType["FACE"])
# create Mesh object on Box shape
-Mesh_1 = smesh.Mesh(Box_1)
+Mesh_1 = smesh_builder.Mesh(Box_1)
# assign mesh algorithms and hypotheses
Regular_1D = Mesh_1.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
def PrintMeshInfo(theMesh):
aMesh = theMesh.GetMesh()
pass
# create a box
-box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
-geompy.addToStudy(box, "box")
+box = geom_builder.MakeBox(0., 0., 0., 20., 20., 20.)
+geom_builder.addToStudy(box, "box")
# select one edge of the box for definition of a local hypothesis
-subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
+subShapeList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["EDGE"])
edge = subShapeList[0]
-name = geompy.SubShapeName(edge, box)
-geompy.addToStudyInFather(box, edge, name)
+name = geom_builder.SubShapeName(edge, box)
+geom_builder.addToStudyInFather(box, edge, name)
# create a mesh
-tria = smesh.Mesh(box, "Mesh 2D")
+tria = smesh_builder.Mesh(box, "Mesh 2D")
algo1D = tria.Segment()
hyp1 = algo1D.NumberOfSegments(3)
algo2D = tria.Triangle()
# Export of a Mesh
+import os
+import tempfile
+import MEDLoader
+
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
+tetra = smesh_builder.Mesh(box, "MeshBox")
tetra.Segment().NumberOfSegments(7)
tetra.Triangle()
tetra.Tetrahedron()
tetra.Compute()
# export the mesh in a MED file
-import tempfile
medFile = tempfile.NamedTemporaryFile(suffix=".med").name
tetra.ExportMED( medFile, 0 )
# export a group in a MED file
-face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side
+face = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0] # a box side
group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the <face>
tetra.ExportMED( medFile, meshPart=group )
# autoDimension parameter
# ========================
-face = geompy.MakeFaceHW( 10, 10, 1, "rectangle" )
-mesh2D = smesh.Mesh( face, "mesh2D" )
+face = geom_builder.MakeFaceHW( 10, 10, 1, "rectangle" )
+mesh2D = smesh_builder.Mesh( face, "mesh2D" )
mesh2D.AutomaticHexahedralization(0)
-import MEDLoader, os
-
# exported mesh is in 2D space because it is a planar mesh lying
# on XOY plane, and autoDimension=True by default
mesh2D.ExportMED( medFile )
#
# This example uses Partition to divide the cylinder into blocks, which is
# a general approach. But for the case of cylinder there is a dedicated
-# command creating a blocked cylinder: geompy.MakeDividedCylinder()
+# command creating a blocked cylinder: geom_builder.MakeDividedCylinder()
+
+import math
import salome
salome.salome_init_without_session()
+
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import math
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Parameters
# ----------
# Build a cylinder
# ----------------
-base = geompy.MakeVertex(0, 0, 0)
-direction = geompy.MakeVectorDXDYDZ(0, 0, 1)
+base = geom_builder.MakeVertex(0, 0, 0)
+direction = geom_builder.MakeVectorDXDYDZ(0, 0, 1)
-cylinder = geompy.MakeCylinder(base, direction, radius, height)
+cylinder = geom_builder.MakeCylinder(base, direction, radius, height)
-geompy.addToStudy(cylinder, "cylinder")
+geom_builder.addToStudy(cylinder, "cylinder")
# Build blocks
# ------------
size = radius/2.0
-box_rot = geompy.MakeBox(-size, -size, 0, +size, +size, height)
-box_axis = geompy.MakeLine(base, direction)
-box = geompy.MakeRotation(box_rot, box_axis, math.pi/4)
+box_rot = geom_builder.MakeBox(-size, -size, 0, +size, +size, height)
+box_axis = geom_builder.MakeLine(base, direction)
+box = geom_builder.MakeRotation(box_rot, box_axis, math.pi/4)
-hole = geompy.MakeCut(cylinder, box)
+hole = geom_builder.MakeCut(cylinder, box)
plane_trim = 2000
-plane_a = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
-plane_b = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
+plane_a = geom_builder.MakePlane(base, geom_builder.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
+plane_b = geom_builder.MakePlane(base, geom_builder.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
-blocks_part = geompy.MakePartition([hole], [plane_a, plane_b], [], [], geompy.ShapeType["SOLID"])
-blocks_list = [box] + geompy.SubShapeAll(blocks_part, geompy.ShapeType["SOLID"])
-blocks_all = geompy.MakeCompound(blocks_list)
-blocks = geompy.MakeGlueFaces(blocks_all, 0.0001)
+blocks_part = geom_builder.MakePartition([hole], [plane_a, plane_b], [], [], geom_builder.ShapeType["SOLID"])
+blocks_list = [box] + geom_builder.SubShapeAll(blocks_part, geom_builder.ShapeType["SOLID"])
+blocks_all = geom_builder.MakeCompound(blocks_list)
+blocks = geom_builder.MakeGlueFaces(blocks_all, 0.0001)
-geompy.addToStudy(blocks, "cylinder:blocks")
+geom_builder.addToStudy(blocks, "cylinder:blocks")
# Build geometric groups
# ----------------------
-group_a = geompy.CreateGroup(blocks, geompy.ShapeType["FACE"])
-geompy.addToStudyInFather(blocks, group_a, "baseA")
-items = geompy.GetShapesOnPlaneWithLocationIDs(blocks, geompy.ShapeType["FACE"], direction, base, GEOM.ST_ON)
-geompy.UnionIDs(group_a, items)
+group_a = geom_builder.CreateGroup(blocks, geom_builder.ShapeType["FACE"])
+geom_builder.addToStudyInFather(blocks, group_a, "baseA")
+items = geom_builder.GetShapesOnPlaneWithLocationIDs(blocks, geom_builder.ShapeType["FACE"], direction, base, GEOM.ST_ON)
+geom_builder.UnionIDs(group_a, items)
-base_b = geompy.MakeVertex(0, 0, height)
-group_b = geompy.CreateGroup(blocks, geompy.ShapeType["FACE"])
-geompy.addToStudyInFather(blocks, group_b, "baseB")
-items = geompy.GetShapesOnPlaneWithLocationIDs(blocks, geompy.ShapeType["FACE"], direction, base_b, GEOM.ST_ON)
-geompy.UnionIDs(group_b, items)
+base_b = geom_builder.MakeVertex(0, 0, height)
+group_b = geom_builder.CreateGroup(blocks, geom_builder.ShapeType["FACE"])
+geom_builder.addToStudyInFather(blocks, group_b, "baseB")
+items = geom_builder.GetShapesOnPlaneWithLocationIDs(blocks, geom_builder.ShapeType["FACE"], direction, base_b, GEOM.ST_ON)
+geom_builder.UnionIDs(group_b, items)
-group_1 = geompy.CreateGroup(blocks, geompy.ShapeType["SOLID"])
-geompy.addToStudyInFather(blocks, group_1, "limit")
-group_1_all = geompy.SubShapeAllIDs(blocks, geompy.ShapeType["SOLID"])
-geompy.UnionIDs(group_1, group_1_all)
-group_1_box = geompy.GetBlockNearPoint(blocks, base)
-geompy.DifferenceList(group_1, [group_1_box])
+group_1 = geom_builder.CreateGroup(blocks, geom_builder.ShapeType["SOLID"])
+geom_builder.addToStudyInFather(blocks, group_1, "limit")
+group_1_all = geom_builder.SubShapeAllIDs(blocks, geom_builder.ShapeType["SOLID"])
+geom_builder.UnionIDs(group_1, group_1_all)
+group_1_box = geom_builder.GetBlockNearPoint(blocks, base)
+geom_builder.DifferenceList(group_1, [group_1_box])
# Mesh the blocks with hexahedral
# -------------------------------
-smesh.UpdateStudy()
+smesh_builder.UpdateStudy()
-hexa = smesh.Mesh(blocks)
+hexa = smesh_builder.Mesh(blocks)
hexa_1d = hexa.Segment()
hexa_1d.NumberOfSegments(1)
-vertex = geompy.MakeVertex(+radius, +radius, 0)
-edge = geompy.GetEdgeNearPoint(blocks, vertex)
+vertex = geom_builder.MakeVertex(+radius, +radius, 0)
+edge = geom_builder.GetEdgeNearPoint(blocks, vertex)
algo = hexa.Segment(edge)
algo.NumberOfSegments(5)
algo.Propagation()
-vertex = geompy.MakeVertex(-radius, +radius, 0)
-edge = geompy.GetEdgeNearPoint(blocks, vertex)
+vertex = geom_builder.MakeVertex(-radius, +radius, 0)
+edge = geom_builder.GetEdgeNearPoint(blocks, vertex)
algo = hexa.Segment(edge)
algo.NumberOfSegments(8)
algo.Propagation()
-vertex = geompy.MakeVertex((radius+size)/2, 0, 0)
-edge = geompy.GetEdgeNearPoint(blocks, vertex)
+vertex = geom_builder.MakeVertex((radius+size)/2, 0, 0)
+edge = geom_builder.GetEdgeNearPoint(blocks, vertex)
algo = hexa.Segment(edge)
algo.NumberOfSegments(10)
algo.Propagation()
-vertex = geompy.MakeVertex(+radius, 0, height/2)
-edge = geompy.GetEdgeNearPoint(blocks, vertex)
+vertex = geom_builder.MakeVertex(+radius, 0, height/2)
+edge = geom_builder.GetEdgeNearPoint(blocks, vertex)
algo = hexa.Segment(edge)
algo.NumberOfSegments(20)
algo.Propagation()
import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
## create a bottom box
-Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
+Box_inf = geom_builder.MakeBox(0., 0., 0., 200., 200., 50.)
# get a top face
-Psup1=geompy.MakeVertex(100., 100., 50.)
-Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
+Psup1=geom_builder.MakeVertex(100., 100., 50.)
+Fsup1=geom_builder.GetFaceNearPoint(Box_inf, Psup1)
# get a bottom face
-Pinf1=geompy.MakeVertex(100., 100., 0.)
-Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
+Pinf1=geom_builder.MakeVertex(100., 100., 0.)
+Finf1=geom_builder.GetFaceNearPoint(Box_inf, Pinf1)
## create a top box
-Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
+Box_sup = geom_builder.MakeBox(100., 100., 50., 200., 200., 100.)
# get a top face
-Psup2=geompy.MakeVertex(150., 150., 100.)
-Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
+Psup2=geom_builder.MakeVertex(150., 150., 100.)
+Fsup2=geom_builder.GetFaceNearPoint(Box_sup, Psup2)
# get a bottom face
-Pinf2=geompy.MakeVertex(150., 150., 50.)
-Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
+Pinf2=geom_builder.MakeVertex(150., 150., 50.)
+Finf2=geom_builder.GetFaceNearPoint(Box_sup, Pinf2)
## Publish in the study
-geompy.addToStudy(Box_inf, "Box_inf")
-geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup")
-geompy.addToStudyInFather(Box_inf, Finf1, "Finf")
+geom_builder.addToStudy(Box_inf, "Box_inf")
+geom_builder.addToStudyInFather(Box_inf, Fsup1, "Fsup")
+geom_builder.addToStudyInFather(Box_inf, Finf1, "Finf")
-geompy.addToStudy(Box_sup, "Box_sup")
-geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
-geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
+geom_builder.addToStudy(Box_sup, "Box_sup")
+geom_builder.addToStudyInFather(Box_sup, Fsup2, "Fsup")
+geom_builder.addToStudyInFather(Box_sup, Finf2, "Finf")
-smesh.UpdateStudy()
+smesh_builder.UpdateStudy()
## create a bottom mesh
-Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
+Mesh_inf = smesh_builder.Mesh(Box_inf, "Mesh_inf")
algo1D_1=Mesh_inf.Segment()
algo1D_1.NumberOfSegments(10)
algo2D_1=Mesh_inf.Quadrangle()
Ginf1=Mesh_inf.Group(Finf1, "Inf")
## create a top mesh
-Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup")
+Mesh_sup = smesh_builder.Mesh(Box_sup, "Mesh_sup")
algo1D_2=Mesh_sup.Segment()
algo1D_2.NumberOfSegments(5)
algo2D_2=Mesh_sup.Quadrangle()
## create compounds
# create a compound of two meshes with renaming namesake groups and
# merging elements with the given tolerance
-Compound1 = smesh.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05,
- name='Compound with RenamedGrps and MergeElems')
+Compound1 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05,
+ name='Compound with RenamedGrps and MergeElems')
# create a compound of two meshes with uniting namesake groups and
# creating groups of all elements
-Compound2 = smesh.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True,
- name='Compound with UniteGrps and GrpsOfAllElems')
+Compound2 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True,
+ name='Compound with UniteGrps and GrpsOfAllElems')
# copy Gsup1 into a separate mesh and translate it
groupMesh = Mesh_inf.TranslateObjectMakeMesh( Gsup1, [300,0,0] )
# add Ginf2 to groupMesh
-smesh.Concatenate([Ginf2], False, meshToAppendTo = groupMesh )
-
+smesh_builder.Concatenate([Ginf2], False, meshToAppendTo = groupMesh )
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# make geometry of a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
+face = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])[0]
# generate a prismatic 3D mesh
-mesh = smesh.Mesh(box, "box")
+mesh = smesh_builder.Mesh(box, "box")
localAlgo = mesh.Triangle(face)
mesh.Segment().NumberOfSegments( 3 )
mesh.Quadrangle()
# make a new mesh by copying different parts of the mesh
# 1. copy the whole mesh
-newMesh = smesh.CopyMesh( mesh, "whole mesh copy")
+newMesh = smesh_builder.CopyMesh( mesh, "whole mesh copy")
# 2. copy a group of 2D elements along with groups
-newMesh = smesh.CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True)
+newMesh = smesh_builder.CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True)
# 3. copy a group of nodes
-newMesh = smesh.CopyMesh( nGroup, "node group copy")
+newMesh = smesh_builder.CopyMesh( nGroup, "node group copy")
# 4. copy some faces
faceIds = fGroup.GetIDs()[-10:]
-newMesh = smesh.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy")
+newMesh = smesh_builder.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy")
# 5. copy some nodes
nodeIds = nGroup.GetIDs()[-10:]
-newMesh = smesh.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy")
+newMesh = smesh_builder.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy")
# 6. copy a sub-mesh
-newMesh = smesh.CopyMesh( subMesh, "sub-mesh copy" )
+newMesh = smesh_builder.CopyMesh( subMesh, "sub-mesh copy" )
# make a new mesh with same hypotheses on a modified geometry
-smallBox = geompy.MakeScaleAlongAxes( box, None, 1, 0.5, 0.5 )
-cutBox = geompy.MakeCut( box, smallBox, theName="box - smallBox" )
+smallBox = geom_builder.MakeScaleAlongAxes( box, None, 1, 0.5, 0.5 )
+cutBox = geom_builder.MakeCut( box, smallBox, theName="box - smallBox" )
-ok, newMesh, groups, submehses, hyps, invIDs = smesh.CopyMeshWithGeom( mesh, cutBox, "cutBox" )
+ok, newMesh, groups, submehses, hyps, invIDs = smesh_builder.CopyMeshWithGeom( mesh, cutBox, "cutBox" )
newMesh.Compute()
-import salome, math
+# Usage of Adaptive 1D hypothesis
+
+import math
+
+import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-box = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
-tool = geompy.MakeTranslation( box, 50, 0, 10 )
-axis = geompy.MakeVector( geompy.MakeVertex( 100, 0, 100 ),geompy.MakeVertex( 100, 10, 100 ),)
-tool = geompy.Rotate( tool, axis, math.pi * 25 / 180. )
-shape = geompy.MakeCut( box, tool )
-cyl = geompy.MakeCylinder( geompy.MakeVertex( -10,5, 95 ), geompy.MakeVectorDXDYDZ(1,0,0), 2, 90)
-shape = geompy.MakeCut( shape, cyl )
-tool = geompy.MakeBoxTwoPnt( geompy.MakeVertex( -10, 2, 15 ), geompy.MakeVertex( 90, 5, 16 ))
-shape = geompy.MakeCut( shape, tool, theName="shape" )
+box = geom_builder.MakeBoxDXDYDZ( 100, 100, 100 )
+tool = geom_builder.MakeTranslation( box, 50, 0, 10 )
+axis = geom_builder.MakeVector( geom_builder.MakeVertex( 100, 0, 100 ),geom_builder.MakeVertex( 100, 10, 100 ),)
+tool = geom_builder.Rotate( tool, axis, math.pi * 25 / 180. )
+shape = geom_builder.MakeCut( box, tool )
+cyl = geom_builder.MakeCylinder( geom_builder.MakeVertex( -10,5, 95 ), geom_builder.MakeVectorDXDYDZ(1,0,0), 2, 90)
+shape = geom_builder.MakeCut( shape, cyl )
+tool = geom_builder.MakeBoxTwoPnt( geom_builder.MakeVertex( -10, 2, 15 ), geom_builder.MakeVertex( 90, 5, 16 ))
+shape = geom_builder.MakeCut( shape, tool, theName="shape" )
# Parameters of Adaptive hypothesis. minSize and maxSize are such that they do not limit
# size of segments because size of geometrical features lies within [2.-100.] range, hence
maxSize = 200
deflection = 0.05
-mesh = smesh.Mesh( shape )
+mesh = smesh_builder.Mesh( shape )
mesh.Segment().Adaptive( minSize, maxSize, deflection )
mesh.Triangle().MaxElementArea( 300 )
mesh.Compute()
-
salome.salome_init_without_session()
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
+box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
+geom_builder.addToStudy(box, "Box")
# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh")
# create a Regular 1D algorithm for edges
algo1D = hexa.Segment()
# optionally reverse node distribution on certain edges
-allEdges = geompy.SubShapeAllSorted( box, geompy.ShapeType["EDGE"])
+allEdges = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["EDGE"])
reversedEdges = [ allEdges[0], allEdges[4] ]
# define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length
# propagate distribution of nodes computed using "Geometric Progression" to parallel edges
gpAlgo.PropagationOfDistribution()
-
# create a quadrangle 2D algorithm for faces
hexa.Quadrangle()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a face from arc and straight segment
-px = geompy.MakeVertex(100., 0. , 0. )
-py = geompy.MakeVertex(0. , 100., 0. )
-pz = geompy.MakeVertex(0. , 0. , 100.)
+px = geom_builder.MakeVertex(100., 0. , 0. )
+py = geom_builder.MakeVertex(0. , 100., 0. )
+pz = geom_builder.MakeVertex(0. , 0. , 100.)
-exy = geompy.MakeEdge(px, py)
-arc = geompy.MakeArc(py, pz, px)
+exy = geom_builder.MakeEdge(px, py)
+arc = geom_builder.MakeArc(py, pz, px)
-wire = geompy.MakeWire([exy, arc])
+wire = geom_builder.MakeWire([exy, arc])
isPlanarFace = 1
-face1 = geompy.MakeFace(wire, isPlanarFace)
-geompy.addToStudy(face1,"Face1")
+face1 = geom_builder.MakeFace(wire, isPlanarFace)
+geom_builder.addToStudy(face1,"Face1")
# get edges from the face
-e_straight,e_arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])
-geompy.addToStudyInFather(face1, e_arc, "Arc Edge")
+e_straight,e_arc = geom_builder.SubShapeAll(face1, geom_builder.ShapeType["EDGE"])
+geom_builder.addToStudyInFather(face1, e_arc, "Arc Edge")
# create hexahedral mesh
-hexa = smesh.Mesh(face1, "Face : triangle mesh")
+hexa = smesh_builder.Mesh(face1, "Face : triangle mesh")
# define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments
algo1D = hexa.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
+box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
+geom_builder.addToStudy(box, "Box")
# get one edge of the box to put local hypothesis on
-p5 = geompy.MakeVertex(5., 0., 0.)
-EdgeX = geompy.GetEdgeNearPoint(box, p5)
-geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+p5 = geom_builder.MakeVertex(5., 0., 0.)
+EdgeX = geom_builder.GetEdgeNearPoint(box, p5)
+geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh")
# set algorithms
algo1D = hexa.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
+box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
+geom_builder.addToStudy(box, "Box")
# get one edge of the box to put local hypothesis on
-p5 = geompy.MakeVertex(5., 0., 0.)
-EdgeX = geompy.GetEdgeNearPoint(box, p5)
-geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+p5 = geom_builder.MakeVertex(5., 0., 0.)
+EdgeX = geom_builder.GetEdgeNearPoint(box, p5)
+geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh")
# set algorithms
algo1D = hexa.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a face
-px = geompy.MakeVertex(100., 0. , 0. )
-py = geompy.MakeVertex(0. , 100., 0. )
-pz = geompy.MakeVertex(0. , 0. , 100.)
+px = geom_builder.MakeVertex(100., 0. , 0. )
+py = geom_builder.MakeVertex(0. , 100., 0. )
+pz = geom_builder.MakeVertex(0. , 0. , 100.)
-vxy = geompy.MakeVector(px, py)
-arc = geompy.MakeArc(py, pz, px)
-wire = geompy.MakeWire([vxy, arc])
+vxy = geom_builder.MakeVector(px, py)
+arc = geom_builder.MakeArc(py, pz, px)
+wire = geom_builder.MakeWire([vxy, arc])
isPlanarFace = 1
-face = geompy.MakeFace(wire, isPlanarFace)
+face = geom_builder.MakeFace(wire, isPlanarFace)
# add the face in the study
-id_face = geompy.addToStudy(face, "Face to be meshed")
+id_face = geom_builder.addToStudy(face, "Face to be meshed")
# create a mesh
-tria_mesh = smesh.Mesh(face, "Face : triangulation")
+tria_mesh = smesh_builder.Mesh(face, "Face : triangulation")
# define 1D meshing:
algo = tria_mesh.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+from salome.geom import geomBuilder
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a cylinder
-cyl = geompy.MakeCylinderRH(30., 50.)
-geompy.addToStudy(cyl, "cyl")
+cyl = geom_builder.MakeCylinderRH(30., 50.)
+geom_builder.addToStudy(cyl, "cyl")
# create a mesh on the cylinder
-tetra = smesh.Mesh(cyl, "Cylinder : tetrahedrical mesh")
+tetra = smesh_builder.Mesh(cyl, "Cylinder : tetrahedrical mesh")
# assign algorithms
algo1D = tetra.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create sketchers
-sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
-sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
+sketcher1 = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
+sketcher2 = geom_builder.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
# create a face from two wires
isPlanarFace = 1
-face1 = geompy.MakeFaces([sketcher1, sketcher2], isPlanarFace)
-geompy.addToStudy(face1, "Face1")
+face1 = geom_builder.MakeFaces([sketcher1, sketcher2], isPlanarFace)
+geom_builder.addToStudy(face1, "Face1")
# create a mesh
-tria = smesh.Mesh(face1, "Face : triangle 2D mesh")
+tria = smesh_builder.Mesh(face1, "Face : triangle 2D mesh")
# Define 1D meshing
algo1D = tria.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-base = geompy.MakeSketcher("Sketcher:F 0 0:TT 10 0:TT 20 10:TT 0 10:WF", theName="F")
-box = geompy.MakePrismDXDYDZ( base, 0,0,10 )
-geompy.addToStudy(box, "Box")
+base = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 10 0:TT 20 10:TT 0 10:WF", theName="F")
+box = geom_builder.MakePrismDXDYDZ( base, 0,0,10 )
+geom_builder.addToStudy(box, "Box")
# get one edge of the box to put local hypothesis on
-p5 = geompy.MakeVertex(5., 0., 0.)
-EdgeX = geompy.GetEdgeNearPoint(box, p5)
-geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+p5 = geom_builder.MakeVertex(5., 0., 0.)
+EdgeX = geom_builder.GetEdgeNearPoint(box, p5)
+geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Propagation of hypothesis")
+hexa = smesh_builder.Mesh(box, "Propagation of hypothesis")
# set global algorithms and hypotheses
algo1D = hexa.Segment()
# compute the mesh which contains prisms
hexa.Compute()
-
# create another mesh on the box
-mesh = smesh.Mesh(box, "Propagation of distribution of nodes")
+mesh = smesh_builder.Mesh(box, "Propagation of distribution of nodes")
# set global algorithms and hypotheses
algo1D = mesh.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
+box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.)
+geom_builder.addToStudy(box, "Box")
# Create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh")
# create a Regular 1D algorithm for edges
algo1D = hexa.Segment()
hexa.Compute()
# 2. Create a tetrahedral mesh on the box
-tetra = smesh.Mesh(box, "Box : tetrahedrical mesh")
+tetra = smesh_builder.Mesh(box, "Box : tetrahedrical mesh")
# create a Regular 1D algorithm for edges
algo1D = tetra.Segment()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Prepare geometry
# Create a parallelepiped
-box = geompy.MakeBoxDXDYDZ(200, 100, 70)
-geompy.addToStudy( box, "box" )
+box = geom_builder.MakeBoxDXDYDZ(200, 100, 70)
+geom_builder.addToStudy( box, "box" )
# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
-faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+faces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
# 2 adjacent faces of the box
f1 = faces[2]
f2 = faces[0]
# face opposite to f2
-f2opp = geompy.GetOppositeFace( box, f2 )
+f2opp = geom_builder.GetOppositeFace( box, f2 )
# Get vertices used to specify how to associate sides of faces at projection
-[v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2]
-[v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2]
-geompy.addToStudyInFather( box, v1F1, "v1F1" )
-geompy.addToStudyInFather( box, v2F1, "v2F1" )
-geompy.addToStudyInFather( box, v1F2, "v1F2" )
-geompy.addToStudyInFather( box, v2F2, "v2F2" )
+[v1F1, v2F1] = geom_builder.SubShapeAll(f1, geom_builder.ShapeType["VERTEX"])[:2]
+[v1F2, v2F2] = geom_builder.SubShapeAll(f2, geom_builder.ShapeType["VERTEX"])[:2]
+geom_builder.addToStudyInFather( box, v1F1, "v1F1" )
+geom_builder.addToStudyInFather( box, v2F1, "v2F1" )
+geom_builder.addToStudyInFather( box, v1F2, "v1F2" )
+geom_builder.addToStudyInFather( box, v2F2, "v2F2" )
# Make group of 3 edges of f1 and f2
-edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"])
-geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3])
-edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"])
-geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3])
-geompy.addToStudyInFather( box, edgesF1, "edgesF1" )
-geompy.addToStudyInFather( box, edgesF2, "edgesF2" )
-
+edgesF1 = geom_builder.CreateGroup(f1, geom_builder.ShapeType["EDGE"])
+geom_builder.UnionList( edgesF1, geom_builder.SubShapeAll(f1, geom_builder.ShapeType["EDGE"])[:3])
+edgesF2 = geom_builder.CreateGroup(f2, geom_builder.ShapeType["EDGE"])
+geom_builder.UnionList( edgesF2, geom_builder.SubShapeAll(f2, geom_builder.ShapeType["EDGE"])[:3])
+geom_builder.addToStudyInFather( box, edgesF1, "edgesF1" )
+geom_builder.addToStudyInFather( box, edgesF2, "edgesF2" )
# Make the source mesh with prisms
-src_mesh = smesh.Mesh(box, "Source mesh")
+src_mesh = smesh_builder.Mesh(box, "Source mesh")
src_mesh.Segment().NumberOfSegments(9,10)
src_mesh.Quadrangle()
src_mesh.Hexahedron()
src_mesh.Triangle(f1) # triangular sub-mesh
src_mesh.Compute()
-
# Mesh the box using projection algorithms
# Define the same global 1D and 2D hypotheses
-tgt_mesh = smesh.Mesh(box, "Target mesh")
+tgt_mesh = smesh_builder.Mesh(box, "Target mesh")
tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True)
tgt_mesh.Quadrangle()
tgt_mesh.Compute()
# Move the source mesh to visually compare the two meshes
-src_mesh.TranslateObject( src_mesh, smesh.MakeDirStruct( 210, 0, 0 ), Copy=False)
+src_mesh.TranslateObject( src_mesh, smesh_builder.MakeDirStruct( 210, 0, 0 ), Copy=False)
# Projection 1D2D
-
# Project triangles from one meshed face to another mesh on the same box
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Prepare geometry
# Create a box
-box = geompy.MakeBoxDXDYDZ(100, 100, 100)
+box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
-faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+faces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
# 2 adjacent faces of the box
Face_1 = faces[2]
Face_2 = faces[0]
-geompy.addToStudy( box, 'box' )
-geompy.addToStudyInFather( box, Face_1, 'Face_1' )
-geompy.addToStudyInFather( box, Face_2, 'Face_2' )
-
+geom_builder.addToStudy( box, 'box' )
+geom_builder.addToStudyInFather( box, Face_1, 'Face_1' )
+geom_builder.addToStudyInFather( box, Face_2, 'Face_2' )
# Make the source mesh triangulated by MEFISTO
-src_mesh = smesh.Mesh(Face_1, "Source mesh")
+src_mesh = smesh_builder.Mesh(Face_1, "Source mesh")
src_mesh.Segment().NumberOfSegments(15)
src_mesh.Triangle()
src_mesh.Compute()
# Mesh the target mesh using the algorithm Projection1D2D
-tgt_mesh = smesh.Mesh(Face_2, "Target mesh")
+tgt_mesh = smesh_builder.Mesh(Face_2, "Target mesh")
tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh)
tgt_mesh.Compute()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-from salome.StdMeshers import StdMeshersBuilder
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Create face and explode it on edges
-face = geompy.MakeFaceHW(100, 100, 1)
-edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"])
-geompy.addToStudy( face, "Face" )
+face = geom_builder.MakeFaceHW(100, 100, 1)
+edges = geom_builder.SubShapeAllSorted(face, geom_builder.ShapeType["EDGE"])
+geom_builder.addToStudy( face, "Face" )
# get the first edge from exploded result
-edge1 = geompy.GetSubShapeID(face, edges[0])
+edge1 = geom_builder.GetSubShapeID(face, edges[0])
# Define Mesh on previously created face
-Mesh_1 = smesh.Mesh(face)
+Mesh_1 = smesh_builder.Mesh(face)
# Create Fixed Point 1D hypothesis and define parameters.
# Note: values greater than 1.0 and less than 0.0 are not taken into account;
# The number of segments should correspond to the number of points (NbSeg = NbPnt-1);
# extra values of segments splitting parameter are not taken into account,
# while missing values are considered to be equal to 1.
-Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D')
+Fixed_points_1D_1 = smesh_builder.CreateHypothesis('FixedPoints1D')
Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] )
Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] )
Fixed_points_1D_1.SetReversedEdges( [edge1] )
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-# Create face from the wire and add to study
-Face = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1])
-geompy.addToStudy(Face,"Face")
-circle, radius1, radius2 = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"])
-geompy.addToStudyInFather(Face, radius1,"radius1")
-geompy.addToStudyInFather(Face, radius2,"radius2")
-geompy.addToStudyInFather(Face, circle,"circle")
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+# Create face from the wire and add to study
+Face = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1])
+geom_builder.addToStudy(Face,"Face")
+circle, radius1, radius2 = geom_builder.SubShapeAllSorted(Face, geom_builder.ShapeType["EDGE"])
+geom_builder.addToStudyInFather(Face, radius1,"radius1")
+geom_builder.addToStudyInFather(Face, radius2,"radius2")
+geom_builder.addToStudyInFather(Face, circle,"circle")
# Define geometry for mesh, and Radial Quadrange algorithm
-mesh = smesh.Mesh(Face)
+mesh = smesh_builder.Mesh(Face)
radial_Quad_algo = mesh.Quadrangle(algo=smeshBuilder.RADIAL_QUAD)
# The Radial Quadrange algorithm can work without any hypothesis
salome.salome_init_without_session()
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-# Get 1/4 part from the disk face.
-Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100)
-Disk_1 = geompy.MakeDiskR(100, 1)
-Common_1 = geompy.MakeCommon(Disk_1, Box_1)
-triaVertex = geompy.GetVertexNearPoint( Common_1, geompy.MakeVertex(0,0,0) )
-geompy.addToStudy( Common_1, "Common_1" )
-geompy.addToStudyInFather( Common_1, triaVertex, "triaVertex" )
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+# Get 1/4 part from the disk face.
+Box_1 = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
+Disk_1 = geom_builder.MakeDiskR(100, 1)
+Common_1 = geom_builder.MakeCommon(Disk_1, Box_1)
+triaVertex = geom_builder.GetVertexNearPoint( Common_1, geom_builder.MakeVertex(0,0,0) )
+geom_builder.addToStudy( Common_1, "Common_1" )
+geom_builder.addToStudyInFather( Common_1, triaVertex, "triaVertex" )
# Set the Geometry for meshing
-Mesh_1 = smesh.Mesh(Common_1)
+Mesh_1 = smesh_builder.Mesh(Common_1)
# Define 1D hypothesis
Regular_1D = Mesh_1.Segment()
import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Make quadrangle face and explode it on edges.
-Vertex_1 = geompy.MakeVertex(0, 0, 0)
-Vertex_2 = geompy.MakeVertex(40, 0, 0)
-Vertex_3 = geompy.MakeVertex(40, 30, 0)
-Vertex_4 = geompy.MakeVertex(0, 30, 0)
-Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2)
-[Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"])
-geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" )
-geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" )
+Vertex_1 = geom_builder.MakeVertex(0, 0, 0)
+Vertex_2 = geom_builder.MakeVertex(40, 0, 0)
+Vertex_3 = geom_builder.MakeVertex(40, 30, 0)
+Vertex_4 = geom_builder.MakeVertex(0, 30, 0)
+Quadrangle_Face_1 = geom_builder.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2)
+[Edge_1,Edge_2,Edge_3,Edge_4] = geom_builder.SubShapeAllSorted(Quadrangle_Face_1, geom_builder.ShapeType["EDGE"])
+geom_builder.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" )
+geom_builder.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" )
# Set the Geometry for meshing
-Mesh_1 = smesh.Mesh(Quadrangle_Face_1)
+Mesh_1 = smesh_builder.Mesh(Quadrangle_Face_1)
# Create Quadrangle parameters and
# define the Type as Quadrangle Preference
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Make a patritioned box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
-N = geompy.MakeVectorDXDYDZ( 1,0,0 )
-O = geompy.MakeVertex( 50,0,0 )
-plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
+N = geom_builder.MakeVectorDXDYDZ( 1,0,0 )
+O = geom_builder.MakeVertex( 50,0,0 )
+plane = geom_builder.MakePlane( O, N, 200 ) # plane YOZ
-shape2boxes = geompy.MakeHalfPartition( box, plane )
-boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
+shape2boxes = geom_builder.MakeHalfPartition( box, plane )
+boxes = geom_builder.SubShapeAllSorted(shape2boxes, geom_builder.ShapeType["SOLID"])
-geompy.addToStudy( boxes[0], "boxes[0]")
-geompy.addToStudy( boxes[1], "boxes[1]")
-midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
-geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
-midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
-geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
+geom_builder.addToStudy( boxes[0], "boxes[0]")
+geom_builder.addToStudy( boxes[1], "boxes[1]")
+midFace0 = geom_builder.SubShapeAllSorted(boxes[0], geom_builder.ShapeType["FACE"])[5]
+geom_builder.addToStudyInFather( boxes[0], midFace0, "middle Face")
+midFace1 = geom_builder.SubShapeAllSorted(boxes[1], geom_builder.ShapeType["FACE"])[0]
+geom_builder.addToStudyInFather( boxes[1], midFace1, "middle Face")
# Mesh one of boxes with quadrangles. It is a source mesh
-srcMesh = smesh.Mesh(boxes[0], "source mesh") # box coloser to CS origin
+srcMesh = smesh_builder.Mesh(boxes[0], "source mesh") # box coloser to CS origin
nSeg1 = srcMesh.Segment().NumberOfSegments(4)
srcMesh.Quadrangle()
srcMesh.Compute()
# Import faces from midFace0 to the target mesh
-tgtMesh = smesh.Mesh(boxes[1], "target mesh")
+tgtMesh = smesh_builder.Mesh(boxes[1], "target mesh")
importAlgo = tgtMesh.UseExisting2DElements(midFace1)
import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
tgtMesh.Segment().NumberOfSegments(3)
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-X = geompy.MakeVectorDXDYDZ( 1,0,0 )
-O = geompy.MakeVertex( 100,50,50 )
-plane = geompy.MakePlane( O, X, 200 ) # plane YZ
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+X = geom_builder.MakeVectorDXDYDZ( 1,0,0 )
+O = geom_builder.MakeVertex( 100,50,50 )
+plane = geom_builder.MakePlane( O, X, 200 ) # plane YZ
-box = geompy.MakeBoxDXDYDZ(200,100,100)
+box = geom_builder.MakeBoxDXDYDZ(200,100,100)
-shape = geompy.MakeHalfPartition( box, plane )
+shape = geom_builder.MakeHalfPartition( box, plane )
-faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"])
+faces = geom_builder.SubShapeAllSorted(shape, geom_builder.ShapeType["FACE"])
face1 = faces[1]
ignoreFaces = [ faces[0], faces[-1]]
-geompy.addToStudy( shape, "shape" )
-geompy.addToStudyInFather( shape, face1, "face1")
+geom_builder.addToStudy( shape, "shape" )
+geom_builder.addToStudyInFather( shape, face1, "face1")
# 3D Viscous layers
-mesh = smesh.Mesh(shape, "CFD")
+mesh = smesh_builder.Mesh(shape, "CFD")
mesh.Segment().NumberOfSegments( 4 )
# 2D Viscous layers
# 3 edges of the 4 edges of face1
-edgeIds = geompy.SubShapeAllIDs( face1, geompy.ShapeType["EDGE"])[:-1]
+edgeIds = geom_builder.SubShapeAllIDs( face1, geom_builder.ShapeType["EDGE"])[:-1]
-mesh = smesh.Mesh(face1,"VicsousLayers2D")
+mesh = smesh_builder.Mesh(face1,"VicsousLayers2D")
mesh.Segment().NumberOfSegments( 5 )
# viscous layers will be created on 1 edge, as we set 3 edges to ignore
import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
+box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 )
# make a mesh
-mesh = smesh.Mesh( box )
+mesh = smesh_builder.Mesh( box )
# define quadrangle meshing
algo1d = mesh.Segment()
# Belong to Mesh Group criterion
# create mesh
-from SMESH_mechanic import *
-print()
+from mechanic import *
# create a group of all faces (quadrangles) generated on sub_face3
quads_on_face3 = mesh.MakeGroup("quads_on_face3", SMESH.FACE, SMESH.FT_BelongToGeom,'=',sub_face3)
# create a group of all the rest quadrangles, generated on other faces by combining 2 criteria:
# - negated FT_BelongToMeshGroup to select elements not included in quads_on_face3
# - FT_ElemGeomType to select quadrangles
-not_on_face3 = smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=',quads_on_face3, SMESH.FT_LogicalNOT )
-quadrangles = smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_QUADRANGLE )
+not_on_face3 = smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=',quads_on_face3, SMESH.FT_LogicalNOT )
+quadrangles = smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_QUADRANGLE )
rest_quads = mesh.MakeGroupByCriteria("rest_quads", [ not_on_face3, quadrangles ])
print("'%s' group includes all the rest %s quadrangles" % ( rest_quads.GetName(), rest_quads.Size() ))
# This script demonstrates various usages of filters
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
# get faces with aspect ratio > 2.5
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with aspect ratio > 2.5:", len(ids))
# get faces with aspect ratio > 1.5
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh)
ids = filter.GetIDs()
print("Number of faces with aspect ratio > 1.5:", len(ids))
# copy the faces with aspect ratio > 1.5 to another mesh;
# this demonstrates that a filter can be used where usually a group or sub-mesh is acceptable
filter.SetMesh( mesh.GetMesh() ) # - actually non necessary as mesh is set at filter creation
-mesh2 = smesh.CopyMesh( filter, "AR > 1.5" )
+mesh2 = smesh_builder.CopyMesh( filter, "AR > 1.5" )
print("Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces())
# create a group (Group on Filter) of faces with Aspect Ratio < 1.5
# combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5;
# note that contents of a GroupOnFilter is dynamically updated as the mesh changes
-crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
- smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ]
+crit = [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
+ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ]
triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit )
print("Number of triangles with aspect ratio < 1.5:", triaGroup.Size())
# Aspect ratio 3D
# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# get volumes with aspect ratio < 2.0
-filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_LessThan, 2.0)
+filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_LessThan, 2.0)
ids = mesh.GetIdsFromFilter(filter)
print("Number of volumes with aspect ratio < 2.0:", len(ids))
# Warping angle
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get faces with warping angle = 2.0e-13 with tolerance 5.0e-14
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids))
# Minimum angle
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get faces with minimum angle > 75
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle,">", 75)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle,">", 75)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with minimum angle > 75:", len(ids))
# Taper
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get faces with taper < 1.e-15
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_LessThan, 1.e-15)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_LessThan, 1.e-15)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with taper < 1.e-15:", len(ids))
# Skew
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get faces with skew > 50
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 50)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 50)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with skew > 50:", len(ids))
# Area
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get faces with area > 60 and < 90
-criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60)
-criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90)
-filter = smesh.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND)
+criterion1 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60)
+criterion2 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90)
+filter = smesh_builder.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with area in range (60,90):", len(ids))
# Volume
# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# get volumes faces with volume > 100
-filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_MoreThan, 100)
+filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_MoreThan, 100)
ids = mesh.GetIdsFromFilter(filter)
print("Number of volumes with volume > 100:", len(ids))
# Free borders
-# initialize SALOME and modules
-import salome, SMESH
+import salome
salome.salome_init_without_session()
+
+import SMESH
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create mesh
-face = geompy.MakeFaceHW(100, 100, 1, theName="quadrangle")
-mesh = smesh.Mesh(face)
+face = geom_builder.MakeFaceHW(100, 100, 1, theName="quadrangle")
+mesh = smesh_builder.Mesh(face)
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(25)
mesh.Compute()
# get all free borders
-filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
+filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
ids = mesh.GetIdsFromFilter(filter)
print("Number of edges on free borders:", len(ids))
# Free edges
-# initialize SALOME and modules
-import salome, SMESH
+import salome
salome.salome_init_without_session()
+
+import SMESH
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create mesh
-face = geompy.MakeFaceHW(100, 100, 1)
-geompy.addToStudy( face, "quadrangle" )
-mesh = smesh.Mesh(face)
+face = geom_builder.MakeFaceHW(100, 100, 1)
+geom_builder.addToStudy( face, "quadrangle" )
+mesh = smesh_builder.Mesh(face)
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(25)
mesh.Compute()
# get all faces with free edges
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with free edges:", len(ids))
# Free nodes
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# add node
mesh.AddNode(0,0,0)
+
# get all free nodes
-filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
+filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
ids = mesh.GetIdsFromFilter(filter)
print("Number of free nodes:", len(ids))
# Free faces
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all free faces
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces)
ids = mesh.GetIdsFromFilter(filter)
print("Number of free faces:", len(ids))
# Bare border faces
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# remove some faces to have faces with bare borders
mesh.RemoveElements( mesh.GetElementsByType(SMESH.FACE)[0:5] )
+
# get all faces with bare borders
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace)
ids = mesh.GetIdsFromFilter(filter)
print("Faces with bare borders:", ids)
# Coplanar faces
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
faceID = mesh.GetElementsByType(SMESH.FACE)[0]
# get all faces co-planar to the first face with tolerance 5 degrees
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_CoplanarFaces,faceID,Tolerance=5.0)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_CoplanarFaces,faceID,Tolerance=5.0)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces coplanar with the first one:", len(ids))
# Over-constrained faces
+
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all over-constrained faces
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace)
ids = mesh.GetIdsFromFilter(filter)
print("Over-constrained faces:", ids)
# Double edges, Double faces, Double volumes
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# make a mesh on a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-mesh = smesh.Mesh( box, "Box" )
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
+mesh = smesh_builder.Mesh( box, "Box" )
mesh.Segment().NumberOfSegments(10)
mesh.Quadrangle()
mesh.Hexahedron()
mesh.Compute()
# copy all elements with translation and Merge nodes
-mesh.TranslateObject( mesh, smesh.MakeDirStruct( 10,0,0), Copy=True )
+mesh.TranslateObject( mesh, smesh_builder.MakeDirStruct( 10,0,0), Copy=True )
mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) )
# create filters to find equal elements
-equalEdgesFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges)
-equalFacesFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces)
-equalVolumesFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_EqualVolumes)
+equalEdgesFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges)
+equalFacesFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces)
+equalVolumesFilter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_EqualVolumes)
# get equal elements
print("Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter )))
print("Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter )))
import salome
salome.salome_init_without_session()
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
+
import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# make a mesh on a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-mesh = smesh.Mesh( box, "Box" )
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
+mesh = smesh_builder.Mesh( box, "Box" )
mesh.Segment().NumberOfSegments(10)
mesh.Quadrangle()
mesh.Hexahedron()
# copy all elements with translation
mesh.TranslateObject( mesh, [10,0,0], Copy=True )
# create a filter to find nodes equal within tolerance of 1e-5
-filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_EqualNodes, Tolerance=1e-5)
+filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_EqualNodes, Tolerance=1e-5)
# get equal nodes
print("Number of equal nodes:", len( mesh.GetIdsFromFilter( filter )))
import salome
salome.salome_init_without_session()
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
+
import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# make a mesh on a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-mesh = smesh.Mesh( box, "Box" )
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
+mesh = smesh_builder.Mesh( box, "Box" )
mesh.Segment().NumberOfSegments(10)
mesh.Quadrangle()
mesh.Hexahedron()
mesh.MergeNodes( mesh.FindCoincidentNodes( 1e-5 ))
# get mesh edges with number of connected elements (faces and volumes) == 3
-filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 3)
+filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 3)
ids = mesh.GetIdsFromFilter(filter)
print("Number of border edges with 3 faces connected:", len(ids))
# Borders at multi-connection 2D
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get faces which consist of edges belonging to 2 mesh elements
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, 2)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, 2)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces consisting of edges belonging to 2 faces:", len(ids))
# Length
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get edges with length > 14
-filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, 14)
+filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, 14)
ids = mesh.GetIdsFromFilter(filter)
print("Number of edges with length > 14:", len(ids))
# Length 2D
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all faces that have edges with length > 14
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, 14)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 14)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with maximum edge length > 14:", len(ids))
# Element Diameter 2D
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all faces that have elements with length > 10
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces with maximum element length > 10:", len(ids))
# Element Diameter 3D
# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# get all volumes that have elements with length > 10
-filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, 10)
+filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, 10)
ids = mesh.GetIdsFromFilter(filter)
print("Number of volumes with maximum element length > 10:", len(ids))
# Bare border volumes
# create mesh
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# remove some volumes to have volumes with bare borders
mesh.RemoveElements(mesh.GetElementsByType(SMESH.VOLUME)[0:5])
# get all volumes with bare borders
-filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume)
+filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume)
ids = mesh.GetIdsFromFilter(filter)
print("Volumes with bare borders:", ids)
# Over-constrained volumes
# create mesh
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# get all over-constrained volumes
-filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume)
+filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume)
ids = mesh.GetIdsFromFilter(filter)
print("Over-constrained volumes:", ids)
# Belong to Geom
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all faces which nodes lie on the face sub_face3
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces which nodes lie on sub_face3:", len(ids))
# Lying on Geom
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all faces at least one node of each lies on the face sub_face3
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_LyingOnGeom, sub_face3)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_LyingOnGeom, sub_face3)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces at least one node of each lies on sub_face3:", len(ids))
# Belong to Plane
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# create plane
-plane_1 = geompy.MakePlane(p3,seg1,2000)
-geompy.addToStudy(plane_1, "plane_1")
+plane_1 = geom_builder.MakePlane(p3,seg1,2000)
+geom_builder.addToStudy(plane_1, "plane_1")
+
# get all nodes which lie on the plane \a plane_1
-filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToPlane, plane_1)
+filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_BelongToPlane, plane_1)
ids = mesh.GetIdsFromFilter(filter)
print("Number of nodes which lie on the plane plane_1:", len(ids))
# Belong to Cylinder
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get all faces which lie on the cylindrical face \a sub_face1
-filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToCylinder, sub_face1)
+filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToCylinder, sub_face1)
ids = mesh.GetIdsFromFilter(filter)
print("Number of faces which lie on the cylindrical surface sub_face1:", len(ids))
# Belong to Surface
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# create b-spline
-spline_1 = geompy.MakeInterpol([p4,p6,p3,p1])
-surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 )
-geompy.addToStudy(surface_1, "surface_1")
+spline_1 = geom_builder.MakeInterpol([p4,p6,p3,p1])
+surface_1 = geom_builder.MakePrismVecH( spline_1, vz, 70.0 )
+geom_builder.addToStudy(surface_1, "surface_1")
+
# get all nodes which lie on the surface \a surface_1
-filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToGenSurface, surface_1)
+filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_BelongToGenSurface, surface_1)
ids = mesh.GetIdsFromFilter(filter)
print("Number of nodes which lie on the surface surface_1:", len(ids))
# Range of IDs
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# get nodes with identifiers [5-10] and [15-30]
-criterion1 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="5-10",\
- BinaryOp=SMESH.FT_LogicalOR)
-criterion2 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="15-30")
-filter = smesh.CreateFilterManager().CreateFilter()
+criterion1 = smesh_builder.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="5-10",\
+ BinaryOp=SMESH.FT_LogicalOR)
+criterion2 = smesh_builder.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="15-30")
+filter = smesh_builder.CreateFilterManager().CreateFilter()
filter.SetCriteria([criterion1,criterion2])
ids = mesh.GetIdsFromFilter(filter)
print("Number of nodes in ranges [5-10] and [15-30]:", len(ids))
# Badly oriented volume
# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# get all badly oriented volumes
-filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume)
+filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume)
ids = mesh.GetIdsFromFilter(filter)
print("Number of badly oriented volumes:", len(ids))
# Linear / quadratic
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
# get linear and quadratic edges
-filter_linear = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic)
-filter_quadratic = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic, SMESH.FT_LogicalNOT)
+filter_linear = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic)
+filter_quadratic = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic, SMESH.FT_LogicalNOT)
ids_linear = mesh.GetIdsFromFilter(filter_linear)
ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
print("Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic))
# Group color
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
+
# create group of edges
all_edges = mesh.GetElementsByType(SMESH.EDGE)
grp = mesh.MakeGroupByIds("edges group", SMESH.EDGE, all_edges[:len(all_edges) // 4])
c = SALOMEDS.Color(0.1, 0.5, 1.0)
grp.SetColor(c)
# get number of the edges not belonging to the group with the given color
-filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT)
+filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT)
ids = mesh.GetIdsFromFilter(filter)
print ("Number of edges not belonging to the group with color (0.1, 0.5, 1.0):", len(ids))
# Geometry type
# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
+from mechanic import *
+
# get all triangles, quadrangles, tetrahedrons, pyramids
-filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_TRIANGLE)
-filter_qua = smesh.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE)
-filter_tet = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_TETRA)
-filter_pyr = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_PYRAMID)
+filter_tri = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_TRIANGLE)
+filter_qua = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE)
+filter_tet = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_TETRA)
+filter_pyr = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_PYRAMID)
ids_tri = mesh.GetIdsFromFilter(filter_tri)
ids_qua = mesh.GetIdsFromFilter(filter_qua)
ids_tet = mesh.GetIdsFromFilter(filter_tet)
# Combine several criteria into a filter
# create mesh
-from SMESH_mechanic import *
+from mechanic import *
# get all the quadrangle faces ...
-criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE, SMESH.FT_LogicalAND)
+criterion1 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE, SMESH.FT_LogicalAND)
# ... but those from sub_face3
-criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3, SMESH.FT_LogicalNOT)
+criterion2 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3, SMESH.FT_LogicalNOT)
-quadFilter = smesh.GetFilterFromCriteria([criterion1,criterion2])
+quadFilter = smesh_builder.GetFilterFromCriteria([criterion1,criterion2])
# get faces satisfying the criteria
ids = mesh.GetIdsFromFilter(quadFilter)
# Entity type
# create a mesh
-from SMESH_mechanic import *
+from mechanic import *
# make the mesh quadratic
mesh.ConvertToQuadratic()
# make some elements bi-quadratic
-for face in SubFaceL[: len(SubFaceL) // 2]:
+for face in shape_faces[: len(shape_faces) // 2]:
mesh.ConvertToQuadratic( theSubMesh=mesh.Group( face ), theToBiQuad=True )
# get triangles with 7 nodes
-filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_EntityType,'=', SMESH.Entity_BiQuad_Triangle )
+filter_tri = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_EntityType,'=', SMESH.Entity_BiQuad_Triangle )
ids_tri = mesh.GetIdsFromFilter(filter_tri)
print("Number of bi-quadratic triangles:", len(ids_tri))
# Ball diameter
# create a mesh
-from SMESH_mechanic import *
+from mechanic import *
# create several balls with increasing diameter
for i in range(1,10):
pass
# get balls with diameter > 5.
-diam_filter = smesh.GetFilter(SMESH.BALL, SMESH.FT_BallDiameter,'>', 5. )
+diam_filter = smesh_builder.GetFilter(SMESH.BALL, SMESH.FT_BallDiameter,'>', 5. )
ids = mesh.GetIdsFromFilter( diam_filter )
print("Number of balls with diameter > 5:", len(ids))
# "Elements of a domain" filter and "Renumber" hypothesis
-import salome, SMESH
+import salome
salome.salome_init_without_session()
+
+import SMESH
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create two boxes to have two domains in the mesh
-box1 = geompy.MakeBoxDXDYDZ( 100,100,100 )
-box2 = geompy.MakeTranslation( box1, 200, 0, 0 )
-boxes = geompy.MakeCompound( [box1, box2] )
-box1, box2 = geompy.SubShapeAll( boxes, geompy.ShapeType["SHAPE"], "box")
+box1 = geom_builder.MakeBoxDXDYDZ( 100,100,100 )
+box2 = geom_builder.MakeTranslation( box1, 200, 0, 0 )
+boxes = geom_builder.MakeCompound( [box1, box2] )
+box1, box2 = geom_builder.SubShapeAll( boxes, geom_builder.ShapeType["SHAPE"], "box")
-vertex = geompy.SubShape( box1, geompy.ShapeType["VERTEX"], [1] )
+vertex = geom_builder.SubShape( box1, geom_builder.ShapeType["VERTEX"], [1] )
# create a mesh
-mesh = smesh.Mesh( boxes )
+mesh = smesh_builder.Mesh( boxes )
mesh.Segment(box1).NumberOfSegments( 5 ) # to have different nb of elements on the boxes
mesh.Segment(box2).NumberOfSegments( 10 )
mesh.Quadrangle()
# Use Renumber hypothesis to get hexahedra and nodes numbered like in a structured mesh.
# k axis of box1 will be ( 100,100,0 ) - ( 100,100,100 )
# k axis of box2 will be ( 0,0,0 ) - (0,0,100), by default
-v000 = geompy.MakeVertex( 100,100,0, theName='v000' ) # can use box sub-vertex or standalone one
-v001 = geompy.GetVertexNearPoint( box1, geompy.MakeVertex(100,100,100), theName='v001')
+v000 = geom_builder.MakeVertex( 100,100,0, theName='v000' ) # can use box sub-vertex or standalone one
+v001 = geom_builder.GetVertexNearPoint( box1, geom_builder.MakeVertex(100,100,100), theName='v001')
ijkAlgo.Renumber([ smeshBuilder.BlockCS( box1, v000, v001 ) ])
mesh.Compute()
# Create filters with FT_ConnectedElements criterion by pointing a domain in different ways:
# using point coordinates in box_1
-nodeFilter = smesh.GetFilter( SMESH.NODE, SMESH.FT_ConnectedElements, "=", "1.,2,10", mesh=mesh )
+nodeFilter = smesh_builder.GetFilter( SMESH.NODE, SMESH.FT_ConnectedElements, "=", "1.,2,10", mesh=mesh )
print("Nb. nodes in box_1:", len( nodeFilter.GetIDs()))
# using point coordinates in box_2
-edgeFilter = smesh.GetFilter( SMESH.EDGE, SMESH.FT_ConnectedElements, "=", [202,1,1 ], mesh=mesh )
+edgeFilter = smesh_builder.GetFilter( SMESH.EDGE, SMESH.FT_ConnectedElements, "=", [202,1,1 ], mesh=mesh )
print("Nb. segments in box_2:", len( edgeFilter.GetIDs()))
# using a geom vertex of box_1
-faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_ConnectedElements, "=", vertex, mesh=mesh )
+faceFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_ConnectedElements, "=", vertex, mesh=mesh )
print("Nb. faces in box_1:", len( edgeFilter.GetIDs()))
# using node ID in box_2
-voluFilter = smesh.GetFilter( SMESH.VOLUME, SMESH.FT_ConnectedElements, "=", 10, mesh=mesh )
+voluFilter = smesh_builder.GetFilter( SMESH.VOLUME, SMESH.FT_ConnectedElements, "=", 10, mesh=mesh )
print("Nb. volumes in box_2:", len( voluFilter.GetIDs()))
-
# Number of connectivities of a node
# create a mesh
-from SMESH_mechanic import *
+from mechanic import *
# get nodes connected to more than 6 tetrahedra
-conn_nb_filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_NodeConnectivityNumber,'>', 6 )
+conn_nb_filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_NodeConnectivityNumber,'>', 6 )
ids = mesh.GetIdsFromFilter( conn_nb_filter )
print("Number of nodes connected to more than 6 tetrahedra:", len(ids))
# This example represents an iron cable (a thin cylinder) in a concrete block (a big cylinder).
# The big cylinder is defined by two geometric volumes.
-
import salome
salome.salome_init_without_session()
+
import GEOM
+import SMESH
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# geometry
-O = geompy.MakeVertex(0, 0, 0)
-OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
-OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
-OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
-Vertex_1 = geompy.MakeVertex(50, 0, 0)
-Cylinder_1 = geompy.MakeCylinder(O, OX, 10, 500)
-Cylinder_2 = geompy.MakeCylinder(Vertex_1, OX, 100, 400)
-Vertex_2 = geompy.MakeVertex(-200, -200, -200)
-Vertex_3 = geompy.MakeVertex(250, 200, 200)
-Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_3)
-Fuse_1 = geompy.MakeFuse(Cylinder_1, Cylinder_2)
-Partition_1 = geompy.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
-[Solid_1,Solid_2] = geompy.GetShapesOnShape(Cylinder_1, Partition_1, geompy.ShapeType["SOLID"], GEOM.ST_IN)
-[Solid_3,Solid_4] = geompy.GetShapesOnShape(Cylinder_2, Partition_1, geompy.ShapeType["SOLID"], GEOM.ST_IN)
-Vertex_4 = geompy.MakeVertex(450, 0, 0)
-Vertex_5 = geompy.MakeVertex(500, 0, 0)
-Vertex_6 = geompy.MakeVertex(550, 0, 0)
-vec1 = geompy.MakeVector(Vertex_4, Vertex_5)
-vec2 = geompy.MakeVector(Vertex_5, Vertex_6)
-[Face_1] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec1, GEOM.ST_ON)
-[Face_2] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec2, GEOM.ST_ON)
+O = geom_builder.MakeVertex(0, 0, 0)
+OX = geom_builder.MakeVectorDXDYDZ(1, 0, 0)
+OY = geom_builder.MakeVectorDXDYDZ(0, 1, 0)
+OZ = geom_builder.MakeVectorDXDYDZ(0, 0, 1)
+Vertex_1 = geom_builder.MakeVertex(50, 0, 0)
+Cylinder_1 = geom_builder.MakeCylinder(O, OX, 10, 500)
+Cylinder_2 = geom_builder.MakeCylinder(Vertex_1, OX, 100, 400)
+Vertex_2 = geom_builder.MakeVertex(-200, -200, -200)
+Vertex_3 = geom_builder.MakeVertex(250, 200, 200)
+Box_1 = geom_builder.MakeBoxTwoPnt(Vertex_2, Vertex_3)
+Fuse_1 = geom_builder.MakeFuse(Cylinder_1, Cylinder_2)
+Partition_1 = geom_builder.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geom_builder.ShapeType["SOLID"], 0, [], 0)
+[Solid_1,Solid_2] = geom_builder.GetShapesOnShape(Cylinder_1, Partition_1, geom_builder.ShapeType["SOLID"], GEOM.ST_IN)
+[Solid_3,Solid_4] = geom_builder.GetShapesOnShape(Cylinder_2, Partition_1, geom_builder.ShapeType["SOLID"], GEOM.ST_IN)
+Vertex_4 = geom_builder.MakeVertex(450, 0, 0)
+Vertex_5 = geom_builder.MakeVertex(500, 0, 0)
+Vertex_6 = geom_builder.MakeVertex(550, 0, 0)
+vec1 = geom_builder.MakeVector(Vertex_4, Vertex_5)
+vec2 = geom_builder.MakeVector(Vertex_5, Vertex_6)
+[Face_1] = geom_builder.GetShapesOnPlane(Partition_1, geom_builder.ShapeType["FACE"], vec1, GEOM.ST_ON)
+[Face_2] = geom_builder.GetShapesOnPlane(Partition_1, geom_builder.ShapeType["FACE"], vec2, GEOM.ST_ON)
# meshing (we have linear tetrahedrons here, but other elements are OK)
-Mesh_1 = smesh.Mesh(Partition_1)
+Mesh_1 = smesh_builder.Mesh(Partition_1)
Regular_1D = Mesh_1.Segment()
Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO)
# Create a Standalone Group
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Get ids of all faces with area > 100
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
anIds = mesh.GetIdsFromFilter(aFilter)
# removes entities
aGroup.Remove( [2,3,4] )
-
-
-
-
-salome.sg.updateObjBrowser()
# Create a Group on Geometry
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBox(0., 0., 0., 100., 100., 100.)
-geompy.addToStudy(box, "box")
+box = geom_builder.MakeBox(0., 0., 0., 100., 100., 100.)
+geom_builder.addToStudy(box, "box")
# add the first face of the box to the study
-subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+subShapeList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
face = subShapeList[0]
-geompy.addToStudyInFather(box, face, "face 1")
+geom_builder.addToStudyInFather(box, face, "face 1")
# create group of edges on the face
-aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"])
-geompy.AddObject(aGeomGroupE, 3)
-geompy.AddObject(aGeomGroupE, 6)
-geompy.AddObject(aGeomGroupE, 8)
-geompy.AddObject(aGeomGroupE, 10)
-geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges")
+aGeomGroupE = geom_builder.CreateGroup(face, geom_builder.ShapeType["EDGE"])
+geom_builder.AddObject(aGeomGroupE, 3)
+geom_builder.AddObject(aGeomGroupE, 6)
+geom_builder.AddObject(aGeomGroupE, 8)
+geom_builder.AddObject(aGeomGroupE, 10)
+geom_builder.addToStudyInFather(face, aGeomGroupE, "Group of Edges")
# create quadrangle 2D mesh on the box
-quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
+quadra = smesh_builder.Mesh(box, "Box : quadrangle 2D mesh")
algo1D = quadra.Segment()
quadra.Quadrangle()
algo1D.NumberOfSegments(7)
# create SMESH group on <aGeomGroupE> with default name
aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE)
-
-salome.sg.updateObjBrowser()
# Create a Group on Filter
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-box = geompy.MakeBoxDXDYDZ(10,10,10)
+box = geom_builder.MakeBoxDXDYDZ(10,10,10)
# make a mesh with quadrangles of different area in range [1,16]
-mesh = smesh.Mesh(box,"Quad mesh")
+mesh = smesh_builder.Mesh(box,"Quad mesh")
hyp1D = mesh.Segment().StartEndLength( 1, 4 )
mesh.Quadrangle()
mesh.Compute()
# create a group on filter selecting faces of medium size
critaria = [ \
- smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ),
- smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 )
+ smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ),
+ smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 )
]
-filt = smesh.GetFilterFromCriteria( critaria )
+filt = smesh_builder.GetFilterFromCriteria( critaria )
filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt )
print("Group on filter contains %s elements" % filtGroup.Size())
print("After mesh change, group on filter contains %s elements" % filtGroup.Size())
# set a new filter defining the group
-filt2 = smesh.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" )
+filt2 = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" )
filtGroup.SetFilter( filt2 )
print("With a new filter, group on filter contains %s elements" % filtGroup.Size())
# group is updated at modification of the filter
-filt2.SetCriteria( [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
+filt2.SetCriteria( [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
filtIDs3 = filtGroup.GetIDs()
print("After filter modification, group on filter contains %s elements" % filtGroup.Size())
-
-salome.sg.updateObjBrowser()
# Edit a Group
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Get ids of all faces with area > 35
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 35.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 35.)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup.Add(anIds)
# Get ids of all faces with area > 40
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 40.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 40.)
anIds = mesh.GetIdsFromFilter(aFilter)
j = j + 1
pass
print("")
-
-salome.sg.updateObjBrowser()
# Union of groups
-import SMESH_mechanic
-import SMESH, SALOMEDS
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
+import SALOMEDS
# Criterion : AREA > 20
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup1.Add(anIds)
# Criterion : AREA = 20
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_EqualTo, 20.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_EqualTo, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
# Please note that also there is UnionGroups() method which works with two groups only
# Criterion : AREA < 20
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 20.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
# create union group : area >= 20 and area < 20
aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
print("Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID()))
-
-salome.sg.updateObjBrowser()
# Intersection of groups
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : AREA > 20
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup1.Add(anIds)
# Criterion : AREA < 60
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.)
anIds = mesh.GetIdsFromFilter(aFilter)
print("Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID()))
# Please note that also there is IntersectGroups() method which works with two groups only
-salome.sg.updateObjBrowser()
# Cut of groups
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : AREA > 20
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroupMain = mesh.MakeGroupByIds("Area > 20", SMESH.FACE, anIds)
# Criterion : AREA < 60
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
print("Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID()))
# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
-
-salome.sg.updateObjBrowser()
# Creating groups of entities basing on nodes of other groups
-import SMESH_mechanic
-import SMESH, SALOMEDS
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
+import SALOMEDS
# Criterion : AREA > 100
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.)
# create a group by adding elements with area > 100
aSrcGroup1 = mesh.GroupOnFilter(SMESH.FACE, "Area > 100", aFilter)
print("Criterion: Area > 100, Nb = ", aSrcGroup1.Size())
# Criterion : AREA < 30
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.)
# create a group by adding elements with area < 30
aSrcGroup2 = mesh.GroupOnFilter(SMESH.FACE, "Area < 30", aFilter)
# Create group of nodes using source groups of faces
aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], SMESH.NODE, "Nodes" )
-
-salome.sg.updateObjBrowser()
import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-geompy = geomBuilder.New()
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a mesh on a box
-box = geompy.MakeBoxDXDYDZ( 10,10,10, theName="Box" )
-mesh = smesh.Mesh(box,"Mesh")
+box = geom_builder.MakeBoxDXDYDZ( 10,10,10, theName="Box" )
+mesh = smesh_builder.Mesh(box,"Mesh")
mesh.AutomaticHexahedralization()
# create groups of faces of each side of the box
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
-from SMESH_mechanic import mesh as mesh1
-from SMESH_test1 import mesh as mesh2
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+# create and mesh two boxes
+
+p1 = geom_builder.MakeVertex(10.0, 10.0, 10.0)
+p2 = geom_builder.MakeVertex(20.0, 20.0, 20.0)
+p3 = geom_builder.MakeVertex(30.0, 40.0, 50.0)
+p4 = geom_builder.MakeVertex(70.0, 100.0, 200.0)
+
+box1 = geom_builder.MakeBoxTwoPnt(p1, p2)
+box2 = geom_builder.MakeBoxTwoPnt(p3, p4)
+
+mesh1 = smesh_builder.Mesh(box1, 'box1')
+mesh1.Segment().NumberOfSegments(2)
+mesh1.Triangle().MaxElementArea(10)
+
+mesh2 = smesh_builder.Mesh(box2, 'box2')
+mesh2.Segment().NumberOfSegments(5)
+mesh2.Triangle().MaxElementArea(20)
mesh1.Compute()
mesh2.Compute()
-# compute min distance from mesh1 to the origin (not available yet)
-smesh.MinDistance(mesh1)
+# compute min distance from grp1 to the origin (not available yet)
+smesh_builder.MinDistance(mesh1)
# compute min distance from node 10 of mesh1 to the origin
-smesh.MinDistance(mesh1, id1=10)
+smesh_builder.MinDistance(mesh1, id1=10)
# ... or
mesh1.MinDistance(10)
# compute min distance between nodes 10 and 20 of mesh1
-smesh.MinDistance(mesh1, id1=10, id2=20)
+smesh_builder.MinDistance(mesh1, id1=10, id2=20)
# ... or
mesh1.MinDistance(10, 20)
# compute min distance from element 100 of mesh1 to the origin (not available yet)
-smesh.MinDistance(mesh1, id1=100, isElem1=True)
+smesh_builder.MinDistance(mesh1, id1=100, isElem1=True)
# ... or
mesh1.MinDistance(100, isElem1=True)
# compute min distance between elements 100 and 200 of mesh1 (not available yet)
-smesh.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True)
+smesh_builder.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True)
# ... or
mesh1.MinDistance(100, 200, True, True)
# compute min distance from element 100 to node 20 of mesh1 (not available yet)
-smesh.MinDistance(mesh1, id1=100, id2=20, isElem1=True)
+smesh_builder.MinDistance(mesh1, id1=100, id2=20, isElem1=True)
# ... or
mesh1.MinDistance(100, 20, True)
# compute min distance from mesh1 to mesh2 (not available yet)
-smesh.MinDistance(mesh1, mesh2)
+smesh_builder.MinDistance(mesh1, mesh2)
# compute min distance from node 10 of mesh1 to node 20 of mesh2
-smesh.MinDistance(mesh1, mesh2, 10, 20)
+smesh_builder.MinDistance(mesh1, mesh2, 10, 20)
# compute min distance from node 10 of mesh1 to element 200 of mesh2 (not available yet)
-smesh.MinDistance(mesh1, mesh2, 10, 200, isElem2=True)
+smesh_builder.MinDistance(mesh1, mesh2, 10, 200, isElem2=True)
# etc...
-
# Bounding Box
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
-from SMESH_mechanic import mesh as mesh1
-from SMESH_test1 import mesh as mesh2
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+# create and mesh two boxes
+
+p1 = geom_builder.MakeVertex(10.0, 10.0, 10.0)
+p2 = geom_builder.MakeVertex(20.0, 20.0, 20.0)
+p3 = geom_builder.MakeVertex(30.0, 40.0, 50.0)
+p4 = geom_builder.MakeVertex(70.0, 100.0, 200.0)
+
+box1 = geom_builder.MakeBoxTwoPnt(p1, p2)
+box2 = geom_builder.MakeBoxTwoPnt(p3, p4)
+
+mesh1 = smesh_builder.Mesh(box1, 'box1')
+mesh1.Segment().NumberOfSegments(2)
+mesh1.Triangle().MaxElementArea(10)
+
+mesh2 = smesh_builder.Mesh(box2, 'box2')
+mesh2.Segment().NumberOfSegments(5)
+mesh2.Triangle().MaxElementArea(20)
mesh1.Compute()
mesh2.Compute()
# compute bounding box for mesh1
mesh1.BoundingBox()
-# compute bounding box for list of nodes of mesh1
-mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381])
+# compute bounding box for list of nodes of mesh2
+mesh2.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381])
-# compute bounding box for list of elements of mesh1
-mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True)
+# compute bounding box for list of elements of mesh2
+mesh2.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True)
# compute common bounding box of mesh1 and mesh2
-smesh.BoundingBox([mesh1, mesh2])
+smesh_builder.BoundingBox([mesh1, mesh2])
# etc...
# Basic Properties
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-face = geompy.SubShapeAllSorted(box, geompy.ShapeType['FACE'])[0]
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
+face = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType['FACE'])[0]
# mesh a box
-mesh = smesh.Mesh(box)
+mesh = smesh_builder.Mesh(box)
submesh_1d = mesh.Segment().NumberOfSegments(5)
submesh_2d = mesh.Quadrangle()
submesh_3d = mesh.Hexahedron()
print("Get basic properties: approach 1 (via measurements tool) ----")
-measure = smesh.CreateMeasurements()
+measure = smesh_builder.CreateMeasurements()
print("* for mesh:")
print(" length:", measure.Length(mesh.mesh))
print("Get basic properties: approach 2 (via smeshBuilder) ----")
print("* for mesh:")
-print(" length:", smesh.GetLength(mesh))
-print(" area:", smesh.GetArea(mesh))
-print(" volume:", smesh.GetVolume(mesh))
+print(" length:", smesh_builder.GetLength(mesh))
+print(" area:", smesh_builder.GetArea(mesh))
+print(" volume:", smesh_builder.GetVolume(mesh))
print("* for group (2d):")
-print(" length:", smesh.GetLength(group_2d))
-print(" area:", smesh.GetArea(group_2d))
-print(" volume:", smesh.GetVolume(group_2d))
+print(" length:", smesh_builder.GetLength(group_2d))
+print(" area:", smesh_builder.GetArea(group_2d))
+print(" volume:", smesh_builder.GetVolume(group_2d))
print("* for submesh (2d):")
-print(" length:", smesh.GetLength(submesh_2d_face))
-print(" area:", smesh.GetArea(submesh_2d_face))
-print(" volume:", smesh.GetVolume(submesh_2d_face))
+print(" length:", smesh_builder.GetLength(submesh_2d_face))
+print(" area:", smesh_builder.GetArea(submesh_2d_face))
+print(" volume:", smesh_builder.GetVolume(submesh_2d_face))
print("Get basic properties: approach 3 (via smeshBuilder.Mesh) ----")
# Angle measurement
-
import salome
salome.salome_init_without_session()
+
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+smesh_builder = smeshBuilder.New()
# use smeshBuilder.GetAngle() to compute angle between 3 arbitrary points
p1 = [0,0,0]
p2 = [0,1,0]
-a1 = smesh.GetAngle(p0, p1, p2)
+a1 = smesh_builder.GetAngle(p0, p1, p2)
print("Right angle measure", a1 )
# use Mesh.GetAngle() to compute angle between 3 nodes of a mesh
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
n0 = mesh.AddNode( *p0 )
n1 = mesh.AddNode( *p1 )
n2 = mesh.AddNode( *p2 )
a2 = mesh.GetAngle( n0,n1,n2 )
-
--- /dev/null
+# Inspired by SMESH_mechanic.py.
+# Creates geometry and a mesh to be used in other examples
+# --------------------------------------------------------
+
+import salome
+salome.salome_init_without_session()
+
+import SMESH
+from salome.geom import geomBuilder
+from salome.smesh import smeshBuilder
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+# Geometry
+# --------
+
+# create planar face on a wire combined from a segment and three arcs
+
+p1 = geom_builder.MakeVertex(100.0, 0.0, 0.0)
+p2 = geom_builder.MakeVertex(50.0, 50.0, 0.0)
+p3 = geom_builder.MakeVertex(100.0, 100.0, 0.0)
+arc1 = geom_builder.MakeArc(p1, p2, p3)
+
+p4 = geom_builder.MakeVertex(170.0, 100.0, 0.0)
+seg1 = geom_builder.MakeVector(p3, p4)
+
+p5 = geom_builder.MakeVertex(200.0, 70.0, 0.0)
+p6 = geom_builder.MakeVertex(170.0, 40.0, 0.0)
+arc2 = geom_builder.MakeArc(p4, p5, p6)
+
+p7 = geom_builder.MakeVertex(120.0, 30.0, 0.0)
+arc3 = geom_builder.MakeArc(p6, p7, p1)
+
+wire1 = geom_builder.MakeWire([arc1, seg1, arc2, arc3])
+face1 = geom_builder.MakeFace(wire1, True)
+
+# create main shape by extruding just created planar face
+
+pO = geom_builder.MakeVertex(0.0, 0.0, 0.0)
+pz = geom_builder.MakeVertex(0.0, 0.0, 100.0)
+vz = geom_builder.MakeVector(pO, pz)
+prism1 = geom_builder.MakePrismVecH(face1, vz, 100.0)
+
+# create two cylinders
+
+pc1 = geom_builder.MakeVertex(90.0, 50.0, -40.0)
+pc2 = geom_builder.MakeVertex(170.0, 70.0, -40.0)
+
+cyl1 = geom_builder.MakeCylinder(pc1, vz, 20.0, 180.0)
+cyl2 = geom_builder.MakeCylinder(pc2, vz, 20.0, 180.0)
+
+# create final shape by cutting one cylinder and fusing with another
+
+shape = geom_builder.MakeBoolean(prism1, cyl1, 2)
+mechanic = geom_builder.MakeBoolean(shape, cyl2, 3)
+
+# get all faces from shape and keep sub of them into variables for future processing
+
+shape_faces = geom_builder.SubShapeAllSorted(mechanic, geom_builder.ShapeType["FACE"])
+
+sub_face1 = shape_faces[0]
+sub_face2 = shape_faces[4]
+sub_face3 = shape_faces[5]
+sub_face4 = shape_faces[10]
+
+# Mesh
+# ----
+
+# create tria+tetra mesh from mechanic shape
+
+mesh = smesh_builder.Mesh(mechanic, "mechanic")
+mesh.Segment().NumberOfSegments(10)
+mesh.Triangle().MaxElementArea(25)
+mesh.Tetrahedron()
+
+# create quad sub-meshes on faces sub_face1 - sub_face4
+
+mesh.Quadrangle(sub_face1)
+mesh.Quadrangle(sub_face2)
+mesh.Quadrangle(sub_face3)
+mesh.Quadrangle(sub_face4)
+
+# finally compute whole mesh
+
+mesh.Compute()
--- /dev/null
+# 3d mesh generation and mesh exploration
+
+import salome
+salome.salome_init_without_session()
+
+import SMESH
+from salome.geom import geomBuilder
+from salome.smesh import smeshBuilder
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+###
+# Geometry: an assembly of a box, a cylinder and a truncated cone
+# to be meshed with tetrahedra
+###
+
+# Define values
+name = "ex21_lamp"
+cote = 60
+section = 20
+size = 200
+radius_1 = 80
+radius_2 = 40
+height = 100
+
+# Build a box
+box = geom_builder.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
+
+# Build a cylinder
+pt1 = geom_builder.MakeVertex(0, 0, cote/3)
+di1 = geom_builder.MakeVectorDXDYDZ(0, 0, 1)
+cyl = geom_builder.MakeCylinder(pt1, di1, section, size)
+
+# Build a truncated cone
+pt2 = geom_builder.MakeVertex(0, 0, size)
+cone = geom_builder.MakeCone(pt2, di1, radius_1, radius_2, height)
+
+# Fuse
+box_cyl = geom_builder.MakeFuse(box, cyl)
+piece = geom_builder.MakeFuse(box_cyl, cone)
+
+# Add to the study
+geom_builder.addToStudy(piece, name)
+
+# Create a group of faces
+faces_group = geom_builder.CreateGroup(piece, geom_builder.ShapeType["FACE"])
+group_name = name + "_grp"
+geom_builder.addToStudy(faces_group, group_name)
+faces_group.SetName(group_name)
+
+# Add faces to the group
+faces = geom_builder.SubShapeAllIDs(piece, geom_builder.ShapeType["FACE"])
+geom_builder.UnionIDs(faces_group, faces)
+
+###
+# Create a mesh
+###
+
+# Define a mesh on a geometry
+tetra = smesh_builder.Mesh(piece, name)
+
+# Define 1D algorithm and hypothesis
+algo1d = tetra.Segment()
+algo1d.LocalLength(10)
+
+# Define 2D algorithm and hypothesis
+algo2d = tetra.Triangle()
+algo2d.LengthFromEdges()
+
+# Define 3D algorithm and hypothesis
+algo3d = tetra.Tetrahedron()
+algo3d.MaxElementVolume(100)
+
+# Compute the mesh
+tetra.Compute()
+
+# Create a mesh group of all triangles generated on geom faces present in faces_group
+group = tetra.Group(faces_group)
+
+###
+# Explore the mesh
+###
+
+# Retrieve coordinates of nodes
+coordStr = ""
+for node in tetra.GetNodesId():
+ x,y,z = tetra.GetNodeXYZ( node )
+ coordStr += "%s (%s, %s, %s) " % ( node, x,y,z )
+ pass
+
+# Retrieve nodal connectivity of triangles
+triaStr = ""
+for tria in tetra.GetElementsByType( SMESH.FACE ):
+ nodes = tetra.GetElemNodes( tria )
+ triaStr += "%s (%s, %s, %s) " % ( tria, nodes[0], nodes[1], nodes[2] )
+
+# Retrieve group contents
+groupStr = ""
+for group in tetra.GetGroups():
+ ids = group.GetIDs()
+ name = group.GetName()
+ eType = group.GetType()
+ groupStr += "'%s' %s: %s \n" % ( name, eType, ids )
import salome
salome.salome_init_without_session()
+
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+smesh_builder = smeshBuilder.New()
# create 3 triangles and 1 segment all sharing edge 1-2
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
n1 = mesh.AddNode( 0, 0, 0)
n2 = mesh.AddNode( 0, 0, -10)
n3 = mesh.AddNode( 10, 0, 0)
salome.salome_init_without_session()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+smesh_builder = smeshBuilder.New()
-
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# add node
new_id = mesh.AddNode(50, 10, 0)
salome.salome_init_without_session()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+smesh_builder = smeshBuilder.New()
-
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# add node
node_id = mesh.AddNode(50, 10, 0)
# Add 0D Element on Element Nodes
-
import salome
salome.salome_init_without_session()
+import SMESH
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a geometry
-box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
-face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0]
+box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 )
+face = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0]
# make 3D mesh
-mesh = smesh.Mesh( box )
+mesh = smesh_builder.Mesh( box )
mesh.AutomaticHexahedralization(0)
# create 0D elements on all nodes of the mesh
res = mesh.Add0DElementsToAllNodes( group )
# remove all 0D elements
-mesh.RemoveElements( mesh.GetIdsFromFilter( smesh.GetFilter( SMESH.ELEM0D,
- SMESH.FT_ElemGeomType,
- "=",SMESH.Geom_POINT )))
+mesh.RemoveElements( mesh.GetIdsFromFilter( smesh_builder.GetFilter( SMESH.ELEM0D,
+ SMESH.FT_ElemGeomType,
+ "=",SMESH.Geom_POINT )))
# create 0D elements on all nodes of some elements
res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() )
# Add Edge
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print("")
+from mechanic import *
# add node
n1 = mesh.AddNode(50, 10, 0)
# Add Triangle
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print("")
+from mechanic import *
# add node
n1 = mesh.AddNode(50, 10, 0)
# Add Quadrangle
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print("")
+from mechanic import *
# add node
n1 = mesh.AddNode(50, 10, 0)
# Add Tetrahedron
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print("")
+from mechanic import *
# add node
n1 = mesh.AddNode(50, 10, 0)
# Add Hexahedron
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print("")
+from mechanic import *
# add nodes
nId1 = mesh.AddNode(50, 10, 0)
import salome
salome.salome_init_without_session()
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+smesh_builder = smeshBuilder.New()
# create an empty mesh structure
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# a method to build a polygonal mesh element with <nb_vert> angles:
def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert, smesh_builder):
f1 = MakePolygon(mesh, 0, 0, 0, 30, 13, smesh_builder=mesh)
f2 = MakePolygon(mesh, 0, 0, 10, 21, 9, smesh_builder=mesh)
f3 = MakePolygon(mesh, 0, 0, 20, 13, 6, smesh_builder=mesh)
-
-salome.sg.updateObjBrowser()
# Add Polyhedron
+import math
import salome
salome.salome_init_without_session()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import math
+smesh_builder = smeshBuilder.New()
# create an empty mesh structure
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# Create nodes for 12-hedron with pentagonal faces
al = 2 * math.pi / 5.0
aa[0], bb[0], cc[0], bb[1], aa[1], # .
aa[0], aa[1], aa[2], aa[3], aa[4]], # bottom
[5,5,5,5,5,5,5,5,5,5,5,5])
-
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser()
# Removing Nodes
-import SMESH_mechanic
-mesh = SMESH_mechanic.mesh
+import salome
+salome.salome_init_without_session()
+
+from salome.geom import geomBuilder
+from salome.smesh import smeshBuilder
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+# create and mesh two boxes
+
+box = geom_builder.MakeBoxDXDYDZ(10.0, 10.0, 10.0)
+mesh = smesh_builder.Mesh(box, 'box')
+mesh.Segment().NumberOfSegments(10)
+mesh.Triangle().MaxElementArea(5)
+
+mesh.Compute()
+print("After Compute(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces()))
# remove nodes #246 and #255
res = mesh.RemoveNodes([246, 255])
-if res == 1: print("Nodes removing is OK!")
-else: print("KO nodes removing.")
-
+print("After RemoveNodes(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces()))
-# Removing a Node with Reconnection
-# ==================================
+# removing node #100 with reconnection
-print("Before RemoveNodeWithReconnection(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces()))
-mesh.RemoveNodeWithReconnection( 600 )
-print("After RemoveNodeWithReconnection(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces()))
+mesh.RemoveNodeWithReconnection( 100 )
+print("After RemoveNodeWithReconnection(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces()))
# Removing Elements
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# remove three elements: #850, #859 and #814
res = mesh.RemoveElements([850, 859, 814])
# Removing Orphan Nodes
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# add orphan nodes
mesh.AddNode(0,0,0)
# Moving Nodes
-
import salome
salome.salome_init_without_session()
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-box = geompy.MakeBoxDXDYDZ(200, 200, 200)
+box = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
-mesh = smesh.Mesh( box )
+mesh = smesh_builder.Mesh( box )
mesh.Segment().AutomaticLength(0.1)
mesh.Quadrangle()
mesh.Compute()
# find node at (0,0,0) which is located on a geom vertex
node000 = None
-for vId in geompy.SubShapeAllIDs( box, geompy.ShapeType["VERTEX"]):
+for vId in geom_builder.SubShapeAllIDs( box, geom_builder.ShapeType["VERTEX"]):
if node000: break
nodeIds = mesh.GetSubMeshNodesId( vId, True )
for node in nodeIds:
# Diagonal Inversion
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+smesh_builder = smeshBuilder.New()
# create an empty mesh structure
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# create the following mesh:
# .----.----.----.
res = mesh.InverseDiag(bb[1], tt[2])
if not res: print("failed!")
else: print("done.")
-
-salome.sg.updateObjBrowser()
# Uniting two Triangles
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+smesh_builder = smeshBuilder.New()
# create an empty mesh structure
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# create the following mesh:
# .----.----.----.
res = mesh.DeleteDiag(bb[1], tt[2])
if not res: print("failed!")
else: print("done.")
-
-salome.sg.updateObjBrowser()
# Uniting a Set of Triangles
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+smesh_builder = smeshBuilder.New()
# create an empty mesh structure
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# create the following mesh:
# .----.----.----.
res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.)
if not res: print("failed!")
else: print("done.")
-
-salome.sg.updateObjBrowser()
# Orientation
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+smesh_builder = smeshBuilder.New()
# create an empty mesh structure
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# build five quadrangles:
dx = 10
# Change the orientation of the second and the fourth faces.
mesh.Reorient([2, 4])
-
-salome.sg.updateObjBrowser()
# Cutting Quadrangles
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# cut two quadrangles: 405 and 406
mesh.QuadToTri([405, 406], SMESH.FT_MinimumAngle)
# Smoothing
-
-import salome
-salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH, SALOMEDS
-from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-
-import SMESH_mechanic
-
-#smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# select the top face
-faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"])
-face = faces[3]
-geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face planar with hole")
+faces = geom_builder.SubShapeAllSorted(mechanic, geom_builder.ShapeType["FACE"])
# create a group of faces to be smoothed
-GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", SMESH.FACE)
+group_smooth = mesh.GroupOnGeom(faces[3], "Group of faces (smooth)", SMESH.FACE)
# perform smoothing
# boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)
-res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH)
+res = mesh.SmoothObject(group_smooth, [], 20, 2., smesh_builder.CENTROIDAL_SMOOTH)
print("\nSmoothing ... ", end=' ')
if not res: print("failed!")
else: print("done.")
-
-salome.sg.updateObjBrowser()
# There is a series of Extrusion Along Line methods added at different times;
# a fully functional method is ExtrusionSweepObjects()
-import salome, math
+import math
+
+import salome
salome.salome_init_without_session()
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+smesh_builder = smeshBuilder.New()
# create an empty mesh
-mesh = smesh.Mesh()
+mesh = smesh_builder.Mesh()
# add a node
mesh.AddNode( 0.,0.,0. )
# extrude all nodes and triangle faces of the disk quarter, applying a scale factor
diskGroup = mesh.GetGroupByName( "line_rotated", SMESH.FACE )[0]
-crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ),
- smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )]
-trianglesFilter = smesh.GetFilterFromCriteria( crit )
+crit = [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ),
+ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )]
+trianglesFilter = smesh_builder.GetFilterFromCriteria( crit )
nodes = [ diskGroup ]
edges = []
stepSize = 5.
nbSteps = 2
mesh.ExtrusionByNormal( elements, stepSize, nbSteps )
-
-salome.sg.updateObjBrowser()
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# 1. Create points
points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]
iv = 1
vertices = []
for point in points:
- vert = geompy.MakeVertex(point[0], point[1], 0)
- #geompy.addToStudy(vert, "Vertex_" + repr(iv))
+ vert = geom_builder.MakeVertex(point[0], point[1], 0)
vertices.append(vert)
iv += 1
- pass
# 2. Create edges and wires
-Edge_straight = geompy.MakeEdge(vertices[0], vertices[4])
-Edge_bezierrr = geompy.MakeBezier(vertices)
-Wire_polyline = geompy.MakePolyline(vertices)
-Edge_Circle = geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])
+Edge_straight = geom_builder.MakeEdge(vertices[0], vertices[4])
+Edge_bezierrr = geom_builder.MakeBezier(vertices)
+Wire_polyline = geom_builder.MakePolyline(vertices)
+Edge_Circle = geom_builder.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])
-geompy.addToStudy(Edge_straight, "Edge_straight")
-geompy.addToStudy(Edge_bezierrr, "Edge_bezierrr")
-geompy.addToStudy(Wire_polyline, "Wire_polyline")
-geompy.addToStudy(Edge_Circle , "Edge_Circle")
+geom_builder.addToStudy(Edge_straight, "Edge_straight")
+geom_builder.addToStudy(Edge_bezierrr, "Edge_bezierrr")
+geom_builder.addToStudy(Wire_polyline, "Wire_polyline")
+geom_builder.addToStudy(Edge_Circle , "Edge_Circle")
# 3. Explode wire on edges, as they will be used for mesh extrusion
-Wire_polyline_edges = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"])
+Wire_polyline_edges = geom_builder.SubShapeAll(Wire_polyline, geom_builder.ShapeType["EDGE"])
for ii in range(len(Wire_polyline_edges)):
- geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + repr(ii + 1))
- pass
+ geom_builder.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + repr(ii + 1))
# Mesh
# Mesh the given shape with the given 1d hypothesis
-def Mesh1D(shape1d, nbSeg, name, smesh_builder):
+def Mesh1D(shape1d, nbSeg, name):
mesh1d_tool = smesh_builder.Mesh(shape1d, name)
algo = mesh1d_tool.Segment()
hyp = algo.NumberOfSegments(nbSeg)
return mesh1d_tool
# Create a mesh with six nodes, seven edges and two quadrangle faces
-def MakeQuadMesh2(mesh_name, smesh_builder):
+def MakeQuadMesh2(mesh_name):
quad_1 = smesh_builder.Mesh(name = mesh_name)
# six nodes
return [quad_1, [1,2,3,4,5,6,7], [8,9]]
# Path meshes
-Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight", smesh_builder=smesh)
-Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr", smesh_builder=smesh)
-Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline", smesh_builder=smesh)
-Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle" , smesh_builder=smesh)
+Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight")
+Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr")
+Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline")
+Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle")
# Initial meshes (to be extruded)
-[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1", smesh_builder=smesh)
-[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2", smesh_builder=smesh)
-[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3", smesh_builder=smesh)
-[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4", smesh_builder=smesh)
-[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5", smesh_builder=smesh)
-[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6", smesh_builder=smesh)
-[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7", smesh_builder=smesh)
+[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1")
+[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2")
+[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3")
+[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4")
+[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5")
+[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6")
+[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7")
# ExtrusionAlongPath
# IDsOfElements, PathMesh, PathShape, NodeStart,
# HasRefPoint=False, RefPoint=[0,0,0], MakeGroups=False,
# ScaleFactors=[], ScalesVariation=False
-quad_1 = MakeQuadMesh2("quad_1", smesh_builder=smesh)[0]
-quad_2 = MakeQuadMesh2("quad_2", smesh_builder=smesh)[0]
-quad_3 = MakeQuadMesh2("quad_3", smesh_builder=smesh)[0]
-quad_4 = MakeQuadMesh2("quad_4", smesh_builder=smesh)[0]
-quad_5 = MakeQuadMesh2("quad_5", smesh_builder=smesh)[0]
-quad_6 = MakeQuadMesh2("quad_6", smesh_builder=smesh)[0]
-quad_7 = MakeQuadMesh2("quad_7", smesh_builder=smesh)[0]
+quad_1 = MakeQuadMesh2("quad_1")[0]
+quad_2 = MakeQuadMesh2("quad_2")[0]
+quad_3 = MakeQuadMesh2("quad_3")[0]
+quad_4 = MakeQuadMesh2("quad_4")[0]
+quad_5 = MakeQuadMesh2("quad_5")[0]
+quad_6 = MakeQuadMesh2("quad_6")[0]
+quad_7 = MakeQuadMesh2("quad_7")[0]
# 1. Extrusion of two mesh edges along a straight path
nn, ee, ff = [], [1,2], []
nn, ee, ff = [], [], quad_7
error = quad_7.ExtrusionAlongPathObjects( nn, ee, ff, Edge_Circle_mesh, Edge_Circle,
Angles=[a45, -a45, a45, -a45, a45, -a45, a45, -a45])
-
-
-salome.sg.updateObjBrowser()
# Revolution
import math
-import SMESH
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-smesh = SMESH_mechanic.smesh
+from mechanic import *
# create a group of faces to be revolved
FacesRotate = [492, 493, 502, 503]
# Pattern Mapping
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# define the geometry
-Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.)
-geompy.addToStudy(Box_1, "Box_1")
+Box_1 = geom_builder.MakeBoxDXDYDZ(200., 200., 200.)
+geom_builder.addToStudy(Box_1, "Box_1")
-faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])
+faces = geom_builder.SubShapeAll(Box_1, geom_builder.ShapeType["FACE"])
Face_1 = faces[0]
Face_2 = faces[1]
-geompy.addToStudyInFather(Box_1, Face_1, "Face_1")
-geompy.addToStudyInFather(Box_1, Face_2, "Face_2")
+geom_builder.addToStudyInFather(Box_1, Face_1, "Face_1")
+geom_builder.addToStudyInFather(Box_1, Face_2, "Face_2")
# build a quadrangle mesh 3x3 on Face_1
-Mesh_1 = smesh.Mesh(Face_1)
+Mesh_1 = smesh_builder.Mesh(Face_1)
algo1D = Mesh_1.Segment()
algo1D.NumberOfSegments(3)
Mesh_1.Quadrangle()
if not isDone: print('Mesh Mesh_1 : computation failed')
# build a triangle mesh on Face_2
-Mesh_2 = smesh.Mesh(Face_2)
+Mesh_2 = smesh_builder.Mesh(Face_2)
algo1D = Mesh_2.Segment()
algo1D.NumberOfSegments(1)
if not isDone: print('Mesh Mesh_2 : computation failed')
# create a 2d pattern
-pattern = smesh.GetPattern()
+pattern = smesh_builder.GetPattern()
isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
if (isDone != 1): print('LoadFromFace :', pattern.GetErrorCode())
if (isDone != 1): print('MakeMesh :', pattern.GetErrorCode())
# create quadrangle mesh
-Mesh_3 = smesh.Mesh(Box_1)
+Mesh_3 = smesh_builder.Mesh(Box_1)
Mesh_3.Segment().NumberOfSegments(1)
Mesh_3.Quadrangle()
Mesh_3.Hexahedron()
if not isDone: print('Mesh Mesh_3 : computation failed')
# create a 3d pattern (hexahedrons)
-pattern_hexa = smesh.GetPattern()
+pattern_hexa = smesh_builder.GetPattern()
smp_hexa = """!!! Nb of points:
15
if (isDone != 1): print('MakeMesh :', pattern_hexa.GetErrorCode())
# create one more quadrangle mesh
-Mesh_4 = smesh.Mesh(Box_1)
+Mesh_4 = smesh_builder.Mesh(Box_1)
Mesh_4.Segment().NumberOfSegments(1)
Mesh_4.Quadrangle()
Mesh_4.Hexahedron()
if not isDone: print('Mesh Mesh_4 : computation failed')
# create another 3d pattern (pyramids)
-pattern_pyra = smesh.GetPattern()
+pattern_pyra = smesh_builder.GetPattern()
smp_pyra = """!!! Nb of points:
9
# Convert mesh to/from quadratic
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create sphere of radius 100
-Sphere = geompy.MakeSphereR( 100 )
-geompy.addToStudy( Sphere, "Sphere" )
+Sphere = geom_builder.MakeSphereR( 100 )
+geom_builder.addToStudy( Sphere, "Sphere" )
# create simple trihedral mesh
-Mesh = smesh.Mesh(Sphere)
+Mesh = smesh_builder.Mesh(Sphere)
Regular_1D = Mesh.Segment()
Nb_Segments = Regular_1D.NumberOfSegments(5)
MEFISTO_2D = Mesh.Triangle()
salome.salome_init_without_session()
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# mesh a hexahedral mesh
-box = geompy.MakeBoxDXDYDZ (1, 1, 1 )
-mesh = smesh.Mesh( box )
+box = geom_builder.MakeBoxDXDYDZ (1, 1, 1 )
+mesh = smesh_builder.Mesh( box )
mesh.AutomaticHexahedralization(0)
print("Nb volumes mesh: %s" % mesh.NbHexas())
# split each hexahedron into 6 tetrahedra
-mesh.SplitVolumesIntoTetra( mesh, smesh.Hex_6Tet )
+mesh.SplitVolumesIntoTetra( mesh, smesh_builder.Hex_6Tet )
print("Nb volumes mesh: %s" % mesh.NbTetras())
# Using SALOME NoteBook
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
+from salome_notebook import notebook
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# set variables
-notebook = salome_notebook.notebook
notebook.set("Length", 100)
notebook.set("Width", 200)
notebook.set("Offset", 50)
notebook.set("MaxElementVolume", 900)
# create a box
-box = geompy.MakeBoxDXDYDZ("Length", "Width", 300)
-idbox = geompy.addToStudy(box, "Box")
+box = geom_builder.MakeBoxDXDYDZ("Length", "Width", 300)
+idbox = geom_builder.addToStudy(box, "Box")
# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
+tetra = smesh_builder.Mesh(box, "MeshBox")
algo1D = tetra.Segment()
algo1D.NumberOfSegments("NbSegments")
salome.salome_init_without_session()
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
-import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-OX = geompy.MakeVectorDXDYDZ(1,0,0)
-OY = geompy.MakeVectorDXDYDZ(0,1,0)
-OZ = geompy.MakeVectorDXDYDZ(0,0,1)
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+OX = geom_builder.MakeVectorDXDYDZ(1,0,0)
+OY = geom_builder.MakeVectorDXDYDZ(0,1,0)
+OZ = geom_builder.MakeVectorDXDYDZ(0,0,1)
# Y ^ Make geometry of a "pipe" with the following base (cross section).
# | Big central quadrangles will be meshed with triangles, walls
# | | | | | | | -->
# +--+--+--+--+--+--+ X
-quadBig = geompy.MakeFaceHW( 20,20, 1 )
-quadBig = geompy.MakeTranslation( quadBig, 15,15,0 )
-quadSmall = geompy.MakeFaceHW( 10,10, 1 )
-smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 )
-smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 )
-smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:]
+quadBig = geom_builder.MakeFaceHW( 20,20, 1 )
+quadBig = geom_builder.MakeTranslation( quadBig, 15,15,0 )
+quadSmall = geom_builder.MakeFaceHW( 10,10, 1 )
+smallQuads1 = geom_builder.MakeMultiTranslation1D( quadSmall, OX, 10, 3 )
+smallQuads2 = geom_builder.MakeMultiTranslation1D( quadSmall, OY, 10, 3 )
+smallQuads2 = geom_builder.SubShapeAllSortedCentres( smallQuads2, geom_builder.ShapeType["FACE"])[1:]
-base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig])
-axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ )
-base = geompy.MultiRotate1DNbTimes( base, axis, 4)
-base = geompy.MakePartition( [base], theName="base")
-path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0])
+base = geom_builder.MakeCompound( smallQuads2 + [smallQuads1, quadBig])
+axis = geom_builder.MakeLine( geom_builder.MakeVertex( 25,25,0), OZ )
+base = geom_builder.MultiRotate1DNbTimes( base, axis, 4)
+base = geom_builder.MakePartition( [base], theName="base")
+path = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0])
# Make the pipe, each quadrangle of the base turns into a prism with composite wall faces
-pipe = geompy.MakePipe( base, path )
-prisms = geompy.MakePartition( [pipe], theName="prisms")
-
+pipe = geom_builder.MakePipe( base, path )
+prisms = geom_builder.MakePartition( [pipe], theName="prisms")
# get base faces of the prism to define sub-mesh on them
-smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad")
-bigQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad")
-
+smallQuad = geom_builder.GetFaceNearPoint( prisms, geom_builder.MakeVertex( 0,0,0 ), "smallQuad")
+bigQuad = geom_builder.GetFaceNearPoint( prisms, geom_builder.MakeVertex( 15,15,0 ), "bigQuad")
-mesh = smesh.Mesh( prisms )
+mesh = smesh_builder.Mesh( prisms )
# assign Global hypotheses
import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a ring face
-circleEdge1 = geompy.MakeCircleR( 3 )
-circleEdge2 = geompy.MakeCircleR( 7 )
-ring = geompy.MakeFaceWires( [ circleEdge1, circleEdge2 ], True, theName='Ring' )
-circleLen1 = geompy.BasicProperties( circleEdge1 )[0]
-circleLen2 = geompy.BasicProperties( circleEdge2 )[0]
+circleEdge1 = geom_builder.MakeCircleR( 3 )
+circleEdge2 = geom_builder.MakeCircleR( 7 )
+ring = geom_builder.MakeFaceWires( [ circleEdge1, circleEdge2 ], True, theName='Ring' )
+circleLen1 = geom_builder.BasicProperties( circleEdge1 )[0]
+circleLen2 = geom_builder.BasicProperties( circleEdge2 )[0]
# make a mesh
-mesh = smesh.Mesh( ring )
+mesh = smesh_builder.Mesh( ring )
circNbSeg = 60
algo1d = mesh.Segment()
# Deflection 2D
-
import salome
salome.salome_init_without_session()
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# fuse a box and a sphere
-Sphere_1 = geompy.MakeSphereR(100)
-Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
-Fuse = geompy.MakeFuse( Sphere_1, Box_1, theName="box + sphere" )
+Sphere_1 = geom_builder.MakeSphereR(100)
+Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
+Fuse = geom_builder.MakeFuse( Sphere_1, Box_1, theName="box + sphere" )
# create a mesh
-mesh = smesh.Mesh( Fuse, "Deflection_2D")
+mesh = smesh_builder.Mesh( Fuse, "Deflection_2D")
algo = mesh.Segment()
algo.LocalLength(35)
algo = mesh.Triangle()
margin = minMax[1] / 2
# get all faces with deflection LESS than the margin
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh)
anIds = aFilter.GetIDs()
print("%s faces have deflection less than %s" %( len(anIds), margin ))
# create a group of faces with deflection MORE than the margin
aGroup = mesh.MakeGroup("Deflection > " + repr(margin), SMESH.FACE, SMESH.FT_Deflection2D,'>',margin)
print("%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] ))
-
-salome.sg.updateObjBrowser()
# Free Borders
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeShell(FaceList)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-mesh = smesh.Mesh(box, "Mesh_free_borders")
+mesh = smesh_builder.Mesh(box, "Mesh_free_borders")
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
mesh.Compute()
# criterion : free borders
-aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
+aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
# create a group
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Free borders")
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Borders at Multiconnection
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeShell(FaceList)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections")
+mesh = smesh_builder.Mesh(box, "Mesh_borders_at_multi-connections")
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
# Criterion : Borders at multi-connection
nb_conn = 2
-aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, nb_conn)
+aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, nb_conn)
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
# create a group
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Borders at multi-connections")
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Length 1D
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeShell(FaceList)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-mesh = smesh.Mesh(box, "Mesh_Length_1D")
+mesh = smesh_builder.Mesh(box, "Mesh_Length_1D")
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
# Criterion : Length > 3.
length_margin = 3.
-aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length_margin)
+aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# print the result
# create a group
aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + repr(length_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Free Edges
-import SMESH_mechanic
-import SMESH
+from mechanic import *
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-aFilterMgr = smesh.CreateFilterManager()
+aFilterMgr = smesh_builder.CreateFilterManager()
# Remove some elements to obtain free edges
# Criterion : AREA > 95.
area_margin = 95.
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroupF.Add([aBorder.myElemId])
aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])
-
-salome.sg.updateObjBrowser()
# Free Nodes
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-mesh = smesh.Mesh(box, "Mesh_free_nodes")
+mesh = smesh_builder.Mesh(box, "Mesh_free_nodes")
algo = mesh.Segment()
algo.NumberOfSegments(10)
algo = mesh.Triangle(smeshBuilder.MEFISTO)
# Criterion : AREA < 80.
area_margin = 80.
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, area_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, area_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
mesh.RemoveElements(anIds)
# criterion : free nodes
-aFilter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
+aFilter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes)
anNodeIds = mesh.GetIdsFromFilter(aFilter)
# create a group
j = j + 1
pass
print("")
-
-salome.sg.updateObjBrowser()
# Free Faces
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-####### GEOM part ########
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
-Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
-Box_1 = geompy.GetMainShape(Box_1_vertex_6)
-Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
-Box_1 = geompy.GetMainShape(Box_1_vertex_16)
-Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
-Box_1 = geompy.GetMainShape(Box_1_vertex_11)
-Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
-Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
-
-Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
-Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
-Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
+####### GEOM part ########
-geompy.addToStudy( Box_1, "Box_1" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
-geompy.addToStudy( Plane_1, "Plane_1" )
-geompy.addToStudy( Partition_1, "Partition_1" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
-geompy.addToStudy( Plane_2, "Plane_2" )
+Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
+Box_1_vertex_6 = geom_builder.GetSubShape(Box_1, [6])
+Box_1 = geom_builder.GetMainShape(Box_1_vertex_6)
+Box_1_vertex_16 = geom_builder.GetSubShape(Box_1, [16])
+Box_1 = geom_builder.GetMainShape(Box_1_vertex_16)
+Box_1_vertex_11 = geom_builder.GetSubShape(Box_1, [11])
+Box_1 = geom_builder.GetMainShape(Box_1_vertex_11)
+Plane_1 = geom_builder.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
+Partition_1 = geom_builder.MakePartition([Box_1], [Plane_1], [], [], geom_builder.ShapeType["SOLID"], 0, [], 0)
+
+Box_1_vertex_19 = geom_builder.GetSubShape(Box_1, [19])
+Box_1_vertex_21 = geom_builder.GetSubShape(Box_1, [21])
+Plane_2 = geom_builder.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
+
+geom_builder.addToStudy( Box_1, "Box_1" )
+geom_builder.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
+geom_builder.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
+geom_builder.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
+geom_builder.addToStudy( Plane_1, "Plane_1" )
+geom_builder.addToStudy( Partition_1, "Partition_1" )
+geom_builder.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
+geom_builder.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
+geom_builder.addToStudy( Plane_2, "Plane_2" )
###### SMESH part ######
-Mesh_1 = smesh.Mesh(Partition_1)
+Mesh_1 = smesh_builder.Mesh(Partition_1)
Regular_1D = Mesh_1.Segment()
Max_Size_1 = Regular_1D.MaxSize(34.641)
MEFISTO_2D = Mesh_1.Triangle()
isDone = Mesh_1.Compute()
# create a group of free faces
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces )
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces )
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Free_faces")
print("")
#filter faces from plane 2
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2)
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup.Remove(aFaceIds)
# create a group of shared faces (located on partition boundary inside box)
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1)
aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Shared_faces")
aGroup.Add(aFaceIds)
-
-salome.sg.updateObjBrowser()
# Bare border faces
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-box = geompy.MakeBoxDXDYDZ(100, 100, 100)
-geompy.addToStudy( box, "box" )
+box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
+geom_builder.addToStudy( box, "box" )
-mesh = smesh.Mesh(box)
+mesh = smesh_builder.Mesh(box)
mesh.Segment().NumberOfSegments(3)
mesh.Quadrangle()
mesh.Compute()
# Bare border volumes
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-box = geompy.MakeBoxDXDYDZ(100, 30, 10)
+box = geom_builder.MakeBoxDXDYDZ(100, 30, 10)
# the smallest face of the box
-face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0]
+face = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["FACE"])[0]
-geompy.addToStudy( box, "box" )
-geompy.addToStudyInFather( box, face, "face" )
+geom_builder.addToStudy( box, "box" )
+geom_builder.addToStudyInFather( box, face, "face" )
-mesh = smesh.Mesh(box)
+mesh = smesh_builder.Mesh(box)
mesh.AutomaticHexahedralization();
# remove half of mesh faces from the smallest face
# Over-constrained faces
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+smesh_builder = smeshBuilder.New()
-mesh = smesh.Mesh()
-faceFilter = smesh.GetFilter(SMESH.FACE,SMESH.FT_OverConstrainedFace)
+mesh = smesh_builder.Mesh()
+faceFilter = smesh_builder.GetFilter(SMESH.FACE,SMESH.FT_OverConstrainedFace)
#make an edge
n1 = mesh.AddNode(0,0,0)
assert( not mesh.GetIdsFromFilter( faceFilter ))
# make faces
-mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 5)
+mesh.ExtrusionSweep([edge], smesh_builder.MakeDirStruct(0,7,0), 5)
assert( 5 == len( mesh.GetIdsFromFilter( faceFilter )))
# Over-constrained volumes
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+smesh_builder = smeshBuilder.New()
-mesh = smesh.Mesh()
-volumeFilter = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_OverConstrainedVolume)
+mesh = smesh_builder.Mesh()
+volumeFilter = smesh_builder.GetFilter(SMESH.VOLUME,SMESH.FT_OverConstrainedVolume)
# make volumes by extrusion of one face
n1 = mesh.AddNode(0,0,0)
n2 = mesh.AddNode(10,0,0)
edge = mesh.AddEdge([n1,n2])
-mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 1)
-mesh.ExtrusionSweep( mesh.GetElementsByType(SMESH.FACE), smesh.MakeDirStruct(0,0,5), 7)
+mesh.ExtrusionSweep([edge], smesh_builder.MakeDirStruct(0,7,0), 1)
+mesh.ExtrusionSweep( mesh.GetElementsByType(SMESH.FACE), smesh_builder.MakeDirStruct(0,0,5), 7)
assert( 7 == len( mesh.GetIdsFromFilter( volumeFilter )))
# Length 2D
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
+box = geom_builder.MakeShell(FaceList)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-mesh = smesh.Mesh(box, "Mesh_Length_2D")
+mesh = smesh_builder.Mesh(box, "Mesh_Length_2D")
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
# Criterion : Length 2D > 5.7
length_margin = 5.7
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, length_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, length_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + repr(length_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Borders at Multiconnection 2D
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a compound of two glued boxes
-box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-box2 = geompy.MakeTranslation(box1, 0., 20., 0)
-comp = geompy.MakeCompound([box1, box2])
-box = geompy.MakeGlueFaces(comp, 0.000001)
-idbox = geompy.addToStudy(box, "box")
+box1 = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.)
+box2 = geom_builder.MakeTranslation(box1, 0., 20., 0)
+comp = geom_builder.MakeCompound([box1, box2])
+box = geom_builder.MakeGlueFaces(comp, 0.000001)
+idbox = geom_builder.addToStudy(box, "box")
# create a mesh
-mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh")
+mesh = smesh_builder.Mesh(box, "Box compound : 2D triangle mesh")
algo = mesh.Segment()
algo.NumberOfSegments(5)
algo = mesh.Triangle()
# Criterion : MULTI-CONNECTION 2D = 3
nb_conn = 3
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, SMESH.FT_EqualTo, nb_conn)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, SMESH.FT_EqualTo, nb_conn)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + repr(nb_conn))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Area
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : AREA > 100.
area_margin = 100.
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + repr(area_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Taper
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : Taper > 3e-20
taper_margin = 3e-20
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, taper_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, taper_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + repr(taper_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Aspect Ratio
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : ASPECT RATIO > 1.8
ar_margin = 1.8
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, ar_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, ar_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + repr(ar_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Minimum Angle
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : MINIMUM ANGLE < 35.
min_angle = 35.
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, min_angle)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, min_angle)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Minimum Angle < " + repr(min_angle))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Warping
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : WARP ANGLE > 1e-15
wa_margin = 1e-15
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, wa_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, wa_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Warp > " + repr(wa_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Skew
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : Skew > 38.
skew_margin = 38.
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, skew_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, skew_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + repr(skew_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Element Diameter 2D
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
+from mechanic import *
# Criterion : ELEMENT DIAMETER 2D > 10
mel_2d_margin = 10
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, mel_2d_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, mel_2d_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + repr(mel_2d_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Aspect Ratio 3D
-import SMESH_mechanic_tetra
-import SMESH
-
-smesh = SMESH_mechanic_tetra.smesh
-mesh = SMESH_mechanic_tetra.mesh
-salome = SMESH_mechanic_tetra.salome
+from mechanic import *
# Criterion : ASPECT RATIO 3D > 4.5
ar_margin = 4.5
-aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_MoreThan, ar_margin)
+aFilter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_MoreThan, ar_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Aspect Ratio 3D > " + repr(ar_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Volume
-import SMESH_mechanic_tetra
-import SMESH
-
-smesh = SMESH_mechanic_tetra.smesh
-mesh = SMESH_mechanic_tetra.mesh
-salome = SMESH_mechanic_tetra.salome
+from mechanic import *
# Criterion : VOLUME < 7.
volume_margin = 7.
-aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_LessThan, volume_margin)
+aFilter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_LessThan, volume_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Volume < " + repr(volume_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
# Element Diameter 3D
-import SMESH_mechanic_tetra
-import SMESH
-
-smesh = SMESH_mechanic_tetra.smesh
-mesh = SMESH_mechanic_tetra.mesh
-salome = SMESH_mechanic_tetra.salome
+from mechanic import *
# Criterion : ELEMENT DIAMETER 3D > 10
mel_3d_margin = 10
-aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, mel_3d_margin)
+aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, mel_3d_margin)
anIds = mesh.GetIdsFromFilter(aFilter)
# create a group
aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + repr(mel_3d_margin))
aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser()
import salome
salome.salome_init_without_session()
+
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-# Create geometry: hollow sphere
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-sphere_1 = geompy.MakeSphereR( 100 )
-sphere_2 = geompy.MakeSphereR( 50 )
+# Create geometry: hollow sphere
-hollow_sphere = geompy.MakeCut( sphere_1, sphere_2, theName="hollow sphere")
+sphere_1 = geom_builder.MakeSphereR( 100 )
+sphere_2 = geom_builder.MakeSphereR( 50 )
-faces = geompy.ExtractShapes( hollow_sphere, geompy.ShapeType["FACE"] )
+hollow_sphere = geom_builder.MakeCut( sphere_1, sphere_2, theName="hollow sphere")
+faces = geom_builder.ExtractShapes( hollow_sphere, geom_builder.ShapeType["FACE"] )
# Create mesh
-mesh = smesh.Mesh( hollow_sphere, "Mesh of hollow sphere" )
+mesh = smesh_builder.Mesh( hollow_sphere, "Mesh of hollow sphere" )
# assign Global Radial Prism algorithm
prism_algo = mesh.Prism()
salome.salome_init_without_session()
from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# make a shape consisting of two quadranges
-OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
-OY1 = geompy.MakeTranslation( OY, 1, 0, 0 )
-OY2 = geompy.MakeTranslation( OY, 2, 0, 0 )
-q1 = geompy.MakeQuad2Edges( OY, OY1 )
-q2 = geompy.MakeQuad2Edges( OY1, OY2 )
+OY = geom_builder.MakeVectorDXDYDZ(0, 1, 0)
+OY1 = geom_builder.MakeTranslation( OY, 1, 0, 0 )
+OY2 = geom_builder.MakeTranslation( OY, 2, 0, 0 )
+q1 = geom_builder.MakeQuad2Edges( OY, OY1 )
+q2 = geom_builder.MakeQuad2Edges( OY1, OY2 )
-shape = geompy.Partition( [q1,q2], theName='shape' )
-ff = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"], theName="quad" )
+shape = geom_builder.Partition( [q1,q2], theName='shape' )
+ff = geom_builder.SubShapeAll( shape, geom_builder.ShapeType["FACE"], theName="quad" )
# mesh one quadrange with quadrangless and the other with triangles
-mesh = smesh.Mesh( shape )
+mesh = smesh_builder.Mesh( shape )
mesh.Segment().NumberOfSegments(1)
mesh.Quadrangle()
mesh.Triangle( ff[1] )
import salome
salome.salome_init_without_session()
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
import SMESHHOMARD
import salome
salome.salome_init_without_session()
-import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
import SMESHHOMARD
# ---------------------------------------------------------------------------
SET(BAD_TESTS
- 3dmesh.py
a3DmeshOnModified2Dmesh.py
creating_meshes_ex01.py
creating_meshes_ex03.py
filters_ex35.py
generate_flat_elements.py
modifying_meshes_ex26.py
+ mesh_3d.py
notebook_smesh.py
quality_controls_ex06.py
quality_controls_ex20.py
# Translation
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# define translation vector
vector = [-150., -150., 0.]
import math
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# define rotation axis and angle
axisXYZ = SMESH.AxisStruct(0., 0., 0., 5., 5., 20.)
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
-f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
+
+Box = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
+f = geom_builder.SubShapeAllSorted(Box, geom_builder.ShapeType["FACE"])
-Mesh1 = smesh.Mesh(f[0])
+Mesh1 = smesh_builder.Mesh(f[0])
Regular_1D = Mesh1.Segment()
Nb_Segments_1 = Regular_1D.NumberOfSegments(3)
Nb_Segments_1.SetDistrType( 0 )
# Symmetry
-import math
-
-import SMESH_mechanic
-import SMESH
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
+from mechanic import *
# create a symmetrical copy of the mesh mirrored through a point
axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0)
-mesh.Mirror([], axis, smesh.POINT, 1)
+mesh.Mirror([], axis, smesh_builder.POINT, 1)
# Merging Nodes
-import SMESH_mechanic, SMESH
-mesh = SMESH_mechanic.mesh
-smesh = SMESH_mechanic.smesh
+from mechanic import *
# criterion of coincidence
Tolerance = 4.0
# find close nodes of triangle elements only
-triangleFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE )
+triangleFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE )
GroupsOfNodesOfTriangles = mesh.FindCoincidentNodesOnPart([triangleFilter],Tolerance)
# prevent nodes located on geom edges from removal during merge:
mesh.MergeNodes(GroupsOfNodesOfTriangles, NodesToKeep=allSegs)
-
# find close nodes in the whole mesh
GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance)
# Merging Elements
-
import salome
salome.salome_init_without_session()
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a face to be meshed
-px = geompy.MakeVertex(100., 0. , 0. )
-py = geompy.MakeVertex(0. , 100., 0. )
-pz = geompy.MakeVertex(0. , 0. , 100.)
+px = geom_builder.MakeVertex(100., 0. , 0. )
+py = geom_builder.MakeVertex(0. , 100., 0. )
+pz = geom_builder.MakeVertex(0. , 0. , 100.)
-vxy = geompy.MakeVector(px, py)
-arc = geompy.MakeArc(py, pz, px)
+vxy = geom_builder.MakeVector(px, py)
+arc = geom_builder.MakeArc(py, pz, px)
-wire = geompy.MakeWire([vxy, arc])
+wire = geom_builder.MakeWire([vxy, arc])
isPlanarFace = 1
-face1 = geompy.MakeFace(wire, isPlanarFace)
-id_face1 = geompy.addToStudy(face1, "Face1")
+face1 = geom_builder.MakeFace(wire, isPlanarFace)
+id_face1 = geom_builder.addToStudy(face1, "Face1")
# create a circle to be an extrusion path
-px1 = geompy.MakeVertex( 100., 100., 0.)
-py1 = geompy.MakeVertex(-100., -100., 0.)
-pz1 = geompy.MakeVertex( 0., 0., 50.)
+px1 = geom_builder.MakeVertex( 100., 100., 0.)
+py1 = geom_builder.MakeVertex(-100., -100., 0.)
+pz1 = geom_builder.MakeVertex( 0., 0., 50.)
-circle = geompy.MakeCircleThreePnt(py1, pz1, px1)
-id_circle = geompy.addToStudy(circle, "Path")
+circle = geom_builder.MakeCircleThreePnt(py1, pz1, px1)
+id_circle = geom_builder.addToStudy(circle, "Path")
# create a 2D mesh on the face
-trias = smesh.Mesh(face1, "Face : 2D mesh")
+trias = smesh_builder.Mesh(face1, "Face : 2D mesh")
algo1D = trias.Segment()
algo1D.NumberOfSegments(6)
faceTriGroup = trias.Group( face1, "face triangles" )
# create a path mesh
-circlemesh = smesh.Mesh(circle, "Path mesh")
+circlemesh = smesh_builder.Mesh(circle, "Path mesh")
algo = circlemesh.Segment()
algo.NumberOfSegments(10)
circlemesh.Compute()
print("Edges : ", trias.NbEdges())
print("Faces : ", trias.NbFaces())
print("Volumes : ", trias.NbVolumes())
-
-salome.sg.updateObjBrowser()
# Sew Meshes Border to Side
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create two faces of a box
-box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.)
-facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+box1 = geom_builder.MakeBox(0., 0., -10., 30., 20., 25.)
+facesList1 = geom_builder.SubShapeAll(box1, geom_builder.ShapeType["FACE"])
face1 = facesList1[2]
-box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+box2 = geom_builder.MakeBox(0., 5., 0., 20., 20., 15.)
+facesList2 = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["FACE"])
face2 = facesList2[1]
-edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
+edgesList = geom_builder.SubShapeAll(face2, geom_builder.ShapeType["EDGE"])
edge1 = edgesList[2]
-aComp = geompy.MakeCompound([face1, face2])
-geompy.addToStudy(aComp, "Two faces")
+aComp = geom_builder.MakeCompound([face1, face2])
+geom_builder.addToStudy(aComp, "Two faces")
# create a mesh on two faces
-mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
+mesh = smesh_builder.Mesh(aComp, "Two faces : quadrangle mesh")
algo1D = mesh.Segment()
algo1D.NumberOfSegments(9)
# Sew Conform Free Borders
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create two faces of the box
-box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.)
-facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+box1 = geom_builder.MakeBox(0., 0., -10., 20., 20., 15.)
+facesList1 = geom_builder.SubShapeAll(box1, geom_builder.ShapeType["FACE"])
face1 = facesList1[2]
-box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+box2 = geom_builder.MakeBox(0., 5., 0., 20., 20., 15.)
+facesList2 = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["FACE"])
face2 = facesList2[1]
-edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
+edgesList = geom_builder.SubShapeAll(face2, geom_builder.ShapeType["EDGE"])
edge1 = edgesList[2]
-aComp = geompy.MakeCompound([face1, face2])
-geompy.addToStudy(aComp, "Two faces")
+aComp = geom_builder.MakeCompound([face1, face2])
+geom_builder.addToStudy(aComp, "Two faces")
# create a mesh on two faces
-mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
+mesh = smesh_builder.Mesh(aComp, "Two faces : quadrangle mesh")
algo1D = mesh.Segment()
algo1D.NumberOfSegments(9)
# Sew Free Borders
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# make two not sewed quadranges
-OY0 = geompy.MakeVectorDXDYDZ(0, 1, 0)
-OY1 = geompy.MakeTranslation( OY0, 1, 0, 0, theName="OY1" )
-OY2 = geompy.MakeTranslation( OY0, 1.01, 0, 0, theName="OY2" )
-OY3 = geompy.MakeTranslation( OY0, 2, 0, 0 )
-q1 = geompy.MakeQuad2Edges( OY0, OY1 )
-q2 = geompy.MakeQuad2Edges( OY2, OY3 )
+OY0 = geom_builder.MakeVectorDXDYDZ(0, 1, 0)
+OY1 = geom_builder.MakeTranslation( OY0, 1, 0, 0, theName="OY1" )
+OY2 = geom_builder.MakeTranslation( OY0, 1.01, 0, 0, theName="OY2" )
+OY3 = geom_builder.MakeTranslation( OY0, 2, 0, 0 )
+q1 = geom_builder.MakeQuad2Edges( OY0, OY1 )
+q2 = geom_builder.MakeQuad2Edges( OY2, OY3 )
-shape = geompy.MakeCompound( [q1,q2], theName='shape' )
+shape = geom_builder.MakeCompound( [q1,q2], theName='shape' )
# make a non-uniform quadrangle mesh on two faces
-mesh = smesh.Mesh(shape, "Two faces : quadrangle mesh")
+mesh = smesh_builder.Mesh(shape, "Two faces : quadrangle mesh")
mesh.Segment().Arithmetic1D( 0.1, 0.4 )
mesh.Segment(q1).NumberOfSegments( 5 )
mesh.Quadrangle()
CreatePolygons, CreatePolyedrs )
print(res)
print("nb polygons:", mesh.NbPolygons())
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create two boxes
-box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.)
-box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
+box1 = geom_builder.MakeBox(0., 0., 0., 10., 10., 10.)
+box2 = geom_builder.MakeBox(0., 15., 0., 20., 25., 10.)
-EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
+EdgesList = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["EDGE"])
-aComp = geompy.MakeCompound([box1, box2])
-geompy.addToStudy(aComp, "Two boxes")
+aComp = geom_builder.MakeCompound([box1, box2])
+geom_builder.addToStudy(aComp, "Two boxes")
# create a mesh on two boxes
-mesh = smesh.Mesh(aComp, "Sew Side Elements")
+mesh = smesh_builder.Mesh(aComp, "Sew Side Elements")
algo1D = mesh.Segment()
algo1D.NumberOfSegments(2)
# sew side elements
# find elements to sew
-face1 = geompy.GetFaceNearPoint( aComp, geompy.MakeVertex( 5, 10, 5 ))
+face1 = geom_builder.GetFaceNearPoint( aComp, geom_builder.MakeVertex( 5, 10, 5 ))
IDsOfSide1Elements = mesh.GetSubMeshElementsId( face1 )
print("side faces 1:",IDsOfSide1Elements)
-face1Translated = geompy.MakeTranslation( face1, 0,5,0 )
-faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated )
+face1Translated = geom_builder.MakeTranslation( face1, 0,5,0 )
+faceFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated )
IDsOfSide2Elements = mesh.GetIdsFromFilter( faceFilter )
print("side faces 2:",IDsOfSide2Elements)
# find corresponding nodes on sides
-edge1 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 10, 5 ))
+edge1 = geom_builder.GetEdgeNearPoint( aComp, geom_builder.MakeVertex( 0, 10, 5 ))
segs1 = mesh.GetSubMeshElementsId( edge1 ) # mesh segments generated on edge1
NodeID1OfSide1ToMerge = mesh.GetElemNode( segs1[0], 0 )
NodeID2OfSide1ToMerge = mesh.GetElemNode( segs1[0], 1 )
print("nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge])
-edge2 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 15, 5 ))
+edge2 = geom_builder.GetEdgeNearPoint( aComp, geom_builder.MakeVertex( 0, 15, 5 ))
segs2 = mesh.GetSubMeshElementsId( edge2 ) # mesh segments generated on edge2
NodeID1OfSide2ToMerge = mesh.GetElemNode( segs2[0], 0 )
NodeID2OfSide2ToMerge = mesh.GetElemNode( segs2[0], 1 )
# Duplicate nodes or/and elements
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-
import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Create a box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.)
# Define hexa mesh on a box
-mesh = smesh.Mesh(box, "Mesh")
+mesh = smesh_builder.Mesh(box, "Mesh")
mesh.Segment().NumberOfSegments(7)
mesh.Quadrangle()
mesh.Hexahedron()
# Duplicate two first edges of the mesh
mesh.DoubleElements([ 1, 2 ])
-
-# Update object browser
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser()
# Create boundary elements
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
-box = geompy.MakeBoxDXDYDZ(100, 100, 100)
-gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBoxDXDYDZ(100, 100, 100)
+gFaces = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])
f1,f2 = gFaces[0],gFaces[1]
-geompy.addToStudy(box,"box")
-geompy.addToStudyInFather(box,f1,"face1")
-geompy.addToStudyInFather(box,f2,"face2")
+geom_builder.addToStudy(box,"box")
+geom_builder.addToStudyInFather(box,f1,"face1")
+geom_builder.addToStudyInFather(box,f2,"face2")
-twoFaces = geompy.MakeCompound([f1,f2])
+twoFaces = geom_builder.MakeCompound([f1,f2])
## -----------
##
## -----------
dim = SMESH.BND_2DFROM3D
-init_mesh = smesh.Mesh(box, "box")
+init_mesh = smesh_builder.Mesh(box, "box")
init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
# remove some faces
init_mesh.RemoveElements( rm_face )
# restore boundary in this mesh
-mesh = smesh.CopyMesh( init_mesh, "2D from 3D")
+mesh = smesh_builder.CopyMesh( init_mesh, "2D from 3D")
groupName = "bnd 2D"
nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
meshName = init_mesh.GetName() + " + boundary"
nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
-
## -----------
##
## 1D from 2D
## -----------
dim = SMESH.BND_1DFROM2D
-init_mesh = smesh.Mesh(f1, "2D mesh")
+init_mesh = smesh_builder.Mesh(f1, "2D mesh")
init_mesh.AutomaticHexahedralization()
# remove some edges
# restore boundary edges in this mesh
-mesh = smesh.CopyMesh( init_mesh, "1D from 2D")
+mesh = smesh_builder.CopyMesh( init_mesh, "1D from 2D")
groupName = "bnd 1D"
nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
meshName = init_mesh.GetName() + " + boundary"
nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
-
-
## ------------------
##
## 1D from 2D GROUPS
## ------------------
dim = SMESH.BND_1DFROM3D
-init_mesh = smesh.Mesh(box, "box")
+init_mesh = smesh_builder.Mesh(box, "box")
init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
# remove all edges
rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
fGroup2 = init_mesh.Group( f2, "f2" )
# make 1D boundary around groups in this mesh
-mesh = smesh.CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
+mesh = smesh_builder.CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
groups = mesh.GetGroups()
nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
# Reorient faces
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a geometry consisting of two faces
-box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
-faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 )
+faces = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["FACE"])
-shape = geompy.MakeCompound( faces[:2] )
-faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] )
-geompy.addToStudy( shape, "shape")
-geompy.addToStudyInFather( shape, faces[0], "faces[0]")
-geompy.addToStudyInFather( shape, faces[1], "faces[1]")
+shape = geom_builder.MakeCompound( faces[:2] )
+faces = geom_builder.SubShapeAll( shape, geom_builder.ShapeType["FACE"] )
+geom_builder.addToStudy( shape, "shape")
+geom_builder.addToStudyInFather( shape, faces[0], "faces[0]")
+geom_builder.addToStudyInFather( shape, faces[1], "faces[1]")
# create a 2D mesh
-mesh = smesh.Mesh( shape, "test_Reorient2D")
+mesh = smesh_builder.Mesh( shape, "test_Reorient2D")
mesh.AutomaticHexahedralization(0.5)
localAlgo = mesh.Segment(faces[0])
localAlgo.NumberOfSegments( 11 )
mesh.Compute()
group = mesh.Group( faces[1] )
-vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 )
+vec = geom_builder.MakeVectorDXDYDZ( 1, 1, 1 )
# ============
# Reorient2D()
# 2DObject - a sub-mesh
# Direction - components of a vector
# FaceOrPoint - a GEOM object (vertex)
-mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec ))
+mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geom_builder.GetFirstVertex( vec ))
#
# 2DObject - a group of faces
# Direction - a SMESH.DirStruct structure
# FaceOrPoint - coordinates of a point
-mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0])
+mesh.Reorient2D( group, smesh_builder.MakeDirStruct( -10, 1, 10 ), [0,0,0])
#
# FaceOrPoint - a SMESH.PointStruct structure
mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0))
# Use Reorient2DBy3D() to orient faces of 2 geom faces to have their normal pointing inside volumes
-mesh3D = smesh.Mesh( box, '3D mesh')
+mesh3D = smesh_builder.Mesh( box, '3D mesh')
mesh3D.AutomaticHexahedralization(0.5)
group0 = mesh3D.Group( faces[0] )
group1 = mesh3D.Group( faces[1] )
# orient the reversed faces back
nbRev = mesh3D.Reorient2DBy3D( mesh3D, mesh3D, theOutsideNormal=True)
print("Nb re-reoriented faces:", nbRev)
-
# Usage of "Use Faces to be Created Manually" algorithm
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
-import salome_notebook
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# define my 2D algorithm
-def my2DMeshing(geomFace, geom_builder, smesh_builder):
+def my2DMeshing(geomFace, mesh):
import numpy as np
# find gravity center of geomFace
nodes = []
for edge, isForward in sortedEdges:
v1,v2 = geom_builder.SubShapeAll( edge, geom_builder.ShapeType["VERTEX"])
- edgeNodes = smesh_builder.GetSubMeshNodesId( v2, all=False ) + \
- smesh_builder.GetSubMeshNodesId( edge, all=False ) + \
- smesh_builder.GetSubMeshNodesId( v1, all=False )
+ edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \
+ mesh.GetSubMeshNodesId( edge, all=False ) + \
+ mesh.GetSubMeshNodesId( v1, all=False )
if not isForward: edgeNodes.reverse()
nodes.extend( edgeNodes[:-1] )
r2 = 1 - r1
nodesInside = []
for n in nodes:
- nXYZ = smesh_builder.GetNodeXYZ( n )
+ nXYZ = mesh.GetNodeXYZ( n )
newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ ))
- nodesInside.append( smesh_builder.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] ))
- smesh_builder.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 )
+ nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] ))
+ mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 )
# find out orientation of faces to create
# geomFace normal
if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face
faceNormXYZ = np.multiply( -1., faceNormXYZ )
# mesh face normal
- e1 = np.subtract( smesh_builder.GetNodeXYZ( nodes[0] ), smesh_builder.GetNodeXYZ( nodes[1] ))
- e2 = np.subtract( smesh_builder.GetNodeXYZ( nodes[0] ), smesh_builder.GetNodeXYZ( nodesInside[0] ))
+ e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] ))
+ e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] ))
meshNorm = np.cross( e1, e2 )
# faces orientation
reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 )
n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1]
iN -= 1
if reverse:
- f = smesh_builder.AddFace( [n1, n2, n3, n4] )
+ f = mesh.AddFace( [n1, n2, n3, n4] )
else:
- f = smesh_builder.AddFace( [n4, n3, n2, n1] )
+ f = mesh.AddFace( [n4, n3, n2, n1] )
# new faces must be assigned to geometry to allow 3D algorithm finding them
- smesh_builder.SetMeshElementOnShape( f, geomFace )
+ mesh.SetMeshElementOnShape( f, geomFace )
if reverse:
nodesInside.reverse()
- polygon = smesh_builder.AddPolygonalFace( nodesInside )
- smesh_builder.SetMeshElementOnShape( polygon, geomFace )
+ polygon = mesh.AddPolygonalFace( nodesInside )
+ mesh.SetMeshElementOnShape( polygon, geomFace )
return
# create geometry and get faces to mesh with my2DMeshing()
-box = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
-f1 = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0]
-f2 = geompy.GetOppositeFace( box, f1 )
-geompy.addToStudy( box, "box" )
-geompy.addToStudy( f1, "f1" )
-geompy.addToStudy( f2, "f2" )
+box = geom_builder.MakeBoxDXDYDZ( 100, 100, 100 )
+f1 = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0]
+f2 = geom_builder.GetOppositeFace( box, f1 )
+geom_builder.addToStudy( box, "box" )
+geom_builder.addToStudy( f1, "f1" )
+geom_builder.addToStudy( f2, "f2" )
# compute 1D mesh
-mesh = smesh.Mesh( box )
+mesh = smesh_builder.Mesh( box )
mesh.Segment().NumberOfSegments( 5 )
mesh.Compute()
mesh.Quadrangle()
mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing();
mesh.UseExistingFaces(f2) # assign UseExistingFaces() BEFORE calling my2DMeshing()!
-my2DMeshing(f1, geom_builder=geompy, smesh_builder=mesh)
-my2DMeshing(f2, geom_builder=geompy, smesh_builder=mesh)
+my2DMeshing(f1, mesh)
+my2DMeshing(f2, mesh)
assert mesh.Compute()
# compute 3D mesh
# Viewing Mesh Infos
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# create a box
-box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
-geompy.addToStudy(box, "box")
-[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+box = geom_builder.MakeBox(0., 0., 0., 20., 20., 20.)
+geom_builder.addToStudy(box, "box")
+[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
+tetra = smesh_builder.Mesh(box, "MeshBox")
algo1D = tetra.Segment()
algo1D.NumberOfSegments(3)
# Get Information About Mesh by GetMeshInfo
print("\nInformation about mesh by GetMeshInfo:")
-info = smesh.GetMeshInfo(tetra)
+info = smesh_builder.GetMeshInfo(tetra)
keys = list(info.keys()); keys.sort()
for i in keys:
print(" %s : %d" % ( i, info[i] ))
# Get Information About Group by GetMeshInfo
print("\nInformation about group by GetMeshInfo:")
-info = smesh.GetMeshInfo(group)
+info = smesh_builder.GetMeshInfo(group)
keys = list(info.keys()); keys.sort()
for i in keys:
print(" %s : %d" % ( i, info[i] ))
# Get Information About SubMesh by GetMeshInfo
print("\nInformation about Submesh by GetMeshInfo:")
-info = smesh.GetMeshInfo(submesh)
+info = smesh_builder.GetMeshInfo(submesh)
keys = list(info.keys()); keys.sort()
for i in keys:
print(" %s : %d" % ( i, info[i] ))
# Find Element by Point
-
import salome
salome.salome_init_without_session()
-import GEOM
-from salome.geom import geomBuilder
-geompy = geomBuilder.New()
-import SMESH, SALOMEDS
+import SMESH
+from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New()
+
+geom_builder = geomBuilder.New()
+smesh_builder = smeshBuilder.New()
# Create a geometry to mesh
-box = geompy.MakeBoxDXDYDZ(100,100,100)
+box = geom_builder.MakeBoxDXDYDZ(100,100,100)
# Create a mesh
-mesh = smesh.Mesh(box,"Mesh")
+mesh = smesh_builder.Mesh(box,"Mesh")
mesh.AutomaticHexahedralization()
mesh.Compute()
Example of 3d mesh generation:
##############################
-.. literalinclude:: ../../examples/3dmesh.py
+.. literalinclude:: ../../examples/mesh_3d.py
:language: python
-:download:`Download this script <../../examples/3dmesh.py>`
+:download:`Download this script <../../examples/mesh_3d.py>`
Examples of Python scripts for Mesh operations are available by
the following links: