From f10e9dd8d216ff91fd748fc775c17c661672ae19 Mon Sep 17 00:00:00 2001 From: Bastien Gorissen <bastien.gorissen@cenaero.be> Date: Thu, 29 Mar 2012 14:21:09 +0000 Subject: [PATCH] Changed and added high order smoothing-related options. --- Common/CommandLine.cpp | 21 ++++++++++++++++----- Common/Context.h | 3 ++- Common/DefaultOptions.h | 11 ++++++----- Common/Options.cpp | 21 ++++++++++++++------- Common/Options.h | 3 ++- Mesh/highOrderTools.cpp | 4 ++-- 6 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 29c042d85b..d66608ff07 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -73,9 +73,10 @@ void PrintUsage(const char *name) Msg::Direct(" del3d, front3d, mmg3d)"); Msg::Direct(" -smooth int Set number of mesh smoothing steps"); Msg::Direct(" -order int Set mesh order (1, ..., 5)"); + Msg::Direct(" -hoOptimize Optimize high order meshes"); + Msg::Direct(" -hoMindisto float Minimum quality for high-order elements before optimization (0.0->1.0)"); + Msg::Direct(" -hoNLayers int Number of high order element layers to optimize"); Msg::Direct(" -optimize[_netgen] Optimize quality of tetrahedral elements"); - Msg::Direct(" -optimize_hom Optimize higher order meshes (in 2D)"); - Msg::Direct(" -hom_nometric Don't use the metric-based high-order mesh generation."); Msg::Direct(" -optimize_lloyd Optimize 2D meshes using Lloyd algorithm"); Msg::Direct(" -clscale float Set global mesh element size scaling factor"); Msg::Direct(" -clmin float Set minimum mesh element size"); @@ -290,13 +291,23 @@ void GetOptions(int argc, char *argv[]) CTX::instance()->mesh.optimizeNetgen = 1; i++; } - else if(!strcmp(argv[i] + 1, "optimize_hom")) { + else if(!strcmp(argv[i] + 1, "hoOptimize")) { i++; opt_mesh_smooth_internal_edges(0, GMSH_SET, 1); } - else if(!strcmp(argv[i] + 1, "hom_nometric")) { + else if(!strcmp(argv[i] + 1, "hoMindisto")) { i++; - opt_mesh_hom_no_metric(0, GMSH_SET, 1); + if(argv[i]) + opt_mesh_ho_mindisto(0, GMSH_SET, atof(argv[i++])); + else + Msg::Fatal("Missing number"); + } + else if(!strcmp(argv[i] + 1, "hoNlayers")) { + i++; + if(argv[i]) + opt_mesh_ho_nlayers(0, GMSH_SET, atoi(argv[i++])); + else + Msg::Fatal("Missing number"); } else if(!strcmp(argv[i] + 1, "optimize_lloyd")) { i++; diff --git a/Common/Context.h b/Common/Context.h index 1bf75b31d7..d218da782d 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -33,11 +33,12 @@ struct contextMeshOptions { int order, secondOrderLinear, secondOrderIncomplete; int secondOrderExperimental, meshOnlyVisible; int smoothInternalEdges, minCircPoints, minCurvPoints; + int smoothNLayers; + double smoothDistoTreshold; int saveAll, saveTri, saveGroupsOfNodes, binary, bdfFieldFormat, saveParametric; int smoothNormals, reverseAllNormals, zoneDefinition, clip; int saveElementTagType; int switchElementTags; - int highOrderNoMetric; int multiplePasses; int cgnsImportOrder; std::map<int,int> algo2d_per_face; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index b7120cf054..45565506b8 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -869,9 +869,12 @@ StringXNumber MeshOptions_Number[] = { { F|O, "Hexahedra" , opt_mesh_hexahedra , 1. , "Display mesh hexahedra?" }, - { F|O, "HighOrderNoMetric" , opt_mesh_hom_no_metric , 0. , - "Don't use metric computation to create high-order meshes." }, - + { F|0, "HighOrderNumLayers", opt_mesh_ho_nlayers, 3., + "Number of high order mesh elements to consider for optimization."}, + { F|O, "HighOrderOptimize" , opt_mesh_smooth_internal_edges , 0 , + "Number of smoothing steps of internal edges for high order meshes" }, + { F|O, "HighOrderSmoothingThreshold", opt_mesh_ho_mindisto, 0.5, + "Distorition threshold when choosing which high order element to optimize."}, { F|O, "LabelSampling" , opt_mesh_label_sampling , 1. , "Label sampling rate (display one label every `LabelSampling' elements)" }, @@ -1027,8 +1030,6 @@ StringXNumber MeshOptions_Number[] = { "Should second order vertices simply be created by linear interpolation?" }, { F|O, "Smoothing" , opt_mesh_nb_smoothing , 1. , "Number of smoothing steps applied to the final mesh" }, - { F|O, "SmoothInternalEdges" , opt_mesh_smooth_internal_edges , 0 , - "Number of smoothing steps of internal edges for high order meshes" }, { F|O, "SmoothNormals" , opt_mesh_smooth_normals , 0. , "Smooth the mesh normals?" }, { F|O, "SmoothRatio" , opt_mesh_smooth_ratio , 1.8 , diff --git a/Common/Options.cpp b/Common/Options.cpp index 75be46b1c2..a300ef8b41 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -5111,6 +5111,20 @@ double opt_mesh_smooth_internal_edges(OPT_ARGS_NUM) return CTX::instance()->mesh.smoothInternalEdges; } +double opt_mesh_ho_nlayers(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->mesh.smoothNLayers = (int)val; + return CTX::instance()->mesh.smoothNLayers; +} + +double opt_mesh_ho_mindisto(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->mesh.smoothDistoTreshold = val; + return CTX::instance()->mesh.smoothDistoTreshold; +} + double opt_mesh_second_order_experimental(OPT_ARGS_NUM) { if(action & GMSH_SET) @@ -5144,13 +5158,6 @@ double opt_mesh_second_order_incomplete(OPT_ARGS_NUM) return CTX::instance()->mesh.secondOrderIncomplete; } -double opt_mesh_hom_no_metric(OPT_ARGS_NUM) -{ - if(action & GMSH_SET) - CTX::instance()->mesh.highOrderNoMetric = (int)val; - return CTX::instance()->mesh.highOrderNoMetric; -} - double opt_mesh_cgns_import_order(OPT_ARGS_NUM) { if(action & GMSH_SET) { diff --git a/Common/Options.h b/Common/Options.h index f782e9329a..7a792231c5 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -403,10 +403,11 @@ double opt_mesh_min_curv_points(OPT_ARGS_NUM); double opt_mesh_multiple_passes(OPT_ARGS_NUM); double opt_mesh_order(OPT_ARGS_NUM); double opt_mesh_smooth_internal_edges(OPT_ARGS_NUM); +double opt_mesh_ho_nlayers(OPT_ARGS_NUM); +double opt_mesh_ho_mindisto(OPT_ARGS_NUM); double opt_mesh_second_order_experimental(OPT_ARGS_NUM); double opt_mesh_second_order_linear(OPT_ARGS_NUM); double opt_mesh_second_order_incomplete(OPT_ARGS_NUM); -double opt_mesh_hom_no_metric(OPT_ARGS_NUM); double opt_mesh_cgns_import_order(OPT_ARGS_NUM); double opt_mesh_dual(OPT_ARGS_NUM); double opt_mesh_voronoi(OPT_ARGS_NUM); diff --git a/Mesh/highOrderTools.cpp b/Mesh/highOrderTools.cpp index 7ed6dce1a1..45f45ee729 100644 --- a/Mesh/highOrderTools.cpp +++ b/Mesh/highOrderTools.cpp @@ -257,9 +257,9 @@ void highOrderTools::applySmoothingTo(std::vector<MElement*> & all, GFace *gf) elasticityTerm El(0, 1.0, .33, _tag); std::vector<MElement*> layer, v; double minD; - getDistordedElements(all, 0.5, v, minD); + getDistordedElements(all, CTX::instance()->mesh.smoothDistoTreshold, v, minD); int numBad = v.size(); - const int nbLayers = 3; + const int nbLayers = CTX::instance()->mesh.smoothNLayers; for (int i = 0; i < nbLayers; i++){ addOneLayer(all, v, layer); v.insert(v.end(), layer.begin(), layer.end()); -- GitLab