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
This commit is contained in:
Jukka Aho
2025-11-23 18:18:24 +02:00
parent 8ae5981c09
commit e8c8c04075
+16
View File
@@ -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