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

Reordered local vertices in load_mesh / flipped tets in mesh #57

Open
Huangzizhou opened this issue Jun 16, 2022 · 4 comments
Open

Reordered local vertices in load_mesh / flipped tets in mesh #57

Huangzizhou opened this issue Jun 16, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@Huangzizhou
Copy link
Contributor

When a mesh in msh22 format is loaded, if I call mesh->cell_vertex(c, v) to get the cell list, the local vertices are sorted.

Here're the first few cells in my mesh

$Elements
31443
1 4 2 0 0 4555 6346 6399 1253
2 4 2 0 0 6346 5707 6399 1253
3 4 2 0 0 6399 1262 4555 1253
4 4 2 0 0 5707 1262 6399 1253
5 4 2 0 0 3491 6716 228 233

Here're the first few cells in the mesh class

1252 4554 6345 6398 
1252 5706 6345 6398 
1252 1261 4554 6398 
1252 1261 5706 6398 
227 232 3490 6715 

This may make tets flip if one wants to export the mesh.

@Huangzizhou Huangzizhou added the bug Something isn't working label Jun 16, 2022
@teseoch
Copy link
Member

teseoch commented Sep 7, 2022

this should fix this one too:
68defd5

@teseoch teseoch closed this as completed Oct 18, 2022
@zfergus
Copy link
Member

zfergus commented Dec 26, 2022

I don't think this issue was ever properly resolved. The commit linked does not fix the problem which is that the CMesh3D class sorts each of the cell's vertices by ID.

In CMesh3D::load(const GEO::Mesh &M), there is a sort of the cell's vertices:

for (auto fid : cell.fs)
{
    cell.vs.insert(cell.vs.end(), mesh_.faces[fid].vs.begin(), mesh_.faces[fid].vs.end());
}
sort(cell.vs.begin(), cell.vs.end());
cell.vs.erase(unique(cell.vs.begin(), cell.vs.end()), cell.vs.end());

Maybe this is only so the unique will work, and removing duplicates while preserving order might fix it. 🤞

There are a number of other sorts in that file as well. Some are doing it to remove duplicates, but others are doing it on temporary local variables to check for equality. The latter seems perfectly fine.

@zfergus zfergus reopened this Dec 26, 2022
@zfergus
Copy link
Member

zfergus commented Dec 26, 2022

Actually even with an order-preserving duplicate removal, I still get inverted elements. I think it comes from the for-loop. It looks like it is creating a cell out of the cell's faces rather than using the cell that was given.

@Huangzizhou
Copy link
Contributor Author

Yes, I once went through this, I also think it's creating every cell from its faces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants