[Gmsh] Mesh and refine from command line

Christophe Geuzaine cgeuzaine at ulg.ac.be
Sun Feb 5 10:42:29 CET 2017


> On 25 Jan 2017, at 19:46, Jérémy Béjanin <jbejanin at uwaterloo.ca> wrote:
> 
> Hello, I would like to mesh a model, refine that mesh and save it from the command line, in one shot, that is without having to call gmsh twice (it seems that doing `gmsh file.geo -2 -refine -o output.msh` does not work...).
> 
> I have found most of the options for this (eg using "Mesh 2;" followed by "RefineMesh;" in the geo file).
> 
> I have now two questions:
> 1. How do I save the mesh using the same filename as the geo file? Is there a way to retrieve the filename from within the geo file? I have seen the "General.FileName" option, but typing "Save General.FileName;" at the end of the geo file does not work.
> 

You could do e.g.

Mesh 2;
Save StrCat(StrPrefix(General.FileName), "_original.msh");
RefineMesh;
Save StrCat(StrPrefix(General.FileName), "_refined.msh");

> 2. I would like to run this from the command line, without the GUI appearing. Since the mesh command is already in the geo file, I cannot just call `gmsh -2` since that will perform the meshing twice...
> 

Just run "gmsh file.geo -" (without "2")

> Thanks,
> Jeremy
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

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

Free software: http://gmsh.info | http://getdp.info | http://onelab.info




More information about the gmsh mailing list