[Gmsh] write a .pos file and read it back -> different results
Christophe Geuzaine
geuzaine at acm.caltech.edu
Sun May 23 22:21:24 CEST 2004
Al Danial wrote:
> I'm trying to write a program that writes .pos files and am having a
> hard time getting the sequence of terms just right. Probably one of
> those ubiquitous "off by one" goofs somewhere. I figured a good way
> to get the format right is to match the output that gmsh itself
> writes.
>
> I start with this file (called "A.pos"):
>
> View "vname_A" {
> ST(0.5,0.5,0.0,1.0,0.5,0.0,1.0,1.0,0.0){1,2,3,4,5,6,7,8,9,10};
> ST(0.5,0.5,0.0,1.0,1.0,0.0,0.5,1.0,0.0){2,3,4,5,6,7,8,9,10,11};
> };
>
> I load it into gmsh and it looks fine. Then I do "Save as/ASCII
> view..." and write the view to the file "B.pos". It looks like this:
>
> $PostFormat /* Gmsh 1.2, ascii */
> 1.2 0 8
> $EndPostFormat
> $View /* vname_A */
> vname_A 3 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 1 2 0.5 1 1 0.5 0.5 1 0 0 0 1 2 3 4 5 6 7 8 9 10 0.5 1 0.5 0.5 1 1
> 0 0 0 2 3 4 5 6 7 8 9 10 11
> $EndView
>
> The problem is that when B.pos is loaded back in it does not resemble
> A.pos at all.
>
> What am I missing? -- Al
Your first file is wrong: for a scalar triangle the number of values has
to be a multiple of 3 (1 number for each node, times the number of steps).
You could for example have:
View "vname_A" {
ST(0.5,0.5,0.0,1.0,0.5,0.0,1.0,1.0,0.0){1,2,3,4,5,6,7,8,9};
ST(0.5,0.5,0.0,1.0,1.0,0.0,0.5,1.0,0.0){2,3,4,5,6,7,8,9,10};
};
PS: Gmsh should definitely output a warning or an error when this
occurs... I'll add a sanity check in the code.
--
Christophe Geuzaine
Applied and Computational Mathematics, Caltech
geuzaine at acm.caltech.edu - http://geuz.org