From e8c8c04075ece831ddbe1222675c89e5bfa9f166 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Sun, 23 Nov 2025 18:18:24 +0200 Subject: [PATCH] feat(topology): Add type-level nnodes() method - Add nnodes(::Type{<:AbstractTopology{N}}) method for type queries - Enables compile-time node count without instantiation - Example: nnodes(Triangle{3}) returns 3 - Complements existing instance method for dispatch consistency --- src/topology/api.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/topology/api.jl b/src/topology/api.jl index dcb6f9e..9ab6828 100644 --- a/src/topology/api.jl +++ b/src/topology/api.jl @@ -177,6 +177,22 @@ Concrete types inherit this implementation automatically. """ nnodes(::AbstractTopology{N}) where N = N +""" + nnodes(::Type{<:AbstractTopology{N}}) -> Int + +Number of nodes for a topology type (compile-time constant from type parameter). + +# Examples + +```julia +nnodes(Triangle{3}) # 3 +nnodes(Triangle{6}) # 6 +nnodes(Quadrilateral{4}) # 4 +nnodes(Quadrilateral{9}) # 9 +``` +""" +nnodes(::Type{<:AbstractTopology{N}}) where N = N + """ dim(topology::AbstractTopology) -> Int