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 parametric function for Chain #1155

Merged
merged 15 commits into from
Dec 19, 2024
Merged

Add parametric function for Chain #1155

merged 15 commits into from
Dec 19, 2024

Conversation

JoshuaLampert
Copy link
Member

This adds a parametric function for Chains, such that a Ring or a Rope can be evaluated at a parameter $t\in [0,1]$. My use case is sampling at the boundary of Ngons and Boxes. I stumbled upon this by trying:

julia> box = Box((0.0, 0.0), (1.0, 1.0))
Box
├─ min: Point(x: 0.0 m, y: 0.0 m)
└─ max: Point(x: 1.0 m, y: 1.0 m)

julia> ring = boundary(box)
Ring
├─ Point(x: 0.0 m, y: 0.0 m)
├─ Point(x: 1.0 m, y: 0.0 m)
├─ Point(x: 1.0 m, y: 1.0 m)
└─ Point(x: 0.0 m, y: 1.0 m)

julia> sampler = RegularSampling(10)
RegularSampling{1}((10,))

julia> collect(sample(ring, sampler))
10-element Vector{Point{𝔼{2}, CoordRefSystems.Cartesian2D{CoordRefSystems.NoDatum, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}}}:
 Point(x: 0.0 m, y: 0.0 m)
 Point(x: 0.4 m, y: 0.0 m)
 Point(x: 0.8 m, y: 0.0 m)
 Point(x: 1.0 m, y: 0.19999999999999996 m)
 Point(x: 1.0 m, y: 0.6000000000000001 m)
 Point(x: 1.0 m, y: 1.0 m)
 Point(x: 0.6000000000000001 m, y: 1.0 m)
 Point(x: 0.20000000000000018 m, y: 1.0 m)
 Point(x: 0.0 m, y: 0.7999999999999998 m)
 Point(x: 0.0 m, y: 0.3999999999999999 m)

where the last failed before.

cc @mikeingold: We could think of using this to make the specializations for Rope and Ring in MeshIntegrals.jl obsolete.

@JoshuaLampert JoshuaLampert marked this pull request as ready for review December 18, 2024 17:15
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.79%. Comparing base (16383a9) to head (e4011bd).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/geometries/polytopes.jl 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1155   +/-   ##
=======================================
  Coverage   87.79%   87.79%           
=======================================
  Files         193      193           
  Lines        6046     6057   +11     
=======================================
+ Hits         5308     5318   +10     
- Misses        738      739    +1     

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

@mikeingold
Copy link
Contributor

cc @mikeingold: We could think of using this to make the specializations for Rope and Ring in MeshIntegrals.jl obsolete.

Without having tried this out to see how well it would work, I’d actually probably lean towards continuing to decompose these into Segments prior to integration. If we treat the entire Chain as a single parametric on a common domain, then differential will usually be discontinuous in value at those segment boundaries, and step changes in integrand values tend to be pretty catastrophic to performance when using adaptive integration rules.

(I’m actually planning to tweak these decomposing methods to make use of reusable buffers that I think will significantly reduce the performance penalty for performing multiple sub-integrals.)

@JoshuaLampert
Copy link
Member Author

Yes, I think you are right @mikeingold. But I think having a parametric function for those geometries can be helpful nevertheless like in the example I gave above.

@mikeingold
Copy link
Contributor

Agreed. I can definitely imagine other uses where having these functions would be useful.

Co-authored-by: Júlio Hoffimann <[email protected]>
test/polytopes.jl Outdated Show resolved Hide resolved
test/polytopes.jl Outdated Show resolved Hide resolved
test/polytopes.jl Outdated Show resolved Hide resolved
JoshuaLampert and others added 4 commits December 19, 2024 13:45
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

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

Thank you @JoshuaLampert. Let's just wait for the tests before merging it.

@juliohm juliohm merged commit 46ee50e into master Dec 19, 2024
15 of 16 checks passed
@juliohm juliohm deleted the parametric-function-ring branch December 19, 2024 13:07
@JoshuaLampert
Copy link
Member Author

When do you plan to release a new version @juliohm?

@juliohm
Copy link
Member

juliohm commented Dec 19, 2024 via email

@juliohm
Copy link
Member

juliohm commented Dec 19, 2024

@JoshuaLampert released a patch to avoid blocking your work: JuliaRegistries/General#121670

Other possible ValidCoords fixes will come in a future patch.

@JoshuaLampert
Copy link
Member Author

Great, thanks!

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.

3 participants