2013-02-12 20:37:44 +06:00
|
|
|
# Moving Nodes
|
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import salome
|
2021-08-12 14:38:10 +05:00
|
|
|
salome.salome_init_without_session()
|
2016-08-24 19:04:22 +05:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
from salome.geom import geomBuilder
|
|
|
|
from salome.smesh import smeshBuilder
|
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
geom_builder = geomBuilder.New()
|
|
|
|
smesh_builder = smeshBuilder.New()
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
box = geom_builder.MakeBoxDXDYDZ(200, 200, 200)
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2022-04-11 18:28:01 +05:00
|
|
|
mesh = smesh_builder.Mesh( box )
|
2013-02-12 20:37:44 +06:00
|
|
|
mesh.Segment().AutomaticLength(0.1)
|
|
|
|
mesh.Quadrangle()
|
2023-02-21 18:59:44 +05:00
|
|
|
if not mesh.Compute(): raise Exception("Error when computing Mesh")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2016-08-24 19:04:22 +05:00
|
|
|
# find node at (0,0,0) which is located on a geom vertex
|
2013-02-12 20:37:44 +06:00
|
|
|
node000 = None
|
2022-04-11 18:28:01 +05:00
|
|
|
for vId in geom_builder.SubShapeAllIDs( box, geom_builder.ShapeType["VERTEX"]):
|
2013-02-12 20:37:44 +06:00
|
|
|
if node000: break
|
|
|
|
nodeIds = mesh.GetSubMeshNodesId( vId, True )
|
|
|
|
for node in nodeIds:
|
|
|
|
xyz = mesh.GetNodeXYZ( node )
|
|
|
|
if xyz[0] == 0 and xyz[1] == 0 and xyz[2] == 0 :
|
|
|
|
node000 = node
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
if not node000:
|
2017-03-29 18:54:42 +05:00
|
|
|
raise Exception("node000 not found")
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2016-08-24 19:04:22 +05:00
|
|
|
# find node000 using a dedicated function
|
2013-02-12 20:37:44 +06:00
|
|
|
n = mesh.FindNodeClosestTo( -1,-1,-1 )
|
|
|
|
if not n == node000:
|
2017-03-20 17:27:30 +05:00
|
|
|
raise Exception("FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 ))
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# move node000 to a new location
|
|
|
|
x,y,z = -10, -10, -10
|
|
|
|
n = mesh.MoveNode( n,x,y,z )
|
|
|
|
if not n:
|
2017-03-20 17:27:30 +05:00
|
|
|
raise Exception("MoveNode() returns " + n)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# check the coordinates of the node000
|
|
|
|
xyz = mesh.GetNodeXYZ( node000 )
|
|
|
|
if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) :
|
2017-03-20 17:27:30 +05:00
|
|
|
raise Exception("Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] ))
|