Commit Graph

1422 Commits

Author SHA1 Message Date
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
Jukka Aho 4c0c2c69c3 feat(assemblers): Add symmetric scatter_blocks_to_triplets!
New file: src/assemblers/scatter_blocks_to_triplets_symmetric.jl (92 lines)

Features:
- scatter_blocks_to_triplets_symmetric!(cache, K_blocks, dofs, N)
- Exploits matrix symmetry (only store upper triangle + diagonal)
- Reduces triplet count by ~50%
- Uses cache for I, J, V, counter

Implementation:
- Outer loop: k in 1:N
- Inner loop: l in k:N (only k ≤ l, upper triangle)
- Store both (i,j) and (j,i) entries for off-diagonal
- Store only (i,i) for diagonal

Optimization over general scatter:
- Half the triplets for symmetric matrices
- Lower memory usage
- Faster sparse matrix construction

Original cache-based version before direct scatter optimization.
2025-11-20 16:56:39 +02:00
Jukka Aho aeadbb2fdd feat(assemblers): Add general scatter_blocks_to_triplets!
New file: src/assemblers/scatter_blocks_to_triplets.jl (74 lines)

Features:
- scatter_blocks_to_triplets!(I, J, V, counter, capacity, K_blocks, dofs, N)
- General scatter for unsymmetric matrices
- Stores all N×N blocks as triplets
- Returns updated counter

Implementation:
- Double loop over node pairs (N × N)
- Triple loop over DOF pairs (3 × 3 per block)
- Direct triplet storage: I[idx], J[idx], V[idx]
- Capacity checking with bounds validation

Not currently used (symmetric version preferred), but available
for unsymmetric problems like convection or non-symmetric contact.
2025-11-20 16:56:39 +02:00
Jukka Aho 6bbda53338 feat(assemblers): Add scatter_blocks_to_force! for force vector assembly
New file: src/assemblers/scatter_blocks_to_force.jl (54 lines)

Features:
- scatter_blocks_to_force!(f_global, f_blocks, dofs, N)
- Scatters element force blocks to global force vector
- Handles 3 DOFs per node (displacement field)
- Uses @inbounds and @inline for performance

Implementation:
- Double loop over nodes (N × 3 DOFs)
- Direct vector indexing f_global[dof] += f_i[component]
- Zero allocations, zero dispatch

Part of the direct scatter strategy that achieved zero-allocation
assembly. Critical for 500K elem/s performance.
2025-11-20 16:56:39 +02:00
Jukka Aho 08f940f3db feat(assemblers): Add node-based COO assembly implementation
New file: src/assemblers/node_based_coo.jl

Features:
- assemble! implementation for nodal assembly
- Assembles contributions node-by-node instead of element-by-element
- Uses node_to_elements connectivity
- Accumulates blocks for all elements touching each node

Architecture:
- Outer loop over nodes (not elements)
- Inner loop over elements containing each node
- Natural for contact mechanics (contact is nodal)

Status: Experimental, proof-of-concept implementation.
Not yet optimized like element-based assembly.
2025-11-20 16:56:39 +02:00
Jukka Aho 9c62148525 feat(assemblers): Add NodalCache for node-based assembly
New file: src/assemblers/nodal_cache.jl

Features:
- NodalCache struct with NodeCache
- Node-based assembly pattern (alternative to element-based)
- Includes reset!, extract_system functions
- create_node_cache constructor

Use case:
- Nodal assembly (assemble node-by-node, not element-by-element)
- Experimental architecture for contact mechanics
- Potential for better parallelization and domain decomposition

Status: Framework in place, not yet optimized like COO assembly.
2025-11-20 16:56:39 +02:00
Jukka Aho f223251fc0 feat(assemblers): Add MaterialStateCache for material state management
New file: src/assemblers/material_cache.jl (247 lines)

Features:
- Parametric MaterialStateCache{StateType}
- Stores stress tensors (σ)
- Stores tangent modulus tensors (𝔻)
- Stores material state history (state, state_new)
- update_material_cache! function

State management:
- EmptyState for stateless materials (LinearElastic)
- Custom state types for plasticity (J2PlasticityState, etc.)
- State evolution tracked across load increments

Type parameter:
- StateType: Material state type (EmptyState, J2PlasticityState, etc.)
- Enables type-stable state access

Also includes ImmutableMaterialStateCache for read-only views
with @inline accessor functions.
2025-11-20 16:56:38 +02:00
Jukka Aho 757e288bf2 feat(assemblers): Add GeometryCache with zero-allocation updates
New file: src/assemblers/geometry_cache.jl (239 lines)

Features:
- GeometryCache for mutable geometry data
- ImmutableGeometryCache for read-only views
- Stores shape function gradients (∇N_data)
- Stores Jacobian determinants with quadrature weights (detJ_w)
- update_geometry_cache! with manual tuple unrolling

Critical optimization:
- Manual tuple construction instead of ntuple with closure
- Eliminates 112 bytes allocation per element
- Key to achieving zero allocations (1300 → 0 allocs)

Code pattern (line ~193):
  X_tuple = (mesh.nodes[nodes[1]], mesh.nodes[nodes[2]], ...)
  # NOT: X_tuple = ntuple(i -> mesh.nodes[nodes[i]], N)
  # Closure captures variables → heap allocation!

Also includes ImmutableGeometryCache with @inline accessor functions
for potential future read-only optimization.
2025-11-20 16:56:38 +02:00
Jukka Aho ef98580eaf feat(assemblers): Add ElementCache for element-level data storage
New file: src/assemblers/element_cache.jl

Features:
- Parametric struct ElementCache{Topo, Basis, IPs}
- Stores element stiffness blocks (K_blocks)
- Stores element force blocks (f_blocks)
- Stores DOF mapping (dofs)
- create_element_cache constructor

Type parameters:
- Topo: Element topology type (Tet4, Hex8, etc.)
- Basis: Basis function type (Lagrange{Tet4,1}, etc.)
- IPs: Integration points tuple type

This cache is reused across all elements, updated once per element
in the assembly loop. Part of three-phase cache update pattern.
2025-11-20 16:56:38 +02:00
Jukka Aho b5ad4728cf feat(assemblers): Add CSC cache for pre-allocated sparse assembly
New file: src/assemblers/csc_cache.jl

Features:
- CSCCache with pre-allocated sparse matrix structure
- Faster than COO for fixed sparsity patterns
- Includes reset!, extract_system functions
- Uses build_sparsity_pattern for initialization

Use case:
- Problems with known, unchanging sparsity pattern
- Faster assembly than COO (no sorting overhead)
- Lower memory usage (no duplicate entries)
2025-11-20 16:56:38 +02:00
Jukka Aho eeecf72656 feat(assemblers): Add parametric COOCache for zero-allocation assembly
New file: src/assemblers/coo_cache.jl (184 lines)

Features:
- Parametric struct COOCache{EC<:ElementCache, MC<:MaterialStateCache}
- Eliminates type instability from cache field accesses
- Stores triplets (I, J, V) for sparse matrix construction
- Includes reset! and extract_system functions

Performance impact:
- Enables zero allocations in assembly loop
- Required for achieving 500K elem/s throughput
- Critical optimization for type stability

Documentation includes:
- COO format explanation
- Performance characteristics
- Use cases and trade-offs
2025-11-20 16:56:38 +02:00
Jukka Aho ae144f93fb test(continuum): Update test suite includes for new architecture
Removed old test files:
- test_kernel_allocations.jl (deleted)

Added new test files:
- test_dofs_per_node.jl - DOF mapping tests
- test_dof_mapping.jl - Field to DOF mapping
- test_helpers.jl - Utility function tests
- test_kernel_functions.jl - Kernel computation tests
- test_reset_functions.jl - Cache reset tests
- test_cache_updates.jl - Three-phase cache update tests
- test_compute_block.jl - Block computation tests
- test_full_assembly.jl - End-to-end assembly tests
- test_validation_hex8.jl - Hex8 element validation

Test suite restructured to match new cache architecture.
2025-11-20 16:56:38 +02:00
Jukka Aho ea5ae07a83 refactor(mesh): Add @inline to mesh size validation
- Added @inline to validate_mesh_size function
- Called during mesh generation/import
- Minor performance optimization
2025-11-20 16:56:37 +02:00
Jukka Aho bb3c3c0680 refactor(materials): Add @inline to PerfectPlasticity functions
- Added @inline to is_finite_strain, has_state
- Trait functions called in assembly loops
- Performance optimization for plastic materials
2025-11-20 16:56:37 +02:00
Jukka Aho 55d09eab3c refactor(materials): Add @inline to LinearElastic functions
- Added @inline to is_finite_strain, has_state trait functions
- Added @inline to compute_stress (called per integration point)
- Critical path optimizations for assembly performance
2025-11-20 16:56:37 +02:00
Jukka Aho 43276cf449 refactor(materials): Add @inline to FiniteStrainPlasticity trait functions
- Added @inline to is_finite_strain, has_state
- Trait functions called frequently during assembly
- Part of performance optimization
2025-11-20 16:56:37 +02:00
Jukka Aho b468fc885d refactor(materials): Add @inline to AbstractMaterial API functions
- Added @inline to is_finite_strain, has_state
- These trait functions are called in hot paths
- Part of selective inlining strategy
2025-11-20 16:56:37 +02:00
Jukka Aho 3227484aef feat(fields): Add DOF mapping and field extraction functions
New functions:
- get_dof_mapping!(dofs, node_ids, field) - maps nodes to global DOFs
- get_field(field) - returns field object from various inputs

Features:
- Handles 1D, 2D, 3D displacement fields
- Supports temperature fields
- Validates node IDs are positive integers
- Added @inline for performance (called per element)

These functions support the new cache update architecture.
2025-11-20 16:56:36 +02:00
Jukka Aho fbb40a21f6 refactor(continuum): Add @inline to compute_block_at_point
- Added @inline annotation for hot path function
- Called once per integration point per element pair
- Critical for achieving 484K elem/s throughput
- Part of selective inlining strategy (97% of max performance)
2025-11-20 16:56:36 +02:00
Jukka Aho dd468a412e refactor(continuum): Add @inline annotations to formulation functions
- Added @inline to dim, strain_size, stress_size
- These are called frequently in assembly loops
- Part of selective inlining strategy for performance
2025-11-20 16:56:36 +02:00
Jukka Aho 39b51716cd refactor(assemblers): Add selective @inline for optimal performance
- Added @inline to compute_block_at_point (hot path, called per integration point)
- Added @inline to helper tensor operations
- Removed @inline from orchestration functions (compute_block, assemble_element!)
- Result: 484K elem/s (97% of max) with 86% less code complexity

Performance analysis:
- Full inline: 500K elem/s, 1448 assembly lines, 111 register spills
- Partial inline: 484K elem/s, 196 assembly lines, 15 register spills
- Optimal balance of performance vs maintainability
2025-11-20 16:56:36 +02:00
Jukka Aho cb8e9ef977 perf(assemblers): Implement zero-allocation COO assembly with direct scatter
Major changes:
- Replaced cache-based scatter with direct array scatter
- Extract counter once before loop, write once after loop
- Use scatter_blocks_to_triplets_symmetric_direct! for zero dispatch
- Use scatter_blocks_to_force! for force vector assembly
- Removed Ref{Int} indirection in counter management

Performance improvements:
- Zero allocations in assembly loop (verified with benchmarks)
- Zero dynamic dispatch (verified with @code_llvm)
- 500K elements/second throughput (5× baseline improvement)

Three-phase cache update pattern:
- update_element_cache! for DOF mapping
- update_geometry_cache! for Jacobian and gradients
- update_material_cache! for stress and tangent modulus
2025-11-20 16:56:36 +02:00
Jukka Aho be8904cff5 refactor(assemblers): Update cache includes and remove old definitions
- Added includes for coo_cache.jl, csc_cache.jl, nodal_cache.jl
- Removed old COOCache, CSCCache, NodalCache definitions (now in separate files)
- Removed old ElementCache, NodeCache definitions (moved to element_cache.jl)
- Kept only high-level cache coordination logic
2025-11-20 16:56:36 +02:00
Jukka Aho a9dcf5b714 refactor(assemblers): Remove unused abstract types
- Removed AbstractAssemblerCache (moved to caches.jl)
- Removed ElementCache, NodeCache abstract types (now concrete in element_cache.jl)
- Kept only AbstractAssembler, AbstractKernel, and assembler style types
- Cleanup for new cache architecture
2025-11-20 16:56:35 +02:00
Jukka Aho 82b9d980e3 refactor(core): Reorganize includes for new cache architecture
Changes to continuum domain:
- Added includes for abstract.jl and types.jl (new files)
- Replaced integration.jl with three update_*_cache.jl files
- Removed assemble.jl include

Changes to assemblers:
- Added includes for element_cache.jl, geometry_cache.jl, material_cache.jl
- Added exports for GeometryCache, MaterialStateCache types
- Added exports for update functions: update_geometry_cache!, update_element_cache!, update_material_cache!

Changes to fields API:
- Added exports for get_dof_mapping!, get_field functions

This restructuring separates cache management into dedicated modules
and implements the three-phase assembly pattern.
2025-11-20 16:56:35 +02:00
Jukka Aho c7276a93d7 deps: Add BenchmarkTools to test dependencies
- Added BenchmarkTools to [extras] section
- Added BenchmarkTools to test target
- Required for performance benchmarking of assembly functions
2025-11-20 16:56:35 +02:00
Jukka Aho ede78a705d feat(continuum): Implement material-independent finite strain kernel
- Implement compute_finite_strain_kernel! for generic material integration
- Support MaterialBehavior trait dispatch (Stateless/Stateful, StrainDependent)
- Compute deformation gradient F from displacement gradients
- Compute Green-Lagrange strain E from deformation gradient
- Call material-specific compute_stress! with strain measure
- Transform Piola-Kirchhoff stress to Cauchy stress
- Support all continuum theory types (3D, PlaneStress, PlaneStrain, Axisymmetric)
- Implement zero-allocation design with pre-allocated buffers
- Document finite strain kinematics and stress transformations
- 199 lines of generic finite strain kernel implementation
2025-11-19 12:01:34 +02:00
Jukka Aho 406889833c test(validation): Add cantilever beam regression test
- Implement full 3D cantilever beam FEM validation
- Test LinearElastic material with known analytical solution
- Verify tip displacement against reference value
- Test assembly pipeline from mesh to solution
- Include boundary conditions (fixed end, tip load)
- Validate solver convergence and accuracy
- Document expected displacement and tolerance
- Serve as integration test for complete FEM workflow
- 359 lines of end-to-end validation test
2025-11-19 11:48:12 +02:00
Jukka Aho 084d563fce test(continuum): Add zero-allocation stiffness assembly tests
- Test compute_stiffness_block! allocations for all materials
- Verify LinearElastic stiffness assembly is allocation-free
- Verify NeoHookean stiffness assembly is allocation-free
- Verify PerfectPlasticity stiffness assembly is allocation-free
- Test all continuum theory types (3D, PlaneStress, PlaneStrain, Axisymmetric)
- Use @test @allocations macro for precise allocation tracking
- Validate material tangent computation maintains zero allocations
- 260 lines of stiffness assembly allocation tests
2025-11-19 11:48:12 +02:00
Jukka Aho 74d3079130 test(continuum): Add zero-allocation kernel tests
- Test compute_stress! allocations for all material types
- Verify LinearElastic kernel is allocation-free
- Verify NeoHookean kernel is allocation-free
- Verify PerfectPlasticity kernel is allocation-free
- Test all continuum theory types (3D, PlaneStress, PlaneStrain, Axisymmetric)
- Use @test @allocations macro for precise allocation tracking
- Ensure material trait dispatch maintains zero allocations
- 257 lines of allocation verification tests
2025-11-19 11:48:12 +02:00
Jukka Aho 65ba108125 feat(plates): Implement complete DKT plate element
- Implement Discrete Kirchhoff Triangle (DKT) plate bending element
- Define DKTPlate formulation type with material and thickness parameters
- Implement assemble_stiffness! for plate bending problems
- Compute element stiffness matrix using DKT basis functions
- Support transverse displacement (w) and rotation (θx, θy) DOFs
- Include numerical integration over triangular domain
- Implement element force vector assembly
- Support distributed and point loads on plate surface
- Document DKT theory and implementation details
- 645 lines of complete DKT plate element implementation
2025-11-19 11:40:27 +02:00
Jukka Aho ee7554f1a4 feat(continuum): Implement v2 assembly with material trait dispatch
- Implement assemble_stiffness! with MaterialBehavior trait dispatch
- Support StatelessStrainDependent materials (LinearElastic, NeoHookean)
- Support StatefulStrainDependent materials (PerfectPlasticity)
- Implement zero-allocation element stiffness assembly
- Use generic material kernel integration
- Replace material-specific assembly functions with unified implementation
- Include integration point loops with Jacobian computation
- Support all continuum theory types (3D, PlaneStress, PlaneStrain, Axisymmetric)
- 522 lines of generic continuum assembly implementation
2025-11-19 11:40:27 +02:00
Jukka Aho 2e31f22240 refactor(assembly): Implement nodal-level assembly data structures
- Define NodalAssembly type for nodal force assembly
- Implement direct nodal force vector accumulation
- Support pre-allocated buffers for zero-allocation assembly
- Provide nodal-to-global DOF mapping
- Include nodal load and constraint data structures
- Document nodal assembly workflow for point loads and BCs
- 234 lines of nodal assembly infrastructure
2025-11-19 11:34:22 +02:00
Jukka Aho 1ce6daddc6 refactor(assembly): Implement element-level assembly data structures
- Define ElementAssembly type for element matrix/vector assembly
- Implement local stiffness matrix and force vector containers
- Support pre-allocated buffers for zero-allocation assembly
- Provide DOF connectivity and element-to-global mapping
- Include element-level integration point data structures
- Document element assembly workflow and memory layout
- 341 lines of element assembly infrastructure
2025-11-19 11:34:22 +02:00
Jukka Aho 2ec68a5107 refactor(legacy): Preserve legacy problem assembly interface
- Move legacy Problem-based assembly to src/legacy/
- Maintain backward compatibility for existing code
- Document deprecation path to new Physics-based API
- Preserve assembly_problem!, solve_problem! functions
- Support legacy element and boundary condition patterns
- Include migration guide in deprecation warnings
- 478 lines of legacy assembly implementation
2025-11-19 11:27:14 +02:00
Jukka Aho 931d5414fb refactor(assembly): Consolidate assembly framework infrastructure
- Define common assembly patterns for all element types
- Implement element-level and global assembly helpers
- Support both sparse and dense assembly strategies
- Provide integration point loop abstractions
- Include DOF mapping and scatter operations
- Document assembly workflow for structural elements
- 201 lines of framework infrastructure
2025-11-19 11:27:14 +02:00
Jukka Aho 1740de62fd feat(plates): Implement DKT plate element basis functions
- Implement Discrete Kirchhoff Triangle shape functions
- Compute rotation field interpolation with C1 continuity
- Calculate bending strain-displacement matrix
- Support transverse displacement and rotation DOFs
- Include shape function derivatives for plate bending
- Implement discrete Kirchhoff constraints at element level
- 416 lines with comprehensive DKT formulation
2025-11-19 11:27:14 +02:00
Jukka Aho 05732d02b0 refactor(plates): Define plate element API interface
- Define AbstractPlateElement abstract type hierarchy
- Implement element assembly interface for plate structures
- Export DKT (Discrete Kirchhoff Triangle) plate element
- Document thin plate theory (Kirchhoff assumptions)
- Support bending and transverse shear
- Include rotation DOF handling for plate kinematics
- 188 lines of API definitions and exports
2025-11-19 11:27:14 +02:00
Jukka Aho 25624a3be4 refactor(shells): Define shell element API interface
- Define AbstractShellElement abstract type hierarchy
- Implement element assembly interface for shell structures
- Export shell formulation and element types
- Document thin shell theory (Kirchhoff-Love, Reissner-Mindlin)
- Support membrane and bending coupling
- Include rotation DOF handling for shell kinematics
- 100 lines of API definitions and exports
2025-11-19 11:27:14 +02:00
Jukka Aho c747844914 refactor(beams): Define beam element API interface
- Define AbstractBeamElement abstract type hierarchy
- Implement element assembly interface for beam structures
- Export beam formulation and element types
- Document Euler-Bernoulli and Timoshenko beam theories
- Support 2D and 3D beam elements
- Include rotation DOF handling for beam kinematics
- 98 lines of API definitions and exports
2025-11-19 11:27:13 +02:00
Jukka Aho 7c0ad5f4a2 refactor(trusses): Define truss element API interface
- Define AbstractTrussElement abstract type hierarchy
- Implement element assembly interface for truss structures
- Export truss formulation and element types
- Document 1D structural element API patterns
- Support both geometric and material nonlinearity
- 79 lines of API definitions and exports
2025-11-19 11:27:13 +02:00
Jukka Aho 555c506f17 test(continuum): Add automated allocation and trait tests
Created test/domains/continuum/runtests.jl:
- Test material trait system (6 tests)
  * LinearElastic: StatelessConstantTangent, !needs_deformation, !needs_state
  * NeoHookean: StatelessStrainDependent, needs_deformation, !needs_state
  * PerfectPlasticity: StatefulStrainDependent, needs_deformation, needs_state
- Include zero-allocation tests (27 tests)
  * Verify 0 bytes for LinearElastic integration
  * Verify 0 bytes for NeoHookean integration
  * Test full assembly loop allocations
- Include type stability tests (15 tests)
  * Verify PreparedElement type stability
  * Verify compute_block! type stability
  * Verify trait dispatch type stability

Updated test/runtests.jl:
- Include test/domains/continuum/runtests.jl in main test suite
- Automatically run on every test invocation
- Ensures zero-allocation property maintained
- Ensures material traits work correctly

Updated test/domains/continuum/test_type_stability.jl:
- Adapt to new generic integration API
- Test prepare_element!, compute_block!, compute_all_blocks!
- Verify type stability for both LinearElastic and NeoHookean
- Test material trait helper functions

Test Results:
- 57 tests passing (all tests)
- 33 continuum domain tests (including new trait tests)
- Zero-allocation verified for LinearElastic AND NeoHookean
- Type stability confirmed for generic integration
- Backward compatibility maintained (cantilever test passes)

Why: Automated tests ensure the refactoring maintains performance properties
(zero allocations, type stability) while adding new functionality (traits).
2025-11-19 10:03:46 +02:00
Jukka Aho ac2a483d26 refactor(materials): Export material behavior trait symbols
- Export MaterialBehavior abstract type
- Export StatelessConstantTangent, StatelessStrainDependent, StatefulStrainDependent
- Export material_behavior, needs_deformation, needs_state functions
- Enables user code to query material requirements at runtime
- 3 lines of exports added after existing material exports
2025-11-19 10:03:45 +02:00
Jukka Aho 66cc937d8c refactor(continuum): Replace material-specific integration with generic functions
BEFORE:
- Separate compute_block! for LinearElastic (lines 152-179)
- Separate compute_block! for NeoHookean (lines 198-236)
- Separate compute_all_blocks! for each material
- Adding 100 materials = 100 copies of integration code

AFTER:
- Single generic compute_block! for ALL materials (lines 310-351)
- Single generic compute_all_blocks! for ALL materials (lines 394-406)
- Trait-based dispatch via material_behavior()
- Constant tangent optimization preserved (lines 324-332)
- Zero code duplication regardless of material count

Implementation:
- Add compute_tangent_at_point() for StatelessConstantTangent
- Add compute_tangent_at_point() for StatelessStrainDependent
- Add compute_tangent_at_point() for StatefulStrainDependent
- Generic compute_block! dispatches on material_behavior()
- Generic compute_all_blocks! calls generic compute_block!
- Type-stable at compile time via trait dispatch

Performance:
- LinearElastic: tangent computed once (O(1) material queries)
- NeoHookean: tangent at each IP (O(NIP) queries)
- PerfectPlasticity: tangent + state at each IP (O(NIP) queries)

Benefits:
- Scalable to arbitrary number of materials
- Zero allocations maintained (verified by tests)
- Type stability maintained (verified by tests)
- Single source of truth for integration logic
2025-11-19 10:03:45 +02:00
Jukka Aho 7e1739a987 feat(materials): Declare PerfectPlasticity as StatefulStrainDependent
- Add material_behavior(::PerfectPlasticity) = StatefulStrainDependent()
- Enables generic integration with state variable handling
- Requires displacement field and state for tangent computation
- Single line trait declaration, zero code duplication
2025-11-19 10:03:45 +02:00
Jukka Aho 589c80dce5 feat(materials): Declare NeoHookean as StatelessStrainDependent
- Add material_behavior(::NeoHookean) = StatelessStrainDependent()
- Enables generic integration to compute tangent at each IP
- Requires displacement field for strain-dependent tangent
- Single line trait declaration, zero code duplication
2025-11-19 10:03:45 +02:00
Jukka Aho c84ad4e228 feat(materials): Declare LinearElastic as StatelessConstantTangent
- Add material_behavior(::LinearElastic) = StatelessConstantTangent()
- Enables generic integration to optimize constant tangent case
- Single line trait declaration, zero code duplication
- Integration computes tangent once and reuses for all IPs
2025-11-19 10:03:45 +02:00