mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-25 08:50:35 +05:00
New updated and tested smesh.py with some examples. Provided by FKL.
This commit is contained in:
parent
f4c7cebbd6
commit
22496e8ddc
@ -39,22 +39,29 @@ LIB_SRC =
|
|||||||
|
|
||||||
SWIG_DEF = libSMESH_Swig.i
|
SWIG_DEF = libSMESH_Swig.i
|
||||||
EXPORT_PYSCRIPTS = libSMESH_Swig.py \
|
EXPORT_PYSCRIPTS = libSMESH_Swig.py \
|
||||||
meshpy.py \
|
smesh.py \
|
||||||
batchmode_smesh.py \
|
batchmode_smesh.py \
|
||||||
batchmode_mefisto.py \
|
batchmode_mefisto.py \
|
||||||
cube2pyGibi.py \
|
ex00_all.py \
|
||||||
cube2geometry.py \
|
ex01_cube2build.py \
|
||||||
cube2partition.py \
|
ex02_cube2primitive.py \
|
||||||
grid4pyGibi.py \
|
ex03_cube2partition.py \
|
||||||
grid4partition.py \
|
ex04_cube5tetraHexa.py \
|
||||||
grid3partition.py \
|
ex05_hole1build.py \
|
||||||
grid17partition.py \
|
ex06_hole1boolean.py \
|
||||||
hole1geometry.py \
|
ex07_hole1partition.py \
|
||||||
hole1partition.py \
|
ex08_hole2build.py \
|
||||||
hole1pyGibi.py \
|
ex09_grid4build.py \
|
||||||
hole2pyGibi.py \
|
ex10_grid4geometry.py \
|
||||||
cyl2geometry.py \
|
ex11_grid3partition.py \
|
||||||
cyl2complementary.py \
|
ex12_grid17partition.py \
|
||||||
|
ex13_hole1partial.py \
|
||||||
|
ex14_cyl1holed.py \
|
||||||
|
ex15_cyl2geometry.py \
|
||||||
|
ex16_cyl2complementary.py \
|
||||||
|
ex17_dome1.py \
|
||||||
|
ex18_dome2.py \
|
||||||
|
ex19_sphereINcube.py \
|
||||||
SMESH_test.py\
|
SMESH_test.py\
|
||||||
SMESH_test0.py\
|
SMESH_test0.py\
|
||||||
SMESH_test1.py \
|
SMESH_test1.py \
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
from geompy import *
|
from geompy import *
|
||||||
from math import *
|
from math import *
|
||||||
|
|
||||||
from meshpy import *
|
import smesh
|
||||||
|
|
||||||
# It is an example of creating a hexahedrical mesh on a sphere.
|
# It is an example of creating a hexahedrical mesh on a sphere.
|
||||||
#
|
#
|
||||||
@ -103,5 +103,9 @@ Id_Result = addToStudy(Result, "Result")
|
|||||||
|
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
#Meshing
|
#Meshing
|
||||||
my_hexa = MeshHexa(Result, NbSeg, "Sphere_Mesh")
|
my_hexa = smesh.Mesh(Result, "Sphere_Mesh")
|
||||||
|
algo = my_hexa.Segment()
|
||||||
|
algo.NumberOfSegments(NbSeg)
|
||||||
|
my_hexa.Quadrangle()
|
||||||
|
my_hexa.Hexahedron()
|
||||||
my_hexa.Compute()
|
my_hexa.Compute()
|
||||||
|
25
src/SMESH_SWIG/ex00_all.py
Normal file
25
src/SMESH_SWIG/ex00_all.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# CEA/LGLS 2005, Francis KLOSS (OCC)
|
||||||
|
# ==================================
|
||||||
|
|
||||||
|
# Load all examples
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
import ex01_cube2build
|
||||||
|
import ex02_cube2primitive
|
||||||
|
#import ex03_cube2partition
|
||||||
|
import ex04_cube5tetraHexa
|
||||||
|
import ex05_hole1build
|
||||||
|
import ex06_hole1boolean
|
||||||
|
import ex07_hole1partition
|
||||||
|
import ex08_hole2build
|
||||||
|
import ex09_grid4build
|
||||||
|
import ex10_grid4geometry
|
||||||
|
import ex11_grid3partition
|
||||||
|
import ex12_grid17partition
|
||||||
|
import ex13_hole1partial
|
||||||
|
import ex14_cyl1holed
|
||||||
|
import ex15_cyl2geometry
|
||||||
|
import ex16_cyl2complementary
|
||||||
|
import ex17_dome1
|
||||||
|
#import ex18_dome2
|
||||||
|
import ex19_sphereINcube
|
@ -1,16 +1,14 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# ========
|
# ========
|
||||||
|
|
||||||
# A small cube centered and put on a great cube
|
# A small cube centered and put on a great cube build by points, edges, faces and solids
|
||||||
|
|
||||||
# Points
|
# Points
|
||||||
# ------
|
# ------
|
||||||
@ -258,13 +256,12 @@ c_l.append(greatBlock13)
|
|||||||
c_l.append(greatBlock23)
|
c_l.append(greatBlock23)
|
||||||
c_l.append(greatBlock33)
|
c_l.append(greatBlock33)
|
||||||
|
|
||||||
c_cpd = MakeCompound(c_l)
|
piece = MakeCompound(c_l)
|
||||||
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Cubes2pyGibi")
|
piece_id = addToStudy(piece, "ex01_cube2build")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
@ -272,24 +269,25 @@ piece_id = addToStudy(piece, "Cubes2pyGibi")
|
|||||||
# Create hexahedrical mesh on piece
|
# Create hexahedrical mesh on piece
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Cubes2pyGibiHexa")
|
hexa = smesh.Mesh(piece, "ex01_cube2build:hexa")
|
||||||
|
|
||||||
# Get edges
|
algo = hexa.Segment()
|
||||||
# ---------
|
algo.NumberOfSegments(4)
|
||||||
|
|
||||||
e_edges = SubShapeAllSorted(piece, ShapeType["EDGE"])
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
# Create local hypothesis
|
# Create local hypothesis
|
||||||
# -----------------------
|
# -----------------------
|
||||||
|
|
||||||
m_local=3
|
algo = hexa.Segment(greatEdgeX111)
|
||||||
|
|
||||||
m_i=10
|
algo.Arithmetic1D(1, 4)
|
||||||
while m_i<18:
|
|
||||||
m_hexa.local(e_edges[m_i], m_local)
|
|
||||||
m_i=m_i+1
|
|
||||||
|
|
||||||
# Compute
|
algo.Propagation()
|
||||||
# -------
|
|
||||||
|
|
||||||
m_hexa.Compute()
|
# Compute the mesh
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,19 +1,17 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# ========
|
# ========
|
||||||
|
|
||||||
# Piece
|
# A small cube centered and put on a great cube build by primitive geometric functionalities
|
||||||
# -----
|
|
||||||
|
|
||||||
# A small cube centered and put on a great cube
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
ox = 0
|
ox = 0
|
||||||
oy = 0
|
oy = 0
|
||||||
@ -29,14 +27,11 @@ blockPoint211 = MakeVertex(ox+arete, oy, oz)
|
|||||||
blockPoint112 = MakeVertex(ox , oy, oz+arete)
|
blockPoint112 = MakeVertex(ox , oy, oz+arete)
|
||||||
blockPoint212 = MakeVertex(ox+arete, oy, oz+arete)
|
blockPoint212 = MakeVertex(ox+arete, oy, oz+arete)
|
||||||
|
|
||||||
# Faces
|
# Face and solid
|
||||||
# -----
|
# --------------
|
||||||
|
|
||||||
blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112)
|
blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112)
|
||||||
|
|
||||||
# Solids
|
|
||||||
# ------
|
|
||||||
|
|
||||||
blockSolid11 = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete)
|
blockSolid11 = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete)
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
@ -55,8 +50,8 @@ blockSolid33 = MakeTranslation(blockSolid23, arete, 0, 0)
|
|||||||
|
|
||||||
blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0)
|
blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0)
|
||||||
|
|
||||||
# Compound
|
# Compound and glue
|
||||||
# --------
|
# -----------------
|
||||||
|
|
||||||
c_l = []
|
c_l = []
|
||||||
c_l.append(blockSolid11)
|
c_l.append(blockSolid11)
|
||||||
@ -71,12 +66,13 @@ c_l.append(blockSolid33)
|
|||||||
c_l.append(blockSolid111)
|
c_l.append(blockSolid111)
|
||||||
|
|
||||||
c_cpd = MakeCompound(c_l)
|
c_cpd = MakeCompound(c_l)
|
||||||
|
|
||||||
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Cubes2geometry")
|
piece_id = addToStudy(piece, "ex02_cube2primitive")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
@ -84,9 +80,16 @@ piece_id = addToStudy(piece, "Cubes2geometry")
|
|||||||
# Create hexahedrical mesh on piece
|
# Create hexahedrical mesh on piece
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Cubes2geometryHexa")
|
hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.LocalLength(1)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Compute the mesh
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,19 +1,17 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
|
||||||
# A small cube centered and put on a great cube
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# A small cube centered and put on a great cube build with partition
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
g_ox = 0
|
g_ox = 0
|
||||||
g_oy = 0
|
g_oy = 0
|
||||||
@ -46,28 +44,22 @@ s_haut = MakeBoxTwoPnt(v_3, v_4)
|
|||||||
|
|
||||||
p_dir1 = MakeVectorDXDYDZ(1, 0, 0)
|
p_dir1 = MakeVectorDXDYDZ(1, 0, 0)
|
||||||
p_dir2 = MakeVectorDXDYDZ(0, 0, 1)
|
p_dir2 = MakeVectorDXDYDZ(0, 0, 1)
|
||||||
|
p_dir3 = MakeVectorDXDYDZ(0, 1, 0)
|
||||||
|
|
||||||
p_tools = []
|
p_tools = []
|
||||||
|
|
||||||
p_tools.append(MakePlane(v_3, p_dir1, g_trim))
|
p_tools.append(MakePlane(v_3, p_dir1, g_trim))
|
||||||
p_tools.append(MakePlane(v_4, p_dir1, g_trim))
|
p_tools.append(MakePlane(v_4, p_dir1, g_trim))
|
||||||
p_tools.append(MakePlane(v_3, p_dir2, g_trim))
|
p_tools.append(MakePlane(v_3, p_dir2, g_trim))
|
||||||
p_tools.append(MakePlane(v_4, p_dir2, g_trim))
|
p_tools.append(MakePlane(v_4, p_dir2, g_trim))
|
||||||
|
p_tools.append(MakePlane(v_3, p_dir3, g_trim))
|
||||||
|
|
||||||
p_element = MakePartition([s_base], p_tools, [], [], ShapeType["SOLID"])
|
piece = MakePartition([s_base, s_haut], p_tools, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
# Compound
|
|
||||||
# --------
|
|
||||||
|
|
||||||
c_element = SubShapeAll(p_element, ShapeType["SOLID"])
|
|
||||||
c_element.append(s_haut)
|
|
||||||
|
|
||||||
c_cpd = MakeCompound(c_element)
|
|
||||||
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
|
||||||
|
|
||||||
# Study
|
# Study
|
||||||
# -----
|
# -----
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Cubes2partition")
|
piece_id = addToStudy(piece, "ex03_cube2partition")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
@ -75,9 +67,16 @@ piece_id = addToStudy(piece, "Cubes2partition")
|
|||||||
# Create hexahedrical mesh on piece
|
# Create hexahedrical mesh on piece
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Cubes2partitionHexa")
|
hexa = smesh.Mesh(piece, "ex03_cube2partition:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.NumberOfSegments(5)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Compute the mesh
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
87
src/SMESH_SWIG/ex04_cube5tetraHexa.py
Normal file
87
src/SMESH_SWIG/ex04_cube5tetraHexa.py
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
|
# =======================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
# Geometry
|
||||||
|
# ========
|
||||||
|
|
||||||
|
# 5 box with a hexahedral mesh and with 2 box in tetrahedral mesh
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
|
arete = 100
|
||||||
|
|
||||||
|
arete0 = 0
|
||||||
|
arete1 = arete
|
||||||
|
arete2 = arete*2
|
||||||
|
arete3 = arete*3
|
||||||
|
|
||||||
|
# Solids
|
||||||
|
# ------
|
||||||
|
|
||||||
|
box_tetra1 = MakeBox(arete0, arete0, 0, arete1, arete1, arete)
|
||||||
|
|
||||||
|
box_ijk1 = MakeBox(arete1, arete0, 0, arete2, arete1, arete)
|
||||||
|
|
||||||
|
box_hexa = MakeBox(arete1, arete1, 0, arete2, arete2, arete)
|
||||||
|
|
||||||
|
box_ijk2 = MakeBox(arete2, arete1, 0, arete3, arete2, arete)
|
||||||
|
|
||||||
|
box_tetra2 = MakeBox(arete2, arete2, 0, arete3 ,arete3, arete)
|
||||||
|
|
||||||
|
# Piece
|
||||||
|
# -----
|
||||||
|
|
||||||
|
piece_cpd = MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2])
|
||||||
|
|
||||||
|
piece = MakeGlueFaces(piece_cpd, 1e-4)
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex04_cube5tetraHexa")
|
||||||
|
|
||||||
|
# Meshing
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# Create a hexahedral mesh
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
mixed = smesh.Mesh(piece, "ex04_cube5tetraHexa:mixed")
|
||||||
|
|
||||||
|
algo = mixed.Segment()
|
||||||
|
|
||||||
|
algo.StartEndLength(3, 25)
|
||||||
|
|
||||||
|
mixed.Quadrangle()
|
||||||
|
|
||||||
|
mixed.Hexahedron()
|
||||||
|
|
||||||
|
# Tetrahedral local mesh
|
||||||
|
# ----------------------
|
||||||
|
|
||||||
|
def localMesh(b, hyp):
|
||||||
|
box = GetInPlace(piece, b)
|
||||||
|
faces = SubShapeAll(box, ShapeType["FACE"])
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
n = len(faces)
|
||||||
|
while i<n:
|
||||||
|
algo = mixed.Triangle(faces[i])
|
||||||
|
if hyp:
|
||||||
|
algo.MaxElementArea(80)
|
||||||
|
else:
|
||||||
|
algo.LengthFromEdges()
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
algo = mixed.Tetrahedron(smesh.NETGEN, box)
|
||||||
|
algo.MaxElementVolume(400)
|
||||||
|
|
||||||
|
localMesh(box_tetra1, 1)
|
||||||
|
localMesh(box_tetra2, 0)
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
mixed.Compute()
|
@ -1,21 +1,19 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
# Piece
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# A centered holed cube
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# A centered holed cube build by build by points, edges, faces and solids
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
ox = 0
|
ox = 0
|
||||||
oy = 0
|
oy = 0
|
||||||
@ -100,17 +98,25 @@ piece = MakeGlueFaces(c_cpd, 1.e-5)
|
|||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Hole1pyGibi")
|
piece_id = addToStudy(piece, "ex05_hole1build")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Hole1pyGibiHexa")
|
hexa = smesh.Mesh(piece, "ex05_hole1build:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
|
||||||
|
|
||||||
m_hexa.Compute()
|
algo.NumberOfSegments(6, 3)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,19 +1,17 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
|
||||||
# A holed cube
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# A not centered holed cube build by boolean geometric operations
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
ox = 0
|
ox = 0
|
||||||
oy = 0
|
oy = 0
|
||||||
@ -75,11 +73,11 @@ holeSolid = MakeCylinder(holePoint, baseVector, rayon, hauteur)
|
|||||||
|
|
||||||
baseHexa1 = MakeCut(baseSolid1, holeSolid)
|
baseHexa1 = MakeCut(baseSolid1, holeSolid)
|
||||||
baseHexa2 = MakeCut(baseSolid2, holeSolid)
|
baseHexa2 = MakeCut(baseSolid2, holeSolid)
|
||||||
baseHexa3 = MakeCut(baseSolid3, MakeRotation(holeSolid, baseVector, 3.141592653))
|
baseHexa3 = MakeCut(baseSolid3, holeSolid)
|
||||||
baseHexa4 = MakeCut(baseSolid4, holeSolid)
|
baseHexa4 = MakeCut(baseSolid4, holeSolid)
|
||||||
|
|
||||||
# Compound
|
# Compound, glue and repair
|
||||||
# --------
|
# -------------------------
|
||||||
|
|
||||||
c_l = []
|
c_l = []
|
||||||
c_l.append(baseHexa1)
|
c_l.append(baseHexa1)
|
||||||
@ -88,22 +86,54 @@ c_l.append(baseHexa3)
|
|||||||
c_l.append(baseHexa4)
|
c_l.append(baseHexa4)
|
||||||
|
|
||||||
c_cpd = MakeCompound(c_l)
|
c_cpd = MakeCompound(c_l)
|
||||||
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
c_glu = MakeGlueFaces(c_cpd, 1.e-5)
|
||||||
|
piece = RemoveExtraEdges(c_glu)
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Hole1geometry")
|
piece_id = addToStudy(piece, "ex06_hole1boolean")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Hole1geometryHexa")
|
hexa = smesh.Mesh(piece, "ex06_hole1boolean:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
|
||||||
|
|
||||||
m_hexa.Compute()
|
algo.NumberOfSegments(11)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Create local hypothesis
|
||||||
|
# -----------------------
|
||||||
|
|
||||||
|
edge1 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz-largeur1))
|
||||||
|
algo1 = hexa.Segment(edge1)
|
||||||
|
algo1.NumberOfSegments(3)
|
||||||
|
algo1.Propagation()
|
||||||
|
|
||||||
|
edge2 = GetEdgeNearPoint(piece, MakeVertex(ox-longueur1, oy, oz))
|
||||||
|
algo2 = hexa.Segment(edge2)
|
||||||
|
algo2.NumberOfSegments(5)
|
||||||
|
algo2.Propagation()
|
||||||
|
|
||||||
|
edge3 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz+largeur2))
|
||||||
|
algo3 = hexa.Segment(edge3)
|
||||||
|
algo3.NumberOfSegments(7)
|
||||||
|
algo3.Propagation()
|
||||||
|
|
||||||
|
edge4 = GetEdgeNearPoint(piece, MakeVertex(ox+longueur2, oy, oz))
|
||||||
|
algo4 = hexa.Segment(edge4)
|
||||||
|
algo4.NumberOfSegments(9)
|
||||||
|
algo4.Propagation()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
79
src/SMESH_SWIG/ex07_hole1partition.py
Normal file
79
src/SMESH_SWIG/ex07_hole1partition.py
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
|
# =======================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
# Geometry
|
||||||
|
# ========
|
||||||
|
|
||||||
|
# A holed cube build by partitioning geometric operations
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
|
g_x = 0
|
||||||
|
g_y = 0
|
||||||
|
g_z = 0
|
||||||
|
|
||||||
|
g_longueur = 50.0
|
||||||
|
g_largeur = 40.0
|
||||||
|
g_hauteur = 25.0
|
||||||
|
|
||||||
|
g_rayon = 10
|
||||||
|
|
||||||
|
g_trim = 1000
|
||||||
|
|
||||||
|
# Box
|
||||||
|
# ---
|
||||||
|
|
||||||
|
b_boite = MakeBox(g_x-g_longueur, g_y-g_hauteur, g_z-g_largeur, g_x+g_longueur, g_y+g_hauteur, g_z+g_largeur)
|
||||||
|
|
||||||
|
# Cylinder
|
||||||
|
# --------
|
||||||
|
|
||||||
|
c_axe = MakeVectorDXDYDZ(0, 1, 0)
|
||||||
|
|
||||||
|
c_cyl = MakeCylinder(MakeVertex(g_x, g_y-g_hauteur, g_z), c_axe, g_rayon, g_hauteur*2)
|
||||||
|
|
||||||
|
c_piece = MakeCut(b_boite, c_cyl)
|
||||||
|
|
||||||
|
# Partition and reperation
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
p_centre = MakeVertex(g_x, g_y, g_z)
|
||||||
|
|
||||||
|
p_tools = []
|
||||||
|
p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ( g_largeur, 0, g_longueur), g_trim))
|
||||||
|
p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ(-g_largeur, 0, g_longueur), g_trim))
|
||||||
|
|
||||||
|
p_part = MakePartition([c_piece], p_tools, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
p_blocs = RemoveExtraEdges(p_part)
|
||||||
|
piece = MakeGlueFaces(p_blocs, 1.e-5)
|
||||||
|
|
||||||
|
# Add in study
|
||||||
|
# ------------
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex07_hole1partition")
|
||||||
|
|
||||||
|
# Meshing
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# Create a hexahedral mesh
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
hexa = smesh.Mesh(piece, "ex07_hole1partition:hexa")
|
||||||
|
|
||||||
|
algo = hexa.Segment()
|
||||||
|
algo.NumberOfSegments(20)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,19 +1,17 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
|
||||||
# A twice holed cube
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# A twice holed cube build by points, edges, faces and solids
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
ox = 0
|
ox = 0
|
||||||
oy = 0
|
oy = 0
|
||||||
@ -37,10 +35,10 @@ piecePoint4 = MakeVertex(ox , oy, oz+largeur)
|
|||||||
|
|
||||||
cz = oz+largeur/2
|
cz = oz+largeur/2
|
||||||
|
|
||||||
cylPoint1 = MakeVertex(ox+cylindre , oy, cz-rayon)
|
cylPoint1 = MakeVertex(ox+cylindre , oy, cz-rayon)
|
||||||
cylPoint2 = MakeVertex(ox+longueur-cylindre, oy, cz-rayon)
|
cylPoint2 = MakeVertex(ox+longueur-cylindre, oy, cz-rayon)
|
||||||
cylPoint3 = MakeVertex(ox+longueur-cylindre, oy, cz+rayon)
|
cylPoint3 = MakeVertex(ox+longueur-cylindre, oy, cz+rayon)
|
||||||
cylPoint4 = MakeVertex(ox+cylindre , oy, cz+rayon)
|
cylPoint4 = MakeVertex(ox+cylindre , oy, cz+rayon)
|
||||||
|
|
||||||
# Edges
|
# Edges
|
||||||
# -----
|
# -----
|
||||||
@ -81,33 +79,34 @@ pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
|
|||||||
pieceSolid4 = MakePrismVecH(pieceFace4, pieceVector, hauteur)
|
pieceSolid4 = MakePrismVecH(pieceFace4, pieceVector, hauteur)
|
||||||
pieceSolid5 = MakePrismVecH(pieceFace5, pieceVector, hauteur)
|
pieceSolid5 = MakePrismVecH(pieceFace5, pieceVector, hauteur)
|
||||||
|
|
||||||
# Compound
|
# Compound and glue
|
||||||
# --------
|
# -----------------
|
||||||
|
|
||||||
c_l = []
|
c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3, pieceSolid4, pieceSolid5])
|
||||||
c_l.append(pieceSolid1)
|
|
||||||
c_l.append(pieceSolid2)
|
|
||||||
c_l.append(pieceSolid3)
|
|
||||||
c_l.append(pieceSolid4)
|
|
||||||
c_l.append(pieceSolid5)
|
|
||||||
|
|
||||||
c_cpd = MakeCompound(c_l)
|
|
||||||
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Hole2pyGibi")
|
piece_id = addToStudy(piece, "ex08_hole2build")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Hole2pyGibiHexa")
|
hexa = smesh.Mesh(piece, "ex08_hole2build:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.NumberOfSegments(7)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,21 +1,19 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
# Piece
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# grid compound by a square with a cylinder on each vertex
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# Element of a grid compound by a square with a cylinder on each vertex build by points, edges, faces and solids
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
ox = 0
|
ox = 0
|
||||||
oy = 0
|
oy = 0
|
||||||
@ -84,31 +82,34 @@ pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur)
|
|||||||
pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
|
pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur)
|
||||||
pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
|
pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur)
|
||||||
|
|
||||||
# Compound
|
# Compound and glue
|
||||||
# --------
|
# -----------------
|
||||||
|
|
||||||
c_l = []
|
c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3])
|
||||||
c_l.append(pieceSolid1)
|
|
||||||
c_l.append(pieceSolid2)
|
|
||||||
c_l.append(pieceSolid3)
|
|
||||||
|
|
||||||
c_cpd = MakeCompound(c_l)
|
|
||||||
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
piece = MakeGlueFaces(c_cpd, 1.e-5)
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Grid4pyGibi")
|
piece_id = addToStudy(piece, "ex09_grid4build")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Grid4pyGibiHexa")
|
hexa = smesh.Mesh(piece, "ex09_grid4build:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.NumberOfSegments(6)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,19 +1,17 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
|
||||||
# grid compound by a square with a cylinder on each vertex
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# Element of a grid compound by a square with a cylinder on each vertex build by using partition
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
ox = 0
|
ox = 0
|
||||||
oy = 0
|
oy = 0
|
||||||
@ -56,17 +54,24 @@ piece = MakePartition([pieceCut4], tools, [], [], ShapeType["SOLID"])
|
|||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Grid4partition")
|
piece_id = addToStudy(piece, "ex10_grid4geometry")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Grid4partitionHexa")
|
hexa = smesh.Mesh(piece, "ex10_grid4geometry:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.NumberOfSegments(10)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,24 +1,22 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
# Geometry
|
||||||
|
# ========
|
||||||
|
|
||||||
# grid compound of 3 x 3 elements
|
# grid compound of 3 x 3 elements
|
||||||
# an element is compound of 3 cylinders concentriques
|
# an element is compound of 3 cylinders concentriques
|
||||||
# an element is centered in a square of the grid
|
# an element is centered in a square of the grid
|
||||||
# the smaller cylinder is a hole
|
# the smaller cylinder is a hole
|
||||||
|
|
||||||
# prisme the grid
|
# prism the grid, and mesh it in hexahedral way
|
||||||
|
|
||||||
# Geometry
|
# Values
|
||||||
# --------
|
# ------
|
||||||
|
|
||||||
g_x = 0
|
g_x = 0
|
||||||
g_y = 0
|
g_y = 0
|
||||||
@ -40,55 +38,61 @@ g_trim = 1000
|
|||||||
|
|
||||||
e_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
|
e_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
|
||||||
|
|
||||||
e_pi4 = 3.141592653/4
|
|
||||||
e_hauteur = 2*g_hauteur
|
e_hauteur = 2*g_hauteur
|
||||||
e_centre = MakeVertex(g_x, g_y-g_hauteur, g_z)
|
e_centre = MakeVertex(g_x, g_y-g_hauteur, g_z)
|
||||||
e_dir = MakeVectorDXDYDZ(0, 1, 0)
|
e_dir = MakeVectorDXDYDZ(0, 1, 0)
|
||||||
|
|
||||||
e_cyl0 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur)
|
e_cyl1 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur)
|
||||||
e_cyl1 = MakeRotation(e_cyl0, e_dir, e_pi4)
|
|
||||||
|
|
||||||
e_blo1 = MakeCut(e_boite, e_cyl1)
|
e_blo1 = MakeCut(e_boite, e_cyl1)
|
||||||
|
|
||||||
e_cyl0 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur)
|
e_cyl2 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur)
|
||||||
e_cyl2 = MakeRotation(e_cyl0, e_dir, e_pi4)
|
|
||||||
|
|
||||||
e_blo2 = MakeCut(e_cyl1, e_cyl2)
|
e_blo2 = MakeCut(e_cyl1, e_cyl2)
|
||||||
|
|
||||||
e_cyl0 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur)
|
e_cyl3 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur)
|
||||||
e_cyl3 = MakeRotation(e_cyl0, e_dir, e_pi4)
|
|
||||||
|
|
||||||
e_blo3 = MakeCut(e_cyl2, e_cyl3)
|
e_blo3 = MakeCut(e_cyl2, e_cyl3)
|
||||||
|
|
||||||
# Partition
|
# Partition and repair
|
||||||
# ---------
|
# --------------------
|
||||||
|
|
||||||
p_tools = []
|
p_tools = []
|
||||||
p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
|
p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
|
||||||
p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
|
p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
|
||||||
|
|
||||||
p_element = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"])
|
p_part = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
# Grid
|
p_element = RemoveExtraEdges(p_part)
|
||||||
# ----
|
|
||||||
|
|
||||||
piece = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid,
|
# Grid and glue
|
||||||
MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
|
# -------------
|
||||||
|
|
||||||
|
grid = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
|
||||||
|
|
||||||
|
piece = MakeGlueFaces(grid, 1e-5)
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Grid3partition")
|
piece_id = addToStudy(piece, "ex11_grid3partition")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Grid3partitionHexa")
|
hexa = smesh.Mesh(piece, "ex11_grid3partition:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.NumberOfSegments(3)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,22 +1,21 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
|
||||||
# grid compound of 17 x 17 elements
|
|
||||||
# an element is compound of 3 cylinders concentriques
|
|
||||||
# an element is centered in a square of the grid
|
|
||||||
# prisme the grid
|
|
||||||
|
|
||||||
# Geometry
|
# Geometry
|
||||||
# --------
|
# ========
|
||||||
|
|
||||||
|
# grid compound of 17 x 17 elements
|
||||||
|
# an element is compound of 3 concentric cylinders
|
||||||
|
# an element is centered in a square of the grid
|
||||||
|
|
||||||
|
# prism the grid, and mesh it in hexahedral way
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
g_x = 0
|
g_x = 0
|
||||||
g_y = 0
|
g_y = 0
|
||||||
@ -29,14 +28,12 @@ g_rayon1 = 20
|
|||||||
g_rayon2 = 30
|
g_rayon2 = 30
|
||||||
g_rayon3 = 40
|
g_rayon3 = 40
|
||||||
|
|
||||||
# The real value for CEA, but need 3 days for computing
|
g_grid = 17
|
||||||
#g_grid = 17
|
|
||||||
g_grid = 3
|
|
||||||
|
|
||||||
g_trim = 1000
|
g_trim = 1000
|
||||||
|
|
||||||
# Solids
|
# Solids and rotation to prevent repair
|
||||||
# ------
|
# -------------------------------------
|
||||||
|
|
||||||
s_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
|
s_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
|
||||||
|
|
||||||
@ -75,34 +72,42 @@ p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
|
|||||||
|
|
||||||
p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"])
|
p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
# Compound
|
# Compound and glue
|
||||||
# --------
|
# -----------------
|
||||||
|
|
||||||
c_cpd = SubShapeAll(p_partie, ShapeType["SOLID"])
|
c_blocs = SubShapeAll(p_partie, ShapeType["SOLID"])
|
||||||
c_cpd.append(s_blo4)
|
c_blocs.append(s_blo4)
|
||||||
|
|
||||||
c_element = MakeCompound(c_cpd)
|
c_cpd = MakeCompound(c_blocs)
|
||||||
|
|
||||||
|
c_element = MakeGlueFaces(c_cpd, 1e-4)
|
||||||
|
|
||||||
# Grid
|
# Grid
|
||||||
# ----
|
# ----
|
||||||
|
|
||||||
piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid,
|
piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
|
||||||
MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
|
|
||||||
|
|
||||||
# Add in study
|
# Add in study
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Grid17partition")
|
piece_id = addToStudy(piece, "ex12_grid17partition")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
# Create a hexahedral mesh
|
||||||
# ---------------------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Grid17partitionHexa")
|
hexa = smesh.Mesh(piece, "ex12_grid17partition:hexa")
|
||||||
|
|
||||||
# Compute
|
algo = hexa.Segment()
|
||||||
# -------
|
algo.NumberOfSegments(2)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
231
src/SMESH_SWIG/ex13_hole1partial.py
Normal file
231
src/SMESH_SWIG/ex13_hole1partial.py
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
# CEA/LGLS 2005, Francis KLOSS (OCC)
|
||||||
|
# ==================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
# Geometry
|
||||||
|
# ========
|
||||||
|
|
||||||
|
# With hexahedral, build a box partially holed by a not centered cylinder with a thickness
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
|
box_dx = 1000
|
||||||
|
box_dy = 900
|
||||||
|
box_dz = 800
|
||||||
|
|
||||||
|
cyl_x = 500
|
||||||
|
cyl_y = 300
|
||||||
|
cyl_dz = 600
|
||||||
|
cyl_radius = 150
|
||||||
|
cyl_thick = 30
|
||||||
|
|
||||||
|
# Triangular face
|
||||||
|
# ---------------
|
||||||
|
|
||||||
|
def triangle(p1, p2, p3):
|
||||||
|
l = []
|
||||||
|
l.append(MakeEdge(p1, p2))
|
||||||
|
l.append(MakeEdge(p2, p3))
|
||||||
|
l.append(MakeEdge(p3, p1))
|
||||||
|
w = MakeWire(l)
|
||||||
|
return MakeFace(w, 1)
|
||||||
|
|
||||||
|
# The holed part
|
||||||
|
# ==============
|
||||||
|
|
||||||
|
# Vertex of the holed part
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
hole_point_11 = MakeVertex(0 , 0 , 0)
|
||||||
|
hole_point_21 = MakeVertex(box_dx, 0 , 0)
|
||||||
|
hole_point_12 = MakeVertex(0 , box_dy, 0)
|
||||||
|
hole_point_22 = MakeVertex(box_dx, box_dy, 0)
|
||||||
|
|
||||||
|
hole_center = MakeVertex(cyl_x, cyl_y, 0)
|
||||||
|
|
||||||
|
# Faces of the holed part
|
||||||
|
# -----------------------
|
||||||
|
|
||||||
|
hole_face_1 = triangle(hole_point_11, hole_point_21, hole_center)
|
||||||
|
hole_face_2 = triangle(hole_point_21, hole_point_22, hole_center)
|
||||||
|
hole_face_3 = triangle(hole_point_12, hole_point_22, hole_center)
|
||||||
|
hole_face_4 = triangle(hole_point_11, hole_point_12, hole_center)
|
||||||
|
|
||||||
|
# Solids of the holed part
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
cyl_dir = MakeVectorDXDYDZ(0, 0, 1)
|
||||||
|
|
||||||
|
hole_solid_1 = MakePrismVecH(hole_face_1, cyl_dir, cyl_dz)
|
||||||
|
hole_solid_2 = MakePrismVecH(hole_face_2, cyl_dir, cyl_dz)
|
||||||
|
hole_solid_3 = MakePrismVecH(hole_face_3, cyl_dir, cyl_dz)
|
||||||
|
hole_solid_4 = MakePrismVecH(hole_face_4, cyl_dir, cyl_dz)
|
||||||
|
|
||||||
|
hole_internal = MakeCylinder(hole_center, cyl_dir, cyl_radius , cyl_dz)
|
||||||
|
hole_external = MakeCylinder(hole_center, cyl_dir, cyl_radius+cyl_thick, cyl_dz)
|
||||||
|
hole_median = MakeCut(hole_external, hole_internal)
|
||||||
|
|
||||||
|
# Boolean operations
|
||||||
|
# ------------------
|
||||||
|
|
||||||
|
blocks = []
|
||||||
|
|
||||||
|
blocks.append( MakeCut(hole_solid_1, hole_external))
|
||||||
|
blocks.append(MakeCommon(hole_solid_1, hole_median ))
|
||||||
|
|
||||||
|
blocks.append( MakeCut(hole_solid_2, hole_external))
|
||||||
|
blocks.append(MakeCommon(hole_solid_2, hole_median ))
|
||||||
|
|
||||||
|
blocks.append( MakeCut(hole_solid_3, hole_external))
|
||||||
|
blocks.append(MakeCommon(hole_solid_3, hole_median ))
|
||||||
|
|
||||||
|
blocks.append( MakeCut(hole_solid_4, hole_external))
|
||||||
|
blocks.append(MakeCommon(hole_solid_4, hole_median ))
|
||||||
|
|
||||||
|
# The full part
|
||||||
|
# =============
|
||||||
|
|
||||||
|
# Vertex of the full part
|
||||||
|
# -----------------------
|
||||||
|
|
||||||
|
full_point_11 = MakeVertex(0 , 0 , cyl_dz)
|
||||||
|
full_point_21 = MakeVertex(box_dx, 0 , cyl_dz)
|
||||||
|
full_point_12 = MakeVertex(0 , box_dy, cyl_dz)
|
||||||
|
full_point_22 = MakeVertex(box_dx, box_dy, cyl_dz)
|
||||||
|
|
||||||
|
full_center = MakeVertex(cyl_x, cyl_y, cyl_dz)
|
||||||
|
|
||||||
|
# Faces of the full part
|
||||||
|
# ----------------------
|
||||||
|
|
||||||
|
full_face_1 = triangle(full_point_11, full_point_21, full_center)
|
||||||
|
full_face_2 = triangle(full_point_21, full_point_22, full_center)
|
||||||
|
full_face_3 = triangle(full_point_12, full_point_22, full_center)
|
||||||
|
full_face_4 = triangle(full_point_11, full_point_12, full_center)
|
||||||
|
|
||||||
|
# Solids of the full part
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
full_dz = box_dz - cyl_dz
|
||||||
|
|
||||||
|
full_solid_1 = MakePrismVecH(full_face_1, cyl_dir, full_dz)
|
||||||
|
full_solid_2 = MakePrismVecH(full_face_2, cyl_dir, full_dz)
|
||||||
|
full_solid_3 = MakePrismVecH(full_face_3, cyl_dir, full_dz)
|
||||||
|
full_solid_4 = MakePrismVecH(full_face_4, cyl_dir, full_dz)
|
||||||
|
|
||||||
|
full_internal = MakeCylinder(full_center, cyl_dir, cyl_radius , full_dz)
|
||||||
|
full_external = MakeCylinder(full_center, cyl_dir, cyl_radius+cyl_thick, full_dz)
|
||||||
|
full_median = MakeCut(full_external, full_internal)
|
||||||
|
|
||||||
|
# Boolean operations
|
||||||
|
# ------------------
|
||||||
|
|
||||||
|
full = []
|
||||||
|
|
||||||
|
full.append( MakeCut(full_solid_1, full_external))
|
||||||
|
full.append(MakeCommon(full_solid_1, full_median))
|
||||||
|
|
||||||
|
full.append( MakeCut(full_solid_2, full_external))
|
||||||
|
full.append(MakeCommon(full_solid_2, full_median ))
|
||||||
|
|
||||||
|
full.append( MakeCut(full_solid_3, full_external))
|
||||||
|
full.append(MakeCommon(full_solid_3, full_median))
|
||||||
|
|
||||||
|
full.append( MakeCut(full_solid_4, full_external))
|
||||||
|
full.append(MakeCommon(full_solid_4, full_median))
|
||||||
|
|
||||||
|
# Filling the hole
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
box_d = cyl_radius/3
|
||||||
|
|
||||||
|
x = cyl_x-box_d
|
||||||
|
y = x * cyl_y / cyl_x
|
||||||
|
box_point_11 = MakeVertex(x, y, cyl_dz)
|
||||||
|
|
||||||
|
x = cyl_x+box_d
|
||||||
|
y = (box_dx - x) * cyl_y / (box_dx - cyl_x)
|
||||||
|
box_point_12 = MakeVertex(x, y, cyl_dz)
|
||||||
|
|
||||||
|
x = cyl_x-box_d
|
||||||
|
y = box_dy - x * (box_dy - cyl_y) / cyl_x
|
||||||
|
box_point_21 = MakeVertex(x, y, cyl_dz)
|
||||||
|
|
||||||
|
x = cyl_x+box_d
|
||||||
|
y = box_dy - (box_dx - x) * (box_dy - cyl_y) / (box_dx - cyl_x)
|
||||||
|
box_point_22 = MakeVertex(x, y, cyl_dz)
|
||||||
|
|
||||||
|
box_face = MakeQuad4Vertices(box_point_11, box_point_12, box_point_21, box_point_22)
|
||||||
|
|
||||||
|
box = MakePrismVecH(box_face, cyl_dir, full_dz)
|
||||||
|
|
||||||
|
full.append(box)
|
||||||
|
|
||||||
|
full.append(MakeCut(MakeCommon(full_solid_1, full_internal), box))
|
||||||
|
full.append(MakeCut(MakeCommon(full_solid_2, full_internal), box))
|
||||||
|
full.append(MakeCut(MakeCommon(full_solid_3, full_internal), box))
|
||||||
|
full.append(MakeCut(MakeCommon(full_solid_4, full_internal), box))
|
||||||
|
|
||||||
|
# Cut the cylinder thikness
|
||||||
|
# -------------------------
|
||||||
|
|
||||||
|
full_plan = MakePlane(MakeVertex(0, 0, cyl_dz+cyl_thick), cyl_dir, 5000)
|
||||||
|
|
||||||
|
full_parts = MakePartition(full, [full_plan], [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
# Geometry result
|
||||||
|
# ---------------
|
||||||
|
|
||||||
|
blocks.append(full_parts)
|
||||||
|
|
||||||
|
piece_cpd = MakeCompound(blocks)
|
||||||
|
|
||||||
|
piece_ok = RemoveExtraEdges(piece_cpd)
|
||||||
|
|
||||||
|
piece = MakeGlueFaces(piece_ok, 1.e-3)
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex13_hole1partial")
|
||||||
|
|
||||||
|
# Meshing
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# Create a mesh
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa = smesh.Mesh(piece, "ex13_hole1partial:hexa")
|
||||||
|
|
||||||
|
algo = hexa.Segment()
|
||||||
|
algo.NumberOfSegments(2)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Local hypothesis
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
def local(x, y, z, d):
|
||||||
|
edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
|
||||||
|
algo = hexa.Segment(edge)
|
||||||
|
algo.NumberOfSegments(d)
|
||||||
|
algo.Propagation()
|
||||||
|
|
||||||
|
local(0, 0, 100, 40)
|
||||||
|
local(0, 0, 700, 15)
|
||||||
|
|
||||||
|
local(100, 0, 0, 20)
|
||||||
|
local(0, 100, 0, 20)
|
||||||
|
|
||||||
|
local(100, 100, 0, 25)
|
||||||
|
|
||||||
|
d = cyl_radius-3*cyl_thick
|
||||||
|
local(cyl_x+d, cyl_y+d, box_dz, 10)
|
||||||
|
|
||||||
|
# Compute the mesh
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
116
src/SMESH_SWIG/ex14_cyl1holed.py
Normal file
116
src/SMESH_SWIG/ex14_cyl1holed.py
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
|
# =======================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
# Geometrie
|
||||||
|
# =========
|
||||||
|
|
||||||
|
# Creer un cylindre avec un trou cylindrique excentre, decoupage en hexahedre et mailler.
|
||||||
|
|
||||||
|
# Donnees
|
||||||
|
# -------
|
||||||
|
|
||||||
|
# unite: millimetre
|
||||||
|
|
||||||
|
g_ox = 0
|
||||||
|
g_oy = 0
|
||||||
|
g_oz = 0
|
||||||
|
|
||||||
|
g_cyl_rayon = 1000
|
||||||
|
g_cyl_demiHauteur = 3000
|
||||||
|
|
||||||
|
g_trou_rayon = 5
|
||||||
|
g_trou_centre = 300
|
||||||
|
|
||||||
|
g_trim = 15000
|
||||||
|
|
||||||
|
# Construire le cylindre
|
||||||
|
# ----------------------
|
||||||
|
|
||||||
|
c_point = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
|
||||||
|
c_dir = MakeVectorDXDYDZ(0, 0, 1)
|
||||||
|
c_hauteur = 2*g_cyl_demiHauteur
|
||||||
|
c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
|
||||||
|
|
||||||
|
# Trouer le cylindre par un minuscule cylindre excentre
|
||||||
|
# -----------------------------------------------------
|
||||||
|
|
||||||
|
t_hauteur = g_cyl_demiHauteur
|
||||||
|
t_point = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
|
||||||
|
t_trou = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
|
||||||
|
|
||||||
|
t_piece = MakeCut(c_cylindre, t_trou)
|
||||||
|
|
||||||
|
# Geometrie hexahedrique
|
||||||
|
# ======================
|
||||||
|
|
||||||
|
# Decouper
|
||||||
|
# --------
|
||||||
|
|
||||||
|
h_outils = []
|
||||||
|
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
|
||||||
|
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
|
||||||
|
|
||||||
|
h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
# Decouper pour les conditions locales
|
||||||
|
# ------------------------------------
|
||||||
|
|
||||||
|
l_outils = []
|
||||||
|
l_i = 1
|
||||||
|
l_n = 12
|
||||||
|
l_hauteur = c_hauteur/l_n
|
||||||
|
|
||||||
|
while l_i<l_n:
|
||||||
|
l_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
|
||||||
|
l_i = l_i+1
|
||||||
|
|
||||||
|
piece = MakePartition([h_piece], l_outils, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
# Ajouter la piece dans l'etude
|
||||||
|
# -----------------------------
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex14_cyl1holed")
|
||||||
|
|
||||||
|
# Maillage
|
||||||
|
# ========
|
||||||
|
|
||||||
|
# Creer un maillage hexahedrique
|
||||||
|
# ------------------------------
|
||||||
|
|
||||||
|
hexa = smesh.Mesh(piece, "ex14_cyl1holed:hexa")
|
||||||
|
|
||||||
|
algo = hexa.Segment()
|
||||||
|
algo.NumberOfSegments(4)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Poser les hypotheses locales
|
||||||
|
# ----------------------------
|
||||||
|
|
||||||
|
m_i = 0
|
||||||
|
m_n = 12
|
||||||
|
m_h = c_hauteur/m_n
|
||||||
|
m_d = [4, 6, 8, 10, 10, 9, 8, 7, 6, 5, 4, 3]
|
||||||
|
|
||||||
|
m_x = g_ox+g_cyl_rayon
|
||||||
|
m_y = g_oy
|
||||||
|
m_z = g_oz-g_cyl_demiHauteur+m_h/2
|
||||||
|
|
||||||
|
while m_i<m_n:
|
||||||
|
m_p = MakeVertex(m_x, m_y, m_z + m_i*m_h)
|
||||||
|
m_e = GetEdgeNearPoint(piece, m_p)
|
||||||
|
m_a = hexa.Segment(m_e)
|
||||||
|
m_a.NumberOfSegments(m_d[m_i])
|
||||||
|
m_a.Propagation()
|
||||||
|
m_i = m_i + 1
|
||||||
|
|
||||||
|
# Calculer le maillage
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,17 +1,18 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
|
||||||
# Creer la geometrie en bloc hexahedrique d'une piece en forme de T composee de 2 cylindres de diametre different dont les axes se coupent orthogonalement,
|
# Geometrie
|
||||||
# puis mailler en hexahedrique.
|
# =========
|
||||||
|
|
||||||
|
# Construire avec des hexahedres une piece faite de 2 cylindres de diametre different
|
||||||
|
# et dont les axes se coupent orthogonalement, puis mailler.
|
||||||
|
|
||||||
|
# Valeurs
|
||||||
|
# -------
|
||||||
|
|
||||||
cx = 0
|
cx = 0
|
||||||
cy = 0
|
cy = 0
|
||||||
@ -25,21 +26,18 @@ p_hauteur = 500
|
|||||||
|
|
||||||
g_trim = 1000
|
g_trim = 1000
|
||||||
|
|
||||||
# Geometrie
|
|
||||||
# =========
|
|
||||||
|
|
||||||
cpd = []
|
|
||||||
|
|
||||||
# Gros cylindre
|
# Gros cylindre
|
||||||
# -------------
|
# -------------
|
||||||
|
|
||||||
|
cpd = []
|
||||||
|
|
||||||
g_base = MakeVertex(cx, cy, cz)
|
g_base = MakeVertex(cx, cy, cz)
|
||||||
g_dir = MakeVectorDXDYDZ(0, 0, 1)
|
g_dir = MakeVectorDXDYDZ(0, 0, 1)
|
||||||
t_hauteur = p_rayon+10.0
|
t_hauteur = p_rayon+10.0
|
||||||
|
|
||||||
g_cyl = MakeCylinder(g_base, g_dir, g_rayon, g_hauteur)
|
g_cyl = MakeCylinder(g_base, g_dir, g_rayon, g_hauteur)
|
||||||
|
|
||||||
g_coupe = MakeVectorDXDYDZ(1, 0, 0)
|
g_coupe = MakeVectorDXDYDZ(1, 0, 0)
|
||||||
|
|
||||||
g_tools = []
|
g_tools = []
|
||||||
g_tools.append(MakePlane(MakeVertex(cx+t_hauteur, cy, cz), g_coupe, g_trim))
|
g_tools.append(MakePlane(MakeVertex(cx+t_hauteur, cy, cz), g_coupe, g_trim))
|
||||||
@ -149,23 +147,29 @@ cpd = cpd + r_element
|
|||||||
# Compound
|
# Compound
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
comp_all = MakeCompound(cpd)
|
piece = RemoveExtraEdges(MakeCompound(cpd))
|
||||||
piece = BlocksOp.RemoveExtraEdges(comp_all)
|
|
||||||
|
|
||||||
# Ajouter la piece dans l'etude
|
# Ajouter la piece dans l'etude
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "T2Cylindres")
|
piece_id = addToStudy(piece, "ex15_cyl2geometry")
|
||||||
|
|
||||||
# Maillage
|
# Meshing
|
||||||
# ========
|
# =======
|
||||||
|
|
||||||
# Mailler des hexahedres
|
# Create a hexahedral mesh
|
||||||
# ----------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "T2CylindresHexa")
|
hexa = smesh.Mesh(piece, "ex15_cyl2geometry:hexa")
|
||||||
|
|
||||||
# Calculer le maillage
|
algo = hexa.Segment()
|
||||||
# --------------------
|
algo.NumberOfSegments(12)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
@ -1,19 +1,20 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
# ==================================
|
# =======================================
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
from geompy import *
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
# Piece
|
import smesh
|
||||||
# -----
|
|
||||||
|
# Geometry
|
||||||
|
# ========
|
||||||
|
|
||||||
# Create the hexahedrical block geometry of a holed parallelepipede.
|
# Create the hexahedrical block geometry of a holed parallelepipede.
|
||||||
# The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
|
# The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
|
||||||
# This piece is meshed in hexahedrical.
|
# This piece is meshed in hexahedrical.
|
||||||
|
|
||||||
|
# Values
|
||||||
|
# ------
|
||||||
|
|
||||||
gx = 0
|
gx = 0
|
||||||
gy = 0
|
gy = 0
|
||||||
gz = 0
|
gz = 0
|
||||||
@ -27,9 +28,6 @@ g_rayonPetit = 50
|
|||||||
|
|
||||||
g_trim = 1000
|
g_trim = 1000
|
||||||
|
|
||||||
# Geometry
|
|
||||||
# ========
|
|
||||||
|
|
||||||
# The parallelepipede
|
# The parallelepipede
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
@ -79,24 +77,42 @@ d_element[10] = MakeCut(d_element[10], c_cyl)
|
|||||||
# Compound
|
# Compound
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
comp_all = MakeCompound(d_element)
|
piece = RemoveExtraEdges(MakeCompound(d_element))
|
||||||
piece = BlocksOp.RemoveExtraEdges(comp_all)
|
|
||||||
#piece = MakeCompound(d_element)
|
|
||||||
|
|
||||||
# Add piece in study
|
# Add piece in study
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "BoxHoled2Cylinders")
|
piece_id = addToStudy(piece, "ex16_cyl2complementary")
|
||||||
|
|
||||||
# Meshing
|
# Meshing
|
||||||
# =======
|
# =======
|
||||||
|
|
||||||
# Mesh with hexahedrons
|
# Create a hexahedral mesh
|
||||||
# ---------------------
|
# ------------------------
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "BoxHoled2CylindersHexa")
|
hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
|
||||||
|
|
||||||
# Compute mesh
|
algo = hexa.Segment()
|
||||||
# ------------
|
algo.NumberOfSegments(12)
|
||||||
|
|
||||||
m_hexa.Compute()
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Define local hypothesis
|
||||||
|
# -----------------------
|
||||||
|
|
||||||
|
def local(x, y, z, d):
|
||||||
|
edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
|
||||||
|
algo = hexa.Segment(edge)
|
||||||
|
algo.NumberOfSegments(d)
|
||||||
|
algo.Propagation()
|
||||||
|
|
||||||
|
local(gx , gy+g_dy, gz+g_dz, 7)
|
||||||
|
local(gx+g_dx, gy+g_dy, gz , 21)
|
||||||
|
local(gx+g_dx, gy-g_dy, gz , 21)
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
78
src/SMESH_SWIG/ex17_dome1.py
Normal file
78
src/SMESH_SWIG/ex17_dome1.py
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
|
# =======================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
# Geometrie
|
||||||
|
# =========
|
||||||
|
|
||||||
|
# Creer un cylindre surplombe d'une demi-sphere le tout troue par un petit cylindre.
|
||||||
|
# Decouper en hexahedre et mailler.
|
||||||
|
|
||||||
|
# Donnees
|
||||||
|
# -------
|
||||||
|
|
||||||
|
cylindre_rayon = 100
|
||||||
|
cylindre_hauteur = 400
|
||||||
|
|
||||||
|
trou_rayon = 20
|
||||||
|
trou_z = cylindre_rayon/2
|
||||||
|
|
||||||
|
plan_trim = 2000
|
||||||
|
|
||||||
|
# Cylindre
|
||||||
|
# --------
|
||||||
|
|
||||||
|
cylindre_base = MakeVertex(0, 0, 0)
|
||||||
|
cylindre_dir = MakeVectorDXDYDZ(1, 0, 0)
|
||||||
|
cylindre = MakeCylinder(cylindre_base, cylindre_dir, cylindre_rayon, cylindre_hauteur)
|
||||||
|
|
||||||
|
# Dome
|
||||||
|
# ----
|
||||||
|
|
||||||
|
dome_sphere = MakeSpherePntR(cylindre_base, cylindre_rayon)
|
||||||
|
dome = MakeFuse(dome_sphere, cylindre)
|
||||||
|
|
||||||
|
# Cheminee
|
||||||
|
# --------
|
||||||
|
|
||||||
|
cheminee_base = MakeVertex(-cylindre_hauteur/2, 0, trou_z)
|
||||||
|
cheminee_trou = MakeCylinder(cheminee_base, cylindre_dir, trou_rayon, 2*cylindre_hauteur)
|
||||||
|
cheminee = MakeCut(dome, cheminee_trou)
|
||||||
|
|
||||||
|
# Decoupage et reparation
|
||||||
|
# -----------------------
|
||||||
|
|
||||||
|
blocs_plan1 = MakePlane(cheminee_base, MakeVectorDXDYDZ(0, 1, 0), plan_trim)
|
||||||
|
blocs_plan2 = MakePlane(cheminee_base, MakeVectorDXDYDZ(0, 0, 1), plan_trim)
|
||||||
|
|
||||||
|
blocs_part = MakePartition([cheminee], [blocs_plan1, blocs_plan2], [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
piece = RemoveExtraEdges(blocs_part)
|
||||||
|
|
||||||
|
# Etude
|
||||||
|
# -----
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex17_dome1")
|
||||||
|
|
||||||
|
# Maillage
|
||||||
|
# ========
|
||||||
|
|
||||||
|
# Maillage hexahedrique
|
||||||
|
# ---------------------
|
||||||
|
|
||||||
|
hexa = smesh.Mesh(piece, "ex17_dome1:hexa")
|
||||||
|
|
||||||
|
algo = hexa.Segment()
|
||||||
|
algo.NumberOfSegments(20)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Calcul du maillage
|
||||||
|
# ------------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
115
src/SMESH_SWIG/ex18_dome2.py
Normal file
115
src/SMESH_SWIG/ex18_dome2.py
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
# CEA/LGLS 2004-2005, Francis KLOSS (OCC)
|
||||||
|
# =======================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
import math
|
||||||
|
|
||||||
|
# Geometrie
|
||||||
|
# =========
|
||||||
|
|
||||||
|
# Creer un cylindre ayant a chaque bout un morceau de sphere et le tout troue par un petit cylindrique excentre.
|
||||||
|
# Decouper en hexahedre et mailler.
|
||||||
|
|
||||||
|
# Donnees
|
||||||
|
# -------
|
||||||
|
|
||||||
|
# unite: millimetre
|
||||||
|
|
||||||
|
g_ox = 0
|
||||||
|
g_oy = 0
|
||||||
|
g_oz = 0
|
||||||
|
|
||||||
|
g_cyl_rayon = 1000
|
||||||
|
g_cyl_demiHauteur = 3000
|
||||||
|
|
||||||
|
g_trou_rayon = 5
|
||||||
|
g_trou_centre = 300
|
||||||
|
|
||||||
|
g_sphere_rayon = 3500
|
||||||
|
|
||||||
|
g_trim = 15000
|
||||||
|
|
||||||
|
# Cylindre
|
||||||
|
# --------
|
||||||
|
|
||||||
|
c_point = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
|
||||||
|
c_dir = MakeVectorDXDYDZ(0, 0, 1)
|
||||||
|
c_hauteur = 2*g_cyl_demiHauteur
|
||||||
|
|
||||||
|
c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
|
||||||
|
|
||||||
|
# Sphere
|
||||||
|
# ------
|
||||||
|
|
||||||
|
s_hauteur = math.sqrt(g_sphere_rayon*g_sphere_rayon - g_cyl_rayon*g_cyl_rayon) - g_cyl_demiHauteur
|
||||||
|
|
||||||
|
s_sphere = MakeSphere(g_ox, g_oy, g_oz-s_hauteur, g_sphere_rayon)
|
||||||
|
|
||||||
|
# Calottes
|
||||||
|
# --------
|
||||||
|
|
||||||
|
c_outils = []
|
||||||
|
c_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz+g_cyl_demiHauteur), MakeVectorDXDYDZ(0, 0, 1), g_trim))
|
||||||
|
|
||||||
|
c_cpd = MakePartition([s_sphere], c_outils, [], [], ShapeType["SOLID"])
|
||||||
|
c_calotte_haut, c_reste = SubShapeAllSorted(c_cpd, ShapeType["SOLID"])
|
||||||
|
|
||||||
|
c_plan = MakePlane(MakeVertex(g_ox, g_oy, g_oz), MakeVectorDXDYDZ(0, 0, 1), g_trim)
|
||||||
|
c_calotte_bas = MakeMirrorByPlane(c_calotte_haut, c_plan)
|
||||||
|
|
||||||
|
# Fusionner
|
||||||
|
# ---------
|
||||||
|
|
||||||
|
f_piece1 = MakeFuse(c_cylindre, c_calotte_haut)
|
||||||
|
f_piece = MakeFuse(f_piece1, c_calotte_bas)
|
||||||
|
|
||||||
|
# Trouer
|
||||||
|
# ------
|
||||||
|
|
||||||
|
t_hauteur = g_sphere_rayon
|
||||||
|
t_point = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
|
||||||
|
t_trou = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
|
||||||
|
|
||||||
|
t_piece = MakeCut(f_piece, t_trou)
|
||||||
|
|
||||||
|
# Decouper
|
||||||
|
# --------
|
||||||
|
|
||||||
|
h_outils = []
|
||||||
|
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
|
||||||
|
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
|
||||||
|
|
||||||
|
h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
# Reparer
|
||||||
|
# -------
|
||||||
|
|
||||||
|
piece = RemoveExtraEdges(h_piece)
|
||||||
|
|
||||||
|
# Ajouter la piece dans l'etude
|
||||||
|
# -----------------------------
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex18_dome2")
|
||||||
|
|
||||||
|
# Maillage
|
||||||
|
# ========
|
||||||
|
|
||||||
|
# Maillage hexahedrique
|
||||||
|
# ---------------------
|
||||||
|
|
||||||
|
hexa = smesh.Mesh(piece, "ex18_dome2:hexa")
|
||||||
|
|
||||||
|
algo = hexa.Segment()
|
||||||
|
algo.NumberOfSegments(2)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Calcul du maillage
|
||||||
|
# ------------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
138
src/SMESH_SWIG/ex19_sphereINcube.py
Normal file
138
src/SMESH_SWIG/ex19_sphereINcube.py
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
# CEA/LGLS 2005, Francis KLOSS (OCC)
|
||||||
|
# ==================================
|
||||||
|
|
||||||
|
from geompy import *
|
||||||
|
|
||||||
|
import smesh
|
||||||
|
|
||||||
|
# Geometrie
|
||||||
|
# =========
|
||||||
|
|
||||||
|
# Mailler en hexahedre une sphere dans un cube.
|
||||||
|
|
||||||
|
# Donnees
|
||||||
|
# -------
|
||||||
|
|
||||||
|
sphere_rayon = 100
|
||||||
|
|
||||||
|
cube_cote = 200
|
||||||
|
|
||||||
|
plan_trim = 1000
|
||||||
|
|
||||||
|
# Sphere
|
||||||
|
# ------
|
||||||
|
|
||||||
|
sphere_centre = MakeVertex(0, 0, 0)
|
||||||
|
|
||||||
|
sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
|
||||||
|
|
||||||
|
# Cube interieur
|
||||||
|
# --------------
|
||||||
|
|
||||||
|
boite_cote = sphere_rayon / 2
|
||||||
|
|
||||||
|
boite = MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
|
||||||
|
|
||||||
|
blocs = [boite]
|
||||||
|
|
||||||
|
# Decoupage sphere
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
sphere_troue = MakeCut(sphere_pleine, boite)
|
||||||
|
|
||||||
|
sphere_outils = []
|
||||||
|
sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim))
|
||||||
|
sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim))
|
||||||
|
sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim))
|
||||||
|
sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim))
|
||||||
|
|
||||||
|
sphere_decoupee = MakePartition([sphere_troue], sphere_outils, [], [], ShapeType["SOLID"])
|
||||||
|
|
||||||
|
sphere_partie = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
|
||||||
|
sphere_bloc = RemoveExtraEdges(sphere_partie)
|
||||||
|
|
||||||
|
blocs.append(sphere_bloc)
|
||||||
|
|
||||||
|
pi2 = 3.141592653/2
|
||||||
|
|
||||||
|
sphere_dir1 = MakeVectorDXDYDZ(0, 1, 0)
|
||||||
|
sphere_dir2 = MakeVectorDXDYDZ(0, 0, 1)
|
||||||
|
|
||||||
|
blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
|
||||||
|
blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
|
||||||
|
|
||||||
|
blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
|
||||||
|
blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
|
||||||
|
|
||||||
|
blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
|
||||||
|
|
||||||
|
# Cube exterieur
|
||||||
|
# --------------
|
||||||
|
|
||||||
|
cube_plein = MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
|
||||||
|
cube_trou = MakeCut(cube_plein, sphere_pleine)
|
||||||
|
cube_decoupe = MakePartition([cube_trou], sphere_outils, [], [], ShapeType["SOLID"])
|
||||||
|
cube_partie = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
|
||||||
|
cube_bloc = RemoveExtraEdges(cube_partie)
|
||||||
|
|
||||||
|
blocs.append(cube_bloc)
|
||||||
|
|
||||||
|
blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
|
||||||
|
blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
|
||||||
|
|
||||||
|
blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
|
||||||
|
blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
|
||||||
|
|
||||||
|
blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
|
||||||
|
|
||||||
|
# Piece
|
||||||
|
# -----
|
||||||
|
|
||||||
|
piece_cpd = MakeCompound(blocs)
|
||||||
|
piece = MakeGlueFaces(piece_cpd, 1.e-3)
|
||||||
|
|
||||||
|
piece_id = addToStudy(piece, "ex19_sphereINcube")
|
||||||
|
|
||||||
|
# Groupe geometrique
|
||||||
|
# ==================
|
||||||
|
|
||||||
|
# Definition du groupe
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
groupe = CreateGroup(piece, ShapeType["SOLID"])
|
||||||
|
|
||||||
|
groupe_nom = "ex19_sphereINcube_interieur"
|
||||||
|
addToStudy(groupe, groupe_nom)
|
||||||
|
groupe.SetName(groupe_nom)
|
||||||
|
|
||||||
|
# Contenu du groupe
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
|
||||||
|
|
||||||
|
UnionList(groupe, groupe_sphere)
|
||||||
|
|
||||||
|
# Meshing
|
||||||
|
# =======
|
||||||
|
|
||||||
|
# Create a hexahedral mesh
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
hexa = smesh.Mesh(piece, "ex19_sphereINcube:hexa")
|
||||||
|
|
||||||
|
algo = hexa.Segment()
|
||||||
|
algo.NumberOfSegments(10)
|
||||||
|
|
||||||
|
hexa.Quadrangle()
|
||||||
|
|
||||||
|
hexa.Hexahedron()
|
||||||
|
|
||||||
|
# Mesh calculus
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
hexa.Compute()
|
||||||
|
|
||||||
|
# Le groupe de mailles
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
hexa_groupe = hexa.Group(groupe)
|
@ -1,75 +0,0 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
from geompy import *
|
|
||||||
from meshpy import *
|
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
# Piece
|
|
||||||
# -----
|
|
||||||
|
|
||||||
# A holed cube at center for partitioning
|
|
||||||
|
|
||||||
# Geometry
|
|
||||||
# --------
|
|
||||||
|
|
||||||
g_x = 0
|
|
||||||
g_y = 0
|
|
||||||
g_z = 0
|
|
||||||
|
|
||||||
g_longueur = 50.0
|
|
||||||
g_largeur = 40.0
|
|
||||||
g_hauteur = 25.0
|
|
||||||
|
|
||||||
g_rayon = 10
|
|
||||||
|
|
||||||
g_trim = 1000
|
|
||||||
|
|
||||||
# Box
|
|
||||||
# ---
|
|
||||||
|
|
||||||
b_boite = MakeBox(g_x-g_longueur, g_y-g_hauteur, g_z-g_largeur,
|
|
||||||
g_x+g_longueur, g_y+g_hauteur, g_z+g_largeur)
|
|
||||||
|
|
||||||
# Cylinder
|
|
||||||
# --------
|
|
||||||
|
|
||||||
c_axe = MakeVectorDXDYDZ(0, 1, 0)
|
|
||||||
|
|
||||||
c_cyl0 = MakeCylinder(MakeVertex(g_x, g_y-g_hauteur, g_z), c_axe, g_rayon, g_hauteur*2)
|
|
||||||
c_cyl = MakeRotation(c_cyl0, c_axe, math.atan(g_longueur/g_largeur))
|
|
||||||
|
|
||||||
c_piece = MakeCut(b_boite, c_cyl)
|
|
||||||
|
|
||||||
# Partition
|
|
||||||
# ---------
|
|
||||||
|
|
||||||
p_centre = MakeVertex(g_x, g_y, g_z)
|
|
||||||
|
|
||||||
p_tools = []
|
|
||||||
p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ( g_largeur, 0, g_longueur), g_trim))
|
|
||||||
p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ(-g_largeur, 0, g_longueur), g_trim))
|
|
||||||
|
|
||||||
piece = MakePartition([c_piece], p_tools, [], [], ShapeType["SOLID"])
|
|
||||||
|
|
||||||
# Add in study
|
|
||||||
# ------------
|
|
||||||
|
|
||||||
piece_id = addToStudy(piece, "Hole1partition")
|
|
||||||
|
|
||||||
# Meshing
|
|
||||||
# =======
|
|
||||||
|
|
||||||
# Create hexahedrical mesh on piece
|
|
||||||
# ---------------------------------
|
|
||||||
|
|
||||||
m_hexa=MeshHexa(piece, 4, "Hole1partitionHexa")
|
|
||||||
|
|
||||||
# Compute
|
|
||||||
# -------
|
|
||||||
|
|
||||||
m_hexa.Compute()
|
|
@ -1,165 +0,0 @@
|
|||||||
# CEA/LGLS 2004, Francis KLOSS (OCC)
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
# Import
|
|
||||||
# ------
|
|
||||||
|
|
||||||
import geompy
|
|
||||||
import salome
|
|
||||||
|
|
||||||
import StdMeshers
|
|
||||||
import SMESH
|
|
||||||
|
|
||||||
"""
|
|
||||||
\namespace meshpy
|
|
||||||
\brief Module meshpy
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
# ---------
|
|
||||||
|
|
||||||
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
|
||||||
smesh.SetCurrentStudy(salome.myStudy)
|
|
||||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
|
||||||
smeshgui.Init(salome.myStudyId)
|
|
||||||
|
|
||||||
class MeshHexaImpl:
|
|
||||||
"""
|
|
||||||
Class MeshHexaImpl for Hexahedrical meshing
|
|
||||||
|
|
||||||
Examples: cube2pyGibi.py, lines 270-295
|
|
||||||
cube2partition.py, lines 72-83
|
|
||||||
"""
|
|
||||||
piece = 0
|
|
||||||
name = 0
|
|
||||||
mesh = 0
|
|
||||||
cpt = 0
|
|
||||||
|
|
||||||
def Mesh1D(self, shape, n, propagate=0):
|
|
||||||
"""
|
|
||||||
Define Wires discretization.
|
|
||||||
Sets algorithm and hypothesis for 1D discretization of \a shape:
|
|
||||||
- algorithm "Regular_1D"
|
|
||||||
- hypothesis "NumberOfSegments" with number of segments \a n
|
|
||||||
\param shape Main shape or sub-shape to define wire discretization of
|
|
||||||
\param n Number of segments to split eash wire of the \a shape on
|
|
||||||
\param propagate Boolean flag. If propagate = 1,
|
|
||||||
"Propagation" hypothesis will be applied also to the \a shape
|
|
||||||
"""
|
|
||||||
hyp1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
|
|
||||||
smeshgui.SetName(salome.ObjectToID(hyp1D), self.name+"/WireDiscretisation/"+str(self.cpt))
|
|
||||||
self.mesh.AddHypothesis(shape, hyp1D)
|
|
||||||
|
|
||||||
hyp=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
|
|
||||||
hyp.SetNumberOfSegments(n)
|
|
||||||
smeshgui.SetName(salome.ObjectToID(hyp), self.name+"/Segments_"+str(n)+"/"+str(self.cpt))
|
|
||||||
self.mesh.AddHypothesis(shape, hyp)
|
|
||||||
|
|
||||||
if propagate:
|
|
||||||
hypPro=smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so")
|
|
||||||
smeshgui.SetName(salome.ObjectToID(hypPro), self.name+"/Propagation/"+str(self.cpt))
|
|
||||||
self.mesh.AddHypothesis(shape, hypPro)
|
|
||||||
|
|
||||||
self.cpt=self.cpt+1
|
|
||||||
|
|
||||||
def __init__(self, piece, n, name):
|
|
||||||
"""
|
|
||||||
Constructor
|
|
||||||
|
|
||||||
Creates mesh on the shape \a piece,
|
|
||||||
sets GUI name of this mesh to \a name. \n
|
|
||||||
Sets the following global algorithms and hypotheses:
|
|
||||||
- for 1D discretization:
|
|
||||||
- algorithm "Regular_1D"
|
|
||||||
- hypothesis "NumberOfSegments" with number of segments \a n
|
|
||||||
- for 2D discretization:
|
|
||||||
- algorithm "Quadrangle_2D"
|
|
||||||
- for 3D discretization:
|
|
||||||
- algorithm "Hexa_3D"
|
|
||||||
\param piece Shape to be meshed
|
|
||||||
\param n Global number of segments for wires discretization
|
|
||||||
\param name Name for mesh to be created
|
|
||||||
"""
|
|
||||||
self.piece = piece
|
|
||||||
self.name = name
|
|
||||||
|
|
||||||
self.mesh = smesh.CreateMesh(piece)
|
|
||||||
smeshgui.SetName(salome.ObjectToID(self.mesh), name)
|
|
||||||
|
|
||||||
self.Mesh1D(piece, n)
|
|
||||||
|
|
||||||
hyp2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
|
|
||||||
smeshgui.SetName(salome.ObjectToID(hyp2D), name+"/Quadrangle")
|
|
||||||
self.mesh.AddHypothesis(piece, hyp2D)
|
|
||||||
|
|
||||||
hyp3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
|
|
||||||
smeshgui.SetName(salome.ObjectToID(hyp3D), name+"/ijk")
|
|
||||||
self.mesh.AddHypothesis(piece, hyp3D)
|
|
||||||
|
|
||||||
def local(self, edge, n):
|
|
||||||
"""
|
|
||||||
Creates sub-mesh of the mesh, created by constructor.
|
|
||||||
This sub-mesh will be created on edge \a edge.
|
|
||||||
Set algorithm and hypothesis for 1D discretization of the \a edge:
|
|
||||||
- algorithm "Regular_1D"
|
|
||||||
- hypothesis "NumberOfSegments" with number of segments \a n
|
|
||||||
\param edge Sub-edge of the main shape
|
|
||||||
\param n Number of segments to split the \a edge on
|
|
||||||
\note: \a edge will be automatically published in study under the shape, given in constructor.
|
|
||||||
"""
|
|
||||||
geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
|
|
||||||
submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
|
|
||||||
self.Mesh1D(edge, n)
|
|
||||||
|
|
||||||
def Propagate(self, edge, n):
|
|
||||||
"""
|
|
||||||
Creates sub-mesh of the mesh, created by constructor.
|
|
||||||
This sub-mesh will be created on edge \a edge and
|
|
||||||
propagate the hypothesis on all correspondant edges.
|
|
||||||
Set algorithm and hypothesis for 1D discretization of the \a edge and all other propagate edges:
|
|
||||||
- algorithm "Regular_1D"
|
|
||||||
- hypothesis "NumberOfSegments" with number of segments \a n
|
|
||||||
- hypothesis "Propagation"
|
|
||||||
\param edge Sub-edge of the main shape
|
|
||||||
\param n Number of segments to split the \a edge and all other propagate edges on
|
|
||||||
\note: \a edge will be automatically published in study under the shape, given in constructor.
|
|
||||||
"""
|
|
||||||
geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
|
|
||||||
submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
|
|
||||||
self.Mesh1D(edge, n, 1)
|
|
||||||
|
|
||||||
def Compute(self):
|
|
||||||
"""
|
|
||||||
Computes mesh, created by constructor.
|
|
||||||
"""
|
|
||||||
smesh.Compute(self.mesh, self.piece)
|
|
||||||
salome.sg.updateObjBrowser(1)
|
|
||||||
|
|
||||||
def Group(self, grp, name=""):
|
|
||||||
"""
|
|
||||||
Creates mesh group based on a geometric group
|
|
||||||
\param grp Geometric group
|
|
||||||
\param name Name for mesh group to be created
|
|
||||||
"""
|
|
||||||
if name == "":
|
|
||||||
name = grp.GetName()
|
|
||||||
tgeo = geompy.GroupOp.GetType(grp)
|
|
||||||
if tgeo == geompy.ShapeType["VERTEX"]:
|
|
||||||
type = SMESH.NODE
|
|
||||||
elif tgeo == geompy.ShapeType["EDGE"]:
|
|
||||||
type = SMESH.EDGE
|
|
||||||
elif tgeo == geompy.ShapeType["FACE"]:
|
|
||||||
type = SMESH.FACE
|
|
||||||
elif tgeo == geompy.ShapeType["SOLID"]:
|
|
||||||
type = SMESH.VOLUME
|
|
||||||
return self.mesh.CreateGroupFromGEOM(type, name, grp)
|
|
||||||
|
|
||||||
def ExportMED(self, filename, groups=0):
|
|
||||||
"""
|
|
||||||
Export mesh in a MED file
|
|
||||||
\param filename Name for MED file to be created
|
|
||||||
\param groups Boolean flag. If groups = 1, mesh groups will be also stored in file
|
|
||||||
"""
|
|
||||||
self.mesh.ExportMED(filename, groups)
|
|
||||||
|
|
||||||
MeshHexa = MeshHexaImpl
|
|
462
src/SMESH_SWIG/smesh.py
Normal file
462
src/SMESH_SWIG/smesh.py
Normal file
@ -0,0 +1,462 @@
|
|||||||
|
# Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
#
|
||||||
|
# File : smesh.py
|
||||||
|
# Author : Francis KLOSS, OCC
|
||||||
|
# Module : SMESH
|
||||||
|
|
||||||
|
"""
|
||||||
|
\namespace smesh
|
||||||
|
\brief Module smesh
|
||||||
|
"""
|
||||||
|
|
||||||
|
import salome
|
||||||
|
import geompy
|
||||||
|
import StdMeshers
|
||||||
|
import SMESH
|
||||||
|
|
||||||
|
# Public variables
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
REGULAR = 1
|
||||||
|
PYTHON = 2
|
||||||
|
|
||||||
|
NETGEN = 3
|
||||||
|
GHS3D = 4
|
||||||
|
|
||||||
|
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
|
||||||
|
smesh.SetCurrentStudy(salome.myStudy)
|
||||||
|
|
||||||
|
# Private functions
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
def GetName(obj):
|
||||||
|
ior = salome.orb.object_to_string(obj)
|
||||||
|
sobj = salome.myStudy.FindObjectIOR(ior)
|
||||||
|
attr = sobj.FindAttribute("AttributeName")[1]
|
||||||
|
return attr.Value()
|
||||||
|
|
||||||
|
def SetName(obj, name):
|
||||||
|
ior = salome.orb.object_to_string(obj)
|
||||||
|
sobj = salome.myStudy.FindObjectIOR(ior)
|
||||||
|
attr = sobj.FindAttribute("AttributeName")[1]
|
||||||
|
attr.SetValue(name)
|
||||||
|
|
||||||
|
# Algorithms and hypothesis
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
# Private class: Mesh_Algorithm
|
||||||
|
# -----------------------------
|
||||||
|
|
||||||
|
class Mesh_Algorithm:
|
||||||
|
"""
|
||||||
|
Mother class to define algorithm, recommended to don't use directly
|
||||||
|
"""
|
||||||
|
|
||||||
|
mesh = 0
|
||||||
|
geom = 0
|
||||||
|
subm = 0
|
||||||
|
|
||||||
|
def GetSubMesh(self):
|
||||||
|
"""
|
||||||
|
If the algorithm is global, return 0
|
||||||
|
else return the submesh associated to this algorithm
|
||||||
|
"""
|
||||||
|
return self.subm
|
||||||
|
|
||||||
|
def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
|
||||||
|
"""
|
||||||
|
Private method
|
||||||
|
"""
|
||||||
|
self.mesh = mesh
|
||||||
|
piece = mesh.geom
|
||||||
|
if geom==0:
|
||||||
|
self.geom = piece
|
||||||
|
name = GetName(piece)
|
||||||
|
else:
|
||||||
|
self.geom = geom
|
||||||
|
name = geompy.SubShapeName(geom, piece)
|
||||||
|
geompy.addToStudyInFather(piece, geom, name)
|
||||||
|
self.subm = mesh.mesh.GetSubMesh(geom, hypo)
|
||||||
|
|
||||||
|
algo = smesh.CreateHypothesis(hypo, so)
|
||||||
|
SetName(algo, name + "/" + hypo)
|
||||||
|
mesh.mesh.AddHypothesis(self.geom, algo)
|
||||||
|
|
||||||
|
def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
|
||||||
|
"""
|
||||||
|
Private method
|
||||||
|
"""
|
||||||
|
hypo = smesh.CreateHypothesis(hyp, so)
|
||||||
|
a = ""
|
||||||
|
s = "="
|
||||||
|
i = 0
|
||||||
|
n = len(args)
|
||||||
|
while i<n:
|
||||||
|
a = a + s + str(args[i])
|
||||||
|
s = ","
|
||||||
|
i = i + 1
|
||||||
|
SetName(hypo, GetName(self.geom) + "/" + hyp + a)
|
||||||
|
self.mesh.mesh.AddHypothesis(self.geom, hypo)
|
||||||
|
return hypo
|
||||||
|
|
||||||
|
# Public class: Mesh_Segment
|
||||||
|
# --------------------------
|
||||||
|
|
||||||
|
class Mesh_Segment(Mesh_Algorithm):
|
||||||
|
"""
|
||||||
|
Class to define a segment 1D algorithm for discretization
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, mesh, geom=0):
|
||||||
|
"""
|
||||||
|
Private constructor
|
||||||
|
"""
|
||||||
|
self.Create(mesh, geom, "Regular_1D")
|
||||||
|
|
||||||
|
def LocalLength(self, l):
|
||||||
|
"""
|
||||||
|
Define "LocalLength" hypothesis to cut an edge in several segments with the same length
|
||||||
|
\param l for the length of segments that cut an edge
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("LocalLength", [l])
|
||||||
|
hyp.SetLength(l)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
def NumberOfSegments(self, n, s=[]):
|
||||||
|
"""
|
||||||
|
Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
|
||||||
|
\param n for the number of segments that cut an edge
|
||||||
|
\param s for the scale factor (optional)
|
||||||
|
"""
|
||||||
|
if s == []:
|
||||||
|
hyp = self.Hypothesis("NumberOfSegments", [n])
|
||||||
|
else:
|
||||||
|
hyp = self.Hypothesis("NumberOfSegments", [n,s])
|
||||||
|
hyp.SetScaleFactor(s)
|
||||||
|
hyp.SetNumberOfSegments(n)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
def Arithmetic1D(self, start, end):
|
||||||
|
"""
|
||||||
|
Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
|
||||||
|
\param start for the length of the first segment
|
||||||
|
\param end for the length of the last segment
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("Arithmetic1D", [start, end])
|
||||||
|
hyp.SetLength(start, 1)
|
||||||
|
hyp.SetLength(end , 0)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
def StartEndLength(self, start, end):
|
||||||
|
"""
|
||||||
|
Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
|
||||||
|
\param start for the length of the first segment
|
||||||
|
\param end for the length of the last segment
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("StartEndLength", [start, end])
|
||||||
|
hyp.SetLength(start, 1)
|
||||||
|
hyp.SetLength(end , 0)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
def Deflection1D(self, d):
|
||||||
|
"""
|
||||||
|
Define "Deflection1D" hypothesis
|
||||||
|
\param d for the deflection
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("Deflection1D", [d])
|
||||||
|
hyp.SetDeflection(d)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
def Propagation(self):
|
||||||
|
"""
|
||||||
|
Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
|
||||||
|
the opposite side in the case of quadrangular faces
|
||||||
|
"""
|
||||||
|
return self.Hypothesis("Propagation")
|
||||||
|
|
||||||
|
# Public class: Mesh_Segment_Python
|
||||||
|
# ---------------------------------
|
||||||
|
|
||||||
|
class Mesh_Segment_Python(Mesh_Segment):
|
||||||
|
"""
|
||||||
|
Class to define a segment 1D algorithm for discretization with python function
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, mesh, geom=0):
|
||||||
|
"""
|
||||||
|
Private constructor
|
||||||
|
"""
|
||||||
|
import Python1dPlugin
|
||||||
|
self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
|
||||||
|
|
||||||
|
def PythonSplit1D(self, n, func):
|
||||||
|
"""
|
||||||
|
Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
|
||||||
|
\param n for the number of segments that cut an edge
|
||||||
|
\param func for the python function that calculate the length of all segments
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so")
|
||||||
|
hyp.SetNumberOfSegments(n)
|
||||||
|
hyp.SetPythonLog10RatioFunction(func)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
# Public class: Mesh_Triangle
|
||||||
|
# ---------------------------
|
||||||
|
|
||||||
|
class Mesh_Triangle(Mesh_Algorithm):
|
||||||
|
"""
|
||||||
|
Class to define a triangle 2D algorithm
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, mesh, geom=0):
|
||||||
|
"""
|
||||||
|
Private constructor
|
||||||
|
"""
|
||||||
|
self.Create(mesh, geom, "MEFISTO_2D")
|
||||||
|
|
||||||
|
def MaxElementArea(self, area):
|
||||||
|
"""
|
||||||
|
Define "MaxElementArea" hypothesis to give the maximun area of each triangles
|
||||||
|
\param area for the maximum area of each triangles
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("MaxElementArea", [area])
|
||||||
|
hyp.SetMaxElementArea(area)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
def LengthFromEdges(self):
|
||||||
|
"""
|
||||||
|
Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
|
||||||
|
"""
|
||||||
|
return self.Hypothesis("LengthFromEdges")
|
||||||
|
|
||||||
|
# Public class: Mesh_Quadrangle
|
||||||
|
# -----------------------------
|
||||||
|
|
||||||
|
class Mesh_Quadrangle(Mesh_Algorithm):
|
||||||
|
"""
|
||||||
|
Class to define a quadrangle 2D algorithm
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, mesh, geom=0):
|
||||||
|
"""
|
||||||
|
Private constructor
|
||||||
|
"""
|
||||||
|
self.Create(mesh, geom, "Quadrangle_2D")
|
||||||
|
|
||||||
|
# Public class: Mesh_Tetrahedron
|
||||||
|
# ------------------------------
|
||||||
|
|
||||||
|
class Mesh_Tetrahedron(Mesh_Algorithm):
|
||||||
|
"""
|
||||||
|
Class to define a tetrahedron 3D algorithm
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, mesh, algo, geom=0):
|
||||||
|
"""
|
||||||
|
Private constructor
|
||||||
|
"""
|
||||||
|
if algo == NETGEN:
|
||||||
|
self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
|
||||||
|
elif algo == GHS3D:
|
||||||
|
import GHS3DPlugin
|
||||||
|
self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
|
||||||
|
|
||||||
|
def MaxElementVolume(self, vol):
|
||||||
|
"""
|
||||||
|
Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
|
||||||
|
\param vol for the maximum volume of each tetrahedral
|
||||||
|
"""
|
||||||
|
hyp = self.Hypothesis("MaxElementVolume", [vol])
|
||||||
|
hyp.SetMaxElementVolume(vol)
|
||||||
|
return hyp
|
||||||
|
|
||||||
|
# Public class: Mesh_Hexahedron
|
||||||
|
# ------------------------------
|
||||||
|
|
||||||
|
class Mesh_Hexahedron(Mesh_Algorithm):
|
||||||
|
"""
|
||||||
|
Class to define a hexahedron 3D algorithm
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, mesh, geom=0):
|
||||||
|
"""
|
||||||
|
Private constructor
|
||||||
|
"""
|
||||||
|
self.Create(mesh, geom, "Hexa_3D")
|
||||||
|
|
||||||
|
# Public class: Mesh
|
||||||
|
# ==================
|
||||||
|
|
||||||
|
class Mesh:
|
||||||
|
"""
|
||||||
|
Class to define a mesh
|
||||||
|
"""
|
||||||
|
|
||||||
|
geom = 0
|
||||||
|
mesh = 0
|
||||||
|
|
||||||
|
def __init__(self, geom, name=0):
|
||||||
|
"""
|
||||||
|
Constructor
|
||||||
|
|
||||||
|
Creates mesh on the shape \a geom,
|
||||||
|
sets GUI name of this mesh to \a name.
|
||||||
|
\param geom Shape to be meshed
|
||||||
|
\param name Study name of the mesh
|
||||||
|
"""
|
||||||
|
self.geom = geom
|
||||||
|
self.mesh = smesh.CreateMesh(geom)
|
||||||
|
if name == 0:
|
||||||
|
SetName(self.mesh, GetName(geom))
|
||||||
|
else:
|
||||||
|
SetName(self.mesh, name)
|
||||||
|
|
||||||
|
def GetMesh(self):
|
||||||
|
"""
|
||||||
|
Method that returns the mesh
|
||||||
|
"""
|
||||||
|
return self.mesh
|
||||||
|
|
||||||
|
def GetShape(self):
|
||||||
|
"""
|
||||||
|
Method that returns the shape associated to the mesh
|
||||||
|
"""
|
||||||
|
return self.geom
|
||||||
|
|
||||||
|
def Segment(self, algo=REGULAR, geom=0):
|
||||||
|
"""
|
||||||
|
Creates a segment discretization 1D algorithm.
|
||||||
|
If the optional \a algo parameter is not sets, this algorithm is REGULAR.
|
||||||
|
If the optional \a geom parameter is not sets, this algorithm is global.
|
||||||
|
Otherwise, this algorithm define a submesh based on \a geom subshape.
|
||||||
|
\param algo values are smesh.REGULAR or smesh.PYTHON for discretization via python function
|
||||||
|
\param geom If defined, subshape to be meshed
|
||||||
|
"""
|
||||||
|
if algo == REGULAR:
|
||||||
|
return Mesh_Segment(self, geom)
|
||||||
|
elif algo == PYTHON:
|
||||||
|
return Mesh_Segment_Python(self, geom)
|
||||||
|
else:
|
||||||
|
return Mesh_Segment(self, algo)
|
||||||
|
|
||||||
|
def Triangle(self, geom=0):
|
||||||
|
"""
|
||||||
|
Creates a triangle 2D algorithm for faces.
|
||||||
|
If the optional \a geom parameter is not sets, this algorithm is global.
|
||||||
|
Otherwise, this algorithm define a submesh based on \a geom subshape.
|
||||||
|
\param geom If defined, subshape to be meshed
|
||||||
|
"""
|
||||||
|
return Mesh_Triangle(self, geom)
|
||||||
|
|
||||||
|
def Quadrangle(self, geom=0):
|
||||||
|
"""
|
||||||
|
Creates a quadrangle 2D algorithm for faces.
|
||||||
|
If the optional \a geom parameter is not sets, this algorithm is global.
|
||||||
|
Otherwise, this algorithm define a submesh based on \a geom subshape.
|
||||||
|
\param geom If defined, subshape to be meshed
|
||||||
|
"""
|
||||||
|
return Mesh_Quadrangle(self, geom)
|
||||||
|
|
||||||
|
def Tetrahedron(self, algo, geom=0):
|
||||||
|
"""
|
||||||
|
Creates a tetrahedron 3D algorithm for solids.
|
||||||
|
The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
|
||||||
|
If the optional \a geom parameter is not sets, this algorithm is global.
|
||||||
|
Otherwise, this algorithm define a submesh based on \a geom subshape.
|
||||||
|
\param algo values are: smesh.NETGEN, smesh.GHS3D
|
||||||
|
\param geom If defined, subshape to be meshed
|
||||||
|
"""
|
||||||
|
return Mesh_Tetrahedron(self, algo, geom)
|
||||||
|
|
||||||
|
def Hexahedron(self, geom=0):
|
||||||
|
"""
|
||||||
|
Creates a hexahedron 3D algorithm for solids.
|
||||||
|
If the optional \a geom parameter is not sets, this algorithm is global.
|
||||||
|
Otherwise, this algorithm define a submesh based on \a geom subshape.
|
||||||
|
\param geom If defined, subshape to be meshed
|
||||||
|
"""
|
||||||
|
return Mesh_Hexahedron(self, geom)
|
||||||
|
|
||||||
|
def Compute(self):
|
||||||
|
"""
|
||||||
|
Compute the mesh and return the status of the computation
|
||||||
|
"""
|
||||||
|
b = smesh.Compute(self.mesh, self.geom)
|
||||||
|
if salome.sg.hasDesktop():
|
||||||
|
salome.sg.updateObjBrowser(1)
|
||||||
|
return b
|
||||||
|
|
||||||
|
def Group(self, grp, name=""):
|
||||||
|
"""
|
||||||
|
Create a mesh group based on geometric object \a grp
|
||||||
|
and give a \a name, if this parameter is not defined
|
||||||
|
the name is the same as the geometric group name
|
||||||
|
\param grp is a geometric group
|
||||||
|
\param name is the name of the mesh group
|
||||||
|
"""
|
||||||
|
if name == "":
|
||||||
|
name = grp.GetName()
|
||||||
|
tgeo = geompy.GetType(grp)
|
||||||
|
if tgeo == geompy.ShapeType["VERTEX"]:
|
||||||
|
type = SMESH.NODE
|
||||||
|
elif tgeo == geompy.ShapeType["EDGE"]:
|
||||||
|
type = SMESH.EDGE
|
||||||
|
elif tgeo == geompy.ShapeType["FACE"]:
|
||||||
|
type = SMESH.FACE
|
||||||
|
elif tgeo == geompy.ShapeType["SOLID"]:
|
||||||
|
type = SMESH.VOLUME
|
||||||
|
return self.mesh.CreateGroupFromGEOM(type, name, grp)
|
||||||
|
|
||||||
|
def ExportToMED(self, f, version, opt=0):
|
||||||
|
"""
|
||||||
|
Export the mesh in a file with the MED format and choice the \a version of MED format
|
||||||
|
\param f is the file name
|
||||||
|
\param version values are smesh.MED_V2_1, smesh.MED_V2_2
|
||||||
|
"""
|
||||||
|
self.mesh.ExportToMED(f, opt, version)
|
||||||
|
|
||||||
|
def ExportMED(self, f, opt=0):
|
||||||
|
"""
|
||||||
|
Export the mesh in a file with the MED format
|
||||||
|
\param f is the file name
|
||||||
|
"""
|
||||||
|
self.mesh.ExportMED(f, opt)
|
||||||
|
|
||||||
|
def ExportDAT(self, f):
|
||||||
|
"""
|
||||||
|
Export the mesh in a file with the DAT format
|
||||||
|
\param f is the file name
|
||||||
|
"""
|
||||||
|
self.mesh.ExportDAT(f)
|
||||||
|
|
||||||
|
def ExportUNV(self, f):
|
||||||
|
"""
|
||||||
|
Export the mesh in a file with the UNV format
|
||||||
|
\param f is the file name
|
||||||
|
"""
|
||||||
|
self.mesh.ExportUNV(f)
|
||||||
|
|
||||||
|
def ExportSTL(self, f, ascii=1):
|
||||||
|
"""
|
||||||
|
Export the mesh in a file with the STL format
|
||||||
|
\param f is the file name
|
||||||
|
\param ascii defined the kind of file contents
|
||||||
|
"""
|
||||||
|
self.mesh.ExportSTL(f, ascii)
|
Loading…
Reference in New Issue
Block a user