Skip to content

Commit 6fa5586

Browse files
wip
1 parent 2f7b697 commit 6fa5586

File tree

4 files changed

+347
-101
lines changed

4 files changed

+347
-101
lines changed

src/Geometry/Geometry.jl

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

25-
import LinearAlgebra
26-
"""
27-
SimpleSymmetric
28-
29-
A simple Symmetric matrix. `LinearAlgebra.Symmetric` has a field
30-
`uplo::Char`, which results in a failed `check_basetype(T, S)`.
31-
"""
32-
struct SimpleSymmetric{T, S <: AbstractMatrix{<:T}} <: AbstractMatrix{T}
33-
data::S
34-
function SimpleSymmetric{T, S}(data) where {T, S <: AbstractMatrix{<:T}}
35-
new{T, S}(data)
36-
end
37-
end
38-
SimpleSymmetric(A) = cc_symmetric_type(typeof(A))(A)
39-
LinearAlgebra.transpose(A::SimpleSymmetric) = A
40-
Base.similar(::Type{SimpleSymmetric{T, S}}, ax) where {T, S} = SimpleSymmetric{T}(similar(S))
41-
42-
Base.size(A::SimpleSymmetric) = Base.size(A.data)
43-
Base.eltype(::SimpleSymmetric{T}) where {T} = T
44-
# Base.iterate(iter, state)
45-
Base.ndims(::SimpleSymmetric{T, S}) where {T, S} = Base.ndims(S)
46-
# Base.:*(A::SimpleSymmetric, B::SimpleSymmetric) = A * copyto!(similar(parent(B)), B)
47-
48-
# Base.:*(A::SimpleSymmetric, x::Number) = SimpleSymmetric(A.data*x)
49-
# Base.:*(x::Number, A::SimpleSymmetric) = SimpleSymmetric(x*A.data)
50-
# Base.:*(A::SimpleSymmetric, B::AbstractMatrix) = A.data * B
51-
# Base.:*(A::AbstractMatrix, B::SimpleSymmetric) = A * B.data
52-
# Base.:/(A::SimpleSymmetric, x::Number) = SimpleSymmetric(A.data / x)
53-
# Base.:/(A::SimpleSymmetric, B::AbstractMatrix) = A.data * B
54-
# Base.:/(A::AbstractMatrix, B::SimpleSymmetric) = A * B.data
55-
56-
"""
57-
cc_symmetric_type(T::Type)
58-
59-
The type of the object returned by `symmetric(::T, ::Symbol)`. For matrices, this is an
60-
appropriately typed `Symmetric`, for `Number`s, it is the original type. If `symmetric` is
61-
implemented for a custom type, so should be `cc_symmetric_type`, and vice versa.
62-
"""
63-
cc_symmetric_type(::Type{T}) where {S, T <: AbstractMatrix{S}} =
64-
SimpleSymmetric{
65-
Union{S, Base.promote_op(transpose, S), cc_symmetric_type(S)},
66-
T,
67-
}
68-
cc_symmetric_type(::Type{T}) where {S <: Number, T <: AbstractMatrix{S}} =
69-
SimpleSymmetric{S, T}
70-
cc_symmetric_type(
71-
::Type{T},
72-
) where {S <: AbstractMatrix, T <: AbstractMatrix{S}} =
73-
SimpleSymmetric{AbstractMatrix, T}
74-
cc_symmetric_type(::Type{T}) where {T <: Number} = T
75-
76-
Base.@propagate_inbounds function Base.getindex(
77-
A::SimpleSymmetric,
78-
i::Integer,
79-
j::Integer,
80-
)
81-
@boundscheck checkbounds(A, i, j)
82-
@inbounds if i == j
83-
data_ij = A.data[i, j]
84-
if data_ij isa AbstractMatrix
85-
return SimpleSymmetric(data_ij)::cc_symmetric_type(eltype(A.data))
86-
elseif data_ij isa Number
87-
return data_ij::cc_symmetric_type(eltype(A.data))
88-
end
89-
elseif (i < j)
90-
return A.data[i, j]
91-
else
92-
return LinearAlgebra.transpose(A.data[j, i])
93-
end
94-
end
95-
96-
Base.@propagate_inbounds Base.getindex(A::SimpleSymmetric, i::Integer) =
97-
A.data[i]
98-
99-
25+
include("simple_symmetric.jl")
10026
include("coordinates.jl")
10127
include("axistensors.jl")
10228
include("localgeometry.jl")

src/Geometry/localgeometry.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end
1818
1919
The necessary local metric information defined at each node.
2020
"""
21-
struct LocalGeometry{I, C <: AbstractPoint, FT, S}
21+
struct LocalGeometry{I, C <: AbstractPoint, FT, S, L}
2222
"Coordinates of the current point"
2323
coordinates::C
2424
"Jacobian determinant of the transformation `ξ` to `x`"
@@ -32,12 +32,18 @@ struct LocalGeometry{I, C <: AbstractPoint, FT, S}
3232
"Partial derivatives of the map from `x` to `ξ`: `∂ξ∂x[i,j]` is ∂ξⁱ/∂xʲ"
3333
∂ξ∂x::Axis2Tensor{FT, Tuple{ContravariantAxis{I}, LocalAxis{I}}, S}
3434
"Contravariant metric tensor (inverse of gᵢⱼ), transforms covariant to contravariant vector components"
35-
gⁱʲ::Axis2Tensor{FT, Tuple{ContravariantAxis{I}, ContravariantAxis{I}}, SimpleSymmetric{FT, S}}
35+
gⁱʲ::Axis2Tensor{
36+
FT,
37+
Tuple{ContravariantAxis{I}, ContravariantAxis{I}},
38+
# SimpleSymmetric{FT, S},
39+
SimpleSymmetric{2, FT, L},
40+
}
3641
"Covariant metric tensor (gᵢⱼ), transforms contravariant to covariant vector components"
3742
gᵢⱼ::Axis2Tensor{
3843
FT,
3944
Tuple{CovariantAxis{I}, CovariantAxis{I}},
40-
SimpleSymmetric{FT, S},
45+
# SimpleSymmetric{FT, S},
46+
SimpleSymmetric{2, FT, L},
4147
}
4248
@inline function LocalGeometry(
4349
coordinates,
@@ -54,7 +60,8 @@ struct LocalGeometry{I, C <: AbstractPoint, FT, S}
5460
isapproxsymmetric(components(gᵢⱼ₀)) || error("gᵢⱼ is not symmetric.")
5561
gⁱʲ = SimpleSymmetric(gⁱʲ₀)
5662
gᵢⱼ = SimpleSymmetric(gᵢⱼ₀)
57-
return new{I, C, FT, S}(coordinates, J, WJ, Jinv, ∂x∂ξ, ∂ξ∂x, gⁱʲ, gᵢⱼ)
63+
L = triangular_nonzeros(S)
64+
return new{I, C, FT, S, L}(coordinates, J, WJ, Jinv, ∂x∂ξ, ∂ξ∂x, gⁱʲ, gᵢⱼ)
5865
end
5966
end
6067

0 commit comments

Comments
 (0)