Skip to content

Commit 6c8cd1f

Browse files
authoredOct 24, 2024··
Explicitly import Meshes.Geometry (#118)
* Explicitly import Meshes.Geometry * Update type params * Update type params * Update type params * Update type params and move _units function
1 parent 93a9b1d commit 6c8cd1f

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed
 

‎src/MeshIntegrals.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module MeshIntegrals
22
using CliffordNumbers: CliffordNumbers, VGA,
33
using CoordRefSystems: CoordRefSystems, CRS
4+
using Meshes: Meshes, Geometry
45

56
import FastGaussQuadrature
67
import HCubature
78
import LinearAlgebra
8-
import Meshes
99
import QuadGK
1010
import Unitful
1111

‎src/differentiation.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ finite-difference approximation with step size `ε`.
1414
- `ε`: step size to use for the finite-difference approximation
1515
"""
1616
function jacobian(
17-
geometry::G,
17+
geometry::Geometry,
1818
ts::V;
1919
ε = 1e-6
20-
) where {G <: Meshes.Geometry, V <: Union{AbstractVector, Tuple}}
20+
) where {V <: Union{AbstractVector, Tuple}}
2121
Dim = Meshes.paramdim(geometry)
2222
if Dim != length(ts)
2323
throw(ArgumentError("ts must have same number of dimensions as geometry."))
@@ -89,9 +89,9 @@ Calculate the differential element (length, area, volume, etc) of the parametric
8989
function for `geometry` at arguments `ts`.
9090
"""
9191
function differential(
92-
geometry::G,
92+
geometry::Geometry,
9393
ts::V
94-
) where {M, CRS, G <: Meshes.Geometry{M, CRS}, V <: Union{AbstractVector, Tuple}}
94+
) where {V <: Union{AbstractVector, Tuple}}
9595
# Calculate the Jacobian, convert Vec -> KVector
9696
J = jacobian(geometry, ts)
9797
J_kvecs = Iterators.map(_kvector, J)

‎src/integral.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function integral end
2323

2424
# If only f and geometry are specified, select default rule
2525
function integral(
26-
f::F,
27-
geometry::G,
26+
f::Function,
27+
geometry::Geometry,
2828
rule::I = Meshes.paramdim(geometry) == 1 ? GaussKronrod() : HAdaptiveCubature();
2929
kwargs...
30-
) where {F <: Function, G <: Meshes.Geometry, I <: IntegrationRule}
30+
) where {I <: IntegrationRule}
3131
_integral(f, geometry, rule; kwargs...)
3232
end
3333

‎src/integral_aliases.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Rule types available:
1515
- HAdaptiveCubature
1616
"""
1717
function lineintegral(
18-
f::F,
19-
geometry::G,
20-
rule::I = GaussKronrod();
18+
f::Function,
19+
geometry::Geometry,
20+
rule::IntegrationRule = GaussKronrod();
2121
kwargs...
22-
) where {F <: Function, G <: Meshes.Geometry, I <: IntegrationRule}
22+
)
2323
N = Meshes.paramdim(geometry)
2424

2525
if N == 1
@@ -47,11 +47,11 @@ Algorithm types available:
4747
- HAdaptiveCubature (default)
4848
"""
4949
function surfaceintegral(
50-
f::F,
51-
geometry::G,
52-
rule::I = HAdaptiveCubature();
50+
f::Function,
51+
geometry::Geometry,
52+
rule::IntegrationRule = HAdaptiveCubature();
5353
kwargs...
54-
) where {F <: Function, G <: Meshes.Geometry, I <: IntegrationRule}
54+
)
5555
N = Meshes.paramdim(geometry)
5656

5757
if N == 2
@@ -79,11 +79,11 @@ Algorithm types available:
7979
- HAdaptiveCubature (default)
8080
"""
8181
function volumeintegral(
82-
f::F,
83-
geometry::G,
84-
rule::I = HAdaptiveCubature();
82+
f::Function,
83+
geometry::Geometry,
84+
rule::IntegrationRule = HAdaptiveCubature();
8585
kwargs...
86-
) where {F <: Function, G <: Meshes.Geometry, I <: IntegrationRule}
86+
)
8787
N = Meshes.paramdim(geometry)
8888

8989
if N == 3

‎src/utils.jl

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@ function _gausslegendre(T, n)
88
return T.(xs), T.(ws)
99
end
1010

11-
# Extract the length units used by the CRS of a Geometry
12-
function _units(g::Meshes.Geometry{M, CRS}) where {M, CRS}
13-
return Unitful.unit(CoordRefSystems.lentype(CRS))
14-
end
15-
1611
# Common error message structure
1712
function _error_unsupported_combination(geometry, rule)
1813
msg = "Integrating a $geometry using a $rule rule not supported."
1914
throw(ArgumentError(msg))
2015
end
2116

2217
################################################################################
23-
# CliffordNumbers Interface
18+
# CliffordNumbers and Units
2419
################################################################################
2520

2621
# Meshes.Vec -> ::CliffordNumber.KVector
2722
function _kvector(v::Meshes.Vec{Dim, T}) where {Dim, T}
2823
ucoords = Iterators.map(Unitful.ustrip, v.coords)
2924
return CliffordNumbers.KVector{1, VGA(Dim)}(ucoords...)
3025
end
26+
27+
# Extract the length units used by the CRS of a Geometry
28+
_units(::Geometry{M, CRS}) where {M, CRS} = Unitful.unit(CoordRefSystems.lentype(CRS))

0 commit comments

Comments
 (0)
Please sign in to comment.