-
Notifications
You must be signed in to change notification settings - Fork 94
Add integral and localintegral #1327
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
d2e040a
Add integral and localintegral
juliohm fcb384f
Add tests from MeshIntegrals.jl
juliohm f1dd042
Increase default order to 100
juliohm 9bd228c
Rename order --> n
juliohm 55c1649
Propagate number type
juliohm 98bdd41
Change default to n=3
juliohm 8f3c1cf
Update tests
juliohm fcb05d3
Fix formatting issues
juliohm ecbcf48
Add integration method for ConeSurface
juliohm e5795f0
Add more special cases
juliohm da77b44
Add method for Domain
juliohm c5dd5ed
Fix typo
juliohm 623861b
Remove method for Point
juliohm d5754f8
Add more tests
juliohm 9252b6e
Fix Cylinder/CylinderSurface bottom and top
juliohm f9fd569
Minor refactor
juliohm a6d59f1
Refactor tests
juliohm 00c6e9e
Add methods for geometries with infinite measure
juliohm 4a612cf
Minor refactor
juliohm 55fe6d9
Add TODO in test/integration.jl
juliohm 07c68ae
Add more TODO tests
juliohm 98e17fe
Add more implementations
juliohm 0b09024
Fix formatting issues
juliohm 29e4507
Fix composition in ray method
juliohm e903f57
fix CylinderSurface test
JoshuaLampert 8e08a41
Apply suggestions from code review
JoshuaLampert 433bf24
Remove localintegral methods
juliohm f014999
Add tests for infinite geometries
juliohm 36c42d5
Remove 0 <= t <= 1 check from Chain
juliohm f46c538
Add more tests
juliohm 5692ebd
Refactor change of variable
juliohm b52f395
Fix parametrization of Chain
juliohm 7bd93a7
Fix tests for Rope and Ring
juliohm ffb13cc
Minor refactor
juliohm 2a0089a
Relax rtol in Ring test
juliohm b56976e
Fix formatting issues
juliohm 408c516
Add more tests
juliohm 0b982e4
Fix formatting issues
juliohm 5685d5e
Refactor trans kwarg for multivariate case
juliohm c6f2fa1
Add methods for simplices
juliohm 32de14c
Add more tests
juliohm 9daa5dd
Add method for Multi
juliohm 947f967
Fix formatting issues
juliohm dd4082d
Add more tests
juliohm bcf0275
Incorporate suggestions
juliohm d316707
Add comments
juliohm afff1a5
Rely on IntegrationInterface.jl
juliohm f0acc81
Refactor in terms of backends
juliohm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # ------------------------------------------------------------------ | ||
| # Licensed under the MIT License. See LICENSE in the project root. | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| """ | ||
| integral(fun, geom; order=1) | ||
|
|
||
| Calculate the integral over the `geom`etry of the `fun`ction that maps | ||
| [`Point`](@ref)s to values in a linear space. | ||
|
|
||
| The quadrature `order` can be specified to increase the accuracy. | ||
|
|
||
| See also [`localintegral`](@ref). | ||
| """ | ||
| integral(fun, geom; order=1) = localintegral(fun ∘ geom, geom; order) | ||
juliohm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| """ | ||
| localintegral(fun, geom; order=1) | ||
|
|
||
| Calculate the integral over the `geom`etry of the `fun`ction that maps | ||
| parametric coordinates `uvw` to values in a linear space. | ||
|
|
||
| The quadrature `order` can be specified to increase the accuracy. | ||
|
|
||
| See also [`integral`](@ref). | ||
| """ | ||
| function localintegral(fun, geom; order=1) | ||
| # parametric dimension | ||
| dim = paramdim(geom) | ||
|
|
||
| # Gauss-Legendre quadrature points and weights | ||
| ts, ws = gausslegendre(order) | ||
juliohm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tgrid = Iterators.product(ntuple(_ -> ts, dim)...) | ||
| wgrid = Iterators.product(ntuple(_ -> ws, dim)...) | ||
|
|
||
| # compute integral with change of variable and differential element | ||
| Σwᵢfᵢ = sum(zip(tgrid, wgrid)) do (t, w) | ||
| # change of variable [-1, 1] → [0, 1] | ||
| uvw = ntuple(i -> (t[i] + 1) / 2, dim) | ||
| prod(w) * fun(uvw...) * differential(geom, uvw) | ||
| end | ||
|
|
||
| # adjust for change of variable | ||
| Σwᵢfᵢ / 2^dim | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @testitem "integral" setup = [Setup] begin | ||
| end | ||
|
|
||
| @testitem "localintegral" setup = [Setup] begin | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.