[Gmsh] Comments in .msh files

Christophe Geuzaine cgeuzaine at ulg.ac.be
Sun Dec 28 12:01:41 CET 2008


Robert Funnell wrote:
> In Section 1.8 of the manual dated 2008 Nov 21 it says 'All Gmsh ASCII 
> text input files support both C and C++ style comments' but a message 
> dated 2008 Nov 19 says 'you cannot add comments in .msh files! (I've 
> added a note in the doc to make this clear.)'. Is that added note in 
> the documentation somewhere that I haven't found?
> 

Indeed, I forgot to commit the change. We don't support C/C++ style
comments in .msh files for performance reasons. However, you can simply
add a section with a dummy header (after the format section), and it
will be ignored by Gmsh.

The new paragraph in the documentation reads:

===
All parsed input files (@file{.geo}) support both C and C++ style
comments:

(...)

You can add comments in a mesh file (@file{.msh}) by adding a section
with an unrecognized label (e.g., @code{$Comments}/@code{$EndComments})
after the @code{$MeshFormat}/@code{$EndMeshFormat} section: see @ref{MSH
ASCII file format}.
===

So you could create a .msh file like this:

$MeshFormat
2 0 8
$EndMeshFormat
$Comments
my comments
$EndComments
$Nodes
...

Cheers,

Christophe


> Are there plans to add the possibility of comments in .msh files?
> I've just added an export-to-gmsh feature to my software and it would 
> be very useful to be able to include history comments. (A student of 
> mine did a comparison of several mesh generators and concluded that 
> Gmsh is the best for our purposes, and a couple of other students then 
> used it. I'm finally getting there myself! Thanks for the great 
> software.)
> 
> - Robert
> 
> 
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh
> 
> 


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