1
+ import LinearAlgebra
2
+ import . Geometry: SimpleSymmetric
3
+
4
+ import InteractiveUtils
1
5
import LinearAlgebra: issymmetric
2
6
3
7
isapproxsymmetric (A:: AbstractMatrix{T} ; rtol = 10 * eps (T)) where {T} =
4
8
Base. isapprox (A, A' ; rtol)
5
9
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
+
6
16
"""
7
17
LocalGeometry
8
18
9
19
The necessary local metric information defined at each node.
10
20
"""
11
- struct LocalGeometry{I, C <: AbstractPoint , FT, S}
21
+ struct LocalGeometry{I, C <: AbstractPoint , FT, S, N, L }
12
22
" Coordinates of the current point"
13
23
coordinates:: C
14
24
" Jacobian determinant of the transformation `ξ` to `x`"
@@ -22,9 +32,17 @@ struct LocalGeometry{I, C <: AbstractPoint, FT, S}
22
32
" Partial derivatives of the map from `x` to `ξ`: `∂ξ∂x[i,j]` is ∂ξⁱ/∂xʲ"
23
33
∂ξ∂x:: Axis2Tensor{FT, Tuple{ContravariantAxis{I}, LocalAxis{I}}, S}
24
34
" 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
+ }
26
40
" 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
+ }
28
46
@inline function LocalGeometry (
29
47
coordinates,
30
48
J,
@@ -34,15 +52,27 @@ struct LocalGeometry{I, C <: AbstractPoint, FT, S}
34
52
∂ξ∂x = inv (∂x∂ξ)
35
53
C = typeof (coordinates)
36
54
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
+ )
42
73
end
43
74
end
44
75
45
-
46
76
"""
47
77
SurfaceGeometry
48
78
@@ -55,7 +85,7 @@ struct SurfaceGeometry{FT, N}
55
85
normal:: N
56
86
end
57
87
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
59
89
undertype (:: Type{SurfaceGeometry{FT, N}} ) where {FT, N} = FT
60
90
61
91
"""
0 commit comments