Skip to content

Commit a10ed11

Browse files
authored
Take advantage of new Quantity-KVector support (#130)
1 parent 49aaf57 commit a10ed11

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
1313
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
1414

1515
[compat]
16-
CliffordNumbers = "0.1.4"
16+
CliffordNumbers = "0.1.9"
1717
CoordRefSystems = "0.12, 0.13, 0.14, 0.15"
1818
FastGaussQuadrature = "1"
1919
HCubature = "1.5"

src/differentiation.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,6 @@ function differential(
125125
ts::Union{AbstractVector{T}, Tuple{T, Vararg{T}}},
126126
diff_method::DifferentiationMethod = _default_method(G)
127127
) where {G <: Geometry, T <: AbstractFloat}
128-
# Calculate the Jacobian, convert Vec -> KVector
129-
J = jacobian(geometry, ts, diff_method)
130-
J_kvecs = Iterators.map(_kvector, J)
131-
132-
# Extract units from Geometry type
133-
Dim = Meshes.paramdim(geometry)
134-
units = _units(geometry)^Dim
135-
136-
# Return norm of the exterior products
137-
element = foldl(, J_kvecs)
138-
return LinearAlgebra.norm(element) * units
128+
J = Iterators.map(_KVector, jacobian(geometry, ts, diff_method))
129+
return LinearAlgebra.norm(foldl(, J))
139130
end

src/utils.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ _default_method(g::G) where {G <: Geometry} = _default_method(G)
4646
# CliffordNumbers and Units
4747
################################################################################
4848

49-
# Meshes.Vec -> ::CliffordNumber.KVector
50-
function _kvector(v::Meshes.Vec{Dim, T}) where {Dim, T}
49+
# Meshes.Vec -> Unitful.Quantity{CliffordNumber.KVector}
50+
function _KVector(v::Meshes.Vec{Dim, T}) where {Dim, T}
5151
ucoords = Iterators.map(Unitful.ustrip, v.coords)
52-
return CliffordNumbers.KVector{1, VGA(Dim)}(ucoords...)
52+
return CliffordNumbers.KVector{1, VGA(Dim)}(ucoords...) * _units(v)
5353
end
5454

5555
# Extract the length units used by the CRS of a Geometry
5656
_units(::Geometry{M, CRS}) where {M, CRS} = Unitful.unit(CoordRefSystems.lentype(CRS))
57+
_units(::Meshes.Vec{Dim, T}) where {Dim, T} = Unitful.unit(T)

test/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@testitem "Utilities" setup=[Setup] begin
22
using LinearAlgebra: norm
33

4-
# _kvector
4+
# _KVector
55
v = Meshes.Vec(3, 4)
6-
@test norm(MeshIntegrals._kvector(v)) 5.0
6+
@test norm(MeshIntegrals._KVector(v)) 5.0u"m"
77

88
# _units
99
p = Point(1.0u"cm", 2.0u"mm", 3.0u"m")

0 commit comments

Comments
 (0)