From 2321f39f835c03d98bea07efe729e103f48d27d8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@uliege.be> Date: Tue, 1 Mar 2022 09:30:55 +0100 Subject: [PATCH] new Mesh.TransfiniteTri option to activate @ermakov's alternative 3-sided transfinite algo --- CREDITS.txt | 6 +++--- doc/texinfo/opt_general.texi | 4 ++-- doc/texinfo/opt_mesh.texi | 5 +++++ src/common/Context.h | 2 +- src/common/DefaultOptions.h | 14 ++++++-------- src/common/Options.cpp | 6 ++++++ src/common/Options.h | 1 + src/geo/GModelIO_OCC.cpp | 5 +++++ src/mesh/meshGFaceTransfinite.cpp | 20 ++++++-------------- 9 files changed, 35 insertions(+), 28 deletions(-) diff --git a/CREDITS.txt b/CREDITS.txt index 134c835f7f..c3883ef9cc 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -32,9 +32,9 @@ Pierre-Alexandre Beaufort (HXT/reparam), Zhidong Han (LSDYNA export), Ismail Badia (hierarchical basis functions), Jeremy Theler (X3D export), Thomas Toulorge (high order mesh optimizer, new CGNS IO), Max Orok (binary PLY), Marek Wojciechowski (PyPi packaging), Maxence Reberol (automatic transfinite, quad -meshing tools), Michael Ermakov (Gambit export, Fortran API, transfinite3), Alex -Krasner (X3D export). See comments in the sources for more information. If we -forgot to list your contributions please send us an email! +meshing tools), Michael Ermakov (Gambit export, Fortran API, TransfiniteTri), +Alex Krasner (X3D export). See comments in the sources for more information. If +we forgot to list your contributions please send us an email! Thanks to the following folks who have contributed by providing fresh ideas on theoretical or programming topics, who have sent patches, requests for changes diff --git a/doc/texinfo/opt_general.texi b/doc/texinfo/opt_general.texi index 63e92de898..678022c0ac 100644 --- a/doc/texinfo/opt_general.texi +++ b/doc/texinfo/opt_general.texi @@ -38,7 +38,7 @@ Saved in: @code{General.OptionsFileName} @item General.BuildInfo Gmsh build information (read-only)@* -Default value: @code{"Version: 4.10.0-git-73b5649f7; License: GNU General Public License; Build OS: MacOSX-sdk; Build date: 20220226; Build host: MacBook-Pro-Christophe.local; Build options: 64Bit ALGLIB[contrib] ANN[contrib] Bamg Blossom Cairo Cgns DIntegration Dlopen DomHex Eigen[contrib] Fltk GMP Gmm[contrib] Hxt Jpeg Kbipack MathEx[contrib] Med Mesh Metis[contrib] Mmg Mpeg Netgen ONELAB ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OpenMP OptHom Parasolid ParasolidSTEP Parser Plugins Png Post QuadMeshingTools QuadTri Solver TetGen/BR TouchBar Voro++[contrib] WinslowUntangler Zlib; FLTK version: 1.4.0; OCC version: 7.7.0; MED version: 4.1.1; Packaged by: geuzaine; Web site: https://gmsh.info; Issue tracker: https://gitlab.onelab.info/gmsh/gmsh/issues"}@* +Default value: @code{"Version: 4.10.0-git-03e3e88f8; License: GNU General Public License; Build OS: MacOSX-sdk; Build date: 20220228; Build host: MacBook-Pro-Christophe.local; Build options: 64Bit ALGLIB[contrib] ANN[contrib] Bamg Blossom Cairo Cgns DIntegration Dlopen DomHex Eigen[contrib] Fltk GMP Gmm[contrib] Hxt Jpeg Kbipack MathEx[contrib] Med Mesh Metis[contrib] Mmg Mpeg Netgen ONELAB ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OpenMP OptHom Parasolid ParasolidSTEP Parser Plugins Png Post QuadMeshingTools QuadTri Solver TetGen/BR TouchBar Voro++[contrib] WinslowUntangler Zlib; FLTK version: 1.4.0; OCC version: 7.7.0; MED version: 4.1.1; Packaged by: geuzaine; Web site: https://gmsh.info; Issue tracker: https://gitlab.onelab.info/gmsh/gmsh/issues"}@* Saved in: @code{-} @item General.BuildOptions @@ -168,7 +168,7 @@ Saved in: @code{General.SessionFileName} @item General.Version Gmsh version (read-only)@* -Default value: @code{"4.10.0-git-73b5649f7"}@* +Default value: @code{"4.10.0-git-03e3e88f8"}@* Saved in: @code{-} @item General.WatchFilePattern diff --git a/doc/texinfo/opt_mesh.texi b/doc/texinfo/opt_mesh.texi index 70f79b1f2d..78e6a20405 100644 --- a/doc/texinfo/opt_mesh.texi +++ b/doc/texinfo/opt_mesh.texi @@ -906,6 +906,11 @@ Display mesh trihedra?@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} +@item Mesh.TransfiniteTri +Use alternative transfinite arrangement when meshing 3-sided surfaces@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + @item Mesh.UnvStrictFormat Use strict format specification for UNV files, with 'D' for exponents (instead of 'E' as used by some tools)@* Default value: @code{1}@* diff --git a/src/common/Context.h b/src/common/Context.h index 032c5a1e58..3a6cfa9946 100644 --- a/src/common/Context.h +++ b/src/common/Context.h @@ -31,7 +31,7 @@ struct contextMeshOptions { int recombineNodeRepositioning; int recombineMinimumQuality; int recombine3DAll, recombine3DLevel, recombine3DConformity; - int flexibleTransfinite, maxRetries; + int flexibleTransfinite, transfiniteTri, maxRetries; int order, secondOrderLinear, secondOrderIncomplete; int meshOnlyVisible, meshOnlyEmpty; int minCircleNodes, minCurveNodes, minLineNodes; diff --git a/src/common/DefaultOptions.h b/src/common/DefaultOptions.h index f31244c24a..cc15918ae3 100644 --- a/src/common/DefaultOptions.h +++ b/src/common/DefaultOptions.h @@ -1400,25 +1400,21 @@ StringXNumber MeshOptions_Number[] = { "Size map method in QuadQuasiStructured. 0: default, 1: cross-field," "2: cross-field + CAD small features adaptation," "3: from background mesh (e.g. sizes in current triangulation)," - "4: cross-field + CAD small features adaptation (clamped by background mesh)" - }, + "4: cross-field + CAD small features adaptation (clamped by background mesh)" }, { F|O, "QuadqsTopologyOptimizationMethods" , opt_mesh_quadqs_topo_optim_methods, 0. , "Topology optimization methods in QuadQuasiStructured. 0: default (all)," "100: pattern-based CAD faces," "010: disk quadrangulation remeshing," "001: cavity remeshing," - "xxx: combination of multiple methods (e.g. 111 for all)" - }, + "xxx: combination of multiple methods (e.g. 111 for all)" }, { F|O, "QuadqsRemeshingBoldness" , opt_mesh_quadqs_remeshing_boldness, 0.66 , "Controls how much cavity remeshing is allowed to distort" " the quad mesh. From 0 (no quality decrease during remeshing) to 1" - " (quality can tend to 0 during remeshing)." - }, + " (quality can tend to 0 during remeshing)." }, { F|O, "QuadqsScalingOnTriangulation" , opt_mesh_quadqs_scaling_on_triangulation, 0.75, "Ratio on the edge length between the triangulation and the quadrangulation." " Use a small ratio (e.g. 0.5) to get a background triangulation finer" - " than the quad mesh. Useful to get a more accurate cross-field." - }, + " than the quad mesh. Useful to get a more accurate cross-field." }, { F|O, "Quadrangles" , opt_mesh_quadrangles , 1. , "Display mesh quadrangles?" }, { F|O, "QualityInf" , opt_mesh_quality_inf , 0.0 , @@ -1564,6 +1560,8 @@ StringXNumber MeshOptions_Number[] = { "Display mesh triangles?" }, { F|O, "Trihedra" , opt_mesh_trihedra , 1. , "Display mesh trihedra?" }, + { F|O, "TransfiniteTri" , opt_mesh_transfinite_tri , 0 , + "Use alternative transfinite arrangement when meshing 3-sided surfaces" }, { F|O, "UnvStrictFormat" , opt_mesh_unv_strict_format , 1 , "Use strict format specification for UNV files, with 'D' for exponents (instead of " diff --git a/src/common/Options.cpp b/src/common/Options.cpp index c0a8f6814c..e6afc04a58 100644 --- a/src/common/Options.cpp +++ b/src/common/Options.cpp @@ -5408,6 +5408,12 @@ double opt_mesh_trihedra(OPT_ARGS_NUM) return CTX::instance()->mesh.trihedra; } +double opt_mesh_transfinite_tri(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) CTX::instance()->mesh.transfiniteTri = (int)val; + return CTX::instance()->mesh.transfiniteTri; +} + double opt_mesh_surface_edges(OPT_ARGS_NUM) { if(action & GMSH_SET) { diff --git a/src/common/Options.h b/src/common/Options.h index d65cb2343f..c9b1c63183 100644 --- a/src/common/Options.h +++ b/src/common/Options.h @@ -471,6 +471,7 @@ double opt_mesh_hexahedra(OPT_ARGS_NUM); double opt_mesh_prisms(OPT_ARGS_NUM); double opt_mesh_pyramids(OPT_ARGS_NUM); double opt_mesh_trihedra(OPT_ARGS_NUM); +double opt_mesh_transfinite_tri(OPT_ARGS_NUM); double opt_mesh_surface_edges(OPT_ARGS_NUM); double opt_mesh_surface_faces(OPT_ARGS_NUM); double opt_mesh_volume_edges(OPT_ARGS_NUM); diff --git a/src/geo/GModelIO_OCC.cpp b/src/geo/GModelIO_OCC.cpp index d70e137354..7d08ebeee0 100644 --- a/src/geo/GModelIO_OCC.cpp +++ b/src/geo/GModelIO_OCC.cpp @@ -2078,6 +2078,11 @@ static bool makeTrimmedSurface(const Handle(Geom_Surface) &surf, } BRepBuilderAPI_MakeFace f(surf, wiresProj[0]); for(std::size_t i = 1; i < wiresProj.size(); i++) f.Add(wiresProj[i]); + f.Build(); + if(!f.IsDone()) { + Msg::Error("Could not create surface"); + return false; + } result = f.Face(); // recover 3D curves for pcurves ShapeFix_Face fix(result); diff --git a/src/mesh/meshGFaceTransfinite.cpp b/src/mesh/meshGFaceTransfinite.cpp index 947aed8cf2..061f9840e9 100644 --- a/src/mesh/meshGFaceTransfinite.cpp +++ b/src/mesh/meshGFaceTransfinite.cpp @@ -263,8 +263,6 @@ int MeshTransfiniteSurface(GFace *gf) V = V2; } - bool transfinite3 = false; - int N1 = N[0], N2 = N[1], N3 = N[2], N4 = N[3]; int L = N2 - N1, H = N3 - N2; if(corners.size() == 4) { @@ -278,26 +276,20 @@ int MeshTransfiniteSurface(GFace *gf) } else { int Lb = m_vertices.size() - N3; -#ifdef TFTria - if(Lb == L && H == L) { - transfinite3 = true; + if(CTX::instance()->mesh.transfiniteTri && Lb == L && H == L) { + gf->meshAttributes.transfinite3 = true; Msg::Info("Using specific algorithm for 3-sided surface %d", gf->tag()); } else { -#endif if(Lb != L) { Msg::Error("Surface %d cannot be meshed using the transfinite algo " "(divisions %d != %d)", gf->tag(), L, Lb); return 0; } -#ifdef TFTria } -#endif } - gf->meshAttributes.transfinite3 = transfinite3; - /* 2L+H +------------+ L+H | | @@ -416,7 +408,7 @@ int MeshTransfiniteSurface(GFace *gf) } else { std::vector<double> u2, v2; - if(transfinite3) { + if(gf->meshAttributes.transfinite3) { u2.reserve(H + 1); for(int j = 0; j <= H; j++) u2.push_back(U[N2 + j]); v2.reserve(H + 1); @@ -432,7 +424,7 @@ int MeshTransfiniteSurface(GFace *gf) int iP3 = ((N3 + N2) - i) % m_vertices.size(); double Up, Vp; if(gf->geomType() != GEntity::RuledSurface) { - if(!transfinite3) { + if(!gf->meshAttributes.transfinite3) { Up = TRAN_TRI(U[iP1], U[iP2], U[iP3], UC1, UC2, UC3, u, v); Vp = TRAN_TRI(V[iP1], V[iP2], V[iP3], VC1, VC2, VC3, u, v); } @@ -489,7 +481,7 @@ int MeshTransfiniteSurface(GFace *gf) else if(gf->meshAttributes.transfiniteSmoothing > 0) numSmooth = gf->meshAttributes.transfiniteSmoothing; - if(corners.size() == 4 && numSmooth && !transfinite3) { + if(corners.size() == 4 && numSmooth && !gf->meshAttributes.transfinite3) { std::vector<std::vector<double> > u(L + 1), v(L + 1); for(int i = 0; i <= L; i++) { u[i].resize(H + 1); @@ -590,7 +582,7 @@ int MeshTransfiniteSurface(GFace *gf) } } else { - if(!transfinite3) { + if(!gf->meshAttributes.transfinite3) { for(int j = 0; j < H; j++) { MVertex *v1 = tab[0][0]; MVertex *v2 = tab[1][j]; -- GitLab