From 355fb61b4b0a0e46ffe0d462cd1dcaf9807b6a50 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 19 Feb 2016 18:26:49 +0000 Subject: [PATCH] Mesh.PreserveNumberingMsh2 --- Common/Context.h | 1 + Common/DefaultOptions.h | 2 ++ Common/Options.cpp | 7 +++++++ Common/Options.h | 1 + Geo/MElement.cpp | 6 ++++-- Mesh/meshGFace.cpp | 12 ++++++------ 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index a0f6c10930..a135bf6d42 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -57,6 +57,7 @@ struct contextMeshOptions { std::map<int,int> curvature_control_per_face; int ignorePartBound; int NewtonConvergenceTestXYZ; + int preserveNumberingMsh2; }; struct contextGeometryOptions { diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 4d3736589b..df5c470891 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1188,6 +1188,8 @@ StringXNumber MeshOptions_Number[] = { "RandomFactor * size(triangle)/size(model) approaches machine accuracy)" }, { F|O, "IgnorePartitionBoundary" , opt_mesh_ignore_part_bound , 0. , "Ignore partitions boundaries (0=no, 1=yes)"}, + { F|O, "PreserveNumberingMsh2" , opt_mesh_preserve_numbering_msh2 , 0. , + "Preserve element numbering in MSH2 format (will break meshes with multiple physical groups for a single elementary entity)"}, #if defined(HAVE_BLOSSOM) { F|O, "RecombinationAlgorithm" , opt_mesh_algo_recombine , 1 , #else diff --git a/Common/Options.cpp b/Common/Options.cpp index 2b85b0ef08..52804dbdc1 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -6524,6 +6524,13 @@ double opt_mesh_ignore_part_bound(OPT_ARGS_NUM) return CTX::instance()->mesh.ignorePartBound; } +double opt_mesh_preserve_numbering_msh2(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->mesh.preserveNumberingMsh2 = (int) val; + return CTX::instance()->mesh.preserveNumberingMsh2; +} + double opt_solver_listen(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index e2ad04ad59..a2952a8479 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -540,6 +540,7 @@ double opt_mesh_partition_metis_edge_matching(OPT_ARGS_NUM); double opt_mesh_partition_metis_refine_algorithm(OPT_ARGS_NUM); double opt_mesh_clip(OPT_ARGS_NUM); double opt_mesh_ignore_part_bound(OPT_ARGS_NUM); +double opt_mesh_preserve_numbering_msh2(OPT_ARGS_NUM); double opt_solver_listen(OPT_ARGS_NUM); double opt_solver_timeout(OPT_ARGS_NUM); double opt_solver_plugins(OPT_ARGS_NUM); diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index 4858e5f8f3..55c70c029c 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -119,7 +119,7 @@ MElement* MElement::createElement(int tag, const std::vector<MVertex*> &vertices case TYPE_TRIH: return new MTrihedron(vertices, num, part); - + case TYPE_HEX: if (order == 1) return new MHexahedron(vertices, num, part); @@ -1059,6 +1059,8 @@ void MElement::writeMSH2(FILE *fp, double version, bool binary, int num, } } + if(CTX::instance()->mesh.preserveNumberingMsh2) num = _num; + if(!binary){ fprintf(fp, "%d %d", num ? num : _num, type); if(version < 2.0) @@ -1160,7 +1162,7 @@ void MElement::writePOS(FILE *fp, bool printElementary, bool printElementNumber, } if(printGamma){ double gamma = gammaShapeMeasure(); - for(int i = 0; i < n; i++){ + for(int i = 0; i < n; i++){ if(first) first = false; else fprintf(fp, ","); // fprintf(fp, "%g", gamma); FIXME fprintf(fp, "%d", getVertex(i)->getNum()); diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index f2b605a949..d5653566b6 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -187,7 +187,7 @@ public: } } GPoint gp = _gf->point((m[0]+m[1]+m[2]+m[3])*0.25); - // FIXME : NOT EXACTLY CORRECT, BUT THAT'S THE PLACE WE WANT THE POINT TO RESIDE + // FIXME : NOT EXACTLY CORRECT, BUT THAT'S THE PLACE WE WANT THE POINT TO RESIDE double XX = 0.25*(v[0]->x()+v[1]->x()+v[2]->x()+v[3]->x()); double YY = 0.25*(v[0]->y()+v[1]->y()+v[2]->y()+v[3]->y()); double ZZ = 0.25*(v[0]->z()+v[1]->z()+v[2]->z()+v[3]->z()); @@ -1132,8 +1132,8 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, doc.points[points.size() + ip].adjacent = 0; doc.points[points.size() + ip].data = pp; } - - + + // Use "fast" inhouse recursive algo to generate the triangulation. // At this stage the triangulation is not what we need @@ -1482,7 +1482,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, // gf->deleteMesh() would also destroy e.g. the data in a compound face, which // we should not do) gf->GFace::deleteMesh(); - + Msg::Debug("Starting to add internal points"); // start mesh generation if(!algoDelaunay2D(gf) && !onlyInitialMesh){ @@ -2331,7 +2331,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) // BOUNDARY LAYER modifyInitialMeshForTakingIntoAccountBoundaryLayers(gf); - + if(algoDelaunay2D(gf)){ if(gf->getMeshingAlgo() == ALGO_2D_FRONTAL) bowyerWatsonFrontal(gf, &equivalence, ¶metricCoordinates); @@ -2376,7 +2376,7 @@ void deMeshGFace::operator() (GFace *gf) } // for debugging, change value from -1 to -100; -int debugSurface = -100; //-1; +int debugSurface = -1; //-1; void meshGFace::operator() (GFace *gf, bool print) { -- GitLab