Commit Graph

52 Commits

Author SHA1 Message Date
Jukka Aho dffdf01af2 test(continuum): scrub Hex8 validation copy of deprecated \"NEW API\" wording
The stiffness check already targets the shipped COO assembler; drop marketing-style
labels from comments and console banners so failures read like ordinary regressions.
2026-05-09 18:45:53 +03:00
Jukka Aho 0f6924f62f test(continuum): reset tests use GlobalMaterialCache + geometry arity
Material-cache reset coverage should populate stresses through the global cache
API rather than the removed `create_material_state` helper.

- Mirror production signatures for `update_geometry_cache!` / `update_material_cache!`.
2026-05-09 18:45:48 +03:00
Jukka Aho 04dc1df09e test(continuum): thread GlobalMaterialCache through kernel integration check
Manual quadrature comparisons must refresh material data with the same global
state container production assembly uses, and geometry updates no longer take the
kernel object.

- Construct `global_cache` beside the per-IP material workspace.
- Pass `global_cache` into `update_material_cache!` and drop the kernel argument
  from `update_geometry_cache!`.
2026-05-09 18:45:46 +03:00
Jukka Aho 4d29e7816c test(continuum): follow assemble! signature without external material state
COO assembly now keeps persistent material history on the cache’s global store,
so tests should not fabricate a separate `state_old` argument.

- Call `assemble!(cache, assembler, kernel, mesh, u_global, Δt)` in correctness,
  allocation, and two-element coverage paths.
- Clarify comments about zero displacement vs nonzero `u_global`.
2026-05-09 18:45:37 +03:00
Jukka Aho e6a1767f99 test(continuum): align cache-update regression with GlobalMaterialCache API
The three-phase cache exerciser still referenced the retired per-call material
state bag and an older `update_geometry_cache!` arity. Fold everything onto the
shared global cache object and the slimmer geometry updater signature.

- Hoist `BenchmarkTools` to module scope for the `@benchmark` block.
- Drop the duplicate legacy `update_material_cache!` testset; keep the zero-alloc
  path driven by `GlobalMaterialCache`.
2026-05-09 18:45:32 +03:00
Jukka Aho e1d46340db test(continuum): drop unused create_material_state helper
Stateful initialization now flows through `GlobalMaterialCache` construction in
the individual tests, so the placeholder helper only duplicated errors.

- Remove `create_material_state` and its docstring from shared continuum helpers.
2026-05-09 18:45:02 +03:00
Jukka Aho 041e0d519d test(continuum): extend runner with mixed formulations and solves
Wire the continuum suite into the newer kernel families beyond baseline elasticity
assembly: branch coverage for material caching, a brick direct solve, and mixed
u–p / Stokes / HR / Hu–Washizu matvec + solver smoke paths.

- Add `test_material_cache_branches.jl` next to the existing cache-update group.
- Include mixed formulation kernels with companion solves or penalty matvec checks.
2026-05-09 18:44:57 +03:00
Jukka Aho b3b3e6faab test(domains): add coupled thermo-elastic kernel regression 2026-05-09 18:38:39 +03:00
Jukka Aho ea4fc4697e test(domains): add thermo-elastic topic runner 2026-05-09 18:38:39 +03:00
Jukka Aho f2492a792d test(domains): add heat conduction kernel regression 2026-05-09 18:38:39 +03:00
Jukka Aho d97435cc91 test(domains): add heat topic runner 2026-05-09 18:38:39 +03:00
Jukka Aho 0dd167b62f test(domains): add primal Darcy potential kernel tests 2026-05-09 18:38:38 +03:00
Jukka Aho 5ff1536052 test(domains): add mixed RT0 Darcy regression 2026-05-09 18:38:38 +03:00
Jukka Aho 9a83e172f8 test(domains): add Darcy topic runner 2026-05-09 18:38:38 +03:00
Jukka Aho 6e255a83f5 test(domains): add Stokes mixed kernel regression 2026-05-09 18:38:29 +03:00
Jukka Aho fc298ee014 test(domains): add Stokes mixed incompressible solve 2026-05-09 18:38:29 +03:00
Jukka Aho e899ebed6a test(domains): add mixed u–p kernel regression 2026-05-09 18:38:29 +03:00
Jukka Aho 4df002e673 test(domains): add mixed u–p incompressible solve 2026-05-09 18:38:28 +03:00
Jukka Aho 7621a27161 test(domains): add material element lab diagnostics 2026-05-09 18:38:28 +03:00
Jukka Aho 62a05646a0 test(domains): cover material cache trait branches 2026-05-09 18:38:27 +03:00
Jukka Aho 6ccb725409 test(domains): add Hu–Washizu matvec penalty tests 2026-05-09 18:38:25 +03:00
Jukka Aho b36cac09ee test(domains): add Hu–Washizu kernel regression 2026-05-09 18:38:25 +03:00
Jukka Aho 2b44a42e95 test(domains): add HR mixed matvec penalty tests 2026-05-09 18:38:25 +03:00
Jukka Aho 360fd26b21 test(domains): add Hellinger–Reissner kernel regression 2026-05-09 18:38:25 +03:00
Jukka Aho 29403d1948 test(domains): add continuum brick direct/Krylov solves 2026-05-09 18:38:24 +03:00
Jukka Aho 5aed0dfffa test(domains): add approximate Schur diagonal preconditioner tests 2026-05-09 18:38:24 +03:00
Jukka Aho 49fd09b69e test(domains): add brick solver helpers for continuum regressions 2026-05-09 18:38:24 +03:00
Jukka Aho b6ec433e23 chore(test): delete continuum type-stability smoke test
Remove outdated `@inferred` continuum checks tied to retired kernels.

- Drop `test/domains/continuum/test_type_stability.jl`.
2026-05-09 18:26:14 +03:00
Jukka Aho 02c821ca4f chore(test): drop continuum stiffness allocation sweep
Remove obsolete block-allocation tests superseded by assembler IR checks.

- Delete `test/domains/continuum/test_stiffness_block_allocations.jl`.
2026-05-09 18:26:13 +03:00
Jukka Aho 6d70168321 test(continuum): remove unused element creation in hex8 validation test
Remove unused Element creation since connectivity is only used for
reference and element is not actually used in the test.
2025-12-12 23:47:11 +02:00
Jukka Aho 7778ff344a test(continuum): update reset tests for AssemblyMaterialWorkspace API
Update test_reset_functions.jl to use get_stress/get_tangent getters
and relax allocation requirements for reset! function.

- Rename test set from MaterialStateCache to AssemblyMaterialWorkspace
- Update field access to use get_stress/get_tangent getter functions
- Relax allocation test for reset! (not in hot path, NamedTuple overhead acceptable)
- Add missing test_helpers.jl include
2025-12-12 23:46:55 +02:00
Jukka Aho dedc5e093d test(continuum): update kernel tests to use get_tangent getter
Update test_kernel_functions.jl to use get_tangent getter function
instead of direct field access to material_cache.𝔻, matching the
new AssemblyMaterialWorkspace API.
2025-12-12 23:46:32 +02:00
Jukka Aho 3cb9a66b94 test(continuum): update cache tests for new material workspace API
Update test_cache_updates.jl to support both legacy and new
GlobalMaterialCache API with proper allocation testing.

- Rename legacy test set to indicate it uses old API
- Update field access to use get_stress/get_tangent getter functions
- Relax allocation test for legacy API (may have NamedTuple overhead)
- Add new test set for GlobalMaterialCache API
- Add zero-allocation verification using BenchmarkTools
- Test both material_cache.σ/𝔻 access patterns
2025-12-12 23:45:56 +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 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 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 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 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 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 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