# 2) Compute 2D mesh
isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# 3) Split quadrangles into triangles
-isDone = Mesh_1.SplitQuadObject( Mesh_1, Diag13=True )
+Mesh_1.SplitQuadObject( Mesh_1, Diag13=True )
# 4) Define a 3D mesher
Mesh_1.Tetrahedron()
# 5) Compute 3D mesh
-Mesh_1.Compute()
+isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
# compute the mesh
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
# define the grid by setting constant spacing
cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
# activate creation of faces
cartHyp.SetToCreateFaces( True )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
# enable consideration of shared faces
cartHyp.SetToConsiderInternalFaces( True )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
spaceFuns = ["5","10+10*t"]
cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("nb hexahedra",mesh.NbHexas())
print("nb tetrahedra",mesh.NbTetras())
print("nb polyhedra",mesh.NbPolyhedrons())
mesh = smesh_builder.Mesh( box, "custom axes")
algo = mesh.BodyFitted()
algo.SetGrid( spc, spc, spc, 10000 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("Default axes")
print(" nb hex:",mesh.NbHexas())
# set axes using edges of the box
algo.SetAxesDirs( xDir, [-0.1,1,0], zDir )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("Manual axes")
print(" nb hex:",mesh.NbHexas())
# set optimal orthogonal axes
algo.SetOptimalAxesDirs( isOrthogonal=True )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("Optimal orthogonal axes")
print(" nb hex:",mesh.NbHexas())
# set optimal non-orthogonal axes
algo.SetOptimalAxesDirs( isOrthogonal=False )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("Optimal non-orthogonal axes")
print(" nb hex:",mesh.NbHexas())
status = Mesh_1.AddHypothesis( Sphere_1, NETGEN_3D_Parameters_1 )
NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
isDone = Mesh_1.Compute()
-
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Creating Dual mesh
dual_Mesh_1 = smesh.CreateDualMesh( Mesh_1, 'dual_Mesh_1', True)
-
assert(dual_Mesh_1.NbPolyhedrons() > 0)
assert(dual_Mesh_1.NbTetras() == 0)
-
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
# compute the mesh
ret = tetra.Compute()
-if ret == 0:
- print("problem when computing the mesh")
-else:
- print("mesh computed")
- pass
+if not ret:
+ raise Exception("problem when computing the mesh")
+
+print("mesh computed")
surfaces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"])
# method 1: no sub-mesh is created
-mesh.Compute( surfaces[0] )
+if not mesh.Compute( surfaces[0] ): raise Exception("Error when computing Mesh")
# method 2: a sub-mesh is created
submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" )
-submesh.Compute()
+if not submesh.Compute(): raise Exception("Error when computing Mesh")
# compute the whole mesh
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# get existing sub-mesh priority order: F1 -> F2 -> F3
[[SubMesh_F1, SubMesh_F3, SubMesh_F2]] = mesh.GetMeshOrder()
isDone = mesh.Compute()
+if not isDone: raise Exception("Error when computing Mesh")
print("Nb elements at initial order of sub-meshes:", mesh.NbElements())
# set new sub-mesh order: F2 -> F1 -> F3
isDone = mesh.SetMeshOrder([[SubMesh_F2, SubMesh_F1, SubMesh_F3]])
isDone = mesh.Compute()
+if not isDone: raise Exception("Error when computing Mesh")
print("Nb elements at new order of sub-meshes:", mesh.NbElements())
# compute with other sub-mesh order: F3 -> F2 -> F1
isDone = mesh.SetMeshOrder([[SubMesh_F3, SubMesh_F2, SubMesh_F1]])
isDone = mesh.Compute()
+if not isDone: raise Exception("Error when computing Mesh")
print("Nb elements at another order of sub-meshes:", mesh.NbElements())
hyp4 = algo_local.Propagation()
# compute the mesh
-tria.Compute()
+if not tria.Compute(): raise Exception("Error when computing Mesh")
PrintMeshInfo(tria)
# remove a local hypothesis
tria.RemoveHypothesis(hyp4, edge)
# compute the mesh
-tria.Compute()
+if not tria.Compute(): raise Exception("Error when computing Mesh")
PrintMeshInfo(tria)
# change the value of the 2D hypothesis
hyp2.SetMaxElementArea(2.)
# compute the mesh
-tria.Compute()
+if not tria.Compute(): raise Exception("Error when computing Mesh")
PrintMeshInfo(tria)
tetra.Tetrahedron()
# compute the mesh
-tetra.Compute()
+if not tetra.Compute(): raise Exception("Error when computing Mesh")
# export the mesh in a MED file
medFile = tempfile.NamedTemporaryFile(suffix=".med").name
hexa.Quadrangle()
hexa.Hexahedron()
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
hexa.Group(group_a)
hexa.Group(group_b)
algo1D_1.NumberOfSegments(10)
algo2D_1=Mesh_inf.Quadrangle()
algo3D_1=Mesh_inf.Hexahedron()
-Mesh_inf.Compute()
+if not Mesh_inf.Compute(): raise Exception("Error when computing Mesh")
# create a group on the top face
Gsup1=Mesh_inf.Group(Fsup1, "Sup")
algo1D_2.NumberOfSegments(5)
algo2D_2=Mesh_sup.Quadrangle()
algo3D_2=Mesh_sup.Hexahedron()
-Mesh_sup.Compute()
+if not Mesh_sup.Compute(): raise Exception("Error when computing Mesh")
# create a group on the top face
Gsup2=Mesh_sup.Group(Fsup2, "Sup")
mesh.Segment().NumberOfSegments( 3 )
mesh.Quadrangle()
mesh.Prism()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# objects to copy
fGroup = mesh.GroupOnGeom( face, "2D on face")
cutBox = geom_builder.MakeCut( box, smallBox, theName="box - smallBox" )
ok, newMesh, groups, submehses, hyps, invIDs = smesh_builder.CopyMeshWithGeom( mesh, cutBox, "cutBox" )
-newMesh.Compute()
+if not newMesh.Compute(): raise Exception("Error when computing Mesh")
print("Starting sequential compute")
start = time.monotonic()
is_done = seq_mesh.Compute()
- assert is_done
+ if not is_done:
+ raise Exception("Error when computing Mesh")
+
stop = time.monotonic()
time_seq = stop-start
print("Starting parallel compute")
start = time.monotonic()
is_done = par_mesh.Compute()
- assert is_done
+ if not is_done:
+ raise Exception("Error when computing Mesh")
+
stop = time.monotonic()
time_par = stop-start
mesh = smesh_builder.Mesh( shape )
mesh.Segment().Adaptive( minSize, maxSize, deflection )
mesh.Triangle().MaxElementArea( 300 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
hexa.Hexahedron()
# compute the mesh
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
algo_local.Deflection1D(1.0)
# compute the mesh
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
algo_local.Propagation()
# compute the mesh
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
algo_local.Propagation()
# compute the mesh
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
algo.MaxElementArea(100)
# compute the mesh
-tria_mesh.Compute()
+if not tria_mesh.Compute(): raise Exception("Error when computing Mesh")
# compute the mesh
ret = tetra.Compute()
if ret == 0:
- print("problem when computing the mesh")
-else:
- print("Computation succeeded")
+ raise Exception("problem when computing the mesh")
+
+print("Computation succeeded")
algo2D.LengthFromEdges()
# compute the mesh
-tria.Compute()
+if not tria.Compute(): raise Exception("Error when computing Mesh")
algo_local.Propagation()
# compute the mesh which contains prisms
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
# create another mesh on the box
mesh = smesh_builder.Mesh(box, "Propagation of distribution of nodes")
algo_local.PropagationOfDistribution()
# compute the mesh which contains hexahedra only
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
algo1D.Arithmetic1D(1, 4)
# compute the mesh
-hexa.Compute()
+if not hexa.Compute(): raise Exception("Error when computing Mesh")
# 2. Create a tetrahedral mesh on the box
tetra = smesh_builder.Mesh(box, "Box : tetrahedrical mesh")
algo2D.LengthFromEdges()
# compute the mesh
-tetra.Compute()
+if not tetra.Compute(): raise Exception("Error when computing Mesh")
src_mesh.Quadrangle()
src_mesh.Hexahedron()
src_mesh.Triangle(f1) # triangular sub-mesh
-src_mesh.Compute()
+if not src_mesh.Compute(): raise Exception("Error when computing Mesh")
# Mesh the box using projection algorithms
# 3D hypotheses to project prisms from the source to the target mesh
proj3D = tgt_mesh.Projection3D()
proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 )
-tgt_mesh.Compute()
+if not tgt_mesh.Compute(): raise Exception("Error when computing Mesh")
# Move the source mesh to visually compare the two meshes
src_mesh.TranslateObject( src_mesh, smesh_builder.MakeDirStruct( 210, 0, 0 ), Copy=False)
src_mesh = smesh_builder.Mesh(Face_1, "Source mesh")
src_mesh.Segment().NumberOfSegments(15)
src_mesh.Triangle()
-src_mesh.Compute()
+if not src_mesh.Compute(): raise Exception("Error when computing Mesh")
# Mesh the target mesh using the algorithm Projection1D2D
tgt_mesh = smesh_builder.Mesh(Face_2, "Target mesh")
tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh)
-tgt_mesh.Compute()
+if not tgt_mesh.Compute(): raise Exception("Error when computing Mesh")
Regular_1D = Mesh_1.Segment()
Quadrangle_2D = Mesh_1.Quadrangle()
# Compute mesh
-Mesh_1.Compute()
+if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")
# The Radial Quadrange algorithm can work without any hypothesis
# In this case it uses "Default Nb of Segments" preferences parameter to discretize edges
# So by default there will be 15 segments in both radial and circular directions
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# The Radial Quadrange uses global or local 1d hypotheses if it does
# not have its own hypotheses.
# So that there will be 5 radial layers and 10 circular segments
global_Nb_Segments = mesh.Segment().NumberOfSegments(5)
local_Nb_Segments = mesh.Segment(circle).NumberOfSegments(10)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Define own parameters of Radial Quadrange algorithm
# The number of radial layers will be 4
radial_Quad_algo.NumberOfLayers( 4 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
Quadrangle_2D = Mesh_1.Quadrangle().TriangleVertex( triaVertex )
# Compute the mesh
-Mesh_1.Compute()
+if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")
Nb_Segments_2 = Regular_1D_1.NumberOfSegments(10)
# Compute mesh (with Quadrangle Preference type)
-isDone = Mesh_1.Compute()
+if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")
# Change type to Reduced and compute again
Quadrangle_Parameters_1.SetQuadType( smeshBuilder.QUAD_REDUCED )
-isDone = Mesh_1.Compute()
+if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")
srcMesh = smesh_builder.Mesh(boxes[0], "source mesh") # box coloser to CS origin
nSeg1 = srcMesh.Segment().NumberOfSegments(4)
srcMesh.Quadrangle()
-srcMesh.Compute()
+if not srcMesh.Compute(): raise Exception("Error when computing Mesh")
srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", SMESH.FACE )
# Import faces from midFace0 to the target mesh
import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
tgtMesh.Segment().NumberOfSegments(3)
tgtMesh.Quadrangle()
-tgtMesh.Compute()
+if not tgtMesh.Compute(): raise Exception("Error when computing Mesh")
# Import the whole source mesh with groups
import2hyp.SetCopySourceMesh(True,True)
-tgtMesh.Compute()
+if not tgtMesh.Compute(): raise Exception("Error when computing Mesh")
ignoreFaces, # optional
groupName = groupName) # optional
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# retrieve boundary prisms created by mesh.Compute()
boundaryGroup = mesh.GetGroupByName( layersHyp.GetGroupName() )[0]
vlHyp = mesh.Triangle().ViscousLayers2D( 2, 3, 1.5,
edgeIds, isEdgesToIgnore=True, # optional
groupName=groupName) # optional
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# retrieve boundary elements created by mesh.Compute()
quadrangles = mesh.GetGroupByName( vlHyp.GetGroupName() )[0]
# viscous layers will be created on 3 edges, as we pass isEdgesToIgnore=False
vlHyp.SetEdges( edgeIds, False )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# define refinement near vertices
algo1d.LengthNearVertex( 0.2 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
mesh = smesh_builder.Mesh(face)
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(25)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# get all free borders
filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
mesh = smesh_builder.Mesh(face)
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(25)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# get all faces with free edges
filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges)
mesh.Segment().NumberOfSegments(10)
mesh.Quadrangle()
mesh.Hexahedron()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# copy all elements with translation and Merge nodes
mesh.TranslateObject( mesh, smesh_builder.MakeDirStruct( 10,0,0), Copy=True )
mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) )
mesh.Segment().NumberOfSegments(10)
mesh.Quadrangle()
mesh.Hexahedron()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# copy all elements with translation
mesh.TranslateObject( mesh, [10,0,0], Copy=True )
# create a filter to find nodes equal within tolerance of 1e-5
mesh.Segment().NumberOfSegments(10)
mesh.Quadrangle()
mesh.Hexahedron()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# copy all elements with translation and merge nodes
mesh.TranslateObject( mesh, [10,0,0], Copy=True )
mesh.MergeNodes( mesh.FindCoincidentNodes( 1e-5 ))
v001 = geom_builder.GetVertexNearPoint( box1, geom_builder.MakeVertex(100,100,100), theName='v001')
ijkAlgo.Renumber([ smeshBuilder.BlockCS( box1, v000, v001 ) ])
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Create filters with FT_ConnectedElements criterion by pointing a domain in different ways:
Mesh_1.Segment().NumberOfSegments(15)
Mesh_1.Triangle().LengthFromEdges()
Mesh_1.Tetrahedron()
-Mesh_1.Compute()
+if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")
# relevant groups of volumes and faces
algo1D.NumberOfSegments(7)
# compute the mesh
-quadra.Compute()
+if not quadra.Compute(): raise Exception("Error when computing Mesh")
# create SMESH group on the face with name "SMESHGroup1"
aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1")
mesh = smesh_builder.Mesh(box,"Quad mesh")
hyp1D = mesh.Segment().StartEndLength( 1, 4 )
mesh.Quadrangle()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# create a group on filter selecting faces of medium size
critaria = [ \
# group on filter is updated if the mesh is modified
hyp1D.SetStartLength( 2.5 )
hyp1D.SetEndLength( 2.5 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("After mesh change, group on filter contains %s elements" % filtGroup.Size())
# set a new filter defining the group
mesh2.Segment().NumberOfSegments(5)
mesh2.Triangle().MaxElementArea(20)
-mesh1.Compute()
-mesh2.Compute()
+if not mesh1.Compute(): raise Exception("Error when computing Mesh")
+if not mesh2.Compute(): raise Exception("Error when computing Mesh")
# compute min distance from grp1 to the origin (not available yet)
smesh_builder.MinDistance(mesh1)
mesh2.Segment().NumberOfSegments(5)
mesh2.Triangle().MaxElementArea(20)
-mesh1.Compute()
-mesh2.Compute()
+if not mesh1.Compute(): raise Exception("Error when computing Mesh")
+if not mesh2.Compute(): raise Exception("Error when computing Mesh")
# compute bounding box for mesh1
mesh1.BoundingBox()
submesh_2d = mesh.Quadrangle()
submesh_3d = mesh.Hexahedron()
submesh_2d_face = mesh.Triangle(face)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# create a group
# finally compute whole mesh
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
algo3d.MaxElementVolume(100)
# Compute the mesh
-tetra.Compute()
+if not tetra.Compute(): raise Exception("Error when computing Mesh")
# Create a mesh group of all triangles generated on geom faces present in faces_group
group = tetra.Group(faces_group)
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(5)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
print("After Compute(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces()))
# remove nodes #246 and #255
mesh = smesh_builder.Mesh( box )
mesh.Segment().AutomaticLength(0.1)
mesh.Quadrangle()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# find node at (0,0,0) which is located on a geom vertex
node000 = None
algo = mesh1d_tool.Segment()
hyp = algo.NumberOfSegments(nbSeg)
isDone = mesh1d_tool.Compute()
- if not isDone: print('Mesh ', name, ': computation failed')
+ if not isDone: raise Exception('Mesh %s: computation failed' % name)
return mesh1d_tool
# Create a mesh with six nodes, seven edges and two quadrangle faces
Mesh_1.Quadrangle()
isDone = Mesh_1.Compute()
-if not isDone: print('Mesh Mesh_1 : computation failed')
+if not isDone: raise Exception('Mesh Mesh_1 : computation failed')
# build a triangle mesh on Face_2
Mesh_2 = smesh_builder.Mesh(Face_2)
algo2D.MaxElementArea(240)
isDone = Mesh_2.Compute()
-if not isDone: print('Mesh Mesh_2 : computation failed')
+if not isDone: raise Exception('Mesh Mesh_2 : computation failed')
# create a 2d pattern
pattern = smesh_builder.GetPattern()
Mesh_3.Quadrangle()
Mesh_3.Hexahedron()
isDone = Mesh_3.Compute()
-if not isDone: print('Mesh Mesh_3 : computation failed')
+if not isDone: raise Exception('Mesh Mesh_3 : computation failed')
# create a 3d pattern (hexahedrons)
pattern_hexa = smesh_builder.GetPattern()
Mesh_4.Quadrangle()
Mesh_4.Hexahedron()
isDone = Mesh_4.Compute()
-if not isDone: print('Mesh Mesh_4 : computation failed')
+if not isDone: raise Exception('Mesh Mesh_4 : computation failed')
# create another 3d pattern (pyramids)
pattern_pyra = smesh_builder.GetPattern()
# compute mesh
-Mesh.Compute()
+if not Mesh.Compute(): raise Exception("Error when computing Mesh")
# convert to quadratic
# theForce3d = 1; this results in the medium node lying at the
algo3D.MaxElementVolume("MaxElementVolume")
# compute the mesh
-ret = tetra.Compute()
+if not tetra.Compute(): raise Exception("Error when computing Mesh")
# translate the mesh
point = SMESH.PointStruct("Offset", 0., 0.)
mesh.Triangle(bigQuad)
# compute the mesh
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
algo2d = mesh.Quadrangle( smeshBuilder.QUAD_MA_PROJ )
algo2d.StartEndLength( circleLen2 / circNbSeg, circleLen1 / circNbSeg ) # radial division
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
algo = mesh.Segment()
algo.LocalLength(35)
algo = mesh.Triangle()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# get min and max deflection
minMax = mesh.GetMinMax( SMESH.FT_Deflection2D )
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# criterion : free borders
aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders)
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Criterion : Borders at multi-connection
nb_conn = 2
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Criterion : Length > 3.
length_margin = 3.
mesh = smesh_builder.Mesh(box, "Mesh_free_nodes")
mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(150.)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Remove some elements to obtain free nodes
# Criterion : AREA < 80.
Mesh_1.Segment().MaxSize(34.641)
Mesh_1.Triangle()
Mesh_1.Tetrahedron()
-Mesh_1.Compute()
+if not Mesh_1.Compute(): raise Exception("Error when computing Mesh")
# create a group of free faces
aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces )
mesh = smesh_builder.Mesh(box)
mesh.Segment().NumberOfSegments(3)
mesh.Quadrangle()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# remove 2 faces
allFaces = mesh.GetElementsByType(SMESH.FACE)
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Criterion : Length 2D > 5.7
length_margin = 5.7
algo.NumberOfSegments(5)
algo = mesh.Triangle()
algo.MaxElementArea(20.)
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Criterion : MULTI-CONNECTION 2D = 3
nb_conn = 3
prism_algo.NumberOfSegments( 4, 5. )
# compute the mesh
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
mesh.Segment().NumberOfSegments(1)
mesh.Quadrangle()
mesh.Triangle( ff[1] )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# make group of quadrangles and extrude them into a hexahedron
quadGroup = mesh.Group( ff[0], "quads")
smeshhomard.SetLogFile(log_file_1)
smeshhomard.SetRemoveLogOnSuccess(False)
smeshhomard.SetVerboseLevel(3)
-smeshhomard.Compute()
+if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
if osp.isfile(output_med_1):
os.remove(output_med_1)
smeshhomard.SetLogFile(log_file_2)
smeshhomard.SetRemoveLogOnSuccess(True)
smeshhomard.SetVerboseLevel(0)
-smeshhomard.Compute()
+if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
if osp.isfile(output_med_2):
print("Test Uniform refinement Case 2: Error: output med file has not been removed")
smeshhomard.SetLogFile(log_file_1)
smeshhomard.SetRemoveLogOnSuccess(False)
smeshhomard.SetVerboseLevel(3)
-smeshhomard.Compute()
+if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
if osp.isfile(output_med_1):
os.remove(output_med_1)
smeshhomard.SetLogFile(log_file_2)
smeshhomard.SetRemoveLogOnSuccess(True)
smeshhomard.SetVerboseLevel(0)
-smeshhomard.Compute()
+if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
if osp.isfile(output_med_2):
print("Test Uniform refinement Case 2: Error: output med file has not been removed")
Nb_Segments_1 = Regular_1D.NumberOfSegments(3)
Nb_Segments_1.SetDistrType( 0 )
Quadrangle_2D = Mesh1.Quadrangle()
-isDone = Mesh1.Compute()
+if not Mesh1.Compute(): raise Exception("Error when computing Mesh")
#Perform scale operation for the whole mesh and creation of a new mesh
newMesh = Mesh1.ScaleMakeMesh(Mesh1,SMESH.PointStruct(100,100,200),[0.5,0.3,0.7],True,"ScaledMesh")
algo2D = trias.Triangle()
algo2D.LengthFromEdges()
-trias.Compute()
+if not trias.Compute(): raise Exception("Error when computing Mesh")
# create a group of all triangles currently present in the mesh
faceTriGroup = trias.Group( face1, "face triangles" )
circlemesh = smesh_builder.Mesh(circle, "Path mesh")
algo = circlemesh.Segment()
algo.NumberOfSegments(10)
-circlemesh.Compute()
+if not circlemesh.Compute(): raise Exception("Error when computing Mesh")
# extrusion of the mesh
trias.ExtrusionAlongPath([], circlemesh, circle, 1, MakeGroups=True )
algo_local.Arithmetic1D(1, 4)
algo_local.Propagation()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# sew border to side
# FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
algo_local.Arithmetic1D(1, 4)
algo_local.Propagation()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# sew conform free borders
# FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2
mesh.Segment().Arithmetic1D( 0.1, 0.4 )
mesh.Segment(q1).NumberOfSegments( 5 )
mesh.Quadrangle()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# sew free borders
algo_local.NumberOfSegments(4)
algo_local.Propagation()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# sew side elements
mesh.Hexahedron()
# Compute mesh
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Duplicate nodes only
mesh.AutomaticHexahedralization(0.5)
localAlgo = mesh.Segment(faces[0])
localAlgo.NumberOfSegments( 11 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
group = mesh.Group( faces[1] )
vec = geom_builder.MakeVectorDXDYDZ( 1, 1, 1 )
# compute 1D mesh
mesh = smesh_builder.Mesh( box )
mesh.Segment().NumberOfSegments( 5 )
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# compute 2D mesh
mesh.Quadrangle()
mesh.UseExistingFaces(f2) # assign UseExistingFaces() BEFORE calling my2DMeshing()!
my2DMeshing(f1, mesh)
my2DMeshing(f2, mesh)
-assert mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# compute 3D mesh
mesh.Prism()
-assert mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
Nb_Segments_1 = Regular_1D_1_1.NumberOfSegments(5)
Nb_Segments_1.SetDistrType( 0 )
Quadrangle_2D = tetra.Quadrangle(geom=Face_1)
-isDone = tetra.Compute()
+if not tetra.Compute(): raise Exception("Error when computing Mesh")
submesh = Regular_1D_1_1.GetSubMesh()
# compute the mesh
-tetra.Compute()
+if not tetra.Compute(): raise Exception("Error when computing Mesh")
# Creation of group
group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' )
# Create a mesh
mesh = smesh_builder.Mesh(box,"Mesh")
mesh.AutomaticHexahedralization()
-mesh.Compute()
+if not mesh.Compute(): raise Exception("Error when computing Mesh")
# Create a point
x,y,z = 0, 0, 1
Hexa_3D = smesh.CreateHypothesis('Hexa_3D')
status = boxmesh.AddHypothesis(Hexa_3D)
isDone = boxmesh.Compute()
+ if not isDone:
+ raise Exception("Error when computing Mesh")
smesh.SetName(boxmesh.GetMesh(), 'boxmesh')
if salome.sg.hasDesktop():
print("---------------------Compute the mesh")
-ret = mesh.Compute()
-print(ret)
+isDone = mesh.Compute()
+print(isDone)
+if not isDone:
+ raise Exception("Error when computing Mesh")
+
salome.sg.updateObjBrowser()
smesh.SetName(hypNbSeg2, "NumberOfSegments 2")
# compute meshes
-mesh1.Compute()
-mesh2.Compute()
+isDone = mesh1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
+
+isDone = mesh2.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# ---- udate object browser
# compute meshes
-mesh1.Compute()
-mesh2.Compute()
+isDone = mesh1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
+
+isDone = mesh2.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# ---- update object browser
salome.sg.updateObjBrowser()
aName = str(theSubShape)
geompy.addToStudyInFather(theShape,theSubShape,aName)
- theMeshGen.Compute(theMesh,theShape)
+ if not theMeshGen.Compute(theMesh,theShape):
+ raise Exception("Error when computing Mesh")
aFilterMgr = theMeshGen.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
aName = str(theSubShape)
geompy.addToStudyInFather(theShape,theSubShape,aName)
- theMesh.Compute()
+ if not theMesh.Compute():
+ raise Exception("Error when computing Mesh")
+
aFilter = smesh.GetFilter(theElemType, SMESH.FT_BelongToGeom, theSubShape)
return aFilter.GetElementsId(theMesh.GetMesh())
algo1D_1.NumberOfSegments(10)
algo2D_1=Mesh_inf.Quadrangle()
algo3D_1=Mesh_inf.Hexahedron()
-Mesh_inf.Compute()
+isDone = Mesh_inf.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# create a group on the top face
Gsup1=Mesh_inf.Group(Fsup1, "Sup")
algo1D_2.NumberOfSegments(5)
algo2D_2=Mesh_sup.Quadrangle()
algo3D_2=Mesh_sup.Hexahedron()
-Mesh_sup.Compute()
+isDone = Mesh_sup.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# create a group on the top face
Gsup2=Mesh_sup.Group(Fsup2, "Sup")
# Compute the mesh created in SMESH_test1
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Create geometry groups on plane:
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
# Compute the mesh created in SMESH_test1
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Create geometry groups on plane:
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
print(" ")
print("Re-compute mesh, contents of aGroupOnShell changes again:")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
+
print("aGroupOnShell size =", aGroupOnShell.Size())
print("aGroupOnShell ids :", aGroupOnShell.GetListOfID())
#Example
from SMESH_test1 import *
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# First way
BuildGroupLyingOn(mesh.GetMesh(), SMESH.FACE, "Group of faces lying on edge #1", edge )
print("-------------------------- compute the mesh of the mechanic piece")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
print("Information about the Nut:")
print("Number of nodes : ", mesh.NbNodes())
print("-------------------------- compute the mesh of alveole ")
ret = mesh.Compute()
-
-if ret != 0:
- log=mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the Mesh_mechanic:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons: ", mesh.NbTetras())
-else:
- print("problem when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the Mesh_mechanic:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons: ", mesh.NbTetras())
salome.sg.updateObjBrowser()
algo.NumberOfSegments(NbSeg)
my_hexa.Quadrangle()
my_hexa.Hexahedron()
-my_hexa.Compute()
+isDone = my_hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
salome.sg.updateObjBrowser()
# compute mesh
-box_mesh.Compute()
+isDone = box_mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
sg.updateObjBrowser()
print("-------------------------- compute shell")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- log = mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the MeshBox2:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons: ", mesh.NbTetras())
-else:
- print("probleme when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the MeshBox2:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons: ", mesh.NbTetras())
salome.sg.updateObjBrowser()
print("-------------------------- compute shell")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- log = mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the MeshBox3:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons: ", mesh.NbTetras())
-else:
- print("probleme when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the MeshBox3:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons: ", mesh.NbTetras())
salome.sg.updateObjBrowser()
print("-------------------------- compute the mesh of the box")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- log = mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the MeshBox:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons: ", mesh.NbTetras())
-else:
- print("probleme when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the MeshBox:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons: ", mesh.NbTetras())
salome.sg.updateObjBrowser()
middle_1 = Mesh_1.GroupOnGeom(middle,'middle',SMESH.FACE)
bottom_1 = Mesh_1.GroupOnGeom(bottom,'bottom',SMESH.FACE)
isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
[ top_1, middle_1, bottom_1 ] = Mesh_1.GetGroups()
algo3d.MaxElementVolume(0.0002)
isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Create groups
d_geom_groups = {}
print("-------------------------- compute the mesh of the volume")
-ret=mesh.Compute()
-
+ret = mesh.Compute()
print(ret)
-if ret != 0:
-## log=mesh.GetLog(0) # no erase trace
-## for linelog in log:
-## print linelog
- print("Information about the MeshBox :")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons: ", mesh.NbTetras())
-else:
- print("problem when Computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+##log=mesh.GetLog(0) # no erase trace
+##for linelog in log:
+## print linelog
+print("Information about the MeshBox :")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons: ", mesh.NbTetras())
salome.sg.updateObjBrowser()
print("-------------------------- compute compshell")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- log = mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the MeshcompShel:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of quadrangles : ", mesh.NbQuadrangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of hexahedrons : ", mesh.NbHexas())
-else:
- print("problem when Computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the MeshcompShel:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of quadrangles : ", mesh.NbQuadrangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of hexahedrons : ", mesh.NbHexas())
salome.sg.updateObjBrowser()
print("-------------------------- compute mesh")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- print("Information about the MeshcompShel:")
- print("Number of nodes : ", mesh.GetMesh().NbNodes())
- print("Number of edges : ", mesh.GetMesh().NbEdges())
- print("Number of faces : ", mesh.GetMesh().NbFaces())
- print("Number of triangles : ", mesh.GetMesh().NbTriangles())
- print("Number of volumes : ", mesh.GetMesh().NbVolumes())
- print("Number of tetrahedrons : ", mesh.GetMesh().NbTetras())
-
-else:
- print("problem when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+print("Information about the MeshcompShel:")
+print("Number of nodes : ", mesh.GetMesh().NbNodes())
+print("Number of edges : ", mesh.GetMesh().NbEdges())
+print("Number of faces : ", mesh.GetMesh().NbFaces())
+print("Number of triangles : ", mesh.GetMesh().NbTriangles())
+print("Number of volumes : ", mesh.GetMesh().NbVolumes())
+print("Number of tetrahedrons : ", mesh.GetMesh().NbTetras())
salome.sg.updateObjBrowser()
print("-------------------------- compute compshell")
ret = mesh.Compute(mesh)
print(ret)
-if ret != 0:
- log = mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the MeshcompShel:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons : ", mesh.NbTetras())
-
-else:
- print("problem when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the MeshcompShel:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons : ", mesh.NbTetras())
salome.sg.updateObjBrowser()
print("-------------------------- compute the skin flight")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- log = mesh.GetLog(0) # no erase trace
- # for linelog in log:
- # print(linelog)
- print("Information about the Mesh_mechanic_tetra:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of volumes : ", mesh.NbVolumes())
-else:
- print("probleme when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+log = mesh.GetLog(0) # no erase trace
+# for linelog in log:
+# print(linelog)
+print("Information about the Mesh_mechanic_tetra:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of volumes : ", mesh.NbVolumes())
salome.sg.updateObjBrowser()
hypArea = algoMef.MaxElementArea(20)
-mesh.Compute()
-
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Criterion : Free edges. Create group.
# ---- compute mesh
print("-------------------------- compute mesh")
ok = mesh.Compute()
-if ok:
- print("Information about the Mesh:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of quadrangles : ", mesh.NbQuadrangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of hexahedrons : ", mesh.NbHexas())
-else:
- print("problem when Computing the mesh")
+if not ok:
+ raise Exception("Error when computing Mesh")
+
+print("Information about the Mesh:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of quadrangles : ", mesh.NbQuadrangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of hexahedrons : ", mesh.NbHexas())
salome.sg.updateObjBrowser()
print("-------------------------- compute the mesh of the mechanic piece")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
print("Information about the Mesh_mechanic:")
print("Number of nodes : ", mesh.NbNodes())
print("-------------------------- compute the mesh of the mechanic piece")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
print("Information about the Mesh_mechanic:")
print("Number of nodes : ", mesh.NbNodes())
print("-------------------------- compute mesh")
ret = mesh.Compute()
print(ret)
-if ret != 0:
- print("Information about the MeshcompShel:")
- print("Number of nodes : ", mesh.NbNodes())
- print("Number of edges : ", mesh.NbEdges())
- print("Number of faces : ", mesh.NbFaces())
- print("Number of triangles : ", mesh.NbTriangles())
- print("Number of quadrangles : ", mesh.NbQuadrangles())
- print("Number of volumes : ", mesh.NbVolumes())
- print("Number of tetrahedrons : ", mesh.NbTetras())
-
-else:
- print("problem when computing the mesh")
+if not ret:
+ raise Exception("Error when computing Mesh")
+
+print("Information about the MeshcompShel:")
+print("Number of nodes : ", mesh.NbNodes())
+print("Number of edges : ", mesh.NbEdges())
+print("Number of faces : ", mesh.NbFaces())
+print("Number of triangles : ", mesh.NbTriangles())
+print("Number of quadrangles : ", mesh.NbQuadrangles())
+print("Number of volumes : ", mesh.NbVolumes())
+print("Number of tetrahedrons : ", mesh.NbTetras())
salome.sg.updateObjBrowser()
print("-------------------------- compute the mesh of the mechanic piece")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
print("Information about the Mesh_mechanic_tetra:")
print("Number of nodes : ", mesh.NbNodes())
ret = mesh.Compute(face)
print(ret)
+if not ret:
+ raise Exception("Error when computing Mesh")
+
log = [] #mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after
for a in log:
print("-------")
print(hypArea2.GetMaxElementArea())
smesh.SetName(hypArea2, "MaxElementArea_500")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
salome.sg.updateObjBrowser()
print("-------------------------- compute box")
ret = mesh.Compute()
print(ret)
+if not ret:
+ raise Exception("Error when computing Mesh")
+
log = mesh.GetLog(0); # no erase trace
# for linelog in log:
# print(linelog)
submesh = algo4.GetSubMesh()
smesh.SetName(submesh, "SubMeshFace")
-mesh.Compute()
+isDone = mesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
faces = submesh.GetElementsByType(SMESH.FACE)
if len(faces) > 1:
Mesh_1 = smesh.Mesh(Box_1)
NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
isDone = Mesh_1.Compute()
-
+if not isDone:
+ raise Exception("Error when computing Mesh")
## Set names of Mesh objects
smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D')
NETGEN_3D_Parameters_1.SetQuadAllowed( 0 )
NETGEN_3D_Parameters_1.SetCheckChartBoundary( 152 )
isDone = Mesh_1.Compute()
-
+if not isDone:
+ raise Exception("Error when computing Mesh")
## Set names of Mesh objects
smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D')
Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
isDone = Mesh_1.Compute()
+ if not isDone:
+ raise Exception("Error when computing Mesh")
smesh.SetName(Mesh_1, 'Mesh_1')
#### Mesh_1.ExportMED( r'Mesh_with_one_field_on_cells.med', 0, 41, 1, Mesh_1.GetMesh(), 1, [ Field_1_1 ], '',-1 )
Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
isDone = Mesh_1.Compute()
+ if not isDone:
+ raise Exception("Error when computing Mesh")
smesh.SetName(Mesh_1, 'Mesh_1')
# 23th of june 2021 : Bug both in ExportMED and in ExportMEDCoupling
algo_1d_sub.Propagation()
isDone = Mesh_1.Compute()
+ if not isDone:
+ raise Exception("Error when computing Mesh")
nb_nodes = Mesh_1.NbNodes()
# Create 2 cracks by two calls of DoubleNodeElemGroups
# Compute the mesh
# ----------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Compute the mesh
# ----------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Compute the mesh
# ----------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-mixed.Compute()
+isDone = mixed.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
t3= time.time()
# Compute the mesh
# ----------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Calculer le maillage
# --------------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Calcul du maillage
# ------------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
+
# Update object browser
# ---------------------
# Calcul du maillage
# ------------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Update object browser
# ---------------------
# Mesh calculus
# -------------
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Le groupe de mailles
# --------------------
# Compute the mesh
# ----------------
-tetra.Compute()
+isDone = tetra.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# Create a groupe of faces
# ------------------------
hexa.Quadrangle()
hexa.Hexahedron()
-hexa.Compute()
+isDone = hexa.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
hexa.Group(group_a)
hexa.Group(group_b)
algo2D = MyMesh.Triangle()
algo2D.MaxElementArea(0.07)
-MyMesh.Compute()
+isDone = MyMesh.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
MyMesh.ExportMED(path+"110_triangles.med", 0)
Nb_Segments_1.SetDistrType( 0 )
Quadrangle_2D = Mesh_1.Quadrangle()
isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# groups creation
# --------------
status = m.Compute()
+if not status:
+ raise Exception("Error when computing Mesh")
# Test if ok
# ----------
Quadrangle_2D = Mesh_1.Quadrangle()
Hexa_3D = Mesh_1.Hexahedron()
isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
### CreateDimGroup()
Mesh_1 = smesh.Mesh( Box_1 )
Mesh_1.Segment().NumberOfSegments(15)
Mesh_1.Triangle()
-Mesh_1.Compute()
+isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
# define arguments for MakePolyLine
Number_of_Segments_1 = Regular_1D.NumberOfSegments(6)
Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
isDone = Mesh_1.Compute()
+if not isDone:
+ raise Exception("Error when computing Mesh")
+
aMaxElementLength2D0x5d7fdf0 = aFilterManager.CreateMaxElementLength2D()
isDone = Mesh_1.QuadToTriObject( Mesh_1, )
Mesh_1.ExtrusionSweepObjects( [ Mesh_1 ], [ Mesh_1 ], [ Mesh_1 ], [ 0, 0, 50 ], 3, 1 )
mesh_2d = smesh.Mesh(groupe_1, 'Maillage_1')
mesh_2d.AddHypothesis(groupe_1, netgen_2d_parameters_1)
mesh_2d.Triangle(algo=smeshBuilder.NETGEN_1D2D)
- is_done = mesh_2d.Compute()
- assert is_done
+ isDone = mesh_2d.Compute()
+ if not isDone:
+ raise Exception("Error when computing Mesh")
+
smesh.SetName(mesh_2d, 'Maillage_1')
with tempfile.TemporaryDirectory() as tmp_dir:
PolyhedronPerSolid_3D = Mesh_1.Polyhedron()
ok = Mesh_1.Compute()
-
if not ok:
raise Exception("Error when computing Mesh")