refactor(topology): Rename Seg2 to Segment, remove hardcoded node count

- Changed struct name from Seg2 to Segment
- Removed nnodes() method (node count now determined by basis)
- Updated all function signatures to use Segment instead of Seg2
- Added Seg2 as backwards compatibility alias
- Added note explaining basis determines node count
This commit is contained in:
Jukka Aho
2025-11-09 09:27:43 +02:00
parent 82758bd7c6
commit 7d5966c3d3
+18 -12
View File
@@ -2,9 +2,9 @@
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE
"""
Seg2 <: AbstractTopology
Segment <: AbstractTopology
2-node linear segment/line element.
Linear segment/line element topology (1D).
Reference element in 1D parametric space [-1, 1].
@@ -14,36 +14,42 @@ Reference element in 1D parametric space [-1, 1].
-1 +1
```
**Note:** Node count determined by basis function degree:
- Lagrange{Segment, 1}: 2 nodes (linear)
- Lagrange{Segment, 2}: 3 nodes (quadratic)
**Zero allocation:** All functions return compile-time sized tuples.
"""
struct Seg2 <: AbstractTopology end
struct Segment <: AbstractTopology end
nnodes(::Seg2) = 2
dim(::Seg2) = 1
dim(::Segment) = 1
# Backwards compatibility alias
const Seg2 = Segment
"""
reference_coordinates(::Seg2) -> NTuple{2, NTuple{1, Float64}}
reference_coordinates(::Segment) -> NTuple{2, NTuple{1, Float64}}
Reference coordinates for 2-node segment: (-1.0,) and (1.0,).
Reference coordinates for segment endpoints: (-1.0,) and (1.0,).
**Zero allocation:** Returns tuple of tuples (stack allocated).
"""
reference_coordinates(::Seg2) = ((-1.0,), (1.0,))
reference_coordinates(::Segment) = ((-1.0,), (1.0,))
"""
edges(::Seg2) -> NTuple{1, Tuple{Int, Int}}
edges(::Segment) -> NTuple{1, Tuple{Int, Int}}
Edge connectivity for segment (the segment itself).
**Zero allocation:** Returns tuple of tuples (stack allocated).
"""
edges(::Seg2) = ((1, 2),)
edges(::Segment) = ((1, 2),)
"""
faces(::Seg2) -> NTuple{0, Tuple{}}
faces(::Segment) -> NTuple{0, Tuple{}}
Faces for 1D element (none in 1D).
**Zero allocation:** Returns empty tuple (stack allocated).
"""
faces(::Seg2) = ()
faces(::Segment) = ()