From: Christophe Bourcier Date: Wed, 17 Apr 2024 13:53:00 +0000 (+0200) Subject: Do not set the mesh in error if there is no log file as requested X-Git-Tag: V9_13_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6d36d60ba777e06177140433fe9f15f1b1aa25f3;p=plugins%2Fghs3dplugin.git Do not set the mesh in error if there is no log file as requested --- diff --git a/doc/salome/examples/examples.set b/doc/salome/examples/examples.set index cf53b27..06cb8b9 100644 --- a/doc/salome/examples/examples.set +++ b/doc/salome/examples/examples.set @@ -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 index 0000000..5638308 --- /dev/null +++ b/doc/salome/examples/ghs3d_optimization_no_log.py @@ -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 + diff --git a/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx index 3446c3b..3c7fd2c 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx @@ -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);