refactor(domains): optimize update_geometry_cache! for zero-allocation

Optimize update_geometry_cache! to eliminate iterator allocations and
update to use coords field.

- Add @inline to update_geometry_cache! for better inlining
- Change enumerate loop to indexed loop to avoid iterator allocation
- Add @inbounds annotation for bounds-check elimination
- Change ip.ξ to ip.coords to use new QuadraturePoint API
This commit is contained in:
Jukka Aho
2025-12-12 23:36:21 +02:00
parent 00448c8c52
commit fb770644c4
@@ -45,7 +45,7 @@ For each integration point:
3. Compute physical gradients ∇N = J^{-T} ⋅ ∇_ξ N
4. Store detJ * weight for integration
"""
function update_geometry_cache!(
@inline function update_geometry_cache!(
geometry_cache::GeometryCache,
element_cache::ElementCache,
kernel::AbstractKernel,
@@ -61,7 +61,9 @@ function update_geometry_cache!(
nnodes = length(conn)
# Extract node coordinates (mesh.nodes already contains Vec{3})
for (i, node) in enumerate(conn)
# Use indexed loop instead of enumerate to avoid iterator allocation
@inbounds for i in 1:nnodes
node = conn[i]
geometry_cache.X[i] = mesh.nodes[node]
end
@@ -71,7 +73,7 @@ function update_geometry_cache!(
@inbounds for ip_idx in 1:nips
ip = ips[ip_idx]
ξ = ip.ξ
ξ = ip.coords
# Reference gradients
dN_dξ = get_basis_derivatives(element_cache.topology, element_cache.basis, ξ)