neperfepx / neper

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

missing physical tags description in the Entities section in msh4 file #781

Closed sharanroongta closed 12 months ago

sharanroongta commented 12 months ago

Describe the bug

After generating a mesh from a tesselation, the msh4 file created does not indicate the physical tags in the $Entities section. As far as my understanding, the tag associated in the $PhysicalNames section should be indicated in the $Entities section too.

To Reproduce

Ran the following commands:

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

The $ Entities section look like:

$Entities
8 12 6 1
1 0.000000000000 0.000000000000 0.000000000000
 0
2 0.100000000000 0.000000000000 0.000000000000
0 
3 0.100000000000 0.100000000000 0.000000000000
0
4 0.000000000000 0.100000000000 0.000000000000
 0 
5 0.000000000000 0.000000000000 0.100000000000
 0 
6 0.000000000000 0.100000000000 0.100000000000
 0 
7 0.100000000000 0.100000000000 0.100000000000
 0 
8 0.100000000000 0.000000000000 0.100000000000
 0 
1 0.000000000000 0.100000000000 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0  2 4 6
2 0.000000000000 0.000000000000 0.100000000000 0.000000000000 0.100000000000 0.100000000000 0  2 6 5
3 0.000000000000 0.000000000000 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0  2 5 1
4 0.000000000000 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0.000000000000 0  2 1 4
5 0.100000000000 0.000000000000 0.000000000000 0.100000000000 0.000000000000 0.100000000000 0  2 2 8
6 0.100000000000 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0.100000000000 0  2 8 7
7 0.100000000000 0.100000000000 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0  2 7 3
8 0.100000000000 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0.000000000000 0  2 3 2
9 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0.000000000000 0.100000000000 0  2 5 8
10 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0.000000000000 0.000000000000 0  2 2 1
11 0.000000000000 0.100000000000 0.000000000000 0.100000000000 0.100000000000 0.000000000000 0  2 4 3
12 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0.100000000000 0.100000000000 0  2 7 6
1 0.000000000000 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0  4 -1 -4 -3 -2 
2 0.100000000000 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0  4 -5 -8 -7 -6 
3 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0.000000000000 0.100000000000 0  4 3 -10 5 -9 
4 0.000000000000 0.100000000000 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0  4 -11 1 -12 7 
5 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0.000000000000 0  4 10 4 11 8 
6 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0.100000000000 0  4 2 9 6 12 
1 0.000000000000 0.000000000000 0.000000000000 0.100000000000 0.100000000000 0.100000000000 0  6 1 2 3 4 5 6
$EndEntities

The number of physical tags indicated is to be 0. However, the tags generated in the $PhysicalNames section should be reflected here?

$PhysicalNames
33
0 1 ver1
0 2 ver2
0 3 ver3
0 4 ver4
0 5 ver5
0 6 ver6
0 7 ver7
0 8 ver8
1 1 edge1
1 2 edge2
1 3 edge3
1 4 edge4
1 5 edge5
1 6 edge6
1 7 edge7
1 8 edge8
1 9 edge9
1 10 edge10
1 11 edge11
1 12 edge12
2 1 face1
2 2 face2
2 3 face3
2 4 face4
2 5 face5
2 6 face6
2 7 x0
2 8 x1
2 9 y0
2 10 y1
2 11 z0
2 12 z1
3 1 poly1
$EndPhysicalNames

If one creates a physical tag using an integer or a string, should be reflected in the $Entities section. For example: Physical Surface{1} = {1}; Physical Surface{"x0"} = {1}; would generate 2 physical tags. Physical Surface{"x0"} = {1}; would generate 1 physical tag

Please correct me if I am wrong, but this what I observed using .geo and gmsh.

Thanks again, Sharan Roongta

rquey commented 12 months ago

Thanks @sharanroongta. This should now be fixed.

sharanroongta commented 12 months ago

Super! Thanks @rquey There is another fix that is required, which is enquoting the string name in the $PhysicalName section.,, i.e.,

$PhysicalNames
1
0 1 "ver0"
$EndPhysicalNames

The current implementation has :

$PhysicalNames
1
0 1 ver0
$EndPhysicalNames

This is the reason to lose the $PhysicalName information after loading the neper generated msh file in gmsh. Please see the issue https://gitlab.onelab.info/gmsh/gmsh/-/issues/2724#note_21790, and the subsequent discussion.

If you agree, I can create a new pull request for the same.

Thanks, Sharan

rquey commented 12 months ago

Yes, if you can, please make the necessary changes and create a pull request (https://neper.info/workflow.html#being-a-contributor).