]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Add tests for viscous layers with body fitting eap/17015_BodyFitting_VL_squashed V9_11_0a1 V9_11_0a2
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 10 May 2023 07:27:16 +0000 (09:27 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 10 May 2023 07:27:16 +0000 (09:27 +0200)
test/body_fitting_viscous_layer_cylinder.py [new file with mode: 0644]
test/body_fitting_viscous_layer_tpipe.py [new file with mode: 0644]
test/tests.set

diff --git a/test/body_fitting_viscous_layer_cylinder.py b/test/body_fitting_viscous_layer_cylinder.py
new file mode 100644 (file)
index 0000000..e50568a
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+
+import math
+import sys
+import salome
+
+# Parameters
+
+r = 6
+h = 20
+
+###
+### SHAPER component
+###
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Cylinder
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), r, h)
+
+### Create Group
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_3")])
+Group_1.setName("Inlet")
+Group_1.result().setName("Inlet")
+
+### Create Group
+Group_2 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_2")])
+Group_2.setName("Outlet")
+Group_2.result().setName("Outlet")
+
+### Create Group
+Group_3 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_1")])
+Group_3.setName("Wall")
+Group_3.result().setName("Wall")
+
+model.end()
+
+###
+### SHAPERSTUDY component
+###
+
+model.publishToShaperStudy()
+import SHAPERSTUDY
+Cylinder_1_1, Inlet, Outlet, Wall, = SHAPERSTUDY.shape(model.featureStringId(Cylinder_1))
+###
+### SMESH component
+###
+
+import  SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+
+smesh = smeshBuilder.New()
+
+Mesh_1 = smesh.Mesh(Cylinder_1_1,'Mesh_1')
+Cartesian_3D = Mesh_1.BodyFitted()
+Body_Fitting_Parameters_1 = Cartesian_3D.SetGrid([ [ '1' ], [ 0, 1 ]],[ [ '1' ], [ 0, 1 ]],[ [ '1' ], [ 0, 1 ]],10000,1)
+Body_Fitting_Parameters_1.SetToCreateFaces( 1 )
+
+width_layer = 1
+Viscous_Layers_1 = Cartesian_3D.ViscousLayers(width_layer,3,1.2,[ Inlet, Outlet ],1,smeshBuilder.SURF_OFFSET_SMOOTH,'Viscous_Layers')
+
+isDone = Mesh_1.Compute()
+
+if not isDone:
+  raise Exception("Mesh_1 not computed")
+
+# Check volume of mesh
+volume_mesh = Mesh_1.GetVolume()
+volume_geom = math.pi*r**2*h
+
+assert abs(volume_mesh-volume_geom)/volume_geom < 1e-2
+
+# Check volume of Viscous layer
+gr_Viscous_Layers = Mesh_1.GetGroupByName("Viscous_Layers")[0]
+
+volume_mesh_VL = smesh.GetVolume(gr_Viscous_Layers)
+volume_geom_VL = volume_geom - math.pi*(r-width_layer)**2*h
+
+assert abs(volume_mesh_VL-volume_geom_VL)/volume_geom_VL < 1e-2
+
+
+if salome.sg.hasDesktop():
+  salome.sg.updateObjBrowser()
diff --git a/test/body_fitting_viscous_layer_tpipe.py b/test/body_fitting_viscous_layer_tpipe.py
new file mode 100644 (file)
index 0000000..ec2f52a
--- /dev/null
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+
+import sys
+import salome
+
+salome.salome_init()
+
+###
+### SHAPER component
+###
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Cylinder
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 0.5, 5)
+
+### Create Point
+Point_2 = model.addPoint(Part_1_doc, -3, 0, 1.5)
+
+### Create Cylinder
+Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 0.3, 3)
+
+### Create Fuse
+Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Cylinder_2_1")], keepSubResults = True)
+
+### Create Group
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_2_1/Face_3")])
+Group_1.setName("Inlet_x")
+Group_1.result().setName("Inlet_x")
+Group_1.result().setColor(0, 85, 255)
+
+### Create Group
+Group_2 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_3")])
+Group_2.setName("Inlet_z")
+Group_2.result().setName("Inlet_z")
+Group_2.result().setColor(170, 0, 0)
+
+### Create Group
+Group_3 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_2")])
+Group_3.setName("Outlet")
+Group_3.result().setName("Outlet")
+Group_3.result().setColor(255, 170, 0)
+
+### Create Group
+Group_4 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Fuse_1_1/Modified_Face&Cylinder_1_1/Face_1"), model.selection("FACE", "Fuse_1_1/Modified_Face&Cylinder_2_1/Face_1")])
+Group_4.setName("Wall")
+Group_4.result().setName("Wall")
+Group_4.result().setColor(85, 255, 0)
+
+### Create Group
+Group_5 = model.addGroup(Part_1_doc, "Vertices", [model.selection("VERTEX", "Fuse_1_1/Generated_Vertex&Cylinder_1_1/Face_1")])
+Group_5.setName("corner")
+Group_5.result().setName("corner")
+
+model.end()
+
+###
+### SHAPERSTUDY component
+###
+
+model.publishToShaperStudy()
+import SHAPERSTUDY
+Fuse_1_1, Inlet_x, Inlet_z, Outlet, Wall, corner, = SHAPERSTUDY.shape(model.featureStringId(Fuse_1))
+
+###
+### SMESH component
+###
+
+import  SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+
+smesh = smeshBuilder.New()
+
+Mesh_1 = smesh.Mesh(Fuse_1_1,'Mesh_1')
+Cartesian_3D_1 = Mesh_1.BodyFitted()
+CartesianParameters3D = Cartesian_3D_1.SetGrid([ [ '0.05' ], [ 0, 1 ]],[ [ '0.05' ], [ 0, 1 ]],[ [ '0.05' ], [ 0, 1 ]],5e+07,1)
+CartesianParameters3D.SetToCreateFaces( 1 )
+ViscousLayers_0_05_3 = Cartesian_3D_1.ViscousLayers(0.05,3,1.1,[ Inlet_x, Inlet_z, Outlet ],1,smeshBuilder.SURF_OFFSET_SMOOTH,'Viscous_Layers')
+
+isDone = Mesh_1.Compute()
+
+if not isDone:
+  raise Exception("Mesh_1 not computed")
+
+# Check volume of mesh
+volume_mesh = Mesh_1.GetVolume()
+volume_geom = 4.640535669879
+
+assert abs(volume_mesh-volume_geom)/volume_geom < 0.005
+
+# Check volume of Viscous layer
+gr_Viscous_Layers = Mesh_1.GetGroupByName("Viscous_Layers")[0]
+
+volume_mesh_VL = smesh.GetVolume(gr_Viscous_Layers)
+volume_geom_reduced = 3.685108989376
+volume_geom_VL = volume_geom - volume_geom_reduced
+
+assert abs(volume_mesh_VL-volume_geom_VL)/volume_geom_VL < 0.005
+
+
+
+if salome.sg.hasDesktop():
+  salome.sg.updateObjBrowser()
index a3f3b0a0088bbadf711cf6dff683b7c26fc85963..a697bdb6f7e893467de16f80c4eec845a59e6de0 100644 (file)
@@ -30,6 +30,8 @@ SET(BAD_TESTS
   blocFissure_05_without_session.py
   blocFissure_06_without_session.py
   blocFissure_07_without_session.py
+  body_fitting_viscous_layer_cylinder.py
+  body_fitting_viscous_layer_tpipe.py
   ex04_cube5tetraHexa.py
   ex21_lamp.py
   ex29_refine.py