From ec708ec89829d24e069418dc85ea3d47a9ba19bf Mon Sep 17 00:00:00 2001 From: Bastien Gorissen <bastien.gorissen@cenaero.be> Date: Mon, 8 Nov 2010 12:36:20 +0000 Subject: [PATCH] Add the option to prevent using metrics for high-order mesh generation (useful for some matched OCC models atm) --- Common/CommandLine.cpp | 5 +++++ Common/Context.h | 1 + Common/DefaultOptions.h | 3 +++ Common/Options.cpp | 7 +++++++ Common/Options.h | 1 + Mesh/highOrderSmoother.cpp | 23 ++++------------------- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index a6be728be2..d22d86a2aa 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -70,6 +70,7 @@ void PrintUsage(const char *name) 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(" -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"); @@ -236,6 +237,10 @@ void GetOptions(int argc, char *argv[]) i++; opt_mesh_smooth_internal_edges(0, GMSH_SET, 1); } + else if(!strcmp(argv[i] + 1, "hom_nometric")) { + i++; + opt_mesh_hom_no_metric(0, GMSH_SET, 1); + } else if(!strcmp(argv[i] + 1, "optimize_lloyd")) { i++; CTX::instance()->mesh.optimizeLloyd = 1; diff --git a/Common/Context.h b/Common/Context.h index a1ee4abc42..e24e7226b0 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -38,6 +38,7 @@ struct contextMeshOptions { int smoothNormals, reverseAllNormals, zoneDefinition, clip; int saveElementTagType; int switchElementTags; + int highOrderNoMetric; }; struct contextGeometryOptions { diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 6cf01b4b24..8ed45e6695 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1104,6 +1104,9 @@ 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|O, "LabelSampling" , opt_mesh_label_sampling , 1. , "Label sampling rate (display one label every `LabelSampling' elements)" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index c07dbe1e28..b413d9370e 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -5807,6 +5807,13 @@ 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_dual(OPT_ARGS_NUM) { if(action & GMSH_SET) { diff --git a/Common/Options.h b/Common/Options.h index 913a271e22..e1ccad3b0c 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -541,6 +541,7 @@ double opt_mesh_smooth_internal_edges(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_dual(OPT_ARGS_NUM); double opt_mesh_voronoi(OPT_ARGS_NUM); double opt_mesh_draw_skin_only(OPT_ARGS_NUM); diff --git a/Mesh/highOrderSmoother.cpp b/Mesh/highOrderSmoother.cpp index b673d447fb..0abbd586a7 100644 --- a/Mesh/highOrderSmoother.cpp +++ b/Mesh/highOrderSmoother.cpp @@ -371,7 +371,7 @@ void highOrderSmoother::optimize(GFace * gf, // } // then try to swap for better configurations - smooth(gf, true); + smooth(gf, !CTX::instance()->mesh.highOrderNoMetric); // for (int i=0;i<100;i++){ @@ -596,8 +596,8 @@ double highOrderSmoother::smooth_metric_(std::vector<MElement*> & v, SPoint2 param; reparamMeshVertexOnFace((*it), gf, param); SPoint2 dparam; - myAssembler.getDofValue((*it), 0, getTag(), dparam[0]); - myAssembler.getDofValue((*it), 1, getTag(), dparam[1]); + myAssembler.getDofValue((*it), 0, getTag(), dparam[0]); + myAssembler.getDofValue((*it), 1, getTag(), dparam[1]); SPoint2 newp = param+dparam; dx += newp.x() * newp.x() + newp.y() * newp.y(); (*it)->setParameter(0, newp.x()); @@ -633,7 +633,7 @@ void highOrderSmoother::smooth(std::vector<MElement*> &all) if (!v.size()) return; - const int nbLayers = 1; + const int nbLayers = 6; for (int i = 0; i < nbLayers; i++){ addOneLayer(all, v, layer); v.insert(v.end(), layer.begin(), layer.end()); @@ -850,21 +850,6 @@ void highOrderSmoother::smooth_cavity(std::vector<MElement*>& cavity, //printf(" Moving %d to %g %g %g\n", (*it)->getNum(),_targetLocation[(*it)][0], _targetLocation[(*it)][1],_targetLocation[(*it)][2] ); } - /* - if (myAssembler.sizeOfR()) { - for (unsigned int i = 0; i < cavity.size(); i++) { - SElement se(cavity[i]); - El.addToMatrix(myAssembler, &se); - } - lsys->systemSolve(); - - } - for (it = verticesToMove.begin(); it != verticesToMove.end(); ++it){ - it->first->x() += myAssembler.getDofValue(it->first, 0, getTag()); - it->first->y() += myAssembler.getDofValue(it->first, 1, getTag()); - it->first->z() += myAssembler.getDofValue(it->first, 2, getTag()); - } - */ delete lsys; } -- GitLab