refactor(topology): Modernize wedge topology implementation

- Apply Vec constructor broadcasting to both Wedge6 and Wedge15
- Convert edges() to return SVector of typed Edge{T} entities (9 edges)
- Convert faces() to return SVector of typed Face{T} entities (5 faces: 2 triangles + 3 quads)
- Add vertices() returning six Vertex{T} instances
- Add cells() returning single Cell{T} instance
- Add entity count methods: nvertices(), nedges(), nfaces()
- Clean syntax with consistent formatting
This commit is contained in:
Jukka Aho
2025-11-23 18:21:05 +02:00
parent b9a92bb364
commit 3ab0ca3f2f
+45 -30
View File
@@ -19,54 +19,69 @@ nnodes(::Wedge{N}) where {N} = N
dim(::Wedge{N}) where {N} = 3
function reference_coordinates(::Wedge{6})
return SVector(
Vec{3,Float64}((0.0, 0.0, -1.0)),
Vec{3,Float64}((1.0, 0.0, -1.0)),
Vec{3,Float64}((0.0, 1.0, -1.0)),
Vec{3,Float64}((0.0, 0.0, 1.0)),
Vec{3,Float64}((1.0, 0.0, 1.0)),
Vec{3,Float64}((0.0, 1.0, 1.0))
)
return SVector(Vec{3,Float64}.((
(0.0, 0.0, -1.0),
(1.0, 0.0, -1.0),
(0.0, 1.0, -1.0),
(0.0, 0.0, 1.0),
(1.0, 0.0, 1.0),
(0.0, 1.0, 1.0)
)))
end
function reference_coordinates(::Wedge{15})
return SVector(
return SVector(Vec{3,Float64}.((
# 6 corner nodes
Vec{3,Float64}((0.0, 0.0, -1.0)),
Vec{3,Float64}((1.0, 0.0, -1.0)),
Vec{3,Float64}((0.0, 1.0, -1.0)),
Vec{3,Float64}((0.0, 0.0, 1.0)),
Vec{3,Float64}((1.0, 0.0, 1.0)),
Vec{3,Float64}((0.0, 1.0, 1.0)),
(0.0, 0.0, -1.0),
(1.0, 0.0, -1.0),
(0.0, 1.0, -1.0),
(0.0, 0.0, 1.0),
(1.0, 0.0, 1.0),
(0.0, 1.0, 1.0),
# 9 edge midpoint nodes
Vec{3,Float64}((0.5, 0.0, -1.0)), # Bottom triangle edges
Vec{3,Float64}((0.5, 0.5, -1.0)),
Vec{3,Float64}((0.0, 0.5, -1.0)),
Vec{3,Float64}((0.5, 0.0, 1.0)), # Top triangle edges
Vec{3,Float64}((0.5, 0.5, 1.0)),
Vec{3,Float64}((0.0, 0.5, 1.0)),
Vec{3,Float64}((0.0, 0.0, 0.0)), # Vertical edges
Vec{3,Float64}((1.0, 0.0, 0.0)),
Vec{3,Float64}((0.0, 1.0, 0.0))
)
(0.5, 0.0, -1.0), # Bottom triangle edges
(0.5, 0.5, -1.0),
(0.0, 0.5, -1.0),
(0.5, 0.0, 1.0), # Top triangle edges
(0.5, 0.5, 1.0),
(0.0, 0.5, 1.0),
(0.0, 0.0, 0.0), # Vertical edges
(1.0, 0.0, 0.0),
(0.0, 1.0, 0.0)
)))
end
function edges(::Wedge{N}) where {N}
return (
function edges(::T) where {T<:Wedge}
return SVector(Edge{T}.((
(1, 2), (2, 3), (3, 1), # Bottom triangle
(4, 5), (5, 6), (6, 4), # Top triangle
(1, 4), (2, 5), (3, 6) # Vertical edges
)
)))
end
function faces(::Wedge{N}) where {N}
return (
function faces(::T) where {T<:Wedge}
return SVector(Face{T}.((
(1, 3, 2), # Bottom triangle
(4, 5, 6), # Top triangle
(1, 2, 5, 4), # Quad face 1
(2, 3, 6, 5), # Quad face 2
(3, 1, 4, 6) # Quad face 3
)))
end
function vertices(::T) where {T<:Wedge}
return SVector(
Vertex{T}(), Vertex{T}(), Vertex{T}(),
Vertex{T}(), Vertex{T}(), Vertex{T}()
)
end
function cells(::T) where {T<:Wedge}
return SVector(Cell{T}())
end
nvertices(::Wedge) = 6
nedges(::Wedge) = 9
nfaces(::Wedge) = 5
export Wedge6, Wedge15