Skip to content
Closed
Show file tree
Hide file tree
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 Feb 27, 2026
fcb384f
Add tests from MeshIntegrals.jl
juliohm Mar 2, 2026
f1dd042
Increase default order to 100
juliohm Mar 2, 2026
9bd228c
Rename order --> n
juliohm Mar 2, 2026
55c1649
Propagate number type
juliohm Mar 2, 2026
98bdd41
Change default to n=3
juliohm Mar 2, 2026
8f3c1cf
Update tests
juliohm Mar 3, 2026
fcb05d3
Fix formatting issues
juliohm Mar 3, 2026
ecbcf48
Add integration method for ConeSurface
juliohm Mar 5, 2026
e5795f0
Add more special cases
juliohm Mar 5, 2026
da77b44
Add method for Domain
juliohm Mar 5, 2026
c5dd5ed
Fix typo
juliohm Mar 5, 2026
623861b
Remove method for Point
juliohm Mar 5, 2026
d5754f8
Add more tests
juliohm Mar 5, 2026
9252b6e
Fix Cylinder/CylinderSurface bottom and top
juliohm Mar 5, 2026
f9fd569
Minor refactor
juliohm Mar 5, 2026
a6d59f1
Refactor tests
juliohm Mar 5, 2026
00c6e9e
Add methods for geometries with infinite measure
juliohm Mar 6, 2026
4a612cf
Minor refactor
juliohm Mar 6, 2026
55fe6d9
Add TODO in test/integration.jl
juliohm Mar 6, 2026
07c68ae
Add more TODO tests
juliohm Mar 6, 2026
98e17fe
Add more implementations
juliohm Mar 6, 2026
0b09024
Fix formatting issues
juliohm Mar 6, 2026
29e4507
Fix composition in ray method
juliohm Mar 6, 2026
e903f57
fix CylinderSurface test
JoshuaLampert Mar 7, 2026
8e08a41
Apply suggestions from code review
JoshuaLampert Mar 7, 2026
433bf24
Remove localintegral methods
juliohm Mar 8, 2026
f014999
Add tests for infinite geometries
juliohm Mar 8, 2026
36c42d5
Remove 0 <= t <= 1 check from Chain
juliohm Mar 8, 2026
f46c538
Add more tests
juliohm Mar 8, 2026
5692ebd
Refactor change of variable
juliohm Mar 9, 2026
b52f395
Fix parametrization of Chain
juliohm Mar 9, 2026
7bd93a7
Fix tests for Rope and Ring
juliohm Mar 9, 2026
ffb13cc
Minor refactor
juliohm Mar 9, 2026
2a0089a
Relax rtol in Ring test
juliohm Mar 9, 2026
b56976e
Fix formatting issues
juliohm Mar 9, 2026
408c516
Add more tests
juliohm Mar 9, 2026
0b982e4
Fix formatting issues
juliohm Mar 9, 2026
5685d5e
Refactor trans kwarg for multivariate case
juliohm Mar 9, 2026
c6f2fa1
Add methods for simplices
juliohm Mar 9, 2026
32de14c
Add more tests
juliohm Mar 9, 2026
9daa5dd
Add method for Multi
juliohm Mar 9, 2026
947f967
Fix formatting issues
juliohm Mar 9, 2026
dd4082d
Add more tests
juliohm Mar 9, 2026
bcf0275
Incorporate suggestions
juliohm Mar 9, 2026
d316707
Add comments
juliohm Mar 17, 2026
afff1a5
Rely on IntegrationInterface.jl
juliohm Mar 17, 2026
f0acc81
Refactor in terms of backends
juliohm Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CoordRefSystems = "b46f11dc-f210-4604-bfba-323c1ec968cb"
DelaunayTriangulation = "927a84f5-c5f4-47a5-9785-b46e178433df"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Expand Down Expand Up @@ -38,6 +39,7 @@ CoordRefSystems = "0.19"
DelaunayTriangulation = "1.0"
DifferentiationInterface = "0.7"
Distances = "0.10"
FastGaussQuadrature = "1.1"
FiniteDifferences = "0.12"
LinearAlgebra = "1.10"
Makie = "0.24"
Expand Down
6 changes: 6 additions & 0 deletions src/Meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import NearestNeighbors: MinkowskiMetric
import DifferentiationInterface as DI
import FiniteDifferences: central_fdm

# Integration API
import FastGaussQuadrature: gausslegendre

# Transforms API
import TransformsBase: Transform, →
import TransformsBase: isrevertible, isinvertible
Expand Down Expand Up @@ -104,6 +107,7 @@ include("predicates.jl")

# calculus
include("differentation.jl")
include("integration.jl")

# operations
include("centroid.jl")
Expand Down Expand Up @@ -458,6 +462,8 @@ export
derivative,
jacobian,
differential,
integral,
localintegral,

# centroids
centroid,
Expand Down
45 changes: 45 additions & 0 deletions src/integration.jl
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)

"""
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)
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
5 changes: 5 additions & 0 deletions test/integration.jl
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
Loading