From 7e3f9bddc1596da99384f61df569be794fae1cb6 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Fri, 21 Nov 2025 00:32:06 +0200 Subject: [PATCH] refactor(topology): Update 3D element reference_coordinates to SVector of Vec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hexahedron changes: - Hex8: tuple of tuples → SVector of Vec{3,Float64} (8 corners) - Added Hex20: SVector with 8 corners + 12 edge midpoints - Added Hex27: SVector with 8 corners + 12 edge midpoints + 6 face centers + 1 volume center Pyramid changes: - Pyr5: tuple of tuples → SVector of Vec{3,Float64} (4 base corners + 1 apex) Wedge changes: - Wedge6: tuple of tuples → SVector of Vec{3,Float64} (2 triangular faces) - Added Wedge15: SVector with 6 corners + 9 edge midpoints --- src/topology/hexahedra.jl | 50 +++++++++++++++++++++++++++++++++++---- src/topology/pyramids.jl | 9 ++++--- src/topology/wedges.jl | 32 ++++++++++++++++++++++--- 3 files changed, 80 insertions(+), 11 deletions(-) diff --git a/src/topology/hexahedra.jl b/src/topology/hexahedra.jl index ea90af4..2a1f582 100644 --- a/src/topology/hexahedra.jl +++ b/src/topology/hexahedra.jl @@ -21,11 +21,51 @@ nnodes(::Hexahedron{N}) where {N} = N dim(::Hexahedron{N}) where {N} = 3 function reference_coordinates(::Hexahedron{8}) - return ( - (-1.0, -1.0, -1.0), (1.0, -1.0, -1.0), - (1.0, 1.0, -1.0), (-1.0, 1.0, -1.0), - (-1.0, -1.0, 1.0), (1.0, -1.0, 1.0), - (1.0, 1.0, 1.0), (-1.0, 1.0, 1.0) + return SVector( + Vec{3,Float64}((-1.0, -1.0, -1.0)), Vec{3,Float64}((1.0, -1.0, -1.0)), + Vec{3,Float64}((1.0, 1.0, -1.0)), Vec{3,Float64}((-1.0, 1.0, -1.0)), + Vec{3,Float64}((-1.0, -1.0, 1.0)), Vec{3,Float64}((1.0, -1.0, 1.0)), + Vec{3,Float64}((1.0, 1.0, 1.0)), Vec{3,Float64}((-1.0, 1.0, 1.0)) + ) +end + +function reference_coordinates(::Hexahedron{20}) + return SVector( + # 8 corner nodes + Vec{3,Float64}((-1.0, -1.0, -1.0)), Vec{3,Float64}((1.0, -1.0, -1.0)), + Vec{3,Float64}((1.0, 1.0, -1.0)), Vec{3,Float64}((-1.0, 1.0, -1.0)), + Vec{3,Float64}((-1.0, -1.0, 1.0)), Vec{3,Float64}((1.0, -1.0, 1.0)), + Vec{3,Float64}((1.0, 1.0, 1.0)), Vec{3,Float64}((-1.0, 1.0, 1.0)), + # 12 edge midpoint nodes + Vec{3,Float64}((0.0, -1.0, -1.0)), Vec{3,Float64}((1.0, 0.0, -1.0)), + Vec{3,Float64}((0.0, 1.0, -1.0)), Vec{3,Float64}((-1.0, 0.0, -1.0)), + Vec{3,Float64}((0.0, -1.0, 1.0)), Vec{3,Float64}((1.0, 0.0, 1.0)), + Vec{3,Float64}((0.0, 1.0, 1.0)), Vec{3,Float64}((-1.0, 0.0, 1.0)), + Vec{3,Float64}((-1.0, -1.0, 0.0)), Vec{3,Float64}((1.0, -1.0, 0.0)), + Vec{3,Float64}((1.0, 1.0, 0.0)), Vec{3,Float64}((-1.0, 1.0, 0.0)) + ) +end + +function reference_coordinates(::Hexahedron{27}) + return SVector( + # 8 corner nodes + Vec{3,Float64}((-1.0, -1.0, -1.0)), Vec{3,Float64}((1.0, -1.0, -1.0)), + Vec{3,Float64}((1.0, 1.0, -1.0)), Vec{3,Float64}((-1.0, 1.0, -1.0)), + Vec{3,Float64}((-1.0, -1.0, 1.0)), Vec{3,Float64}((1.0, -1.0, 1.0)), + Vec{3,Float64}((1.0, 1.0, 1.0)), Vec{3,Float64}((-1.0, 1.0, 1.0)), + # 12 edge midpoint nodes + Vec{3,Float64}((0.0, -1.0, -1.0)), Vec{3,Float64}((1.0, 0.0, -1.0)), + Vec{3,Float64}((0.0, 1.0, -1.0)), Vec{3,Float64}((-1.0, 0.0, -1.0)), + Vec{3,Float64}((0.0, -1.0, 1.0)), Vec{3,Float64}((1.0, 0.0, 1.0)), + Vec{3,Float64}((0.0, 1.0, 1.0)), Vec{3,Float64}((-1.0, 0.0, 1.0)), + Vec{3,Float64}((-1.0, -1.0, 0.0)), Vec{3,Float64}((1.0, -1.0, 0.0)), + Vec{3,Float64}((1.0, 1.0, 0.0)), Vec{3,Float64}((-1.0, 1.0, 0.0)), + # 6 face center nodes + Vec{3,Float64}((0.0, 0.0, -1.0)), Vec{3,Float64}((0.0, 0.0, 1.0)), + Vec{3,Float64}((0.0, -1.0, 0.0)), Vec{3,Float64}((0.0, 1.0, 0.0)), + Vec{3,Float64}((-1.0, 0.0, 0.0)), Vec{3,Float64}((1.0, 0.0, 0.0)), + # 1 volume center node + Vec{3,Float64}((0.0, 0.0, 0.0)) ) end diff --git a/src/topology/pyramids.jl b/src/topology/pyramids.jl index c897ee5..4866872 100644 --- a/src/topology/pyramids.jl +++ b/src/topology/pyramids.jl @@ -18,9 +18,12 @@ nnodes(::Pyramid{N}) where {N} = N dim(::Pyramid{N}) where {N} = 3 function reference_coordinates(::Pyramid{5}) - return ( - (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0), - (0.0, 0.0, 1.0) + return SVector( + Vec{3,Float64}((-1.0, -1.0, 0.0)), + Vec{3,Float64}((1.0, -1.0, 0.0)), + Vec{3,Float64}((1.0, 1.0, 0.0)), + Vec{3,Float64}((-1.0, 1.0, 0.0)), + Vec{3,Float64}((0.0, 0.0, 1.0)) ) end diff --git a/src/topology/wedges.jl b/src/topology/wedges.jl index a698ad6..71ae3f8 100644 --- a/src/topology/wedges.jl +++ b/src/topology/wedges.jl @@ -19,9 +19,35 @@ nnodes(::Wedge{N}) where {N} = N dim(::Wedge{N}) where {N} = 3 function reference_coordinates(::Wedge{6}) - return ( - (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) + 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)) + ) +end + +function reference_coordinates(::Wedge{15}) + return SVector( + # 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)), + # 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)) ) end