mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-11 16:19:16 +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):
|
||||
raise ValueError("geom argument must be a geometry")
|
||||
|
||||
import SHAPERSTUDY
|
||||
import shaperBuilder
|
||||
try:
|
||||
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 isinstance(geom, SHAPERSTUDY.SHAPERSTUDY_ORB._objref_SHAPER_Object):
|
||||
self._geom_obj = _shaperstudy2geom(geompyD, geom)
|
||||
if isinstance(geom, shaper_object):
|
||||
geom_obj = _shaperstudy2geom(geompyD, geom)
|
||||
elif isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
|
||||
geom_obj = geom
|
||||
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
|
||||
# list of 3D elements
|
||||
|
@ -23,7 +23,6 @@ import salome
|
||||
salome.salome_init_without_session()
|
||||
|
||||
import GEOM
|
||||
import SHAPERSTUDY
|
||||
from salome.geom import geomBuilder
|
||||
from salome.smesh import smeshBuilder
|
||||
from salome.shaper import model
|
||||
@ -32,7 +31,7 @@ def assertAlmostEqual(a,b,tol):
|
||||
if ( abs(a-b) < tol ):
|
||||
return True
|
||||
else:
|
||||
print( "not close vals", a, b )
|
||||
print( "not close vals", a, b )
|
||||
return False
|
||||
|
||||
|
||||
@ -66,7 +65,7 @@ ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
||||
MesherShinkBox = smesh_builder.Mesh(ShrinkBox, "ShrinkMesh")
|
||||
ShrinkBoxMesh = MesherShinkBox.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
|
||||
|
||||
#Compute
|
||||
#Compute
|
||||
success = MesherShinkBox.Compute()
|
||||
assert( success )
|
||||
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")
|
||||
ShrinkBoxMesh2 = MesherShinkBox2.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
|
||||
|
||||
#Compute
|
||||
#Compute
|
||||
success = MesherShinkBox2.Compute()
|
||||
assert( success )
|
||||
|
||||
@ -112,7 +111,7 @@ algo = MesherShinkFace.Segment()
|
||||
numOfSegments = 4
|
||||
algo.NumberOfSegments(numOfSegments)
|
||||
ShrinkFaceMesh = MesherShinkFace.Triangle()
|
||||
#Compute
|
||||
#Compute
|
||||
success = MesherShinkFace.Compute()
|
||||
assert( success )
|
||||
numFaceElementShrinkGeom = MesherShinkFace.NbFaces()
|
||||
@ -135,11 +134,11 @@ numOfSegments = 12
|
||||
algo.NumberOfSegments(numOfSegments)
|
||||
ShrinkCircleMesh = MesherShinkCircle.Triangle()
|
||||
|
||||
#Compute
|
||||
#Compute
|
||||
success = MesherShinkCircle.Compute()
|
||||
numFaceElementShrinkGeom = MesherShinkCircle.NbFaces()
|
||||
assert( success )
|
||||
FinalCircleMesh = viscousBuilder.AddLayers( MesherShinkCircle )
|
||||
finalNumOfElements = FinalCircleMesh.NbFaces()
|
||||
assert( numFaceElementShrinkGeom + numOfSegments * numberOfLayers == finalNumOfElements )
|
||||
#############END MESH CIRCULAR FACE
|
||||
#############END MESH CIRCULAR FACE
|
||||
|
@ -23,7 +23,6 @@ import salome
|
||||
salome.salome_init_without_session()
|
||||
|
||||
import GEOM
|
||||
import SHAPERSTUDY
|
||||
from salome.geom import geomBuilder
|
||||
from salome.smesh import smeshBuilder
|
||||
from salome.shaper import model
|
||||
@ -32,7 +31,7 @@ def assertAlmostEqual(a,b,tol):
|
||||
if ( abs(a-b) < tol ):
|
||||
return True
|
||||
else:
|
||||
print( "not close vals", a, b )
|
||||
print( "not close vals", a, b )
|
||||
return False
|
||||
|
||||
|
||||
@ -69,7 +68,7 @@ assert( BoxProperties[2] > ShrinkBoxProperties[2] )
|
||||
|
||||
assert( assertAlmostEqual( BoxProperties[2], (10.0)**(3.0), 1e-12 ) )
|
||||
#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
|
||||
|
||||
####SHRINK THE BOX EXCEPT FOR ONE FACE
|
||||
@ -80,7 +79,7 @@ viscousBuilder.setBuilderParameters( offset, 4, 1.2, [ selectableFaces[ 0 ] ], T
|
||||
ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
||||
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
|
||||
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
|
||||
|
||||
####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
|
||||
ShrinkBox = viscousBuilder.GetShrinkGeometry()
|
||||
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"])
|
||||
####END SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
|
||||
|
||||
@ -110,11 +109,11 @@ viscousBuilder.setBuilderParameters( offset, 4, 1.2 )
|
||||
ShrinkSphere = viscousBuilder.GetShrinkGeometry()
|
||||
ShrinkSphereProperties = geompy.BasicProperties(ShrinkSphere)
|
||||
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
|
||||
|
||||
####SHRINK THE ENTIRE CYLINDER
|
||||
#Test shrinking cylinder
|
||||
#Test shrinking cylinder
|
||||
Cylinder = geompy.MakeCylinderRH(10,30)
|
||||
MesherCylinder = smesh_builder.Mesh(Cylinder, "Cylinder")
|
||||
viscousBuilder = MesherCylinder.ViscousLayerBuilder()
|
||||
@ -155,9 +154,9 @@ sBox = geompy.MakeHalfPartition( box, plane )
|
||||
# 4 left, 34 middle, 50 right
|
||||
ignoreFaces = [4,34,50]
|
||||
geompy.addToStudy( sBox, "SisterBox" )
|
||||
MesherSBox = smesh_builder.Mesh( sBox, "SisterBoxMesh")
|
||||
MesherSBox = smesh_builder.Mesh( sBox, "SisterBoxMesh")
|
||||
ViscousBuilder = MesherSBox.ViscousLayerBuilder()
|
||||
thickness = 20
|
||||
thickness = 20
|
||||
numberOfLayers = 10
|
||||
stretchFactor = 1.5
|
||||
ViscousBuilder.setBuilderParameters( thickness, numberOfLayers, stretchFactor, ignoreFaces )
|
||||
@ -197,7 +196,7 @@ assertAlmostEqual( ShrinkFaceProperties[1], (5.0-offset*2.0)**(2.0), 1e-12 )
|
||||
######SHRINK CIRCLE
|
||||
Disk = geompy.MakeDiskR(5, 1)
|
||||
|
||||
#Test with circle
|
||||
#Test with circle
|
||||
MesherCircle = smesh_builder.Mesh(Disk, "Disk")
|
||||
viscousBuilder = MesherCircle.ViscousLayerBuilder()
|
||||
viscousBuilder.setBuilderParameters( offset, numberOfLayers, 1.2 )
|
||||
|
Loading…
Reference in New Issue
Block a user