Merge "facegear_example_beta_0.stl";
//Merge "facegear_example1.stl";
Mesh.CharacteristicLengthFactor=6;
// Create the topology of the discrete model
CreateTopology;

// 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

// 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(2) = 1;

// element size imposed by a size field
Field[1] = MathEval;
Field[1].F = "0.5";
Background Field = 1;

DefineConstant[
  funny = {0, Choices{0,1}, Name "Apply funny mesh size field?"},
  hide = {0, Choices{0,1}, Name "Hide compound sub-entities"}
];

//If(funny)
//  Field[1].F = "2*Sin((x+y)/5) + 3";
//EndIf

DefineConstant[  ];

Mesh.RemeshAlgorithm = 1; // automatic
//Mesh.RemeshParametrization = 7; // conformal finite element
Mesh.RemeshParametrization=1; //(0) harmonic (1) conformal 
Geometry.HideCompounds = hide; // hide the compound sub-entities?
//Mesh.Algorithm = 2; // (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad)
Mesh.Algorithm3D = 4; //  (1=Delaunay, 4=Frontal, 5=Frontal Delaunay, 6=Frontal Hex, 7=MMG3D, 9=R-tree)

