PR: examples adaptation

This commit is contained in:
prascle 2013-03-14 08:43:02 +00:00
parent 682bea02c0
commit 1d6c201310
22 changed files with 232 additions and 98 deletions

View File

@ -1,7 +1,14 @@
# Arithmetic 1D
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a box
box = geompy.MakeBoxDXDYDZ(10., 10., 10.)

View File

@ -1,7 +1,14 @@
# Deflection 1D and Number of Segments
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a face from arc and straight segment
px = geompy.MakeVertex(100., 0. , 0. )

View File

@ -1,16 +1,23 @@
# Start and End Length
from geompy import *
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a box
box = MakeBoxDXDYDZ(10., 10., 10.)
addToStudy(box, "Box")
box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
geompy.addToStudy(box, "Box")
# get one edge of the box to put local hypothesis on
p5 = MakeVertex(5., 0., 0.)
EdgeX = GetEdgeNearPoint(box, p5)
addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
p5 = geompy.MakeVertex(5., 0., 0.)
EdgeX = geompy.GetEdgeNearPoint(box, p5)
geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
hexa = smesh.Mesh(box, "Box : hexahedrical mesh")

View File

@ -1,16 +1,23 @@
# Local Length
from geompy import *
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a box
box = MakeBoxDXDYDZ(10., 10., 10.)
addToStudy(box, "Box")
box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
geompy.addToStudy(box, "Box")
# get one edge of the box to put local hypothesis on
p5 = MakeVertex(5., 0., 0.)
EdgeX = GetEdgeNearPoint(box, p5)
addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
p5 = geompy.MakeVertex(5., 0., 0.)
EdgeX = geompy.GetEdgeNearPoint(box, p5)
geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
hexa = smesh.Mesh(box, "Box : hexahedrical mesh")

View File

@ -1,8 +1,14 @@
# Maximum Element Area
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a face
px = geompy.MakeVertex(100., 0. , 0. )

View File

@ -1,7 +1,14 @@
# Maximum Element Volume
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a cylinder
cyl = geompy.MakeCylinderRH(30., 50.)

View File

@ -1,7 +1,14 @@
# Length from Edges
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create sketchers
sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")

View File

@ -1,16 +1,23 @@
# Propagation
from geompy import *
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a box
box = MakeBoxDXDYDZ(10., 10., 10.)
addToStudy(box, "Box")
box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
geompy.addToStudy(box, "Box")
# get one edge of the box to put local hypothesis on
p5 = MakeVertex(5., 0., 0.)
EdgeX = GetEdgeNearPoint(box, p5)
addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
p5 = geompy.MakeVertex(5., 0., 0.)
EdgeX = geompy.GetEdgeNearPoint(box, p5)
geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
hexa = smesh.Mesh(box, "Box : hexahedrical mesh")

View File

@ -1,7 +1,14 @@
# Defining Meshing Algorithms
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create a box
box = geompy.MakeBoxDXDYDZ(10., 10., 10.)

View File

@ -2,7 +2,15 @@
# Project prisms from one meshed box to another mesh on the same box
from smesh import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Prepare geometry
@ -36,7 +44,7 @@ geompy.addToStudyInFather( box, edgesF2, "edgesF2" )
# Make the source mesh with prisms
src_mesh = Mesh(box, "Source mesh")
src_mesh = smesh.Mesh(box, "Source mesh")
src_mesh.Segment().NumberOfSegments(9,10)
src_mesh.Quadrangle()
src_mesh.Hexahedron()
@ -47,7 +55,7 @@ src_mesh.Compute()
# Mesh the box using projection algoritms
# Define the same global 1D and 2D hypotheses
tgt_mesh = Mesh(box, "Target mesh")
tgt_mesh = smesh.Mesh(box, "Target mesh")
tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True)
tgt_mesh.Quadrangle()
@ -73,4 +81,4 @@ proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 )
tgt_mesh.Compute()
# Move the source mesh to visualy compare the two meshes
src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False)
src_mesh.TranslateObject( src_mesh, smesh.MakeDirStruct( 210, 0, 0 ), Copy=False)

View File

@ -2,7 +2,15 @@
# Project triangles from one meshed face to another mesh on the same box
from smesh import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Prepare geometry
@ -20,7 +28,7 @@ geompy.addToStudyInFather( box, Face_1, 'Face_1' )
geompy.addToStudyInFather( box, Face_2, 'Face_2' )
# Make the source mesh with Netgem2D
src_mesh = Mesh(Face_1, "Source mesh")
src_mesh = smesh.Mesh(Face_1, "Source mesh")
src_mesh.Segment().NumberOfSegments(15)
src_mesh.Triangle()
src_mesh.Compute()

View File

@ -1,8 +1,14 @@
# 1D Mesh with Fixed Points example
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import StdMeshers
# Create face and explode it on edges

View File

@ -1,8 +1,14 @@
# Radial Quadrangle 1D2D example
from smesh import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
SetCurrentStudy(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# 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])
@ -16,7 +22,7 @@ geompy.addToStudyInFather(Face, circle,"circle")
# Define geometry for mesh, and Radial Quadrange algorithm
mesh = smesh.Mesh(Face)
radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD)
radial_Quad_algo = mesh.Quadrangle(algo=smeshBuilder.RADIAL_QUAD)
# The Radial Quadrange algorithm can work without any hypothesis
# In this case it uses "Default Nb of Segments" preferences parameter to discretize edges

View File

@ -1,7 +1,14 @@
# Quadrangle Parameters example 1 (meshing a face with 3 edges)
from smesh import *
SetCurrentStudy(salome.myStudy)
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Get 1/4 part from the disk face.
Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100)

View File

@ -1,7 +1,14 @@
# Quadrangle Parameters example 2 (using different types)
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import StdMeshers
# Make quadrangle face and explode it on edges.

View File

@ -1,7 +1,14 @@
# "Use Existing Elements" example
from smesh import *
SetCurrentStudy(salome.myStudy)
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Make a patritioned box
@ -23,15 +30,15 @@ geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
# Mesh one of boxes with quadrangles. It is a source mesh
srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin
srcMesh = smesh.Mesh(boxes[0], "source mesh") # box coloser to CS origin
nSeg1 = srcMesh.Segment().NumberOfSegments(4)
srcMesh.Quadrangle()
srcMesh.Compute()
srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE )
srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", SMESH.FACE )
# Import faces from midFace0 to the target mesh
tgtMesh = Mesh(boxes[1], "target mesh")
tgtMesh = smesh.Mesh(boxes[1], "target mesh")
importAlgo = tgtMesh.UseExisting2DElements(midFace1)
import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
tgtMesh.Segment().NumberOfSegments(3)

View File

@ -1,7 +1,14 @@
# Viscous layers construction
from smesh import *
SetCurrentStudy(salome.myStudy)
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
X = geompy.MakeVectorDXDYDZ( 1,0,0 )
O = geompy.MakeVertex( 100,50,50 )
@ -19,7 +26,7 @@ geompy.addToStudy( shape, "shape" )
geompy.addToStudyInFather( shape, face1, "face1")
mesh = Mesh(shape, "CFD")
mesh = smesh.Mesh(shape, "CFD")
mesh.Segment().NumberOfSegments( 4 )
@ -35,6 +42,6 @@ layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFa
mesh.Compute()
mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA)
mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID)
mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA)
mesh.MakeGroup("Tetras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_TETRA)
mesh.MakeGroup("Pyras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PYRAMID)
mesh.MakeGroup("Prims",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PENTA)

View File

@ -28,8 +28,14 @@
#-------------------------------------------------------------------------
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import StdMeshers

View File

@ -21,8 +21,15 @@
# =======================================
# Procedure that take a triangulation and split all triangles in 4 others triangles
#
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import os
@ -81,10 +88,10 @@ def triangle(m, f, n1, n2, n3):
def SplitTrianglesIn4(m):
# Get all triangles
triangles = m.GetElementsByType(smesh.FACE)
triangles = m.GetElementsByType(SMESH.FACE)
# Remove all edges
m.RemoveElements(m.GetElementsByType(smesh.EDGE))
m.RemoveElements(m.GetElementsByType(SMESH.EDGE))
# Get the list of nodes (ids) associated with the CAD vertices
shape = m.GetShape()
@ -222,4 +229,4 @@ MyMesh.ExportMED(path+str(NbCells4)+"_triangles.med", 0)
# Update the object browser
# -------------------------
geompy.salome.sg.updateObjBrowser(1)
salome.sg.updateObjBrowser(1)

View File

@ -18,18 +18,17 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
import sys
import salome
import geompy
import math
import SALOMEDS
import SMESH
import smesh
salome.salome_init()
aStudyId = salome.myStudy._get_StudyId()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import math
geompy.init_geom(salome.myStudy)
global Face_1
Face_1 = geompy.MakeFaceHW(100, 100, 1)
geompy.addToStudy( Face_1, "Face_1" )
@ -51,7 +50,7 @@ aListOfElems = [ 52, 53, 54, 55, 56, 57,
72, 73, 74, 75, 76, 77,
82, 83, 84, 85, 86, 87 ]
aRedGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Red" )
aRedGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Red" )
aRedGroup.Add( aListOfElems );
aRedGroup.SetColor( SALOMEDS.Color( 1, 0, 0 ) )
@ -64,7 +63,7 @@ aListOfElems = [ 55, 56, 57, 58, 59,
115, 116, 117, 118, 119,
125, 126, 127, 128, 129 ]
aGreenGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Green" )
aGreenGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Green" )
aGreenGroup.Add( aListOfElems );
aGreenGroup.SetColor( SALOMEDS.Color( 0, 1, 0 ) )
@ -75,7 +74,7 @@ aListOfElems = [ 63, 64, 65, 66, 67, 68,
103, 104, 105, 106, 107, 108,
113, 114, 115, 116, 117, 118 ]
aBlueGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Blue" )
aBlueGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Blue" )
aBlueGroup.Add( aListOfElems );
aBlueGroup.SetColor( SALOMEDS.Color( 0, 0, 1 ) )

View File

@ -22,8 +22,15 @@
#
import os
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Parameters
# ----------
@ -53,7 +60,7 @@ m = smesh.Mesh(cylinder)
# 2D mesh with BLSURF
# -------------------
algo2d = m.Triangle(smesh.BLSURF)
algo2d = m.Triangle(smeshBuilder.BLSURF)
algo2d.SetPhysicalMesh(1)
algo2d.SetPhySize(5)
@ -63,7 +70,7 @@ algo2d.SetGeometricMesh(0)
# 3D mesh with tepal
# ------------------
algo3d = m.Tetrahedron(smesh.GHS3DPRL)
algo3d = m.Tetrahedron(smeshBuilder.GHS3DPRL)
algo3d.SetMEDName(results)
algo3d.SetNbPart(4)

View File

@ -18,20 +18,17 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
import sys
import salome
import geompy
import math
import SALOMEDS
import SMESH
import smesh
salome.salome_init()
aStudyId = salome.myStudy._get_StudyId()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
geompy.init_geom(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import math
geompy.init_geom(salome.myStudy)
global Box_1
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
geompy.addToStudy( Box_1, "Box_1" )
@ -50,18 +47,18 @@ isDone = Mesh_1.Compute()
aListOf3d_1=range(721,821)
aGrp3D_1=Mesh_1.GetMesh().CreateGroup( smesh.VOLUME, "Src 3D 1" )
aGrp3D_1=Mesh_1.GetMesh().CreateGroup( SMESH.VOLUME, "Src 3D 1" )
aGrp3D_1.Add( aListOf3d_1 )
aListOf3d_2=range(821, 921)
aGrp3D_2=Mesh_1.GetMesh().CreateGroup( smesh.VOLUME, "Src 3D 2" )
aGrp3D_2=Mesh_1.GetMesh().CreateGroup( SMESH.VOLUME, "Src 3D 2" )
aGrp3D_2.Add( aListOf3d_2 )
aGrp2D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], smesh.FACE, "Faces" )
aGrp2D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], SMESH.FACE, "Faces" )
aGrp1D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], smesh.EDGE, "Edges" )
aGrp1D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], SMESH.EDGE, "Edges" )
aGrp0D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], smesh.NODE, "Nodes" )
aGrp0D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], SMESH.NODE, "Nodes" )
salome.sg.updateObjBrowser( 1 )