neperfepx / neper

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

Gmsh file cannot be parsed by Neper #209

Closed CsatiZoltan closed 3 years ago

CsatiZoltan commented 3 years ago

Hi,

To visualize 3D_testFEPX.msh with Neper, I called neper -V 3D_testFEPX.msh -print 2.png, which gave me the following result:

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.1.2
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2020, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/home/zoltan/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -V loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] 3D_testFEPX.msh -print 2.png
Info   : ---------------------------------------------------------------
Info   : Loading mesh...
Info   :     [i] Parsing file `3D_testFEPX.msh'...
Info   :     [i] Parsed file `3D_testFEPX.msh'.
Info   : Reconstructing mesh...
Info   :     > Reconstructing 2D mesh... 100%      
Info   :     > Reconstructing 1D mesh... 100%      
Info   :     > Reconstructing 0D mesh... 100%      
Error  : You have discovered a bug in Neper!  Please file an issue at
         https://github.com/rquey/neper/issues.  Thank you.

To spot the mistake, I started removing entities from the example mesh of FEPX so that it resembles my mesh data structure. The mutilated example mesh is called test_mesh.msh and calling neper -V test_mesh.msh -print 1.png gave me the expected output with the following log:

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.1.2
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2020, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/home/zoltan/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -V loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] test_mesh.msh -print 1.png
Info   : ---------------------------------------------------------------
Info   : Loading mesh...
Info   :     [i] Parsing file `test_mesh.msh'...
Info   :     [i] Parsed file `test_mesh.msh'.
Info   : Reconstructing mesh...
Info   :     > Reconstructing 2D mesh... 100%      
Info   :     > Reconstructing 1D mesh... 100%      
Info   :     > Reconstructing 0D mesh... 100%      
Info   : Printing image...
Info   :     [o] Writing file `1.png.pov'...
Info   :   - Printing mesh...
Info   :     > Reducing data...
Info   :       . 3D...
Info   :       . 2D...
Info   :       . Number of 3D elt faces reduced by  95% (to 1612).
Info   :       . Number of 3D elt edges reduced by  50% (to 2418).
Info   :       . Number of 0D elts      reduced by 100% (to 0).
Info   :     [o] Wrote file `1.png.pov'.
Info   :   - Generating png file (1200x900 pixels)...
Info   :     [o] Writing file `1.png.png'...
Info   :     [o] Wrote file `1.png.png'.
Info   : Printing scale...
Info   : Elapsed time: 1.942 secs.

I cannot see why Neper fails on my mesh, the only difference I see compared to the working mesh (test_mesh.msh) is that my mesh is not partitioned, so the partition index is 1 for all the tetrahedra. I also checked my mesh in Gmsh as well as in ParaView, but I couldn't spot the error visually. See the mesh files attached. test_mesh.msh.txt 3D_testFEPX.msh.txt

Thank you, Zoltan

CsatiZoltan commented 3 years ago

Further input that may help. I realized that in some cases what makes Neper fail is the existence of multiple element sets. E.g. in the example mesh above (3D_testFEPX.msh.txt), if I associate all the elements with set 1 (such as modifying the line 1526 11 3 2 2 1 799 25 784 48 801 788 804 1801 1766 1310 to 1526 11 3 1 1 1 799 25 784 48 801 788 804 1801 1766 1310) it solves the issue. I am sure that this is a problem in Neper itself and not in FEPX. To ascertain, I ran a simulation with FEPX for two setups:

  1. Only one element set (grain) with a given triple of Euler angles.
  2. Two elements sets (grains), associating the same triples of Euler angles with both

Performing a file diff on the outputs (node positions, strain and stress tensor components), no change was detected, which is the expected behaviour (on the other hand, perturbing the Euler angles of the second grain slightly changed the results). This implies that the issue is not on the side of FEPX. I would argue that this is a bug in Neper, as simply associating a different label (element set) with selected elements does not change the mesh topology.

rquey commented 3 years ago

Sorry for the delay in responding, but this is actually a simple and well-known problem. Your mesh is probably perfectly fine, but Neper fails to reconstruct its topology as it is not the one of a typical Neper tessellation: your geometry has loop edges (which aren't associated to any vertices), which Neper does not expect.

There are probably workarounds. What is your ultimate goal?

CsatiZoltan commented 3 years ago

In the meantime, I created a parser for Neper. Based on that, I modified the element sets by setting their labels to 1. Neper now properly processes the mesh. The only downside of this approach is that the original element set information is lost, so the original grains cannot be identified on the exported .png file. An alternative solution, which I have not implemented yet, is

  1. perform the element set modification using my parser
  2. export the results to .vtk using Neper
  3. create a parser for .vtk and restore the original element sets

What is your ultimate goal?

My ultimate goal is to be able to show the original element sets so as to see how grains deform under load. The 3-step approach above is viable for the .vtk backend, but being able to do it for the raster output too would be useful as Neper can create beautiful .png files using POV-Ray.

your geometry has loop edges (which aren't associated to any vertices)

What do you mean? My mesh has volumetric elements only (all elements are quadratic tetrahedra, with type 11).

this is actually a simple and well-known problem

I did not read about it in the manual. Could you give me a reference?

rquey commented 3 years ago

What is your ultimate goal?

My ultimate goal is to be able to show the original element sets so as to see how grains deform under load. The 3-step approach above is viable for the .vtk backend, but being able to do it for the raster output too would be useful as Neper can create beautiful .png files using POV-Ray.

In version 4.1.3-13, you can now include

$Topology
0
$ENdTopology

to your msh file (right after $EndMeshFormat, in your file), to tell Neper that it should not attempt to reconstruct the topology for that particular mesh.

your geometry has loop edges (which aren't associated to any vertices)

What do you mean? My mesh has volumetric elements only (all elements are quadratic tetrahedra, with type 11).

When you give a 3D mesh, Neper attempts to reconstruct the 2D, 1D and 0D meshes of the interfaces, for internal use and to be able to show them in -V. The circular grain generates 1D elsets ("tessellation edges") that are not associated to 0D elsets ("tessellation vertices"), which Neper does not like.

this is actually a simple and well-known problem

I did not read about it in the manual. Could you give me a reference?

Well-know to me... The manual describes what Neper does but not what it doesn't.

image

CsatiZoltan commented 3 years ago

Thank you for the patch. I confirm that it works well with the latest commit.