mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-10 04:50:49 +00:00
feat(basis): Add ndofs interface to query DOF counts for basis types
- Add `ndofs(::AbstractBasis)` / `ndofs(::Type{<:AbstractBasis})` with docstring and examples
- Default implementation: `ndofs == nnodes` for standard Lagrange bases
- Export `ndofs` alongside `Lagrange` and `nnodes`
This provides a stable API for callers to preallocate element-local buffers and supports plate elements that have multiple DOFs per node.
This commit is contained in:
+30
-2
@@ -298,5 +298,33 @@ nnodes(::Type{Pyr5}) = 5
|
||||
nnodes(::Type{Wedge6}) = 6
|
||||
nnodes(::Type{Wedge15}) = 15
|
||||
|
||||
# Export the new parametric type and node count function
|
||||
export Lagrange, nnodes
|
||||
# ============================================================================
|
||||
# Additional Interface Methods
|
||||
# ============================================================================
|
||||
|
||||
"""
|
||||
ndofs(basis::AbstractBasis) -> Int
|
||||
ndofs(::Type{<:AbstractBasis}) -> Int
|
||||
|
||||
Number of degrees of freedom for this basis.
|
||||
|
||||
For standard nodal elements (Lagrange), ndofs == nnodes.
|
||||
For plate elements and others with multiple DOFs per node, ndofs > nnodes.
|
||||
|
||||
# Example
|
||||
|
||||
```julia
|
||||
ndofs(Lagrange{Triangle, 1}()) # → 3 (same as nnodes)
|
||||
ndofs(DKT()) # → 9 (3 nodes × 3 DOFs/node)
|
||||
```
|
||||
|
||||
See also: [`nnodes`](@ref), [`AbstractPlateBasis`](@ref)
|
||||
"""
|
||||
function ndofs end
|
||||
|
||||
# Default: For standard elements, ndofs == nnodes
|
||||
ndofs(B::AbstractBasis) = nnodes(B)
|
||||
ndofs(B::Type{<:AbstractBasis}) = nnodes(B)
|
||||
|
||||
# Export the new parametric type and interface functions
|
||||
export Lagrange, nnodes, ndofs
|
||||
|
||||
Reference in New Issue
Block a user