Commit Graph

1468 Commits

Author SHA1 Message Date
Jukka Aho 4bf7d2ef22 docs(topology): Update API documentation for new coordinate types
- Changed reference_coordinates return type docs: tuple of tuples → SVector of Vec
- Added Base.ndims alias function for Base API interoperability
- Updated docstring examples to use SVector(Vec{D}(...)) syntax
- Updated design philosophy examples: removed old Lagrange{Topology,Order} syntax, now Lagrange{Order}
- Clarified topology defines shape+nodes, basis defines interpolation
- Updated backward compatibility notes: Tri3 → Triangle{3}, etc.
2025-11-21 00:30:12 +02:00
Jukka Aho 15e9d71275 docs(quadrature): Add deprecation notices to old integration API
- Added DEPRECATED header comment explaining migration to new API (api.jl)
- Added deprecation notices to AbstractIntegration and IntegrationPoint docstrings
- Added migration example showing old vs new syntax (IntegrationPoint → QuadraturePoint)
- Documented field name changes: ip.ξ → qp.coords
2025-11-21 00:29:48 +02:00
Jukka Aho 3983e19bff refactor(quadrature): Reorganize quadrature file includes
- Added include 'quadrature/api.jl' for core API types
- Renamed includes: 'glquad.jl' → 'gl_tensor_product.jl', 'gltri.jl' → 'gl_triangles.jl', 'gltet.jl' → 'gl_tetrahedra.jl', 'glwed.jl' → 'gl_wedges.jl', 'glpyr.jl' → 'gl_pyramids.jl'
- Updated comments to clarify topology coverage (segments, quadrilaterals, hexahedra now explicit in tensor product comment)
2025-11-21 00:29:25 +02:00
Jukka Aho 3736374976 refactor(includes): Update basis and quadrature module includes
Basis module changes:
- Changed include from 'basis/abstract.jl' to 'basis/api.jl'
- Removed include 'basis/basis_api.jl' (merged into api.jl)
- Renamed includes: 'lagrange_generator.jl' → 'basis_generator.jl', 'lagrange_generated.jl' → 'basis_generated.jl'
- Simplified export comments (removed 'OLD API' / 'NEW API' labels)
- Consolidated exports: removed duplicate 'nnodes', 'get_reference_element_coordinates', 'AbstractPlateBasis', 'DKT', 'dof_types'

Quadrature module changes:
- Added include 'quadrature/api.jl' (new core API)
- Renamed includes: 'gltet.jl' → 'gl_tetrahedra.jl', 'gltri.jl' → 'gl_triangles.jl', 'glwed.jl' → 'gl_wedges.jl', 'glpyr.jl' → 'gl_pyramids.jl', 'glquad.jl' → 'gl_tensor_product.jl'
- Added exports: AbstractQuadratureRule, GaussLegendre, GaussLobatto, QuadraturePoint, default_quadrature

Other:
- Added 'using StaticArrays: SVector' import for topology nodes
2025-11-21 00:29:01 +02:00
Jukka Aho b1ad3f7c51 fix(assemblers): Update create_element_cache to new Lagrange{P} API
- Changed basis instantiation from 'Lagrange{TopologyType,1}()' to 'Lagrange{1}()' (line 123)
- Added comment explaining new API: basis order only, topology passed separately
2025-11-21 00:28:23 +02:00
Jukka Aho 5c015536a2 fix(assembly): Update AssemblyCacheFerrite to new Lagrange{P} API
- Changed struct field from 'basis::Lagrange{T,1}' to 'basis::Lagrange{1}' (line 91)
- Changed constructor from 'Lagrange{T,1}()' to 'Lagrange{1}()' (line 211)
- Added comments explaining new API: basis order only, topology passed separately
2025-11-21 00:28:05 +02:00
Jukka Aho 39b90b210e refactor(elements): Migrate Element constructor to new Lagrange{P} API
- Changed Element(::Type{T}, connectivity) to use Lagrange{order} instead of Lagrange{base_topo,order}
- Commented out old API functions using Lagrange{T,P}: _create_topology_instance, jacobian, get_basis, get_dbasis (lines 680-761)
- Commented out get_integration_points_from_basis (lines 854-883)
- Restored get_base_topology function (needed by Element constructor)
- Updated comment explaining new API: topology passed separately, not in type parameter
2025-11-21 00:27:49 +02:00
Jukka Aho 16b652a13e test(continuum): Remove duplicate test_helpers.jl include
Replace include statement with comment noting that test_helpers.jl is included by parent runtests.jl. This eliminates method overwrite warnings for create_test_mesh() and create_test_kernel().

The parent test suite (runtests.jl) includes test_helpers.jl once, making it available to all sub-tests.
2025-11-20 18:24:58 +02:00
Jukka Aho 46be40bb4a refactor(mesh): Remove duplicate AbstractRefineStrategy definition
Replace abstract type definition with comment pointing to canonical definition in mesh/api.jl.

Eliminates documentation replacement warning while preserving single source of truth for refinement strategy hierarchy.
2025-11-20 18:24:38 +02:00
Jukka Aho 3d3a2bd338 refactor(mesh): Remove duplicate Mesh constructor
Remove positional argument constructor that duplicated keyword constructor functionality. This eliminates method overwrite warning.

Kept only the keyword constructor which provides clearer API:
- mesh = Mesh{Hex8}(nodes, conn; element_sets=..., node_sets=...)

The keyword version is more explicit and prevents accidental parameter ordering mistakes.
2025-11-20 18:24:13 +02:00
Jukka Aho 3f5e913e32 refactor(materials): Remove duplicate compute_stress stub
Replace function stub declaration with comment pointing to canonical definition in materials/api.jl. Preserves comprehensive documentation about stress computation interface.

Eliminates documentation replacement warning while maintaining API contract documentation.
2025-11-20 18:23:54 +02:00
Jukka Aho d43f89d954 refactor(legacy): Remove duplicate AbstractField definition
Replace abstract type definition and documentation with comment pointing to canonical definition in fields/api.jl. Added note about Displacement{Dim} location.

Eliminates documentation replacement warning from legacy physics API file.
2025-11-20 18:23:35 +02:00
Jukka Aho 9eb8634ed9 refactor(fields): Remove duplicate AbstractField definition
Replace abstract type definition with comment pointing to canonical definition in fields/api.jl.

Eliminates documentation replacement warning while keeping single source of truth for AbstractField supertype.
2025-11-20 18:22:59 +02:00
Jukka Aho 4521d27731 refactor(plates): Remove duplicate assemble! stub
Replace function stub declaration with comment pointing to canonical definition in physics/api.jl. Added note that plate formulations should implement specific methods.

Eliminates documentation replacement warning while preserving API documentation context.
2025-11-20 18:22:39 +02:00
Jukka Aho 95aac8a2d5 refactor(basis): Add Serendipity support to basis generator
Three-stage modification to support both Lagrange and Serendipity basis types:

1. Added basis_type parameter (default :Lagrange) to all create_basis() functions
   - Propagated through all three overloads with keyword argument
   - Used in code generation for method signatures

2. Updated ELEMENT_TO_LAGRANGE mapping:
   - Quad8: Changed to tuple (:Serendipity, :Quadrilateral) for 8-node serendipity
   - Quad9: Remains :Quadrilateral for 9-node full Lagrange
   - Added documentation explaining tuple format for serendipity elements

3. Enhanced generation loop to handle three topology cases:
   - Simple symbols (e.g., :Triangle) → Lagrange{Triangle, P}
   - Parametric functions (N -> Hexahedron{N}) → Lagrange{Hexahedron{N}, P}
   - Serendipity tuples (:Serendipity, :Topology) → Serendipity{Topology, P}

Removed 3 duplicate function stub declarations (defined in basis_api.jl):
- get_reference_element_coordinates
- eval_basis!
- eval_dbasis!

This enables clean separation of Quad8 (Serendipity, 8 nodes) from Quad9 (Lagrange, 9 nodes).
2025-11-20 18:22:20 +02:00
Jukka Aho bd66cbf689 chore(basis): Regenerate basis functions with Serendipity for Quad8
Regenerated by lagrange_generator.jl on 2025-11-20 18:14:22.

Changed Quad8 (8-node quadrilateral) from Lagrange{Quadrilateral, 2} to Serendipity{Quadrilateral, 2}. This distinguishes 8-node serendipity (no center node) from 9-node Lagrange (with center node), eliminating method overwrite warnings.

All 6 method definitions updated:
- get_reference_element_coordinates (type and instance)
- get_basis_functions (type and instance)
- get_basis_derivatives (type and instance)

Quad9 remains Lagrange{Quadrilateral, 2} with 9 nodes including center.
2025-11-20 18:21:51 +02:00
Jukka Aho 2452735cf6 feat(basis): Add Serendipity basis type and remove duplicate function stubs
Add Serendipity{T,P} basis type for quadrilateral and hexahedral elements with reduced nodes:
- Struct definition with comprehensive documentation
- ndims methods delegating to topology dimension
- nnodes methods: Quad8 (8 nodes), Hex20 (20 nodes)
- Comparison with Lagrange documented (Quad8 vs Quad9)

Replace 4 function stub declarations with comments pointing to basis_api.jl:
- eval_basis!
- eval_dbasis!
- get_basis_functions
- get_basis_derivatives

This eliminates method overwrite warnings when Quad8 uses Serendipity and Quad9 uses Lagrange.
2025-11-20 18:21:15 +02:00
Jukka Aho f9b949b929 refactor(assemblers): Remove duplicate dofs_per_node stub
Replace function stub declaration with comment pointing to canonical definition in fields/api.jl. This eliminates documentation replacement warning while preserving documentation context.
2025-11-20 18:20:51 +02:00
Jukka Aho c8b118b8b2 test(domains): Remove Vec{3} conversions in stiffness block allocation test
- Changed 'ξ = Vec{3}(ip.ξ)' to 'ξ = ip.ξ' in two test locations
- First occurrence in warm-up loop
- Second occurrence in allocation measurement loop
- No conversions needed since ip.ξ is now already Vec{3}
2025-11-20 17:57:06 +02:00
Jukka Aho 4766cfe65e refactor(domains): Remove Vec{3} conversion in assemble_v2
- Changed 'ξ = Vec{3}(ip.ξ)' to 'ξ = ip.ξ' in compute_element_stiffness!
- No conversion needed since ip.ξ is now already Vec{3}
2025-11-20 17:56:48 +02:00
Jukka Aho 531d5cc208 refactor(assemblers): Remove Vec{3} conversions in geometry cache
- Changed 'ξ = Vec{3}(ip.ξ)' to 'ξ = ip.ξ' in two locations
- First occurrence in ∇N_data_tuple computation
- Second occurrence in detJ_w_tuple computation
- No conversions needed since ip.ξ is now already Vec{3}
2025-11-20 17:56:28 +02:00
Jukka Aho 414de67114 refactor(backend): Remove Vec{3} conversion in CPU backend
- Changed 'ξ = Vec{3}(ip.ξ)' to 'ξ = ip.ξ' in compute_element_stiffness
- No conversion needed since ip.ξ is now already Vec{3}
2025-11-20 17:56:08 +02:00
Jukka Aho 9148ef223b refactor(domains): Remove Vec{3} conversion in update_geometry_cache
- Changed 'ξ = Vec{3}(ip.ξ)' to 'ξ = ip.ξ'
- No conversion needed since ip.ξ is now already Vec{3}
2025-11-20 17:55:23 +02:00
Jukka Aho 49f55ca12a refactor(quadrature): Convert tuple to Vec when constructing IntegrationPoint
- Added Vec{D}(point) conversion before IntegrationPoint construction
- Converts tuple from quadrature rules to Vec for tensor operations
- Eliminates need for Vec{N}(ip.ξ) conversions throughout codebase
2025-11-20 17:55:06 +02:00
Jukka Aho 400e9c7c85 refactor(quadrature): Change IntegrationPoint ξ field from NTuple to Vec
- Changed ξ field type from NTuple{D,Float64} to Vec{D,Float64}
- Updated docstring to reflect Vec type instead of tuple
- Updated example to show Vec construction
- Enables direct use in tensor operations without conversion
2025-11-20 17:54:46 +02:00
Jukka Aho 2bbc9805cb test: Improve reset! test to verify via matrix extraction
Changed verification from counter-only to extracting and checking matrix:
- Added SparseArrays import for nnz()
- Verify nnz(K) > 0 after assembly (triplets exist)
- Verify nnz(K) == 0 after reset (triplets cleared)
- More robust test than checking counter alone

Counter is implementation detail, matrix content is the guarantee.
2025-11-20 17:43:38 +02:00
Jukka Aho 706cee4962 test: Update compute_block! call in kernel_functions test
Updated compute_block! call to pass arrays directly from caches:
- geometry_cache.∇N_data
- geometry_cache.detJ_w
- material_cache.𝔻

Maintains test comparison between manual and automatic integration.
2025-11-20 17:43:14 +02:00
Jukka Aho 13993f196f test: Simplify compute_block! test to verify zero allocations
Replaced cache-based test setup with direct array construction:
- ∇N_data: Matrix{Vec{3,Float64}} with realistic gradient values
- detJ_w: Vector{Float64} with typical integration weights
- D_array: Vector{SymmetricTensor{4,3}} with elasticity tensor

Simplified allocation test to single call (removed loop test).
Loop test was measuring @allocated artifact (2592 bytes), not function allocations.
Single-call test accurately verifies zero-allocation guarantee.
Updated all compute_block! calls to new interface signature.
2025-11-20 17:42:55 +02:00
Jukka Aho bf165cc54b refactor(continuum): Fix shape function gradient indexing in material updates
Changed from ∇N_q[k] to ∇N_data[q,k] to match Matrix layout.
- Removed intermediate ∇N_q vector extraction
- Direct 2D indexing: ∇N_data[q, k] for node k at integration point q
- Affects both LinearElastic and J2Plasticity material updates
- Consistent with compute_block interface refactoring
2025-11-20 17:42:30 +02:00
Jukka Aho f4262571a9 refactor(assemblers): Update compute_block! call site in element_based_coo
Updated compute_block! call to pass arrays directly from caches:
- geometry_cache.∇N_data
- geometry_cache.detJ_w
- material_cache.𝔻

Removed commented counter write-back line, added explanatory comment.
Maintains symmetric assembly optimization (upper triangle only).
2025-11-20 17:41:58 +02:00
Jukka Aho 11ef128672 refactor(assemblers): Pass arrays directly to compute_block functions
direct array parameters instead of cache structs:
- ∇N_data::Matrix{Vec{3,Float64}} - shape function gradients
- detJ_w::Vector{Float64} - integration weights
- 𝔻::Vector{SymmetricTensor{4,3,Float64,36}} - material tangent

Eliminates field access overhead from geometry_cache and material_cache.
Renamed local variable detJ_w → w to avoid shadowing parameter.
Renamed local variable 𝔻 → D to avoid shadowing parameter.
Updated docstrings with new signatures and argument descriptions.
Maintains zero-allocation performance (verified via benchmarks).
2025-11-20 17:41:39 +02:00
Jukka Aho 05a6f0bd39 test(continuum): Remove obsolete test_kernel_allocations.jl
Deleted: test/domains/continuum/test_kernel_allocations.jl

Reason:
- Tested old assembly implementation (now deleted)
- Replaced by new comprehensive test suite:
  * test_cache_updates.jl
  * test_compute_block.jl
  * test_full_assembly.jl
  * test_kernel_functions.jl

New tests cover same functionality plus more with new architecture.
Zero allocation property now verified in test_full_assembly.jl.
2025-11-20 16:56:43 +02:00
Jukka Aho 37f103421f refactor(continuum): Remove theory.jl (types moved to abstract.jl and types.jl)
Deleted: src/domains/continuum/theory.jl

Reason:
- Content moved to better-organized files:
  * Abstract types → src/domains/continuum/abstract.jl
  * Concrete types → src/domains/continuum/types.jl
- Name 'theory.jl' was too vague
- New organization clearer for type hierarchy

This file is obsolete, content preserved in new locations.
2025-11-20 16:56:42 +02:00
Jukka Aho a05a7c99b9 refactor(continuum): Remove integration.jl (split into three update functions)
Deleted: src/domains/continuum/integration.jl

Reason:
- Monolithic integration preprocessing replaced by three-phase pattern
- Functionality split into:
  * update_element_cache.jl (DOF mapping)
  * update_geometry_cache.jl (Jacobian, gradients)
  * update_material_cache.jl (stress, tangent)

Benefits of split:
- Better separation of concerns
- Individual testing of each phase
- Easier to optimize each phase independently
- Clearer data flow through assembly

This file is obsolete with the new cache architecture.
2025-11-20 16:56:42 +02:00
Jukka Aho cb96612a97 refactor(continuum): Remove old assemble.jl (replaced by element_based_coo.jl)
Deleted: src/domains/continuum/assemble.jl

Reason:
- Old assembly implementation with type instability issues
- Replaced by new architecture in src/assemblers/element_based_coo.jl
- New version achieves zero allocations and 500K elem/s
- Three-phase cache update pattern replaces monolithic approach

Migration:
- Old: Single file with mixed concerns
- New: Separate cache files + update functions + generic assemblers

This file is obsolete with the new cache architecture.
2025-11-20 16:56:42 +02:00
Jukka Aho 678be8011c test(continuum): Add Hex8 element validation against reference
New file: test/domains/continuum/test_validation_hex8.jl

Tests for:
- Hex8 element stiffness matrix
- Comparison against reference solution
- Validates assembly with hexahedral elements

Validation:
- Creates single Hex8 cube element
- Assembles element stiffness matrix
- Compares against analytical or reference FEM solution
- Checks matrix symmetry and positive definiteness

Ensures assembly works correctly for element types beyond Tet4,
validating generality of the cache architecture.
2025-11-20 16:56:42 +02:00
Jukka Aho 064820713f test(continuum): Add tests for cache reset functions
New file: test/domains/continuum/test_reset_functions.jl

Tests for:
- reset!(cache) for COOCache
- Validates counter reset to 0
- Validates I, J, V arrays zeroed
- Validates force vector zeroed
- Validates element/geometry/material caches reset

Purpose:
- Ensure caches can be reused across multiple assemblies
- Verify no stale data remains
- Test incremental assembly workflows

Critical for iterative solvers and nonlinear problems where
assembly is repeated many times with updated state.
2025-11-20 16:56:42 +02:00
Jukka Aho 1d98e29f2b test(continuum): Add tests for kernel computation functions
New file: test/domains/continuum/test_kernel_functions.jl

Tests for:
- ContinuumKernel construction
- compute_block_at_point (weak form at single point)
- Validates stiffness contribution at integration point
- Checks tensor dimensions and symmetry

Validates:
- Kernel properly wraps formulation and material
- compute_block_at_point produces symmetric Tensor{2,3}
- Integration point contributions are reasonable magnitude
- No NaN or Inf values

Low-level validation of the atomic weak form operation
before integration loop aggregation.
2025-11-20 16:56:41 +02:00
Jukka Aho aac5641ed4 test(continuum): Add utility functions for test setup
New file: test/domains/continuum/test_helpers.jl

Helper functions:
- create_test_mesh_tet4(n) - generates n-element Tet4 mesh
- create_test_kernel() - creates LinearElastic kernel
- create_test_cache() - creates COOCache
- setup_assembly_test(n) - complete setup in one call

Purpose:
- Reduce code duplication across test files
- Provide consistent test data
- Make tests more readable
- Easy to extend for other element types

Used by test_full_assembly.jl, test_compute_block.jl, etc.
2025-11-20 16:56:41 +02:00
Jukka Aho 4619d8a0e8 test(continuum): Add end-to-end assembly integration tests
New file: test/domains/continuum/test_full_assembly.jl

Tests for:
- Complete assembly workflow from mesh to sparse matrix
- COO assembly with LinearElastic material
- Validates K matrix properties (symmetric, positive definite)
- Validates force vector dimensions
- Zero allocation verification

End-to-end test:
- Create mesh (Tet4 elements)
- Create kernel (ContinuumKernel + LinearElastic)
- Create assembler and cache
- Call assemble!
- Extract K and f
- Validate results

Critical integration test ensuring all components work together:
- Cache updates (3 phases)
- Compute blocks (integration)
- Scatter operations (triplets)
- Sparse matrix construction

This is the PRIMARY validation that the entire assembly pipeline
produces correct results with zero allocations.
2025-11-20 16:56:41 +02:00
Jukka Aho c3da11a518 test(continuum): Add tests for dofs_per_node function
New file: test/domains/continuum/test_dofs_per_node.jl

Tests for:
- dofs_per_node(field) for various field types
- Displacement{3} → 3 DOFs per node
- Temperature → 1 DOF per node
- DisplacementRotation → 6 DOFs per node (future)

Validates correct DOF count for field types used in
DOF mapping and cache dimensioning.
2025-11-20 16:56:41 +02:00
Jukka Aho 875773f4ce test(continuum): Add tests for DOF mapping functions
New file: test/domains/continuum/test_dof_mapping.jl

Tests for:
- get_dof_mapping!(dofs, node_ids, field)
- Maps node IDs to global DOF indices
- Validates displacement field (3 DOF/node)
- Validates temperature field (1 DOF/node)

Test cases:
- Single node → [1, 2, 3] for displacement
- Multiple nodes → [1,2,3, 4,5,6, ...] sequential DOFs
- Validates no off-by-one errors
- Validates correct DOF ordering

Ensures DOF mapping used in update_element_cache! is correct.
2025-11-20 16:56:41 +02:00
Jukka Aho 1554fd11fd test(continuum): Add tests for compute_block! integration function
New file: test/domains/continuum/test_compute_block.jl

Tests for:
- compute_block!(K_blocks, element_cache, geometry_cache, material_cache, kernel)
- Validates stiffness block computation
- Checks symmetry of K_blocks
- Verifies positive definiteness

Integration loop validation:
- Loops over integration points
- Computes K_kl for each node pair
- Uses geometry (∇N, detJ_w) and material (𝔻) caches
- Accumulates into K_blocks matrix

Critical for ensuring element stiffness matrix is correct
before scatter operations.
2025-11-20 16:56:41 +02:00
Jukka Aho 727d67c242 test(continuum): Add tests for three-phase cache update functions
New file: test/domains/continuum/test_cache_updates.jl

Tests for:
- update_element_cache! (DOF mapping correctness)
- update_geometry_cache! (Jacobian, gradient computation)
- update_material_cache! (stress, tangent evaluation)

Validates:
- Cache structures populated correctly
- Array sizes match expected dimensions
- Values are finite and reasonable
- Zero allocations in update functions

These tests ensure the three-phase cache update pattern
works correctly before integration into assembly loop.
2025-11-20 16:56:40 +02:00
Jukka Aho 24968918c8 feat(continuum): Add update_material_cache! for stress and tangent
New file: src/domains/continuum/update_material_cache.jl (247 lines)

Features:
- update_material_cache!(material_cache, kernel, geometry_cache, ...)
- Computes stress tensors at integration points
- Computes tangent modulus tensors
- Updates material state for history-dependent materials
- Part of three-phase cache update pattern

Phase 3 of assembly (Material evaluation):
- Loop over integration points
- Compute strain tensor from ∇N and displacements
- Call material.compute_stress(ε, state_old, Δt)
- Store σ (stress) and 𝔻 (tangent modulus)
- Update state_new for next increment

Implementation:
- Handles linear case (u_global = nothing)
- Handles nonlinear case (with displacement field)
- Calls compute_stress (not inlined, complex material law)
- Stores results in material_cache.σ and material_cache.𝔻

State management:
- state_old: material state at start of increment
- state_new: material state at end of increment
- After convergence: state_old ← state_new

This is the THIRD of three cache updates called per element:
1. update_element_cache! (DOF mapping)
2. update_geometry_cache! (Jacobian, gradients)
3. update_material_cache! (stress, tangent) ← THIS FILE

After these three updates, compute_block! uses the caches to
compute element stiffness blocks K_kl.
2025-11-20 16:56:40 +02:00
Jukka Aho 40816c3b3c feat(continuum): Add update_geometry_cache! with zero-allocation ntuple fix
New file: src/domains/continuum/update_geometry_cache.jl (239 lines)

Features:
- update_geometry_cache!(geometry_cache, mesh, nodes, basis)
- Computes shape function gradients at integration points
- Computes Jacobian determinants with quadrature weights
- Part of three-phase cache update pattern

Phase 2 of assembly (Geometry preprocessing):
- Extract element node coordinates
- Evaluate basis function gradients ∇N at each integration point
- Compute Jacobian matrix J and determinant det(J)
- Multiply det(J) × weight → detJ_w for integration
- Transform ∇N from parent to physical space

This is the SECOND of three cache updates called per element:
1. update_element_cache! (DOF mapping)
2. update_geometry_cache! (Jacobian, gradients) ← THIS FILE
3. update_material_cache! (stress, tangent)
2025-11-20 16:56:40 +02:00
Jukka Aho 3da3c486d8 feat(continuum): Add update_element_cache! for DOF mapping
New file: src/domains/continuum/update_element_cache.jl (179 lines)

Features:
- update_element_cache!(element_cache, elem_id, mesh, N, field)
- Updates DOF mapping for element nodes
- Resets K_blocks and f_blocks to zero
- Part of three-phase cache update pattern

Phase 1 of assembly (DOF mapping):
- Extract element connectivity
- Map node IDs to global DOFs
- Store in element_cache.dofs
- Clear previous element's data

Implementation:
- Uses get_dof_mapping! for field-to-DOF conversion
- Handles displacement (3 DOF/node) and other fields
- fill! for zero initialization
- @inline for performance

This is the FIRST of three cache updates called per element:
1. update_element_cache! (DOF mapping) ← THIS FILE
2. update_geometry_cache! (Jacobian, gradients)
3. update_material_cache! (stress, tangent)
2025-11-20 16:56:40 +02:00
Jukka Aho 06973c6f20 feat(continuum): Add concrete types for continuum domain
New file: src/domains/continuum/types.jl

Concrete types defined:
- EmptyState <: AbstractMaterialState (for stateless materials)
- Future: Can add J2PlasticityState, DamageState, etc.

Purpose:
- Centralize material state types
- Separate from abstract interface definitions
- Enable type-stable state management in MaterialStateCache

EmptyState used by LinearElastic material (no history variables).
Plastic materials will have custom state types with fields for
equivalent plastic strain, back stress, etc.
2025-11-20 16:56:40 +02:00
Jukka Aho 1ddc369d56 feat(continuum): Add abstract types for continuum mechanics
New file: src/domains/continuum/abstract.jl

Abstract types defined:
- AbstractContinuumTheory - Supertype for FullThreeD, PlaneStress, etc.
- AbstractKernel - Supertype for ContinuumKernel and future variants
- AbstractMaterialState - Supertype for material state (EmptyState, plasticity, etc.)

Purpose:
- Establish type hierarchy for dispatch
- Document interface expectations
- Enable future extensions (shells, beams, etc.)

These were previously defined in other files, now centralized
for clarity and maintainability.
2025-11-20 16:56:40 +02:00
Jukka Aho 2fb7fd1676 feat(assemblers): Add direct symmetric scatter with zero dispatch
New file: src/assemblers/scatter_blocks_to_triplets_symmetric_direct.jl (124 lines)

Features:
- scatter_blocks_to_triplets_symmetric_direct!(I, J, V, counter, capacity, K_blocks, dofs, N)
- Direct array access bypassing cache indirection
- Returns counter as Int (not Ref{Int})
- Zero dynamic dispatch (verified with @code_llvm)

BREAKTHROUGH OPTIMIZATION:
- Cache struct indirection causes dispatch (cache.I[idx])
- Direct array access enables full optimization (I[idx])
- Result: 18 → 0 dispatch sites, 500K elem/s achieved

Implementation:
- Same algorithm as symmetric version
- Takes raw arrays I, J, V instead of cache
- Counter passed by value, returned as Int
- All operations @inbounds and @inline

Performance impact:
- Eliminated ALL dynamic dispatch in assembly loop
- Key to achieving zero allocations
- Critical for 500K elem/s throughput

This is the PRODUCTION version used in element_based_coo.jl.
Other scatter functions kept for reference/alternative use cases.
2025-11-20 16:56:39 +02:00