From a6de7544b5b0382e16cfedaa23342120b49d7265 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 20 Apr 2010 19:01:53 +0000 Subject: [PATCH] don't do Lloyd optimization based on the value of mesh.optimize: this prevents optimizing 3D meshes without also optimizing 2D meshes with Lloyd introduced mesh.optimizeLloyd to fix this --- Common/CommandLine.cpp | 15 ++++++++++----- Common/Context.cpp | 1 + Common/Context.h | 4 ++-- Mesh/Generator.cpp | 10 ++++------ Mesh/meshGFace.cpp | 9 ++++----- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 4ed07b1e08..ab81e39ddf 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -69,9 +69,10 @@ void PrintUsage(const char *name) Msg::Direct(" -numsubedges Set the number of subdivisions when displaying high order elements"); Msg::Direct(" -algo string Select mesh algorithm (meshadapt, del2d, front2d, del3d, front3d)"); Msg::Direct(" -smooth int Set number of mesh smoothing steps"); - Msg::Direct(" -optimize[_netgen] Optimize quality of tetrahedral elements"); Msg::Direct(" -order int Set mesh order (1, ..., 5)"); + Msg::Direct(" -optimize[_netgen] Optimize quality of tetrahedral elements"); Msg::Direct(" -optimize_hom Optimize higher order meshes (in 2D)"); + Msg::Direct(" -optimize_lloyd Optimize 2D meshes using Lloyd algorithm"); Msg::Direct(" -clscale float Set characteristic length scaling factor"); Msg::Direct(" -clmin float Set minimum characteristic length"); Msg::Direct(" -clmax float Set maximum characteristic length"); @@ -227,6 +228,14 @@ void GetOptions(int argc, char *argv[]) CTX::instance()->mesh.optimizeNetgen = 1; i++; } + else if(!strcmp(argv[i] + 1, "optimize_hom")) { + i++; + opt_mesh_smooth_internal_edges(0, GMSH_SET, 1); + } + else if(!strcmp(argv[i] + 1, "optimize_lloyd")) { + i++; + CTX::instance()->mesh.optimizeLloyd = 1; + } else if(!strcmp(argv[i] + 1, "nopopup")) { CTX::instance()->noPopup = 1; i++; @@ -443,10 +452,6 @@ void GetOptions(int argc, char *argv[]) else Msg::Fatal("Missing argument"); } - else if(!strcmp(argv[i] + 1, "optimize_hom")) { - i++; - opt_mesh_smooth_internal_edges(0, GMSH_SET, 1); - } else if(!strcmp(argv[i] + 1, "format") || !strcmp(argv[i] + 1, "f")) { i++; if(argv[i]) { diff --git a/Common/Context.cpp b/Common/Context.cpp index 26b21abfd5..0906ce556c 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -80,6 +80,7 @@ CTX::CTX() numWindows = numTiles = 1; deltaFontSize = 0; recentFiles.resize(5); + mesh.optimizeLloyd = 0; } CTX *CTX::_instance = 0; diff --git a/Common/Context.h b/Common/Context.h index 0658b032cb..45c61735ea 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -17,8 +17,8 @@ struct contextMeshOptions { int draw, changed, light, lightTwoSide, lightLines, pointType; int points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, pyramids; int surfacesEdges, surfacesFaces, volumesEdges, volumesFaces, numSubEdges; - int pointsNum, linesNum, surfacesNum, volumesNum; - int optimize, optimizeNetgen, refineSteps, qualityType, labelType, remove4triangles; + int pointsNum, linesNum, surfacesNum, volumesNum, qualityType, labelType; + int optimize, optimizeNetgen, optimizeLloyd, refineSteps, remove4triangles; double normals, tangents, explode, angleSmoothNormals, allowSwapEdgeAngle; double mshFileVersion, mshFilePartitioned, labelFrequency, pointSize, lineWidth; double qualityInf, qualitySup, radiusInf, radiusSup; diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index d80371fd38..7728ca5a79 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -419,16 +419,14 @@ static void Mesh2D(GModel *m) std::for_each(classFaces.begin(), classFaces.end(), meshGFace()); std::for_each(compFaces.begin(), compFaces.end(), meshGFace()); - //lloyd optimization - if (CTX::instance()->mesh.optimize > 0 ){ + // lloyd optimization + if (CTX::instance()->mesh.optimizeLloyd){ for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it){ GFace *gf = *it; int recombine = gf->meshAttributes.recombine; Msg::Info("Lloyd optimization for face %d", gf->tag()); - gf->lloyd(40,recombine); - - if(recombine) recombineIntoQuads(gf); - + gf->lloyd(40, recombine); + if(recombine) recombineIntoQuads(gf); } } diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 158f6df895..e20c319fb8 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -674,9 +674,8 @@ static bool meshGenerator(GFace *gf, int RECUR_ITER, // delete the mesh delete m; - if(gf->meshAttributes.recombine && CTX::instance()->mesh.optimize == 0){ - recombineIntoQuads(gf); - } + if(gf->meshAttributes.recombine && !CTX::instance()->mesh.optimizeLloyd) + recombineIntoQuads(gf); computeElementShapes(gf, gf->meshStatistics.worst_element_shape, gf->meshStatistics.average_element_shape, @@ -1218,8 +1217,8 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) // delete the mesh delete m; - if(gf->meshAttributes.recombine && CTX::instance()->mesh.optimize == 0) - recombineIntoQuads(gf); + if(gf->meshAttributes.recombine && !CTX::instance()->mesh.optimizeLloyd) + recombineIntoQuads(gf); computeElementShapes(gf, gf->meshStatistics.worst_element_shape, gf->meshStatistics.average_element_shape, -- GitLab