feat(assemblers): add scatter_to_force! for force vector assembly

New 37-line scatter function for element-based force assembly:
- Scatters element force vector to global force vector in-place
- Zero-allocation guarantee (modifies global vector directly)
- Legacy format support
- Required dependency for element_based_coo.jl

Provides core force scattering functionality for COO assembly.
This commit is contained in:
Jukka Aho
2025-12-15 06:05:51 +02:00
parent 71b580f5ea
commit 5995115e72
+37
View File
@@ -0,0 +1,37 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
"""
scatter_to_force!(f::Vector{Float64}, fe::AbstractVector, dofs::AbstractVector{Int})
Scatter element force vector to global force vector **in-place** (legacy format).
Accumulates element contributions: `f[dofs] += fe`
# Arguments
- `f`: Global force vector (modified in-place)
- `fe`: Element force vector [ndofs_elem]
- `dofs`: Global DOF indices [ndofs_elem]
# Zero-Allocation Guarantee
No allocations - modifies `f` in-place.
# Algorithm
```julia
for (i_local, i_global) in enumerate(dofs)
f[i_global] += fe[i_local]
end
```
"""
function scatter_to_force!(
f::Vector{Float64},
fe::Vector{Float64},
dofs::Vector{Int}
)
for (i_local, i_global) in enumerate(dofs)
f[i_global] += fe[i_local]
end
return nothing
end