Skip to content

Conversation

@como2099
Copy link
Contributor

This PR fixes a crash in PUMI adapt that occurs for 2D mixed-element meshes (tri + quad) when quad layers are frozen.

The issue was discovered while using PUMI with CFD workflow. In this configuration, adaptation should proceed on triangle elements even when quad layers are excluded.

The fix adds a guard in maQuality.cc to allow safe adaptation of triangles
in mixed-element 2D meshes without affecting existing workflows.

Bug originally found in release v4.1.0; tested by building against current develop and running the affected
adaptation path.

Fixes #523

…rs; added a check to the maQuality routine that allows adaptation of tris in mixed element 2d meshes
@cwsmith cwsmith changed the base branch from master to develop December 15, 2025 20:05
@joshia5
Copy link
Contributor

joshia5 commented Dec 16, 2025

Thank you for the fix @como2099. The changes in the pr adds a check by computing the validity (using positive area) of a quadrilateral element. In line 586, it assumes a 2d mesh in (x,y) coordinate system, which can work fine by itself if the mesh is 2D however until we might get to putting something similar to measureQuadQuality in place in future, will you be able to modify this line 586 to check for +ve magnitude and direction of the two resultant cross products for a general coordinate system without this assumption?

@como2099
Copy link
Contributor Author

Updated the quad validity check to be fully orientation-independent:

  • Replaced the z-component area test with a cross/dot product check for general 3D
  • Added a small relative tolerance to handle near-degenerate triangles and floating-point noise

This ensures consistent orientation without assuming a specific coordinate system.

ma/maQuality.cc Outdated
Vector d2 = apf::cross(p[2] - p[0], p[3] - p[0]);

// If both triangles have positive area in same direction, quad is OK
return (d1[2] > 0 && d2[2] > 0) || (d1[2] < 0 && d2[2] < 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

check for +ve magnitude and direction

@cwsmith
Copy link
Contributor

cwsmith commented Dec 16, 2025

/runtests

@github-actions
Copy link

Build Log
Simmetrix Test Result: success
Simmetrix + CGNS Test Result: success

@joshia5 joshia5 merged commit e04ea58 into SCOREC:develop Dec 16, 2025
21 checks passed
@como2099 como2099 deleted the cwm/adapt_mixed_2d_fix_develop branch December 18, 2025 21:36
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.

Adapt crashes for mixed-element 2D meshes with frozen quad layers

4 participants