Skip to content

Commit

Permalink
Take advantage of new Quantity-KVector support (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold authored Nov 8, 2024
1 parent 49aaf57 commit a10ed11
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
CliffordNumbers = "0.1.4"
CliffordNumbers = "0.1.9"
CoordRefSystems = "0.12, 0.13, 0.14, 0.15"
FastGaussQuadrature = "1"
HCubature = "1.5"
Expand Down
13 changes: 2 additions & 11 deletions src/differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ function differential(
ts::Union{AbstractVector{T}, Tuple{T, Vararg{T}}},
diff_method::DifferentiationMethod = _default_method(G)
) where {G <: Geometry, T <: AbstractFloat}
# Calculate the Jacobian, convert Vec -> KVector
J = jacobian(geometry, ts, diff_method)
J_kvecs = Iterators.map(_kvector, J)

# Extract units from Geometry type
Dim = Meshes.paramdim(geometry)
units = _units(geometry)^Dim

# Return norm of the exterior products
element = foldl(, J_kvecs)
return LinearAlgebra.norm(element) * units
J = Iterators.map(_KVector, jacobian(geometry, ts, diff_method))
return LinearAlgebra.norm(foldl(, J))
end
7 changes: 4 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ _default_method(g::G) where {G <: Geometry} = _default_method(G)
# CliffordNumbers and Units
################################################################################

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

# Extract the length units used by the CRS of a Geometry
_units(::Geometry{M, CRS}) where {M, CRS} = Unitful.unit(CoordRefSystems.lentype(CRS))
_units(::Meshes.Vec{Dim, T}) where {Dim, T} = Unitful.unit(T)
4 changes: 2 additions & 2 deletions test/utils.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@testitem "Utilities" setup=[Setup] begin
using LinearAlgebra: norm

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

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

0 comments on commit a10ed11

Please sign in to comment.