refactor(topology): Implement Wedge{N} with type parameter

Update Wedge to use node count type parameter per ADR-002.

Changes:
- struct Wedge → struct Wedge{N} <: AbstractTopology{N}
- Aliases: Wedge6 = Wedge{6}, Wedge15 = Wedge{15}
- Simplified implementation following same pattern
- Remove old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old files removed: wedge6.jl, wedge15.jl
New file: Single wedges.jl handles all variants via {N}
This commit is contained in:
Jukka Aho
2025-11-15 04:07:28 +02:00
parent a9e31c1ed2
commit 75735ea63c
+24 -109
View File
@@ -2,130 +2,45 @@
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE
"""
Wedge <: AbstractTopology
Wedge{N} <: AbstractTopology{N}
Wedge/prism element topology (3D, triangular prism).
Wedge (prism) topology with N nodes.
**Important:** This type defines ONLY the geometric shape. Node count is determined
by the interpolation scheme (basis functions):
- `Lagrange{Wedge, 1}` → 6 nodes (linear)
- `Lagrange{Wedge, 2}` → 15 nodes (quadratic, with edge midpoints)
# Reference Element
```
N6
/|\\
/ | \\
N4-------N5
| | |
| N3 |
| / \\ |
|/ \\|
N1------N2
```
# Standard Corner Node Positions
1-3: Bottom triangle
4-6: Top triangle (directly above 1-3)
# Topology Properties
- Dimension: 3
- Corner nodes: 6
- Edges: 9
- Faces: 5 (2 triangles + 3 quads)
**Zero allocation:** All functions return compile-time sized tuples.
See also: [`AbstractTopology`](@ref), [`Pyramid`](@ref)
# Node Count Variants
- `Wedge{6}` (alias `Wedge6`): Linear wedge (P1)
- `Wedge{15}` (alias `Wedge15`): Quadratic wedge (P2)
"""
struct Wedge <: AbstractTopology end
struct Wedge{N} <: AbstractTopology{N} end
dim(::Wedge) = 3
const Wedge6 = Wedge{6}
const Wedge15 = Wedge{15}
"""
reference_coordinates(::Wedge)
nnodes(::Wedge{N}) where {N} = N
dim(::Wedge{N}) where {N} = 3
Get corner node positions for Wedge (6 vertices).
"""
function reference_coordinates(::Wedge)
function reference_coordinates(::Wedge{6})
return (
(0.0, 0.0, -1.0), # Node 1: Bottom triangle
(1.0, 0.0, -1.0), # Node 2: Bottom triangle
(0.0, 1.0, -1.0), # Node 3: Bottom triangle
(0.0, 0.0, 1.0), # Node 4: Top triangle
(1.0, 0.0, 1.0), # Node 5: Top triangle
(0.0, 1.0, 1.0), # Node 6: Top triangle
(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
"""
edges(::Wedge)
Edge connectivity for wedge (corner nodes).
"""
function edges(::Wedge)
function edges(::Wedge{N}) where {N}
return (
(1, 2), (2, 3), (3, 1), # Bottom triangle edges
(4, 5), (5, 6), (6, 4), # Top triangle edges
(1, 4), (2, 5), (3, 6), # Vertical edges
(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
"""
faces(::Wedge)
Face connectivity for wedge (2 triangular + 3 quadrilateral faces).
"""
function faces(::Wedge)
function faces(::Wedge{N}) where {N}
return (
(1, 3, 2), # Face 1: Bottom triangle
(4, 5, 6), # Face 2: Top triangle
(1, 2, 5, 4), # Face 3: Quad
(2, 3, 6, 5), # Face 4: Quad
(3, 1, 4, 6), # Face 5: Quad
(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
# ============================================================================
# Deprecated aliases (for backwards compatibility)
# ============================================================================
"""
Wedge6
**DEPRECATED:** Backward compatibility alias. Use `Wedge` with `Lagrange{Wedge, 1}`.
This alias allows old code to work:
```julia
# Old style (still works)
element = Element(Wedge6, (1, 2, 3, 4, 5, 6))
# Internally converted to:
element = Element(Wedge, (1, 2, 3, 4, 5, 6)) # Infers Lagrange{Wedge, 1}
```
New code should use explicit topology + basis:
```julia
element = Element(Lagrange{Wedge, 1}, (1, 2, 3, 4, 5, 6))
```
"""
const Wedge6 = Wedge
"""
Wedge15
**DEPRECATED:** Backward compatibility alias. Use `Wedge` with `Lagrange{Wedge, 2}`.
This alias allows old code to work:
```julia
# Old style (still works)
element = Element(Wedge15, (1, 2, ..., 15))
# Internally converted to:
element = Element(Wedge, (1, 2, ..., 15)) # Infers Lagrange{Wedge, 2}
```
New code should use explicit topology + basis:
```julia
element = Element(Lagrange{Wedge, 2}, (1, 2, ..., 15))
```
"""
const Wedge15 = Wedge # Same topology! Node count from basis.
export Wedge6, Wedge15