]> SALOME platform Git repositories - plugins/ghs3dplugin.git/commitdiff
Salome HOME
Do not set the mesh in error if there is no log file as requested
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 17 Apr 2024 13:53:00 +0000 (15:53 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 17 Apr 2024 13:53:00 +0000 (15:53 +0200)
doc/salome/examples/examples.set
doc/salome/examples/ghs3d_optimization_no_log.py [new file with mode: 0644]
src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx

index cf53b278c55fdff4ce9b24c0ab8082a641bc801e..06cb8b95b07af1d52e07e05525d8e5663ec47919 100644 (file)
@@ -23,4 +23,5 @@ SET(EXAMPLE_NAMES
   ghs3d_enfmesh
   ghs3d_enfvert
   ghs3d_optimization
+  ghs3d_optimization_no_log
 )
diff --git a/doc/salome/examples/ghs3d_optimization_no_log.py b/doc/salome/examples/ghs3d_optimization_no_log.py
new file mode 100644 (file)
index 0000000..5638308
--- /dev/null
@@ -0,0 +1,54 @@
+import salome
+salome.salome_init()
+
+from salome.geom import geomBuilder
+geompy = geomBuilder.New()
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh =  smeshBuilder.New()
+
+# create a disk
+disk = geompy.MakeDiskR(100., 1, theName="disk")
+
+# triangulate the disk
+mesh = smesh.Mesh( disk )
+cadsurf = mesh.Triangle( smeshBuilder.MG_CADSurf )
+cadsurf.SetQuadAllowed( True )
+ok = mesh.Compute()
+if not ok:
+  raise Exception("Error when computing mesh")
+
+# extrude the 2D mesh into a prismatic mesh
+mesh.ExtrusionSweepObject( mesh, [0,0,10], 7 )
+
+# split prisms into tetrahedra
+mesh.SplitVolumesIntoTetra( mesh )
+
+# copy the mesh into a new mesh, since only a mesh not based of geometry
+# can be optimized using MG-Tetra Optimization
+optMesh = smesh.CopyMesh( mesh, "optimization" )
+
+# add MG-Tetra Optimization
+mg_opt = optMesh.Tetrahedron( smeshBuilder.MG_Tetra_Optimization )
+mg_opt.SetSmoothOffSlivers( True )
+mg_opt.SetOptimizationLevel( smeshBuilder.Strong_Optimization )
+mg_opt.SetPrintLogInFile( False )
+
+# run optimization
+ok = optMesh.Compute()
+if not ok:
+  raise Exception("Error when computing optimization mesh")
+
+print("Nb tetra before optimization", mesh.NbTetras())
+print("Nb tetra after  optimization", optMesh.NbTetras())
+
+# Check that aspect ratio 3D of optimized mesh is better than original mesh
+min_aspectratio_orig, max_aspectratio_orig = mesh.GetMinMax(SMESH.FT_AspectRatio3D)
+min_aspectratio_optim, max_aspectratio_optim = optMesh.GetMinMax(SMESH.FT_AspectRatio3D)
+
+assert (min_aspectratio_orig - min_aspectratio_optim)/min_aspectratio_orig < 0.5
+assert (max_aspectratio_orig - max_aspectratio_optim)/max_aspectratio_orig < 0.5
+
+# End of script
+
index 3446c3bfef511795c5a9775e302778baa7af4eb3..3c7fd2cd9711c447517bebedf2ba34521c35b42c 100644 (file)
@@ -471,7 +471,7 @@ bool GHS3DPlugin_Optimizer::Compute(SMESH_Mesh&         theMesh,
                                                      mgTetra.GetLog(), conv, Ok ));
     }
   }
-  else {
+  else if (!logInStandardOutput) {
     // the log file is empty
     removeFile( aLogFileName );
     INFOS( "MG-Tetra Error, " << errStr);