[Gmsh] Imported stl mesh size control

Christophe Geuzaine cgeuzaine at ulg.ac.be
Fri Jun 6 07:17:52 CEST 2008


Ashton Peters wrote:
> Hi,
> 
> I have an stl file generated in another program that I want to use as input, and create a 3D tetrahedral mesh with Gmsh. I can import the stl by opening a .geo file with the following contents into Gmsh:
> 
> Merge "surf.stl";
> Surface Loop (1)= {1};
> Volume (1)= {1};
> Recombine Surface {1};
> 
> ... here obviously my stl file is called "surf.stl".
> 
> After importing the stl I can generate a 3D mesh easily.
> 
> The problem is that I have no idea how to impose any kind of size control on the 3D elements Gmsh creates. All I want to do is control mesh size using a single number that represents an average element edge length (or similar) across the entire mesh. Characteristic lengths don't seem to work, as my stl import has no points associated with it that I can assign a characteristic length. I've tried Fields, but nothing I try seems to have any effect on the size of the final mesh - it always ends up with the same size elements!
> 
> I'm sure Gmsh can do this (very simple) task, but I am getting lost amongst a lot of very flexible, complicated, and sparsely-documented controls, and I'm now stuck.
> 
> Can someone please tell me what I need to do to impose a constant size control on an imported stl file when meshing with simple tetrahedral elements? Ideally I want Gmsh to re-mesh the surface with the new element size before meshing the internal volume.
> 
> Thanks in advance for any help. I'm using Gmsh 2.2.0 on Windows, ideally in non-interactive mode.

Hi Ashton - The case of STL files is a bit special: since there is no 
CAD, Gmsh infers the size of the elements inside from the size of the 
elements on the boundary. To disable this, use

Mesh.CharacteristicLengthExtendFromBoundary = 0;

Then you can fix the size inside using the usual options, e.g.:

Mesh.CharacteristicLengthMax = the_max_elem_size_you_want;



> 
> Ashton
> 


-- 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine