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

Fix Mesh.flip(mask=None): Take care of the mask #625

Merged
merged 2 commits into from
Feb 16, 2024
Merged

Fix Mesh.flip(mask=None): Take care of the mask #625

merged 2 commits into from
Feb 16, 2024

Conversation

adtzlr
Copy link
Owner

@adtzlr adtzlr commented Feb 16, 2024

fixes #624 (as mentioned in #622)

Example

from skfem import MeshTet

mesh_skfem = MeshTet().refined(2)
mesh_skfem.save("trialMesh.xdmf")

from meshio import xdmf
import felupe as fem
import numpy as np

meshio_mesh = xdmf.read("trialMesh.xdmf")
mesh = fem.Mesh(
    points=meshio_mesh.points,
    cells=meshio_mesh.get_cells_type("tetra"),
    cell_type=meshio_mesh.cells[0].type,
)

# ensure positive cell volumes (before adding midpoints on edges!)
region = fem.RegionTetra(mesh)
mesh = mesh.flip(np.any(region.dV < 0, axis=0))
region.reload(mesh)
assert np.all(region.dV > 0)

region_u = fem.RegionQuadraticTetra(mesh.add_midpoints_edges())
region_p = fem.RegionTetra(
    mesh=fem.mesh.dual(mesh, disconnect=False),
    quadrature=region_u.quadrature,
    grad=False,
)

@adtzlr adtzlr added the bug Something isn't working label Feb 16, 2024
@adtzlr adtzlr self-assigned this Feb 16, 2024
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cafae00) 96.30% compared to head (cac217b) 96.30%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #625   +/-   ##
=======================================
  Coverage   96.30%   96.30%           
=======================================
  Files          91       91           
  Lines        4681     4681           
=======================================
  Hits         4508     4508           
  Misses        173      173           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adtzlr adtzlr merged commit cd15db1 into main Feb 16, 2024
9 checks passed
@adtzlr adtzlr deleted the fix-mesh-flip branch February 16, 2024 12:38
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

Successfully merging this pull request may close these issues.

Bug in Mesh.flip(mask=None): The mask is ignored
1 participant