Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] If a line is discretized by one element, import and export with meshio does not yield a file readable by GMSH #1421

Open
TimS-HSU opened this issue Jul 11, 2023 · 0 comments

Comments

@TimS-HSU
Copy link

I am currently facing an issue with reading in a msh file from GMSH (4.11.1), and saving it again (without modification) to a GMSH msh file. For this, I use the following:

import meshio
msh = meshio.read("test.msh")
meshio.gmsh.write("test2.msh", msh, binary=False)

meshio.__version__ returns 5.0.0.

The initial msh file test.msh can be opened by GMSH again. The resulting msh file test2.msh however cannot. The test.geo file (from which the test.msh is generated) is:

Point(1) = {0, 0, 0, 1};
//+
Point(2) = {1., 0, 0, 1};
//+
Point(3) = {1., 1., 0, 1};
//+
Point(4) = {0, 1., 0, 1};
//+
Line(1) = {1, 2};
//+
Line(2) = {2, 3};
//+
Line(3) = {3, 4};
//+
Line(4) = {4, 1};
//+
Curve Loop(1) = {1, 2, 3, 4};
//+
Plane Surface(1) = {1};
//+
Physical Curve("bottom", 1) = {1};
//+
Physical Curve("right", 2) = {2};
//+
Physical Curve("top", 3) = {3};
//+
Physical Curve("left", 4) = {4};
//+
Physical Surface("domain", 10) = {1};

The resulting test.msh looks as follows:

$MeshFormat
4.1 0 8
$EndMeshFormat
$PhysicalNames
5
1 1 "bottom"
1 2 "right"
1 3 "top"
1 4 "left"
2 10 "domain"
$EndPhysicalNames
$Entities
4 4 1 0
1 0 0 0 0 
2 1 0 0 0 
3 1 1 0 0 
4 0 1 0 0 
1 0 0 0 1 0 0 1 1 2 1 -2 
2 1 0 0 1 1 0 1 2 2 2 -3 
3 0 1 0 1 1 0 1 3 2 3 -4 
4 0 0 0 0 1 0 1 4 2 4 -1 
1 0 0 0 1 1 0 1 10 4 1 2 3 4 
$EndEntities
$Nodes
9 5 1 5
0 1 0 1
1
0 0 0
0 2 0 1
2
1 0 0
0 3 0 1
3
1 1 0
0 4 0 1
4
0 1 0
1 1 0 0
1 2 0 0
1 3 0 0
1 4 0 0
2 1 0 1
5
0.5 0.5 0
$EndNodes
$Elements
5 8 1 8
1 1 1 1
1 1 2 
1 2 1 1
2 2 3 
1 3 1 1
3 3 4 
1 4 1 1
4 4 1 
2 1 2 4
5 1 2 5 
6 4 1 5 
7 2 3 5 
8 3 4 5 
$EndElements

After reading in and saving the file as msh with meshio again, this yields

$MeshFormat
4.1 0 8
$EndMeshFormat
$PhysicalNames
5
1 1 "bottom"
1 2 "right"
1 3 "top"
1 4 "left"
2 10 "domain"
$EndPhysicalNames
$Entities
4 0 1 0
1 0 0 0 0 
2 0 0 0 0 
3 0 0 0 0 
4 0 0 0 0 
1 0 0 0 0 0 0 1 10 4 1 2 3 4 
$EndEntities
$Nodes
5 5 1 5
0 1 0 1
1
0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
0 2 0 1
2
1.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
0 3 0 1
3
1.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00
0 4 0 1
4
0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00
2 1 0 1
5
5.0000000000000000e-01 5.0000000000000000e-01 0.0000000000000000e+00
$EndNodes
$Elements
5 8 1 8
1 1 1 1
1 1 2
1 2 1 1
2 2 3
1 3 1 1
3 3 4
1 4 1 1
4 4 1
2 1 2 4
5 1 2 5
6 4 1 5
7 2 3 5
8 3 4 5
$EndElements

I have realized that 1. the entities representing the lines are missing, and 2. the "nodes"(?) representing the elements (previously 1 1 0 0, 1 2 0 0, 1 3 0 0 and 1 4 0 0) are missing (and the entries in the first line are therefore also different). If adding the missing entries in "Nodes" by hand, the lines are discretized, but GMSH reads it in fine. If also adding the entities, no discretization is necessary and GMSH reads it in fine aswell.

Can someone maybe point me to a solution to this problem? Of course my real mesh is a little more complicated, but it boils down to this issue.

@TimS-HSU TimS-HSU changed the title [BUG] If a line is discretized by one element, the gmsh:dim_tags is missing [BUG] If a line is discretized by one element, import and export with meshio does not yield a file readable by GMSH Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant