From 7d5966c3d37af78d43a14f9ba91ae5ebd8d479e0 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Sun, 9 Nov 2025 09:27:43 +0200 Subject: [PATCH] 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 --- src/topology/seg2.jl | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/topology/seg2.jl b/src/topology/seg2.jl index 2f77bec..7a4f533 100644 --- a/src/topology/seg2.jl +++ b/src/topology/seg2.jl @@ -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) = ()