mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-16 16:53:19 +00:00
refactor(topology): Modernize segment topology implementation
- Apply Vec constructor broadcasting: Vec{1,Float64}.((...))
- Convert edges() to return typed Edge{T} in SVector
- Convert faces() to return typed Vertex{T} (endpoints in 1D)
- Add vertices() method returning two Vertex{T} instances
- Add cells() method returning single Cell{T}
- Add entity count methods: nvertices(), nedges(), nfaces()
- Clean up syntax with consistent formatting
This commit is contained in:
+25
-13
@@ -19,26 +19,38 @@ nnodes(::Segment{N}) where {N} = N
|
||||
dim(::Segment{N}) where {N} = 1
|
||||
|
||||
function reference_coordinates(::Segment{2})
|
||||
return SVector(
|
||||
Vec{1,Float64}((-1.0,)),
|
||||
Vec{1,Float64}((1.0,))
|
||||
)
|
||||
return SVector(Vec{1,Float64}.((
|
||||
(-1.0,),
|
||||
(1.0,)
|
||||
)))
|
||||
end
|
||||
|
||||
function reference_coordinates(::Segment{3})
|
||||
return SVector(
|
||||
Vec{1,Float64}((-1.0,)),
|
||||
Vec{1,Float64}((1.0,)),
|
||||
Vec{1,Float64}((0.0,))
|
||||
)
|
||||
return SVector(Vec{1,Float64}.((
|
||||
(-1.0,),
|
||||
(1.0,),
|
||||
(0.0,)
|
||||
)))
|
||||
end
|
||||
|
||||
function edges(::Segment{N}) where {N}
|
||||
return ((1, 2),)
|
||||
function edges(::T) where {T<:Segment}
|
||||
return SVector(Edge{T}((1, 2)))
|
||||
end
|
||||
|
||||
function faces(::Segment{N}) where {N}
|
||||
return ((1,), (2,)) # Endpoints are "faces" in 1D
|
||||
function faces(::T) where {T<:Segment}
|
||||
return SVector(Vertex{T}(), Vertex{T}()) # Endpoints are "faces" in 1D
|
||||
end
|
||||
|
||||
function vertices(::T) where {T<:Segment}
|
||||
return SVector(Vertex{T}(), Vertex{T}())
|
||||
end
|
||||
|
||||
function cells(::T) where {T<:Segment}
|
||||
return SVector(Cell{T}())
|
||||
end
|
||||
|
||||
nvertices(::Segment) = 2
|
||||
nedges(::Segment) = 1
|
||||
nfaces(::Segment) = 2 # Two endpoints
|
||||
|
||||
export Seg2, Seg3
|
||||
|
||||
Reference in New Issue
Block a user