neperfepx / neper

Polycrystal generation and meshing
http://neper.info
GNU General Public License v3.0
214 stars 53 forks source link

incorrect msh4 format generated from neper #779

Closed sharanroongta closed 12 months ago

sharanroongta commented 12 months ago

Incorrect msh4 format generated from neper. There are two extra sections added in the msh file which is not present in the official gmsh documentation: $MeshVersion

$EndMeshVersion $Domain

$EndDomain

Also,

In the $Entities section, the volumes are malformed. We have

1 0.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 0.921109989703 0 2 1 2 3 4 5 6 2 0.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 1.000000000000 0 2 7 8 9 10 11 12 6

So the number of bounding surfaces is "2", but 6 and 7 surface tags are given respectively. This contradicts the GMsh format

To Reproduce

The commands I ran using the latest development version of neper:

$ neper -T -n 2 -o test

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.7.1-4
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/home/work/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -T loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] -n 2 -o test
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   : Creating domain...
Info   : Creating tessellation...
Info   :   - Setting seeds... 
Info   :   - Running tessellation...
Info   : Generating crystal orientations...
Info   : Writing results...
Info   :     [o] Writing file `test.tess'...
Info   :     [o] Wrote file `test.tess'.
Info   : Elapsed time: 0.152 secs.
========================================================================
neper -M test.tess -format msh4

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.7.1-4
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/home/work/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -M loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] test.tess -format msh4
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   :   - Reading arguments...
Info   : Loading input data...
Info   :   - Loading tessellation...
Info   :     [i] Parsing file `test.tess'...
Info   :     [i] Parsed file `test.tess'.
Info   : Meshing...
Info   :   - Preparing... (cl = 0.3969) 100%
Info   :   - 0D meshing... 100%
Info   :   - 1D meshing... 100%
Info   :   - 2D meshing... 100% (0.44|0.79/100%| 0%| 0%)
Info   :   - Fixing 2D-mesh pinches...
Info   :   - 3D meshing... 100% (0.88|0.89/100%| 0%| 0%)
Info   : Searching nsets and fasets...
Info   : Writing mesh results...
Info   :   - Preparing mesh...
Info   :   - Mesh properties:
Info   :     > Node number:       98
Info   :     > Elt  number:      262
Info   :     > Mesh volume:    1.000
Info   :   - Writing mesh...
Info   :     [o] Writing file `test.msh4'...
Info   :     [o] Wrote file `test.msh4'.
Info   : Elapsed time: 6.807 secs.
========================================================================

The msh4 file until the end of $Entities section look like this:

4.1 0 8
$EndMeshFormat
$MeshVersion
2.2.3
$EndMeshVersion
$Domain
cube
$EndDomain
$Entities
13 22 12 2
1 1.000000000000 0.000000000000 0.000000000000
 0
2 1.000000000000 1.000000000000 0.000000000000
 0
3 0.000000000000 1.000000000000 0.000000000000
 0
4 -0.000000000000 0.072876995892 -0.000000000000
 0
5 -0.000000000000 1.000000000000 0.523792986818
 0
6 1.000000000000 1.000000000000 0.921109989703
 0
7 1.000000000000 -0.000000000000 0.356143977106
 0
8 0.103627646137 -0.000000000000 -0.000000000000
 0
9 0.000000000000 0.000000000000 0.000000000000
 0
10 0.000000000000 0.000000000000 1.000000000000
 0
11 0.000000000000 1.000000000000 1.000000000000
 0
12 1.000000000000 1.000000000000 1.000000000000
 0
13 1.000000000000 0.000000000000 1.000000000000
 0
1 0.000000000000 0.072876995892 0.000000000000 0.000000000000 1.000000000000 0.000000000000 0  2 3 4
2 -0.000000000000 0.072876995892 -0.000000000000 -0.000000000000 1.000000000000 0.523792986818 0  2 4 5
3 0.000000000000 1.000000000000 0.000000000000 0.000000000000 1.000000000000 0.523792986818 0  2 5 3
4 1.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 0.000000000000 0  2 1 2
5 1.000000000000 1.000000000000 0.000000000000 1.000000000000 1.000000000000 0.921109989703 0  2 2 6
6 1.000000000000 -0.000000000000 0.356143977106 1.000000000000 1.000000000000 0.921109989703 0  2 6 7
7 1.000000000000 -0.000000000000 0.000000000000 1.000000000000 -0.000000000000 0.356143977106 0  2 7 1
8 0.103627646137 -0.000000000000 -0.000000000000 1.000000000000 -0.000000000000 0.356143977106 0  2 7 8
9 0.103627646137 0.000000000000 0.000000000000 1.000000000000 0.000000000000 0.000000000000 0  2 8 1
10 0.000000000000 1.000000000000 0.000000000000 1.000000000000 1.000000000000 0.000000000000 0  2 2 3
11 -0.000000000000 1.000000000000 0.523792986818 1.000000000000 1.000000000000 0.921109989703 0  2 5 6
12 -0.000000000000 -0.000000000000 -0.000000000000 0.103627646137 0.072876995892 -0.000000000000 0  2 8 4
13 0.000000000000 0.000000000000 0.000000000000 0.000000000000 0.000000000000 1.000000000000 0  2 9 10
14 0.000000000000 0.000000000000 1.000000000000 0.000000000000 1.000000000000 1.000000000000 0  2 10 11
15 0.000000000000 1.000000000000 0.523792986818 0.000000000000 1.000000000000 1.000000000000 0  2 11 5
16 0.000000000000 0.000000000000 0.000000000000 0.000000000000 0.072876995892 0.000000000000 0  2 4 9
17 1.000000000000 0.000000000000 1.000000000000 1.000000000000 1.000000000000 1.000000000000 0  2 12 13
18 1.000000000000 0.000000000000 0.356143977106 1.000000000000 0.000000000000 1.000000000000 0  2 13 7
19 1.000000000000 1.000000000000 0.921109989703 1.000000000000 1.000000000000 1.000000000000 0  2 6 12
20 0.000000000000 0.000000000000 1.000000000000 1.000000000000 0.000000000000 1.000000000000 0  2 13 10
21 0.000000000000 0.000000000000 0.000000000000 0.103627646137 0.000000000000 0.000000000000 0  2 9 8
22 0.000000000000 1.000000000000 1.000000000000 1.000000000000 1.000000000000 1.000000000000 0  2 11 12
1 0.000000000000 0.072876995892 0.000000000000 0.000000000000 1.000000000000 0.523792986818 0  3 1 2 3
2 1.000000000000 -0.000000000000 0.000000000000 1.000000000000 1.000000000000 0.921109989703 0  4 4 5 6 7
3 0.103627646137 0.000000000000 0.000000000000 1.000000000000 0.000000000000 0.356143977106 0  3 -7 8 9
4 0.000000000000 1.000000000000 0.000000000000 1.000000000000 1.000000000000 0.921109989703 0  4 10 -3 11 -5
5 0.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 0.000000000000 0  5 -10 -4 -9 12 -1
6 -0.000000000000 -0.000000000000 -0.000000000000 1.000000000000 1.000000000000 0.921109989703 0  5 2 11 6 8 12
7 0.000000000000 0.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 0  5 13 14 15 -2 16
8 1.000000000000 0.000000000000 0.356143977106 1.000000000000 1.000000000000 1.000000000000 0  4 17 18 -6 19
9 0.000000000000 0.000000000000 0.000000000000 1.000000000000 0.000000000000 1.000000000000 0  5 20 -13 21 -8 -18
10 0.000000000000 1.000000000000 0.523792986818 1.000000000000 1.000000000000 1.000000000000 0  4 22 -19 -11 -15
11 0.000000000000 0.000000000000 0.000000000000 0.103627646137 0.072876995892 0.000000000000 0  3 -16 -12 -21
12 0.000000000000 0.000000000000 1.000000000000 1.000000000000 1.000000000000 1.000000000000 0  4 -17 -22 -14 -20
1 0.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 0.921109989703 0  2 1 2 3 4 5 6
2 0.000000000000 0.000000000000 0.000000000000 1.000000000000 1.000000000000 1.000000000000 0  2 7 8 9 10 11 12 6
$EndEntities

Thanks

Sharan

rquey commented 12 months ago

Thanks @sharanroongta. I fixed the $Entities bug. The $MeshVersion and $Domain (and possibly other) sections are specific to Neper - they are not recognized by Gmsh and are ignored during parsing.

sharanroongta commented 12 months ago

Thanks @rquey for the fix. Can I ask another question here? While loading the msh4 file to view in Gmsh, I get several warnings

Info    : Reading 'C:\Users\s.roongta\Downloads\msh4\msh4\n2-id1.msh4'...
Info    : 49 entities
Warning : Entity 4 not found in the Brep of entity 2
Warning : Entity 5 not found in the Brep of entity 2
Warning : Entity 5 not found in the Brep of entity 3
Warning : Entity 3 not found in the Brep of entity 3
Warning : Entity 2 not found in the Brep of entity 4
Warning : Entity 2 not found in the Brep of entity 5
Warning : Entity 6 not found in the Brep of entity 5
Warning : Entity 6 not found in the Brep of entity 6
Warning : Entity 7 not found in the Brep of entity 6
Warning : Entity 7 not found in the Brep of entity 7
Warning : Entity 7 not found in the Brep of entity 8
Warning : Entity 8 not found in the Brep of entity 8
Warning : Entity 8 not found in the Brep of entity 9
Warning : Entity 2 not found in the Brep of entity 10
Warning : Entity 3 not found in the Brep of entity 10
Warning : Entity 5 not found in the Brep of entity 11
Warning : Entity 6 not found in the Brep of entity 11
Warning : Entity 8 not found in the Brep of entity 12
Warning : Entity 4 not found in the Brep of entity 12
Warning : Entity 9 not found in the Brep of entity 13
Warning : Entity 10 not found in the Brep of entity 13
Warning : Entity 10 not found in the Brep of entity 14
Warning : Entity 11 not found in the Brep of entity 14
Warning : Entity 11 not found in the Brep of entity 15
Warning : Entity 5 not found in the Brep of entity 15
Warning : Entity 4 not found in the Brep of entity 16
Warning : Entity 9 not found in the Brep of entity 16
Warning : Entity 12 not found in the Brep of entity 17
Warning : Entity 13 not found in the Brep of entity 17
Warning : Entity 13 not found in the Brep of entity 18
Warning : Entity 7 not found in the Brep of entity 18
Warning : Entity 6 not found in the Brep of entity 19
Warning : Entity 12 not found in the Brep of entity 19
Warning : Entity 13 not found in the Brep of entity 20
Warning : Entity 10 not found in the Brep of entity 20
Warning : Entity 9 not found in the Brep of entity 21
Warning : Entity 8 not found in the Brep of entity 21
Warning : Entity 11 not found in the Brep of entity 22
Warning : Entity 12 not found in the Brep of entity 22
Warning : Entity 1 not found in the Brep of entity 1
Warning : Entity -1 not found in the Brep of entity 5
Info    : 90 nodes
Info    : Creating discrete point 2
Info    : Creating discrete point 3
Info    : Creating discrete point 4
Info    : Creating discrete point 5
Info    : Creating discrete point 6
Info    : Creating discrete point 7
Info    : Creating discrete point 8
Info    : Creating discrete point 9
Info    : Creating discrete point 10
Info    : Creating discrete point 11
Info    : Creating discrete point 12
Info    : Creating discrete point 13
Info    : Creating discrete curve 1
Info    : 496 elements
Info    : Done reading 'C:\Users\s.roongta\Downloads\msh4\msh4\n2-id1.msh4'
Info    : Writing 'C:\Users\s.roongta\Downloads\msh4\msh4\test'...

There is also an additional point generated which is out of the domain. msh_in_gmsh

Having said that, if i output the neper tessellation in .geo format, and load in gmsh everything seems fine, but i lose the $PhysicalNames section. Any idea as to why it might be happening? I can create a new issue if you want. Wasn't sure

Thanks, Sharan

rquey commented 12 months ago

There is also an additional point generated which is out of the domain.

What command(s) are you running?

sharanroongta commented 12 months ago
neper -T -n 2 -o test

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.7.1-5
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 4 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/nethome/s.roongta/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -T loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] -n 2 -o test
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   : Creating domain...
Info   : Creating tessellation...
Info   :   - Setting seeds...
Info   :   - Running tessellation...
Info   : Generating crystal orientations...
Info   : Writing results...
Info   :     [o] Writing file `test.tess'...
Info   :     [o] Wrote file `test.tess'.
Info   : Elapsed time: 0.035 secs.
========================================================================

meshing:

neper -M test.tess -format msh4
========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.7.1-5
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 4 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/nethome/s.roongta/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -M loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] test.tess -format msh4
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   :   - Reading arguments...
Info   : Loading input data...
Info   :   - Loading tessellation...
Info   :     [i] Parsing file `test.tess'...
Info   :     [i] Parsed file `test.tess'.
Info   : Meshing...
Info   :   - Preparing... (cl = 0.3969) 100%
Info   :   - 0D meshing... 100%
Info   :   - 1D meshing... 100%
Info   :   - 2D meshing... 100% (0.44|0.8/100%| 0%| 0%)
Info   :   - Fixing 2D-mesh pinches...
Info   :   - 3D meshing... 100% (0.89|0.89/100%| 0%| 0%)
Info   : Searching nsets and fasets...
Info   : Writing mesh results...
Info   :   - Preparing mesh...
Info   :   - Mesh properties:
Info   :     > Node number:       90
Info   :     > Elt  number:      232
Info   :     > Mesh volume:    1.000
Info   :   - Writing mesh...
Info   :     [o] Writing file `test.msh4'...
Info   :     [o] Wrote file `test.msh4'.
Info   : Elapsed time: 6.320 secs.
========================================================================

Thereafter visualizing the file in Gmsh gui. Tools->options->Geometry shows this additional point (not a part of the mesh)

Thanks, Sharan

rquey commented 12 months ago

No idea why this point shows up, as it is not part of the msh4 file.

An even simpler example is:

neper -T -n 1 -domain "cube(0.1,0.1,0.1)" -o test
neper -M test.tess -cl 1 -for msh4

In Gmsh's GUI, you'll see a point at (2,0.1,0.1), while grep "2\.0" test.msh4 returns nothing.

sharanroongta commented 12 months ago

Strange. In any case, I don't think it would be a problem. Just wondered why it happened. Shall contact the gmsh people if needed.

Also, any comment on the removal of $PhysicalNames bit while saving the mesh file using gmsh? It is probably not a neper thing?

rquey commented 12 months ago

Yes, more a Gmsh issue.

sharanroongta commented 12 months ago

Many thanks for the quick response, and the help.