mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-12 14:07:27 +05:00
Handling cas were shaperstudy is not avaialable for salome on demand
This commit is contained in:
parent
29136aef51
commit
2f85c8d0c4
@ -7821,13 +7821,24 @@ class ParallelMesh(Mesh):
|
|||||||
if not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
|
if not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
|
||||||
raise ValueError("geom argument must be a geometry")
|
raise ValueError("geom argument must be a geometry")
|
||||||
|
|
||||||
import SHAPERSTUDY
|
try:
|
||||||
import shaperBuilder
|
import SHAPERSTUDY
|
||||||
|
shaper_object = SHAPERSTUDY.SHAPERSTUDY_ORB._objref_SHAPER_Object
|
||||||
|
has_shaper = True
|
||||||
|
except ImportError:
|
||||||
|
shaper_object = int
|
||||||
|
has_shaper = False
|
||||||
|
|
||||||
# If we have a shaper object converting it into geom (temporary solution)
|
# If we have a shaper object converting it into geom (temporary solution)
|
||||||
if isinstance(geom, SHAPERSTUDY.SHAPERSTUDY_ORB._objref_SHAPER_Object):
|
if isinstance(geom, shaper_object):
|
||||||
self._geom_obj = _shaperstudy2geom(geompyD, geom)
|
geom_obj = _shaperstudy2geom(geompyD, geom)
|
||||||
|
elif isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
|
||||||
|
geom_obj = geom
|
||||||
else:
|
else:
|
||||||
self._geom_obj = geom
|
msg= ""
|
||||||
|
if not has_shaper:
|
||||||
|
msg = "\nShaper was not compiled"
|
||||||
|
raise Exception("Could not handle geom format {}.{} ".format(type(geom), msg))
|
||||||
|
|
||||||
# Splitting geometry into one geom containing 1D and 2D elements and a
|
# Splitting geometry into one geom containing 1D and 2D elements and a
|
||||||
# list of 3D elements
|
# list of 3D elements
|
||||||
|
@ -23,7 +23,6 @@ import salome
|
|||||||
salome.salome_init_without_session()
|
salome.salome_init_without_session()
|
||||||
|
|
||||||
import GEOM
|
import GEOM
|
||||||
import SHAPERSTUDY
|
|
||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
from salome.smesh import smeshBuilder
|
from salome.smesh import smeshBuilder
|
||||||
from salome.shaper import model
|
from salome.shaper import model
|
||||||
@ -32,7 +31,7 @@ def assertAlmostEqual(a,b,tol):
|
|||||||
if ( abs(a-b) < tol ):
|
if ( abs(a-b) < tol ):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print( "not close vals", a, b )
|
print( "not close vals", a, b )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
|||||||
MesherShinkBox = smesh_builder.Mesh(ShrinkBox, "ShrinkMesh")
|
MesherShinkBox = smesh_builder.Mesh(ShrinkBox, "ShrinkMesh")
|
||||||
ShrinkBoxMesh = MesherShinkBox.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
|
ShrinkBoxMesh = MesherShinkBox.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
|
||||||
|
|
||||||
#Compute
|
#Compute
|
||||||
success = MesherShinkBox.Compute()
|
success = MesherShinkBox.Compute()
|
||||||
assert( success )
|
assert( success )
|
||||||
assert( MesherShinkBox.NbVolumes() == 5 ) # if Fails! change the default value of volumes when meshing with Netgen!
|
assert( MesherShinkBox.NbVolumes() == 5 ) # if Fails! change the default value of volumes when meshing with Netgen!
|
||||||
@ -82,7 +81,7 @@ ShrinkBox2 = viscousBuilder.GetShrinkGeometry()
|
|||||||
MesherShinkBox2 = smesh_builder.Mesh(ShrinkBox2, "ShrinkMesh2")
|
MesherShinkBox2 = smesh_builder.Mesh(ShrinkBox2, "ShrinkMesh2")
|
||||||
ShrinkBoxMesh2 = MesherShinkBox2.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
|
ShrinkBoxMesh2 = MesherShinkBox2.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
|
||||||
|
|
||||||
#Compute
|
#Compute
|
||||||
success = MesherShinkBox2.Compute()
|
success = MesherShinkBox2.Compute()
|
||||||
assert( success )
|
assert( success )
|
||||||
|
|
||||||
@ -112,7 +111,7 @@ algo = MesherShinkFace.Segment()
|
|||||||
numOfSegments = 4
|
numOfSegments = 4
|
||||||
algo.NumberOfSegments(numOfSegments)
|
algo.NumberOfSegments(numOfSegments)
|
||||||
ShrinkFaceMesh = MesherShinkFace.Triangle()
|
ShrinkFaceMesh = MesherShinkFace.Triangle()
|
||||||
#Compute
|
#Compute
|
||||||
success = MesherShinkFace.Compute()
|
success = MesherShinkFace.Compute()
|
||||||
assert( success )
|
assert( success )
|
||||||
numFaceElementShrinkGeom = MesherShinkFace.NbFaces()
|
numFaceElementShrinkGeom = MesherShinkFace.NbFaces()
|
||||||
@ -135,11 +134,11 @@ numOfSegments = 12
|
|||||||
algo.NumberOfSegments(numOfSegments)
|
algo.NumberOfSegments(numOfSegments)
|
||||||
ShrinkCircleMesh = MesherShinkCircle.Triangle()
|
ShrinkCircleMesh = MesherShinkCircle.Triangle()
|
||||||
|
|
||||||
#Compute
|
#Compute
|
||||||
success = MesherShinkCircle.Compute()
|
success = MesherShinkCircle.Compute()
|
||||||
numFaceElementShrinkGeom = MesherShinkCircle.NbFaces()
|
numFaceElementShrinkGeom = MesherShinkCircle.NbFaces()
|
||||||
assert( success )
|
assert( success )
|
||||||
FinalCircleMesh = viscousBuilder.AddLayers( MesherShinkCircle )
|
FinalCircleMesh = viscousBuilder.AddLayers( MesherShinkCircle )
|
||||||
finalNumOfElements = FinalCircleMesh.NbFaces()
|
finalNumOfElements = FinalCircleMesh.NbFaces()
|
||||||
assert( numFaceElementShrinkGeom + numOfSegments * numberOfLayers == finalNumOfElements )
|
assert( numFaceElementShrinkGeom + numOfSegments * numberOfLayers == finalNumOfElements )
|
||||||
#############END MESH CIRCULAR FACE
|
#############END MESH CIRCULAR FACE
|
||||||
|
@ -23,7 +23,6 @@ import salome
|
|||||||
salome.salome_init_without_session()
|
salome.salome_init_without_session()
|
||||||
|
|
||||||
import GEOM
|
import GEOM
|
||||||
import SHAPERSTUDY
|
|
||||||
from salome.geom import geomBuilder
|
from salome.geom import geomBuilder
|
||||||
from salome.smesh import smeshBuilder
|
from salome.smesh import smeshBuilder
|
||||||
from salome.shaper import model
|
from salome.shaper import model
|
||||||
@ -32,7 +31,7 @@ def assertAlmostEqual(a,b,tol):
|
|||||||
if ( abs(a-b) < tol ):
|
if ( abs(a-b) < tol ):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print( "not close vals", a, b )
|
print( "not close vals", a, b )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ assert( BoxProperties[2] > ShrinkBoxProperties[2] )
|
|||||||
|
|
||||||
assert( assertAlmostEqual( BoxProperties[2], (10.0)**(3.0), 1e-12 ) )
|
assert( assertAlmostEqual( BoxProperties[2], (10.0)**(3.0), 1e-12 ) )
|
||||||
#The geometry is shrank in all directions
|
#The geometry is shrank in all directions
|
||||||
assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(3), 1e-12 ) )
|
assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(3), 1e-12 ) )
|
||||||
####END SHRINK THE BOX IN ALL DIRECTIONS
|
####END SHRINK THE BOX IN ALL DIRECTIONS
|
||||||
|
|
||||||
####SHRINK THE BOX EXCEPT FOR ONE FACE
|
####SHRINK THE BOX EXCEPT FOR ONE FACE
|
||||||
@ -80,7 +79,7 @@ viscousBuilder.setBuilderParameters( offset, 4, 1.2, [ selectableFaces[ 0 ] ], T
|
|||||||
ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
||||||
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
|
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
|
||||||
selectableShrinkFaces = geompy.SubShapeAllSortedCentresIDs(ShrinkBox, geompy.ShapeType["FACE"])
|
selectableShrinkFaces = geompy.SubShapeAllSortedCentresIDs(ShrinkBox, geompy.ShapeType["FACE"])
|
||||||
assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(2)*(10.0-offset), 1e-12 ) )
|
assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(2)*(10.0-offset), 1e-12 ) )
|
||||||
####END SHRINK THE BOX EXCEPT FOR ONE FACE
|
####END SHRINK THE BOX EXCEPT FOR ONE FACE
|
||||||
|
|
||||||
####SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
|
####SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
|
||||||
@ -88,7 +87,7 @@ assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(2)*(10.0-of
|
|||||||
viscousBuilder.setBuilderParameters( offset, 4, 1.2, [ selectableFaces[ 0 ] ], False ) # Shrink only the faceid
|
viscousBuilder.setBuilderParameters( offset, 4, 1.2, [ selectableFaces[ 0 ] ], False ) # Shrink only the faceid
|
||||||
ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
||||||
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
|
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
|
||||||
assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0)**(2)*(10.0-offset), 1e-12 ) )
|
assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0)**(2)*(10.0-offset), 1e-12 ) )
|
||||||
selectableShrinkFaces = geompy.SubShapeAllSortedCentresIDs(ShrinkBox, geompy.ShapeType["FACE"])
|
selectableShrinkFaces = geompy.SubShapeAllSortedCentresIDs(ShrinkBox, geompy.ShapeType["FACE"])
|
||||||
####END SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
|
####END SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
|
||||||
|
|
||||||
@ -110,11 +109,11 @@ viscousBuilder.setBuilderParameters( offset, 4, 1.2 )
|
|||||||
ShrinkSphere = viscousBuilder.GetShrinkGeometry()
|
ShrinkSphere = viscousBuilder.GetShrinkGeometry()
|
||||||
ShrinkSphereProperties = geompy.BasicProperties(ShrinkSphere)
|
ShrinkSphereProperties = geompy.BasicProperties(ShrinkSphere)
|
||||||
assert( ShrinkSphereProperties[2] < 4.0/3.0*math.pi * Radius**3 )
|
assert( ShrinkSphereProperties[2] < 4.0/3.0*math.pi * Radius**3 )
|
||||||
assert( assertAlmostEqual( ShrinkSphereProperties[2], 4.0/3.0*math.pi*(10.0-offset)**(3), 1e-12 ) )
|
assert( assertAlmostEqual( ShrinkSphereProperties[2], 4.0/3.0*math.pi*(10.0-offset)**(3), 1e-12 ) )
|
||||||
####END SHRINK THE ENTIRE SPHERE
|
####END SHRINK THE ENTIRE SPHERE
|
||||||
|
|
||||||
####SHRINK THE ENTIRE CYLINDER
|
####SHRINK THE ENTIRE CYLINDER
|
||||||
#Test shrinking cylinder
|
#Test shrinking cylinder
|
||||||
Cylinder = geompy.MakeCylinderRH(10,30)
|
Cylinder = geompy.MakeCylinderRH(10,30)
|
||||||
MesherCylinder = smesh_builder.Mesh(Cylinder, "Cylinder")
|
MesherCylinder = smesh_builder.Mesh(Cylinder, "Cylinder")
|
||||||
viscousBuilder = MesherCylinder.ViscousLayerBuilder()
|
viscousBuilder = MesherCylinder.ViscousLayerBuilder()
|
||||||
@ -155,9 +154,9 @@ sBox = geompy.MakeHalfPartition( box, plane )
|
|||||||
# 4 left, 34 middle, 50 right
|
# 4 left, 34 middle, 50 right
|
||||||
ignoreFaces = [4,34,50]
|
ignoreFaces = [4,34,50]
|
||||||
geompy.addToStudy( sBox, "SisterBox" )
|
geompy.addToStudy( sBox, "SisterBox" )
|
||||||
MesherSBox = smesh_builder.Mesh( sBox, "SisterBoxMesh")
|
MesherSBox = smesh_builder.Mesh( sBox, "SisterBoxMesh")
|
||||||
ViscousBuilder = MesherSBox.ViscousLayerBuilder()
|
ViscousBuilder = MesherSBox.ViscousLayerBuilder()
|
||||||
thickness = 20
|
thickness = 20
|
||||||
numberOfLayers = 10
|
numberOfLayers = 10
|
||||||
stretchFactor = 1.5
|
stretchFactor = 1.5
|
||||||
ViscousBuilder.setBuilderParameters( thickness, numberOfLayers, stretchFactor, ignoreFaces )
|
ViscousBuilder.setBuilderParameters( thickness, numberOfLayers, stretchFactor, ignoreFaces )
|
||||||
@ -197,7 +196,7 @@ assertAlmostEqual( ShrinkFaceProperties[1], (5.0-offset*2.0)**(2.0), 1e-12 )
|
|||||||
######SHRINK CIRCLE
|
######SHRINK CIRCLE
|
||||||
Disk = geompy.MakeDiskR(5, 1)
|
Disk = geompy.MakeDiskR(5, 1)
|
||||||
|
|
||||||
#Test with circle
|
#Test with circle
|
||||||
MesherCircle = smesh_builder.Mesh(Disk, "Disk")
|
MesherCircle = smesh_builder.Mesh(Disk, "Disk")
|
||||||
viscousBuilder = MesherCircle.ViscousLayerBuilder()
|
viscousBuilder = MesherCircle.ViscousLayerBuilder()
|
||||||
viscousBuilder.setBuilderParameters( offset, numberOfLayers, 1.2 )
|
viscousBuilder.setBuilderParameters( offset, numberOfLayers, 1.2 )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user