Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jcs15c
Copy link
Contributor

@jcs15c jcs15c commented Sep 29, 2025

This PR will be merged after #1683.

Summary

In order that the SamplingShaper in quest is compatible with recent GWN accelerations via memoization, the primal::CurvedPolygon<T, NDIMS> class is enhanced so that it is templated directly on curve type, i.e. primal::CurvedPolygon<CurveType>. Currently supported curve types are BezierCurve, NURBSCurve, and the new NURBSCurveGWNCache. Because CurvedPolygon is used in many of primal's operators, this requires many updates:

  • All 2D GWN algorithms (and by association methods in in_curved_polygon have been made compatible with all curve types.
  • All 2D integral evaluation methods are compatible with all curve types.
  • Methods in compute_moments.hpp are currently only compatible with CurvedPolygon<BezierCurve<T, 2>>, since the methods within expect Bezier curves, and would require a non-trivial extension to work on NURBSCurve objects via Bezier extraction.

The tests for these methods are updated in their respective suites to ensure compatibility with the new template.

On the quest side of things, this PR makes the following changes related to SamplingShaper

  • Updates MFEMReader so that the default input for an MFEM mesh is a CurvedPolygon<NURBS> instead of Bezier.
  • Updates WindingNumberSamper.hpp so that the sampler stores an array of "cached contours," i.e. CurvedPolygon<NURBSCurveGWNCache> instead of a view of CurvedPolygon<BezierCurve>s.

Performance Improvements

These changes reduce the time to complete the test quest_shaping_driver_ex_heroic_roses_mfem_cp from 85.93 seconds on a debug build of develop to 56.68 seconds (or from 12.67s to 6.91s on a release build) on the current branch. Accounting for the time to process the curves and construct/access the BVH (~31.31s debug/~4.47s release) this is about a 2x improvement.

@jcs15c jcs15c changed the title Enhance primal::CurvedPolygon so WN memoization works with sampling shaper Enhance CurvedPolygon so WN memoization works with sampling shaper Sep 29, 2025
@jcs15c jcs15c self-assigned this Sep 29, 2025
@jcs15c jcs15c added enhancement New feature or request Primal Issues related to Axom's 'primal component labels Sep 29, 2025
Base automatically changed from feature/spainhour/winding_number_memoization to develop October 1, 2025 16:14
Copy link
Member

@kennyweiss kennyweiss left a comment

Choose a reason for hiding this comment

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

Looks reasonable so far.

Lingering questions for this PR include:

  • Many operations on a CurvedPolygon are forbidden at compile time (e.g. split and reverseOrientation) to ensure that the GWN cache is not made invalid. Is this the right approach? Or should the methods be allowed after the cache is cleared, and a warning message displayed to inform the user that this has happened?

    • Seems reasonable to start by disallowing these operations (as long as this is documented) since invalidating the cache can have severe performance costs. If we need to allow this in the future, we can add support for it.
  • Some template boilerplate is required in CurvedPolygon.hpp to deduce the numeric type from the curve type. Is this implemented in the right way? Should those template methods be in a detail file?

    • I'd leave it as is since it's reasonably self contained. Perhaps move it inside an anonymous namespace or a detail namespace (within the same file)?

@jcs15c jcs15c changed the base branch from develop to feature/spainhour/mfemless_gauss_legendre October 6, 2025 20:19
@jcs15c jcs15c marked this pull request as ready for review October 13, 2025 16:58
Copy link
Member

@kennyweiss kennyweiss left a comment

Choose a reason for hiding this comment

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

Thanks @jcs15c -- really nice improvement!

template <typename Lambda, typename T, int NDIMS>
double evaluate_vector_line_integral(const axom::Array<primal::NURBSCurve<T, NDIMS>>& narray,
template <typename Lambda, typename CurveType>
double evaluate_vector_line_integral(const axom::Array<CurveType>& carray,
Copy link
Member

Choose a reason for hiding this comment

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

Possible generalization for the future -- perhaps the exposed API should use axom::ArrayView instead of axom::Array ?

@kennyweiss
Copy link
Member

Performance Improvements

These changes reduce the time to complete the test quest_shaping_driver_ex_heroic_roses_mfem_cp from 85.93 seconds on a debug build of develop to 56.68 seconds on the current branch. Accounting for the time to process the curves and construct/access the BVH (~31.31s) this is about a 2x improvement.

Thanks for adding the performance improvement. Could you please also adding the performance change for a Release config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Primal Issues related to Axom's 'primal component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants