mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-27 20:50:32 +05:00
Run all SMESH tests at once: all tests pass in 2min instead of 1h20min
This commit is contained in:
parent
85e5c78452
commit
0ec5c9efb1
@ -19,14 +19,21 @@
|
|||||||
|
|
||||||
INCLUDE(tests.set)
|
INCLUDE(tests.set)
|
||||||
|
|
||||||
|
SET(TEST_REINIT_SALOME "False")
|
||||||
|
SALOME_CONFIGURE_FILE(tests.py.in tests.py)
|
||||||
|
|
||||||
SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
|
SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
|
||||||
|
|
||||||
FOREACH(test ${GOOD_TESTS})
|
IF(SMESH_JOIN_TESTS)
|
||||||
GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
|
ADD_TEST(NAME SMESH_examples COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py tests.py)
|
||||||
ADD_TEST(NAME ${testname}
|
ELSE(SMESH_JOIN_TESTS)
|
||||||
COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${test})
|
FOREACH(test ${GOOD_TESTS})
|
||||||
SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}")
|
GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
|
||||||
ENDFOREACH()
|
ADD_TEST(NAME ${testname}
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${test})
|
||||||
|
SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}")
|
||||||
|
ENDFOREACH()
|
||||||
|
ENDIF(SMESH_JOIN_TESTS)
|
||||||
|
|
||||||
# install Python scripts
|
# install Python scripts
|
||||||
SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/SMESH)
|
SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/SMESH)
|
||||||
|
@ -58,24 +58,19 @@ geompy.addToStudy(blocks, "cylinder:blocks")
|
|||||||
# Build geometric groups
|
# Build geometric groups
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
def group(name, shape, type, base=None, direction=None):
|
group_a = geompy.CreateGroup(blocks, geompy.ShapeType["FACE"])
|
||||||
t = geompy.ShapeType[type]
|
geompy.addToStudyInFather(blocks, group_a, "baseA")
|
||||||
g = geompy.CreateGroup(shape, t)
|
items = geompy.GetShapesOnPlaneWithLocationIDs(blocks, geompy.ShapeType["FACE"], direction, base, GEOM.ST_ON)
|
||||||
|
geompy.UnionIDs(group_a, items)
|
||||||
|
|
||||||
geompy.addToStudyInFather(shape, g, name)
|
base_b = geompy.MakeVertex(0, 0, height)
|
||||||
|
group_b = geompy.CreateGroup(blocks, geompy.ShapeType["FACE"])
|
||||||
|
geompy.addToStudyInFather(blocks, group_b, "baseB")
|
||||||
|
items = geompy.GetShapesOnPlaneWithLocationIDs(blocks, geompy.ShapeType["FACE"], direction, base_b, GEOM.ST_ON)
|
||||||
|
geompy.UnionIDs(group_b, items)
|
||||||
|
|
||||||
if base!=None:
|
group_1 = geompy.CreateGroup(blocks, geompy.ShapeType["SOLID"])
|
||||||
l = geompy.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, GEOM.ST_ON)
|
geompy.addToStudyInFather(blocks, group_1, "limit")
|
||||||
geompy.UnionIDs(g, l)
|
|
||||||
|
|
||||||
return g
|
|
||||||
|
|
||||||
group_a = group("baseA", blocks, "FACE", base, direction)
|
|
||||||
|
|
||||||
base_b = geompy.MakeVertex(0, 0, height)
|
|
||||||
group_b = group("baseB", blocks, "FACE", base_b, direction)
|
|
||||||
|
|
||||||
group_1 = group("limit", blocks, "SOLID")
|
|
||||||
group_1_all = geompy.SubShapeAllIDs(blocks, geompy.ShapeType["SOLID"])
|
group_1_all = geompy.SubShapeAllIDs(blocks, geompy.ShapeType["SOLID"])
|
||||||
geompy.UnionIDs(group_1, group_1_all)
|
geompy.UnionIDs(group_1, group_1_all)
|
||||||
group_1_box = geompy.GetBlockNearPoint(blocks, base)
|
group_1_box = geompy.GetBlockNearPoint(blocks, base)
|
||||||
@ -86,22 +81,34 @@ geompy.DifferenceList(group_1, [group_1_box])
|
|||||||
|
|
||||||
smesh.UpdateStudy()
|
smesh.UpdateStudy()
|
||||||
|
|
||||||
def discretize(x, y, z, nbSeg, shape=blocks):
|
|
||||||
vert = geompy.MakeVertex( x, y, z )
|
|
||||||
edge = geompy.GetEdgeNearPoint( shape, vert )
|
|
||||||
algo = hexa.Segment( edge )
|
|
||||||
algo.NumberOfSegments( nbSeg )
|
|
||||||
algo.Propagation()
|
|
||||||
|
|
||||||
hexa = smesh.Mesh(blocks)
|
hexa = smesh.Mesh(blocks)
|
||||||
|
|
||||||
hexa_1d = hexa.Segment()
|
hexa_1d = hexa.Segment()
|
||||||
hexa_1d.NumberOfSegments(1)
|
hexa_1d.NumberOfSegments(1)
|
||||||
|
|
||||||
discretize(+radius , +radius, 0, 5)
|
vertex = geompy.MakeVertex(+radius, +radius, 0)
|
||||||
discretize(-radius , +radius, 0, 8)
|
edge = geompy.GetEdgeNearPoint(blocks, vertex)
|
||||||
discretize((radius+size)/2, 0, 0, 10)
|
algo = hexa.Segment(edge)
|
||||||
discretize( +radius, 0, height/2, 20)
|
algo.NumberOfSegments(5)
|
||||||
|
algo.Propagation()
|
||||||
|
|
||||||
|
vertex = geompy.MakeVertex(-radius, +radius, 0)
|
||||||
|
edge = geompy.GetEdgeNearPoint(blocks, vertex)
|
||||||
|
algo = hexa.Segment(edge)
|
||||||
|
algo.NumberOfSegments(8)
|
||||||
|
algo.Propagation()
|
||||||
|
|
||||||
|
vertex = geompy.MakeVertex((radius+size)/2, 0, 0)
|
||||||
|
edge = geompy.GetEdgeNearPoint(blocks, vertex)
|
||||||
|
algo = hexa.Segment(edge)
|
||||||
|
algo.NumberOfSegments(10)
|
||||||
|
algo.Propagation()
|
||||||
|
|
||||||
|
vertex = geompy.MakeVertex(+radius, 0, height/2)
|
||||||
|
edge = geompy.GetEdgeNearPoint(blocks, vertex)
|
||||||
|
algo = hexa.Segment(edge)
|
||||||
|
algo.NumberOfSegments(20)
|
||||||
|
algo.Propagation()
|
||||||
|
|
||||||
hexa.Quadrangle()
|
hexa.Quadrangle()
|
||||||
hexa.Hexahedron()
|
hexa.Hexahedron()
|
||||||
|
@ -1,37 +1,36 @@
|
|||||||
# Add Polygon
|
# Add Polygon
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
import salome
|
import salome
|
||||||
salome.salome_init()
|
salome.salome_init()
|
||||||
|
|
||||||
import SMESH, SALOMEDS
|
import SMESH, SALOMEDS
|
||||||
from salome.smesh import smeshBuilder
|
from salome.smesh import smeshBuilder
|
||||||
smesh = smeshBuilder.New()
|
smesh = smeshBuilder.New()
|
||||||
|
|
||||||
|
|
||||||
# create an empty mesh structure
|
# create an empty mesh structure
|
||||||
mesh = smesh.Mesh()
|
mesh = smesh.Mesh()
|
||||||
|
|
||||||
# a method to build a polygonal mesh element with <nb_vert> angles:
|
# a method to build a polygonal mesh element with <nb_vert> angles:
|
||||||
def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert):
|
def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert, smesh_builder):
|
||||||
|
import math
|
||||||
|
|
||||||
al = 2.0 * math.pi / nb_vert
|
al = 2.0 * math.pi / nb_vert
|
||||||
node_ids = []
|
node_ids = []
|
||||||
|
|
||||||
# Create nodes for a polygon
|
# Create nodes for a polygon
|
||||||
for ii in range(nb_vert):
|
for ii in range(nb_vert):
|
||||||
nid = mesh.AddNode(x0 + radius * math.cos(ii*al),
|
nid = smesh_builder.AddNode(x0 + radius * math.cos(ii*al),
|
||||||
y0 + radius * math.sin(ii*al),
|
y0 + radius * math.sin(ii*al),
|
||||||
z0)
|
z0)
|
||||||
node_ids.append(nid)
|
node_ids.append(nid)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create a polygon
|
# Create a polygon
|
||||||
return mesh.AddPolygonalFace(node_ids)
|
return smesh_builder.AddPolygonalFace(node_ids)
|
||||||
|
|
||||||
# Create three polygons
|
# Create three polygons
|
||||||
f1 = MakePolygon(mesh, 0, 0, 0, 30, 13)
|
f1 = MakePolygon(mesh, 0, 0, 0, 30, 13, smesh_builder=mesh)
|
||||||
f2 = MakePolygon(mesh, 0, 0, 10, 21, 9)
|
f2 = MakePolygon(mesh, 0, 0, 10, 21, 9, smesh_builder=mesh)
|
||||||
f3 = MakePolygon(mesh, 0, 0, 20, 13, 6)
|
f3 = MakePolygon(mesh, 0, 0, 20, 13, 6, smesh_builder=mesh)
|
||||||
|
|
||||||
salome.sg.updateObjBrowser()
|
salome.sg.updateObjBrowser()
|
||||||
|
@ -44,8 +44,8 @@ for ii in range(len(Wire_polyline_edges)):
|
|||||||
# Mesh
|
# Mesh
|
||||||
|
|
||||||
# Mesh the given shape with the given 1d hypothesis
|
# Mesh the given shape with the given 1d hypothesis
|
||||||
def Mesh1D(shape1d, nbSeg, name):
|
def Mesh1D(shape1d, nbSeg, name, smesh_builder):
|
||||||
mesh1d_tool = smesh.Mesh(shape1d, name)
|
mesh1d_tool = smesh_builder.Mesh(shape1d, name)
|
||||||
algo = mesh1d_tool.Segment()
|
algo = mesh1d_tool.Segment()
|
||||||
hyp = algo.NumberOfSegments(nbSeg)
|
hyp = algo.NumberOfSegments(nbSeg)
|
||||||
isDone = mesh1d_tool.Compute()
|
isDone = mesh1d_tool.Compute()
|
||||||
@ -53,8 +53,8 @@ def Mesh1D(shape1d, nbSeg, name):
|
|||||||
return mesh1d_tool
|
return mesh1d_tool
|
||||||
|
|
||||||
# Create a mesh with six nodes, seven edges and two quadrangle faces
|
# Create a mesh with six nodes, seven edges and two quadrangle faces
|
||||||
def MakeQuadMesh2(mesh_name):
|
def MakeQuadMesh2(mesh_name, smesh_builder):
|
||||||
quad_1 = smesh.Mesh(name = mesh_name)
|
quad_1 = smesh_builder.Mesh(name = mesh_name)
|
||||||
|
|
||||||
# six nodes
|
# six nodes
|
||||||
n1 = quad_1.AddNode(0, 20, 10)
|
n1 = quad_1.AddNode(0, 20, 10)
|
||||||
@ -79,19 +79,19 @@ def MakeQuadMesh2(mesh_name):
|
|||||||
return [quad_1, [1,2,3,4,5,6,7], [8,9]]
|
return [quad_1, [1,2,3,4,5,6,7], [8,9]]
|
||||||
|
|
||||||
# Path meshes
|
# Path meshes
|
||||||
Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight")
|
Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight", smesh_builder=smesh)
|
||||||
Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr")
|
Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr", smesh_builder=smesh)
|
||||||
Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline")
|
Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline", smesh_builder=smesh)
|
||||||
Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle")
|
Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle" , smesh_builder=smesh)
|
||||||
|
|
||||||
# Initial meshes (to be extruded)
|
# Initial meshes (to be extruded)
|
||||||
[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1")
|
[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1", smesh_builder=smesh)
|
||||||
[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2")
|
[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2", smesh_builder=smesh)
|
||||||
[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3")
|
[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3", smesh_builder=smesh)
|
||||||
[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4")
|
[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4", smesh_builder=smesh)
|
||||||
[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5")
|
[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5", smesh_builder=smesh)
|
||||||
[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6")
|
[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6", smesh_builder=smesh)
|
||||||
[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7")
|
[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7", smesh_builder=smesh)
|
||||||
|
|
||||||
# ExtrusionAlongPath
|
# ExtrusionAlongPath
|
||||||
# IDsOfElements, PathMesh, PathShape, NodeStart,
|
# IDsOfElements, PathMesh, PathShape, NodeStart,
|
||||||
|
35
doc/salome/examples/tests.py.in
Normal file
35
doc/salome/examples/tests.py.in
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
DIR='@CMAKE_CURRENT_SOURCE_DIR@'
|
||||||
|
TESTS='@GOOD_TESTS@'
|
||||||
|
REINIT_SALOME=@TEST_REINIT_SALOME@
|
||||||
|
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import salome
|
||||||
|
|
||||||
|
class MyTest(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
if REINIT_SALOME:
|
||||||
|
salome.salome_init()
|
||||||
|
def tearDown(self):
|
||||||
|
if REINIT_SALOME:
|
||||||
|
salome.salome_close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
tests = TESTS.split(';')
|
||||||
|
for test in tests:
|
||||||
|
file_name = os.path.basename(test)
|
||||||
|
if os.path.isabs(test):
|
||||||
|
file_path = file_name
|
||||||
|
else:
|
||||||
|
file_path = os.path.join(DIR, file_name)
|
||||||
|
case_name = 'test_' + file_name[:-3]
|
||||||
|
code = """
|
||||||
|
def func(self):
|
||||||
|
with open('{}') as f:
|
||||||
|
exec(f.read())
|
||||||
|
"""
|
||||||
|
exec(code.format(file_path))
|
||||||
|
setattr(MyTest, case_name, func)
|
||||||
|
|
||||||
|
unittest.main()
|
@ -12,26 +12,25 @@ from salome.smesh import smeshBuilder
|
|||||||
smesh = smeshBuilder.New()
|
smesh = smeshBuilder.New()
|
||||||
import salome_notebook
|
import salome_notebook
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
# define my 2D algorithm
|
# define my 2D algorithm
|
||||||
def my2DMeshing( geomFace ):
|
def my2DMeshing(geomFace, geom_builder, smesh_builder):
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
# find gravity center of geomFace
|
# find gravity center of geomFace
|
||||||
gcXYZ = geompy.PointCoordinates( geompy.MakeCDG( geomFace ))
|
gcXYZ = geom_builder.PointCoordinates( geom_builder.MakeCDG( geomFace ))
|
||||||
|
|
||||||
# define order and orientation of edges
|
# define order and orientation of edges
|
||||||
sortedEdges = []
|
sortedEdges = []
|
||||||
geomEdges = geompy.SubShapeAll( geomFace, geompy.ShapeType["EDGE"])
|
geomEdges = geom_builder.SubShapeAll( geomFace, geom_builder.ShapeType["EDGE"])
|
||||||
sortedEdges.append(( geomEdges.pop(0), True ))
|
sortedEdges.append(( geomEdges.pop(0), True ))
|
||||||
while geomEdges:
|
while geomEdges:
|
||||||
prevEdge_rev = sortedEdges[ -1 ]
|
prevEdge_rev = sortedEdges[ -1 ]
|
||||||
prevVV = geompy.SubShapeAll( prevEdge_rev[0], geompy.ShapeType["VERTEX"])
|
prevVV = geom_builder.SubShapeAll( prevEdge_rev[0], geom_builder.ShapeType["VERTEX"])
|
||||||
prevV2 = prevVV[ prevEdge_rev[1] ]
|
prevV2 = prevVV[ prevEdge_rev[1] ]
|
||||||
found = False
|
found = False
|
||||||
for iE in range( len( geomEdges )):
|
for iE in range( len( geomEdges )):
|
||||||
v1,v2 = geompy.SubShapeAll( geomEdges[ iE ], geompy.ShapeType["VERTEX"])
|
v1,v2 = geom_builder.SubShapeAll( geomEdges[ iE ], geom_builder.ShapeType["VERTEX"])
|
||||||
same1,same2 = [( geompy.MinDistance( prevV2, v ) < 1e-7 ) for v in [v1,v2] ]
|
same1,same2 = [( geom_builder.MinDistance( prevV2, v ) < 1e-7 ) for v in [v1,v2] ]
|
||||||
if not same1 and not same2: continue
|
if not same1 and not same2: continue
|
||||||
sortedEdges.append(( geomEdges.pop( iE ), same1 ))
|
sortedEdges.append(( geomEdges.pop( iE ), same1 ))
|
||||||
found = True
|
found = True
|
||||||
@ -42,10 +41,10 @@ def my2DMeshing( geomFace ):
|
|||||||
# put nodes on edges in a right order
|
# put nodes on edges in a right order
|
||||||
nodes = []
|
nodes = []
|
||||||
for edge, isForward in sortedEdges:
|
for edge, isForward in sortedEdges:
|
||||||
v1,v2 = geompy.SubShapeAll( edge, geompy.ShapeType["VERTEX"])
|
v1,v2 = geom_builder.SubShapeAll( edge, geom_builder.ShapeType["VERTEX"])
|
||||||
edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \
|
edgeNodes = smesh_builder.GetSubMeshNodesId( v2, all=False ) + \
|
||||||
mesh.GetSubMeshNodesId( edge, all=False ) + \
|
smesh_builder.GetSubMeshNodesId( edge, all=False ) + \
|
||||||
mesh.GetSubMeshNodesId( v1, all=False )
|
smesh_builder.GetSubMeshNodesId( v1, all=False )
|
||||||
if not isForward: edgeNodes.reverse()
|
if not isForward: edgeNodes.reverse()
|
||||||
nodes.extend( edgeNodes[:-1] )
|
nodes.extend( edgeNodes[:-1] )
|
||||||
|
|
||||||
@ -54,23 +53,23 @@ def my2DMeshing( geomFace ):
|
|||||||
r2 = 1 - r1
|
r2 = 1 - r1
|
||||||
nodesInside = []
|
nodesInside = []
|
||||||
for n in nodes:
|
for n in nodes:
|
||||||
nXYZ = mesh.GetNodeXYZ( n )
|
nXYZ = smesh_builder.GetNodeXYZ( n )
|
||||||
newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ ))
|
newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ ))
|
||||||
nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] ))
|
nodesInside.append( smesh_builder.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] ))
|
||||||
mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 )
|
smesh_builder.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 )
|
||||||
|
|
||||||
# find out orientation of faces to create
|
# find out orientation of faces to create
|
||||||
# geomFace normal
|
# geomFace normal
|
||||||
faceNorm = geompy.GetNormal( geomFace )
|
faceNorm = geom_builder.GetNormal( geomFace )
|
||||||
v1,v2 = [ geompy.PointCoordinates( v ) \
|
v1,v2 = [ geom_builder.PointCoordinates( v ) \
|
||||||
for v in geompy.SubShapeAll( faceNorm, geompy.ShapeType["VERTEX"]) ]
|
for v in geom_builder.SubShapeAll( faceNorm, geom_builder.ShapeType["VERTEX"]) ]
|
||||||
faceNormXYZ = np.subtract( v2, v1 )
|
faceNormXYZ = np.subtract( v2, v1 )
|
||||||
outDirXYZ = np.subtract( v1, [ 50, 50, 50 ] )
|
outDirXYZ = np.subtract( v1, [ 50, 50, 50 ] )
|
||||||
if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face
|
if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face
|
||||||
faceNormXYZ = np.multiply( -1., faceNormXYZ )
|
faceNormXYZ = np.multiply( -1., faceNormXYZ )
|
||||||
# mesh face normal
|
# mesh face normal
|
||||||
e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] ))
|
e1 = np.subtract( smesh_builder.GetNodeXYZ( nodes[0] ), smesh_builder.GetNodeXYZ( nodes[1] ))
|
||||||
e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] ))
|
e2 = np.subtract( smesh_builder.GetNodeXYZ( nodes[0] ), smesh_builder.GetNodeXYZ( nodesInside[0] ))
|
||||||
meshNorm = np.cross( e1, e2 )
|
meshNorm = np.cross( e1, e2 )
|
||||||
# faces orientation
|
# faces orientation
|
||||||
reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 )
|
reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 )
|
||||||
@ -81,16 +80,16 @@ def my2DMeshing( geomFace ):
|
|||||||
n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1]
|
n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1]
|
||||||
iN -= 1
|
iN -= 1
|
||||||
if reverse:
|
if reverse:
|
||||||
f = mesh.AddFace( [n1, n2, n3, n4] )
|
f = smesh_builder.AddFace( [n1, n2, n3, n4] )
|
||||||
else:
|
else:
|
||||||
f = mesh.AddFace( [n4, n3, n2, n1] )
|
f = smesh_builder.AddFace( [n4, n3, n2, n1] )
|
||||||
# new faces must be assigned to geometry to allow 3D algorithm finding them
|
# new faces must be assigned to geometry to allow 3D algorithm finding them
|
||||||
mesh.SetMeshElementOnShape( f, geomFace )
|
smesh_builder.SetMeshElementOnShape( f, geomFace )
|
||||||
|
|
||||||
if reverse:
|
if reverse:
|
||||||
nodesInside.reverse()
|
nodesInside.reverse()
|
||||||
polygon = mesh.AddPolygonalFace( nodesInside )
|
polygon = smesh_builder.AddPolygonalFace( nodesInside )
|
||||||
mesh.SetMeshElementOnShape( polygon, geomFace )
|
smesh_builder.SetMeshElementOnShape( polygon, geomFace )
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -111,8 +110,8 @@ mesh.Compute()
|
|||||||
mesh.Quadrangle()
|
mesh.Quadrangle()
|
||||||
mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing();
|
mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing();
|
||||||
mesh.UseExistingFaces(f2) # assign UseExistingFaces() BEFORE calling my2DMeshing()!
|
mesh.UseExistingFaces(f2) # assign UseExistingFaces() BEFORE calling my2DMeshing()!
|
||||||
my2DMeshing( f1 )
|
my2DMeshing(f1, geom_builder=geompy, smesh_builder=mesh)
|
||||||
my2DMeshing( f2 )
|
my2DMeshing(f2, geom_builder=geompy, smesh_builder=mesh)
|
||||||
assert mesh.Compute()
|
assert mesh.Compute()
|
||||||
|
|
||||||
# compute 3D mesh
|
# compute 3D mesh
|
||||||
|
Loading…
Reference in New Issue
Block a user