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

Add ignore_orientation and ignore_interior_facets flags #1050

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

kinnala
Copy link
Owner

@kinnala kinnala commented Aug 17, 2023

In [1]: from skfem import *

In [2]: %time m = MeshTet.load('labelled.msh')

CPU times: user 632 ms, sys: 27.8 ms, total: 660 ms
Wall time: 704 ms

becomes

In [1]: from skfem import *

In [2]: %time m = MeshTet.load('labelled.msh', ignore_orientation=True)

CPU times: user 193 ms, sys: 31.8 ms, total: 225 ms
Wall time: 260 ms

due to vectorized matching. However, the latter is more memory intensive. The memory usage can be reduced by entirely ignoring the interior facets via MeshTet.load('labelled.msh', ignore_interior_facets=True.

Fixes #1049.

Copy link

@Vinc0110 Vinc0110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to speed up the mesh loading from labeled gmsh files, which also take a very long time in my cases (sometimes several minutes).

Testing this new code with ignore_orientation=True, I get an error, unfortunately:

File "/usr/local/lib/python3.8/dist-packages/skfem/io/meshio.py", line 134, in from_meshio
    boundaries[k] = np.nonzero((a == b[:, None]).all(axis=2).any(axis=1))[0]
AttributeError: 'bool' object has no attribute 'all'

I'm using Python 3.8 with numpy 1.24.4.

Copy link

@Vinc0110 Vinc0110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works great with Python 3.10. Huge speed improvement (about 10x). Thanks a lot!

@kinnala kinnala changed the title Add ignore_orientation flag Add ignore_orientation and ignore_interior_facets flags Oct 25, 2023
@kinnala kinnala merged commit 292b201 into master Oct 25, 2023
4 checks passed
@kinnala kinnala deleted the add-ignore-orientation branch October 25, 2023 06:08
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

Successfully merging this pull request may close these issues.

slow to build meshes with labeled subdomains
2 participants