Skip to content

warp_and_refine_until_resolved: support tensor product elements#494

Merged
inducer merged 2 commits intomainfrom
copilot/support-tensor-product-elements
Mar 19, 2026
Merged

warp_and_refine_until_resolved: support tensor product elements#494
inducer merged 2 commits intomainfrom
copilot/support-tensor-product-elements

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

TODO:

  • Revert repoint in req.txt

warp_and_refine_until_resolved previously raised TypeError for any non-simplex element group. This extends support to TensorProductElementGroup (quads/hexes).

Changes

  • meshmode/mesh/generation.py

    • Drop hard SimplexElementGroup-only guard; accept TensorProductElementGroup as well
    • Inline the interpolation error estimator matrix construction (previously delegated to simplex_interp_error_coefficient_estimator_matrix), selecting high-order modes via:
      • sum(mode_id) for simplex elements (total polynomial degree)
      • max(mode_id) for tensor product elements (max per-direction degree, matching Q^k space structure)
    • Eliminates a redundant vdm_inv computation that existed in the original code
  • test/test_mesh.py

    • Add test_warp_and_refine_until_resolved_tensor_product: creates a 2D quad mesh, applies a sinusoidal warp, and verifies the function converges and refines elements
mesh = generate_regular_rect_mesh(
    a=(0, 0), b=(1, 1), nelements_per_axis=(3, 3),
    group_cls=TensorProductElementGroup, order=4)

result = warp_and_refine_until_resolved(mesh, warp_mesh, 1e-3)
# Previously raised: TypeError: Unsupported element group type: 'TensorProductElementGroup'
Original prompt

This section details on the original issue you should resolve

<issue_title>warp_and_refine_until_resolved: support tensor product elements</issue_title>
<issue_description>cc @ShawnL00</issue_description>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Add support for tensor product elements in warp_and_refine_until_resolved warp_and_refine_until_resolved: support tensor product elements Mar 19, 2026
Copilot AI requested a review from inducer March 19, 2026 16:10
Copilot AI and others added 2 commits March 19, 2026 12:57
@inducer inducer force-pushed the copilot/support-tensor-product-elements branch from c2cbdb7 to 2eb4ef2 Compare March 19, 2026 17:59
@inducer inducer mentioned this pull request Mar 19, 2026
1 task
@inducer inducer force-pushed the copilot/support-tensor-product-elements branch from 2eb4ef2 to 7dad429 Compare March 19, 2026 20:13
@inducer inducer marked this pull request as ready for review March 19, 2026 20:13
Copilot AI review requested due to automatic review settings March 19, 2026 20:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extends warp_and_refine_until_resolved to work on Modepy-based non-simplex element groups (notably TensorProductElementGroup for quads/hexes) and adds a regression test to cover the new capability.

Changes:

  • Generalize warp_and_refine_until_resolved from simplex-only to ModepyElementGroup and switch to a generic Modepy interpolation error estimator matrix.
  • Add a new test exercising warp_and_refine_until_resolved on a warped quad mesh.
  • Minor typing cleanup in tensor-product quadrature node reshaping.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
meshmode/mesh/generation.py Removes simplex-only restriction and uses Modepy’s generic interpolation error estimator for refinement decisions.
test/test_mesh.py Adds a tensor-product (quad) regression test for warp_and_refine_until_resolved.
meshmode/discretization/poly_element.py Simplifies node reshaping code by removing an unnecessary cast.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@inducer inducer enabled auto-merge (rebase) March 19, 2026 20:43
@inducer inducer merged commit f56efe5 into main Mar 19, 2026
16 checks passed
@inducer inducer deleted the copilot/support-tensor-product-elements branch March 19, 2026 20:49
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.

warp_and_refine_until_resolved: support tensor product elements

3 participants