X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Fsalome%2Fgui%2FSMESH%2Finput%2Ftui_modifying_meshes.doc;h=1dd65bfa111a59f7759b36f7846b6f8d8d2a452d;hb=d992d85973a627445c091bd3f6df766b4990b282;hp=66b6361fa0b724214ad4fc2481bc234471388625;hpb=2daa321efae3d0c6ce41199fa5a2482630d505d9;p=modules%2Fsmesh.git diff --git a/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc b/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc index 66b6361fa..1dd65bfa1 100644 --- a/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc @@ -22,6 +22,26 @@ if new_id == 0: print "KO node addition." else: print "New Node has been added with ID ", new_id \endcode +
+\anchor tui_add_0DElement +

Add 0D Element

+ +\code +import SMESH_mechanic + +mesh = SMESH_mechanic.mesh + +# add node +node_id = mesh.AddNode(50, 10, 0) + +# add 0D Element +new_id = mesh.Add0DElement(node_id) + +print "" +if new_id == 0: print "KO node addition." +else: print "New 0D Element has been added with ID ", new_id +\endcode +
\anchor tui_add_edge

Add Edge

@@ -262,35 +282,40 @@ else: print "KO Elements removing." \endcode
-\anchor tui_renumbering_nodes_and_elements -

Renumbering Nodes and Elements

+\anchor tui_removing_orphan_nodes +

Removing Orphan Nodes

\code import SMESH_mechanic mesh = SMESH_mechanic.mesh -mesh.RenumberNodes() - -mesh.RenumberElements() +# add orphan nodes +mesh.AddNode(0,0,0) +mesh.AddNode(1,1,1) +# remove just created orphan nodes +res = mesh.RemoveOrphanNodes() +if res == 1: print "Removed %d nodes!" % res +else: print "KO nodes removing." \endcode
-\anchor tui_moving_nodes -

Moving Nodes

+\anchor tui_renumbering_nodes_and_elements +

Renumbering Nodes and Elements

\code import SMESH_mechanic mesh = SMESH_mechanic.mesh -# move node #38 -mesh.MoveNode(38, 20., 10., 0.) +mesh.RenumberNodes() + +mesh.RenumberElements() \endcode
-\anchor tui_mesh_through_point -

Mesh through point

+\anchor tui_moving_nodes +

Moving Nodes

\code from geompy import * @@ -324,16 +349,11 @@ n = mesh.FindNodeClosestTo( -1,-1,-1 ) if not n == node000: raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 ) -# check if any node will be found for a point inside a box -n = mesh.FindNodeClosestTo( 100, 100, 100 ) -if not n > 0: - raise "FindNodeClosestTo( 100, 100, 100 ) fails" - # move node000 to a new location x,y,z = -10, -10, -10 -n = mesh.MeshToPassThroughAPoint( x,y,z ) -if not n == node000: - raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 ) +n = mesh.MoveNode( n,x,y,z ) +if not n: + raise "MoveNode() returns " + n # check the coordinates of the node000 xyz = mesh.GetNodeXYZ( node000 ) @@ -768,7 +788,6 @@ mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) \code import geompy - import smesh # define the geometry @@ -802,17 +821,100 @@ algo2D.MaxElementArea(240) isDone = Mesh_2.Compute() if not isDone: print 'Mesh Mesh_2 : computation failed' -# create a pattern +# create a 2d pattern pattern = smesh.GetPattern() isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0) if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode() # apply the pattern to a face of the first mesh -pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), [17], 0, 0) - +facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE) +print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit)) +pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0) isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0) if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode() + +# create quadrangle mesh +Mesh_3 = smesh.Mesh(Box_1) +Mesh_3.Segment().NumberOfSegments(1) +Mesh_3.Quadrangle() +Mesh_3.Hexahedron() +isDone = Mesh_3.Compute() +if not isDone: print 'Mesh Mesh_3 : computation failed' + +# create a 3d pattern (hexahedrons) +pattern_hexa = smesh.GetPattern() + +smp_hexa = """!!! Nb of points: +15 + 0 0 0 !- 0 + 1 0 0 !- 1 + 0 1 0 !- 2 + 1 1 0 !- 3 + 0 0 1 !- 4 + 1 0 1 !- 5 + 0 1 1 !- 6 + 1 1 1 !- 7 + 0.5 0 0.5 !- 8 + 0.5 0 1 !- 9 + 0.5 0.5 0.5 !- 10 + 0.5 0.5 1 !- 11 + 1 0 0.5 !- 12 + 1 0.5 0.5 !- 13 + 1 0.5 1 !- 14 + !!! Indices of points of 4 elements: + 8 12 5 9 10 13 14 11 + 0 8 9 4 2 10 11 6 + 2 10 11 6 3 13 14 7 + 0 1 12 8 2 3 13 10""" + +pattern_hexa.LoadFromFile(smp_hexa) + +# apply the pattern to a mesh +volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME) +print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit)) +pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3) +isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True) +if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode() + +# create one more quadrangle mesh +Mesh_4 = smesh.Mesh(Box_1) +Mesh_4.Segment().NumberOfSegments(1) +Mesh_4.Quadrangle() +Mesh_4.Hexahedron() +isDone = Mesh_4.Compute() +if not isDone: print 'Mesh Mesh_4 : computation failed' + +# create another 3d pattern (pyramids) +pattern_pyra = smesh.GetPattern() + +smp_pyra = """!!! Nb of points: +9 + 0 0 0 !- 0 + 1 0 0 !- 1 + 0 1 0 !- 2 + 1 1 0 !- 3 + 0 0 1 !- 4 + 1 0 1 !- 5 + 0 1 1 !- 6 + 1 1 1 !- 7 + 0.5 0.5 0.5 !- 8 + !!! Indices of points of 6 elements: + 0 1 5 4 8 + 7 5 1 3 8 + 3 2 6 7 8 + 2 0 4 6 8 + 0 2 3 1 8 + 4 5 7 6 8""" + +pattern_pyra.LoadFromFile(smp_pyra) + +# apply the pattern to a face mesh +volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME) +print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit)) +pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0) +isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True) +if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode() \endcode
@@ -857,6 +959,13 @@ Mesh.ConvertFromQuadratic() Mesh.ConvertToQuadratic( theForce3d=0 ) +# to convert not the whole mesh but a sub-mesh, provide it as +# an additional argument to the functions: +# Mesh.ConvertToQuadratic( 0, subMesh ) +# Mesh.ConvertFromQuadratic( subMesh ) +# +# Note that the mesh becomes non-conformal at conversion of sub-mesh. + \endcode */