Skip to content
Snippets Groups Projects
Commit c269e7f6 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

No commit message

No commit message
parent a4233644
No related branches found
No related tags found
No related merge requests found
......@@ -2,56 +2,65 @@
*
* Gmsh tutorial 12
*
* Remeshing STL with compounds
* Cross-patch meshing with compounds
*
*********************************************************************/
// Compound geometrical entities can be defined to compute a new
// parametrization of groups of elementary geometrical entities. This
// parametrization can then be used for remeshing the compound as if
// it were a CAD entity.
// it were a single CAD entity.
// Merge the original mesh, that we would like to remesh. This mesh
// was reclassified ("colored") from an initial STL triangulation
// using the "Reclassify 2D" tool in Gmsh, so that we can preserve
// sharp geometrical features.
Merge "t12_data.msh";
lc = 0.2;
Point(1) = {0, 0, 0, lc};
Point(2) = {1, 0, 0, lc};
Point(3) = {1, 1, 0.5, lc};
Point(4) = {0, 1, 0.4, lc};
Point(5) = {0.3, 0.2, 0, lc};
Point(6) = {0, 0.01, 0.01, lc};
Point(7) = {0, 0.02, 0.02, lc};
Point(8) = {1, 0.05, 0.02, lc};
Point(9) = {1, 0.32, 0.02, lc};
Line(1) = {1, 2};
Line(2) = {2, 8};
Line(3) = {8, 9};
Line(4) = {9, 3};
Line(5) = {3, 4};
Line(6) = {4, 7};
Line(7) = {7, 6};
Line(8) = {6, 1};
Spline(9) = {7, 5, 9};
Line(10) = {6, 8};
Line Loop(11) = {5, 6, 9, 4};
Ruled Surface(12) = {11};
Line Loop(13) = {9, -3, -10, -7};
Ruled Surface(14) = {13};
Line Loop(15) = {10, -2, -1, -8};
Ruled Surface(16) = {15};
// Since the original mesh is a bit coarse, we refine it once
RefineMesh;
// Treat lines 2, 3 and 4 as a single line
Compound Line(100) = {2, 3, 4};
// Idem with lines 6, 7 and 8
Compound Line(101) = {6, 7, 8};
// Create the topology of the discrete model
CreateTopology;
// We can now define a compound line (resp. surface) for each discrete
// line (resp. surface) in the model
ll[] = Line "*";
For j In {0 : #ll[]-1}
Compound Line(newl) = ll[j];
EndFor
ss[] = Surface "*";
s = news;
For i In {0 : #ss[]-1}
Compound Surface(s+i) = ss[i];
EndFor
Surface Loop(1) = {s : s + #ss[]-1};
Volume(1) = {1};
Physical Surface(1) = {s : s + #ss[]-1};
Physical Volume(1) = 1;
// Apply a funny mesh size field, just because we can :-)
Field[1] = MathEval;
Field[1].F = "2*Sin((x+y)/5) + 3.3";
Background Field = 1;
Mesh.RemeshAlgorithm = 1; // (0) no split (1) automatic (2) automatic only with metis
Mesh.RemeshParametrization = 1; // (0) harmonic (1) conformal
// Treat surfaces 12, 14 and 16 as a single surface
Compound Surface(200) = {12, 14, 16};
// More details about the reparametrization technique can be found in
// the following papers:
//
// * J.-F. Remacle, C. Geuzaine, G. Compère and E. Marchandise,
// "High-Quality Surface Remeshing Using Harmonic Maps",
// International Journal for Numerical Methods in Engineering,
// 83 (4), pp. 403-425, 2010.
//
//
// * E. Marchandise, G. Compère, M. Willemet, G. Bricteux, C. Geuzaine
// and J-F Remacle, "Quality meshing based on STL triangulations for
// biomedical simulations", International Journal for Numerical
// Methods in Biomedical Engineering", 26 (7), pp. 876-889, 2010.
//
// * E. Marchandise, C. Carton de Wiart, W. G. Vos, C. Geuzaine and
// J.-F. Remacle, "High Quality Surface Remeshing Using Harmonic
// Maps. Part II: Surfaces with High Genus and of Large Aspect
// Ratio", International Journal for Numerical Methods in
// Engineering, 86 (11), pp. 1303-1321, 2011.
......@@ -2,12 +2,50 @@
*
* Gmsh tutorial 13
*
* Cross-patch meshing with compounds
* Remeshing STL with compounds
*
*********************************************************************/
// Compound geometrical entities can be defined to compute a new
// parametrization of groups of elementary geometrical entities. This
// parametrization can then be used for remeshing the compound as if
// it were a CAD entity.
// Since compound geometrical compute a new parametrization, one can
// also use them to remesh STL files, even if there's only a single
// elementary per compound.
// Let's merge the mesh that we would like to remesh. This mesh was
// reclassified ("colored") from an initial STL triangulation using
// the "Reclassify 2D" tool in Gmsh, so that we could split it along
// sharp geometrical features.
Merge "t13_data.msh";
// Since the original mesh is a bit coarse, we refine it once
RefineMesh;
// Create the topology of the discrete model
CreateTopology;
// We can now define a compound line (resp. surface) for each discrete
// line (resp. surface) in the model
ll[] = Line "*";
For j In {0 : #ll[]-1}
Compound Line(newl) = ll[j];
EndFor
ss[] = Surface "*";
s = news;
For i In {0 : #ss[]-1}
Compound Surface(s+i) = ss[i];
EndFor
// And we can create the volume based on the new compound entities
Surface Loop(1) = {s : s + #ss[]-1};
Volume(1) = {1};
Physical Surface(1) = {s : s + #ss[]-1};
Physical Volume(1) = 1;
// Apply a funny mesh size field, just because we can :-)
Field[1] = MathEval;
Field[1].F = "2*Sin((x+y)/5) + 3.3";
Background Field = 1;
Mesh.RemeshAlgorithm = 1; // (0) no split (1) automatic (2) automatic only with metis
Mesh.RemeshParametrization = 1; // (0) harmonic (1) conformal
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment