From abfb573e003f0c9a8bd4cf44fbb7cfc3967b7de4 Mon Sep 17 00:00:00 2001 From: Bastien Gorissen <bastien.gorissen@cenaero.be> Date: Fri, 30 Mar 2012 10:02:16 +0000 Subject: [PATCH] Added another option for controlling ho mesh smoothing. --- Common/CommandLine.cpp | 8 ++++++++ Common/Context.h | 2 +- Common/DefaultOptions.h | 5 ++++- Common/Options.cpp | 17 +++++++++++++++-- Common/Options.h | 1 + Mesh/highOrderTools.cpp | 4 ++-- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index d66608ff07..1cce9b9a02 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -76,6 +76,7 @@ void PrintUsage(const char *name) 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(" -hoElasticity float Poisson ration for the elasticity analogy (-1.0 < nu < 0.5)"); Msg::Direct(" -optimize[_netgen] Optimize quality of tetrahedral elements"); Msg::Direct(" -optimize_lloyd Optimize 2D meshes using Lloyd algorithm"); Msg::Direct(" -clscale float Set global mesh element size scaling factor"); @@ -302,6 +303,13 @@ void GetOptions(int argc, char *argv[]) else Msg::Fatal("Missing number"); } + else if(!strcmp(argv[i] + 1, "hoElasticity")) { + i++; + if(argv[i]) + opt_mesh_ho_poisson(0, GMSH_SET, atof(argv[i++])); + else + Msg::Fatal("Missing number"); + } else if(!strcmp(argv[i] + 1, "hoNlayers")) { i++; if(argv[i]) diff --git a/Common/Context.h b/Common/Context.h index c2a049ba5a..204376376a 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -34,7 +34,7 @@ struct contextMeshOptions { int secondOrderExperimental, meshOnlyVisible; int smoothInternalEdges, minCircPoints, minCurvPoints; int smoothNLayers; - double smoothDistoTreshold; + double smoothDistoThreshold, smoothPoissonRatio; int saveAll, saveTri, saveGroupsOfNodes, binary, bdfFieldFormat, saveParametric; int smoothNormals, reverseAllNormals, zoneDefinition, clip; int saveElementTagType; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 7f8027f846..841ce5e6e9 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -871,8 +871,11 @@ StringXNumber MeshOptions_Number[] = { "Display mesh hexahedra?" }, { 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 , + { F|O, "HighOrderOptimize" , opt_mesh_smooth_internal_edges , 0., "Number of smoothing steps of internal edges for high order meshes" }, + { F|0, "HighOrderPoissonRatio", opt_mesh_ho_poisson, 0.33, + "Poisson ratio of the material used in the elastic smoother for high order meshes." + "Must be between -1.0 and 0.5, excluded."}, { F|O, "HighOrderSmoothingThreshold", opt_mesh_ho_mindisto, 0.5, "Distorition threshold when choosing which high order element to optimize."}, diff --git a/Common/Options.cpp b/Common/Options.cpp index c9a6280a84..0fbf35b552 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -5121,8 +5121,21 @@ double opt_mesh_ho_nlayers(OPT_ARGS_NUM) double opt_mesh_ho_mindisto(OPT_ARGS_NUM) { if(action & GMSH_SET) - CTX::instance()->mesh.smoothDistoTreshold = val; - return CTX::instance()->mesh.smoothDistoTreshold; + CTX::instance()->mesh.smoothDistoThreshold = val; + return CTX::instance()->mesh.smoothDistoThreshold; +} + +double opt_mesh_ho_poisson(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) { + double ratio = val; + if (ratio <= -1.0) + ratio = -0.999; + else if (ratio >= 0.5) + ratio = 0.499; + CTX::instance()->mesh.smoothPoissonRatio = ratio; + } + return CTX::instance()->mesh.smoothPoissonRatio; } double opt_mesh_second_order_experimental(OPT_ARGS_NUM) diff --git a/Common/Options.h b/Common/Options.h index 00597f5064..7903d2d602 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -405,6 +405,7 @@ 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_ho_poisson(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); diff --git a/Mesh/highOrderTools.cpp b/Mesh/highOrderTools.cpp index 6db9c028ad..b08328e5f9 100644 --- a/Mesh/highOrderTools.cpp +++ b/Mesh/highOrderTools.cpp @@ -254,10 +254,10 @@ void highOrderTools::applySmoothingTo(std::vector<MElement*> & all, GFace *gf) // compute the straight sided positions of high order nodes that are // on the edges of the face in the UV plane dofManager<double> myAssembler(lsys); - elasticityTerm El(0, 1.0, .33, _tag); + elasticityTerm El(0, 1.0, CTX::instance()->mesh.smoothPoissonRatio, _tag); std::vector<MElement*> layer, v; double minD; - getDistordedElements(all, CTX::instance()->mesh.smoothDistoTreshold, v, minD); + getDistordedElements(all, CTX::instance()->mesh.smoothDistoThreshold, v, minD); int numBad = v.size(); const int nbLayers = CTX::instance()->mesh.smoothNLayers; for (int i = 0; i < nbLayers; i++){ -- GitLab