Add tests for viscous layers with body fitting

This commit is contained in:
Christophe Bourcier 2023-05-10 09:27:16 +02:00
parent c9294ee688
commit 58f6f92639
3 changed files with 202 additions and 0 deletions

View File

@ -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()

View File

@ -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()

View 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