Skip to content

Commit 9d00e24

Browse files
Use Symmetric Covariant Axis2Tensor
1 parent 13c6176 commit 9d00e24

File tree

10 files changed

+442
-19
lines changed

10 files changed

+442
-19
lines changed

.buildkite/pipeline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ steps:
180180
key: unit_rmul_with_projection
181181
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/Geometry/rmul_with_projection.jl"
182182

183+
- label: "Unit: simple_symmetric"
184+
key: unit_simple_symmetric
185+
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/Geometry/unit_simple_symmetric.jl"
186+
183187
- group: "Unit: Meshes"
184188
steps:
185189

src/Geometry/Geometry.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export Contravariant1Vector,
2222
Contravariant23Vector,
2323
Contravariant123Vector
2424

25-
26-
25+
include("simple_symmetric.jl")
2726
include("coordinates.jl")
2827
include("axistensors.jl")
2928
include("localgeometry.jl")

src/Geometry/axistensors.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct AxisTensor{
136136
T,
137137
N,
138138
A <: NTuple{N, AbstractAxis},
139-
S <: StaticArray{<:Tuple, T, N},
139+
S <: Union{SimpleSymmetric{N, T}, StaticArray{<:Tuple, T, N}},
140140
} <: AbstractArray{T, N}
141141
axes::A
142142
components::S
@@ -147,7 +147,7 @@ AxisTensor(
147147
components::S,
148148
) where {
149149
A <: Tuple{Vararg{AbstractAxis}},
150-
S <: StaticArray{<:Tuple, T, N},
150+
S <: Union{SimpleSymmetric{N, T}, StaticArray{<:Tuple, T, N}},
151151
} where {T, N} = AxisTensor{T, N, A, S}(axes, components)
152152

153153
AxisTensor(axes::Tuple{Vararg{AbstractAxis}}, components) =
@@ -396,8 +396,16 @@ end
396396
function Base.:*(x::AxisVector, y::AdjointAxisVector)
397397
AxisTensor((axes(x, 1), axes(y, 2)), components(x) * components(y))
398398
end
399+
import InteractiveUtils
399400
function Base.:*(A::Axis2TensorOrAdj, x::AxisVector)
400401
check_dual(axes(A, 2), axes(x, 1))
402+
c = components(A) * components(x)
403+
# @show typeof(A)
404+
# @show typeof(x)
405+
# s = InteractiveUtils.@which components(A) * components(x)
406+
# @show s
407+
# # @show typeof(x)
408+
# @show c
401409
return AxisVector(axes(A, 1), components(A) * components(x))
402410
end
403411
function Base.:*(A::Axis2TensorOrAdj, B::Axis2TensorOrAdj)

src/Geometry/localgeometry.jl

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
import LinearAlgebra
2+
import .Geometry: SimpleSymmetric
3+
4+
import InteractiveUtils
15
import LinearAlgebra: issymmetric
26

37
isapproxsymmetric(A::AbstractMatrix{T}; rtol = 10 * eps(T)) where {T} =
48
Base.isapprox(A, A'; rtol)
59

10+
function SimpleSymmetric(x::AxisTensor{FT}) where {FT}
11+
c = SimpleSymmetric(components(x))
12+
A = axes(x)
13+
return AxisTensor{FT, ndims(x), typeof(A), typeof(c)}(A, c)
14+
end
15+
616
"""
717
LocalGeometry
818
919
The necessary local metric information defined at each node.
1020
"""
11-
struct LocalGeometry{I, C <: AbstractPoint, FT, S}
21+
struct LocalGeometry{I, C <: AbstractPoint, FT, S, N, L}
1222
"Coordinates of the current point"
1323
coordinates::C
1424
"Jacobian determinant of the transformation `ξ` to `x`"
@@ -22,9 +32,17 @@ struct LocalGeometry{I, C <: AbstractPoint, FT, S}
2232
"Partial derivatives of the map from `x` to `ξ`: `∂ξ∂x[i,j]` is ∂ξⁱ/∂xʲ"
2333
∂ξ∂x::Axis2Tensor{FT, Tuple{ContravariantAxis{I}, LocalAxis{I}}, S}
2434
"Contravariant metric tensor (inverse of gᵢⱼ), transforms covariant to contravariant vector components"
25-
gⁱʲ::Axis2Tensor{FT, Tuple{ContravariantAxis{I}, ContravariantAxis{I}}, S}
35+
gⁱʲ::Axis2Tensor{
36+
FT,
37+
Tuple{ContravariantAxis{I}, ContravariantAxis{I}},
38+
SimpleSymmetric{N, FT, L},
39+
}
2640
"Covariant metric tensor (gᵢⱼ), transforms contravariant to covariant vector components"
27-
gᵢⱼ::Axis2Tensor{FT, Tuple{CovariantAxis{I}, CovariantAxis{I}}, S}
41+
gᵢⱼ::Axis2Tensor{
42+
FT,
43+
Tuple{CovariantAxis{I}, CovariantAxis{I}},
44+
SimpleSymmetric{N, FT, L},
45+
}
2846
@inline function LocalGeometry(
2947
coordinates,
3048
J,
@@ -34,15 +52,27 @@ struct LocalGeometry{I, C <: AbstractPoint, FT, S}
3452
∂ξ∂x = inv(∂x∂ξ)
3553
C = typeof(coordinates)
3654
Jinv = inv(J)
37-
gⁱʲ = ∂ξ∂x * ∂ξ∂x'
38-
gᵢⱼ = ∂x∂ξ' * ∂x∂ξ
39-
isapproxsymmetric(components(gⁱʲ)) || error("gⁱʲ is not symmetric.")
40-
isapproxsymmetric(components(gᵢⱼ)) || error("gᵢⱼ is not symmetric.")
41-
return new{I, C, FT, S}(coordinates, J, WJ, Jinv, ∂x∂ξ, ∂ξ∂x, gⁱʲ, gᵢⱼ)
55+
gⁱʲ₀ = ∂ξ∂x * ∂ξ∂x'
56+
gᵢⱼ₀ = ∂x∂ξ' * ∂x∂ξ
57+
isapproxsymmetric(components(gⁱʲ₀)) || error("gⁱʲ is not symmetric.")
58+
isapproxsymmetric(components(gᵢⱼ₀)) || error("gᵢⱼ is not symmetric.")
59+
gⁱʲ = SimpleSymmetric(gⁱʲ₀)
60+
gᵢⱼ = SimpleSymmetric(gᵢⱼ₀)
61+
L = triangular_nonzeros(S)
62+
N = size(components(gⁱʲ₀), 1)
63+
return new{I, C, FT, S, N, L}(
64+
coordinates,
65+
J,
66+
WJ,
67+
Jinv,
68+
∂x∂ξ,
69+
∂ξ∂x,
70+
gⁱʲ,
71+
gᵢⱼ,
72+
)
4273
end
4374
end
4475

45-
4676
"""
4777
SurfaceGeometry
4878
@@ -55,7 +85,7 @@ struct SurfaceGeometry{FT, N}
5585
normal::N
5686
end
5787

58-
undertype(::Type{LocalGeometry{I, C, FT, S}}) where {I, C, FT, S} = FT
88+
undertype(::Type{<:LocalGeometry{I, C, FT}}) where {I, C, FT} = FT
5989
undertype(::Type{SurfaceGeometry{FT, N}}) where {FT, N} = FT
6090

6191
"""

0 commit comments

Comments
 (0)