Commit Graph

432 Commits

Author SHA1 Message Date
Jukka Aho 92bd0b9704 test(quadrature): add wedge quadrature test
Test file included in test/quadrature/runtests.jl
Tests quadrature rules for wedge elements
2025-12-15 06:39:35 +02:00
Jukka Aho 5bc7965983 test(quadrature): add triangle quadrature test
Test file included in test/quadrature/runtests.jl
Tests quadrature rules for triangular elements
2025-12-15 06:39:31 +02:00
Jukka Aho 7dc48934d6 test(quadrature): add tetrahedra quadrature test
Test file included in test/quadrature/runtests.jl
Tests quadrature rules for tetrahedral elements
2025-12-15 06:39:28 +02:00
Jukka Aho 1e3839bf69 test(quadrature): add tensor product quadrature test
Test file included in test/quadrature/runtests.jl
Tests tensor product quadrature rules
2025-12-15 06:39:21 +02:00
Jukka Aho c082000a5c test(quadrature): add pyramid quadrature test
Test file included in test/quadrature/runtests.jl
Tests quadrature rules for pyramid elements
2025-12-15 06:39:04 +02:00
Jukka Aho 1663e6d59b test(quadrature): add legacy API test
Test file included in test/quadrature/runtests.jl
Tests backward compatibility with legacy quadrature API
2025-12-15 06:38:41 +02:00
Jukka Aho 5c4c9e2224 test(quadrature): add API test
Test file included in test/quadrature/runtests.jl
Tests quadrature API functions and interface
2025-12-15 06:38:05 +02:00
Jukka Aho 26e14723f4 test(quadrature): add accuracy test
Test file included in test/quadrature/runtests.jl
Tests numerical accuracy of quadrature rules
2025-12-15 06:37:26 +02:00
Jukka Aho fc43bd457b test(physics): add strain extraction test
New 137-line test file included in main test/runtests.jl:
- Tests extract_strain() function (displacement gradient → strain tensor)
- Tests extract_strain_rate() function (velocity gradient → strain rate tensor)
- Tests pure extension, shear deformation, and general deformation cases
- Tests quasi-static strain rate from increments
- Validates symmetric tensor properties and engineering shear strain

Ensures strain extraction functions work correctly for continuum mechanics.
2025-12-15 06:37:02 +02:00
Jukka Aho 3376ba15db test(materials): add assembly workspace refactor test
New 294-line test file included in main test/runtests.jl:
- Tests refactored AssemblyMaterialWorkspace with compositional field design
- Tests field structure inference from material traits
- Tests workspace creation with correct field types
- Tests field access (backward compatibility)
- Tests multiphysics support preparation
- Validates zero allocations in workspace operations

Ensures assembly workspace refactoring maintains backward compatibility and performance.
2025-12-15 06:36:54 +02:00
Jukka Aho ac0fc346af test(materials): add cantilever material cache zero allocations test
New 308-line test file included in main test/runtests.jl:
- Tests GlobalMaterialCache with cantilever beam problem
- Verifies ZERO allocations during state access and updates
- Tests cache creation from material traits (automatic)
- Tests time-stepping workflow with zero allocations in hot loop
- Includes performance benchmarks using BenchmarkTools
- Validates material state type inference

Comprehensive performance test ensuring material cache system has zero allocations.
2025-12-15 06:36:46 +02:00
Jukka Aho b7c4f64151 test(materials): add plasticity integration test
New 229-line test file included in main test/runtests.jl:
- Tests PerfectPlasticity material instantiation and traits
- Tests global material cache creation for stateful materials
- Tests direct NamedTuple state manipulation (compositional design)
- Tests cache access and manipulation (set_state!, update_cache!)
- Tests multi-step plasticity simulation workflow
- Tests state variable helpers (get_state_variable, set_state_variable)
- Validates type stability of key operations

Comprehensive integration test ensuring plasticity material works with cache system.
2025-12-15 06:36:30 +02:00
Jukka Aho b5772b141b test(materials): add global material cache test
New 98-line test file included in main test/runtests.jl:
- Tests GlobalMaterialCache construction for stateless and stateful materials
- Tests state access and update operations (get_state, set_state!, update_cache!, reset_cache!)
- Tests state variable helpers (get_state_variable, set_state_variable)
- Tests integration with material traits (create_global_material_cache)
- Validates cache structure and state management for time-dependent materials

Ensures material cache system works correctly for storing state variables at integration points.
2025-12-15 06:36:03 +02:00
Jukka Aho e3527dac93 test(materials): add material traits test
New 99-line test file included in main test/runtests.jl:
- Tests LinearElastic material traits (supported_physics, required_field_types, required_state_variables)
- Validates trait function existence and exports
- Tests helper functions (is_stateful, get_state_variable_types, get_state_variable_symbols)
- Verifies compositional design philosophy for state variables
- Tests physics-to-field-type derivation

Ensures material trait system works correctly for compositional material design.
2025-12-15 06:34:56 +02:00
Jukka Aho 5e1b66cb67 test(materials): add state variables test
New 93-line test file included in main test/runtests.jl:
- Tests AbstractStateVariable type hierarchy
- Validates state_variable_type trait (returns concrete types)
- Validates default_symbol trait (returns symbols like :ε_p, :α, :κ, :d)
- Tests concrete type instantiation (PlasticStrain, Backstress, etc.)
- Tests NamedTuple usage with state variable symbols
- Verifies trait consistency across all state variable types

Ensures state variable system works correctly for material models.
2025-12-15 06:34:44 +02:00
Jukka Aho 6514c025d0 test(fields): add LocalField structure test
Test file included in main test/runtests.jl
Tests LocalField{T,G,R,GR} structure for material evaluation
2025-12-15 06:32:57 +02:00
Jukka Aho b0897a40e3 test(elements): add local field interpolation test
Test file included in main test/runtests.jl
Tests interpolate_local_fields() function for LocalField creation
2025-12-15 06:32:50 +02:00
Jukka Aho c78096fd85 test(element): add test_celement_interpolation test
Test file included in test/element/runtests.jl
2025-12-15 06:32:46 +02:00
Jukka Aho b547a1d668 test(element): add test_celement_creation test
Test file included in test/element/runtests.jl
2025-12-15 06:32:46 +02:00
Jukka Aho 2cebb46340 test(element): add test_celement_type test
Test file included in test/element/runtests.jl
2025-12-15 06:32:45 +02:00
Jukka Aho 8ff03a6505 test(dofs): add field unification test
Test file included in test/dofs/runtests.jl
Tests DOF field specification unification system
2025-12-15 06:32:38 +02:00
Jukka Aho dd7cff1ce5 test(basis): add test_gradient_properties test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:29 +02:00
Jukka Aho f3861b4f84 test(basis): add test_numerical_accuracy test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:29 +02:00
Jukka Aho a3e31dd4b1 test(basis): add test_type_stability test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:29 +02:00
Jukka Aho cba43d24dc test(basis): add test_kronecker_delta test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:29 +02:00
Jukka Aho db3106547c test(basis): add test_all_elements test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:29 +02:00
Jukka Aho 764047cce0 test(basis): add test_interpolation test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:29 +02:00
Jukka Aho a0030d4531 test(basis): add test_derivatives test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:28 +02:00
Jukka Aho 48e1874dff test(basis): add test_svector_returns test
Test file included in test/basis/runtests.jl
2025-12-15 06:32:28 +02:00
Jukka Aho 2f972c1106 test(basis): add partition of unity test
New 31-line test for partition of unity property:
- Tests that sum of basis functions equals 1.0
- Covers Seg2, Tri3, Quad4 elements
- Included in test/basis/runtests.jl
- Validates fundamental basis function property

Ensures basis functions satisfy partition of unity requirement.
2025-12-15 06:32:21 +02:00
Jukka Aho 2a1920a959 test(validation): refactor cantilever test for new DOF-based architecture
Update test_cantilever_regression.jl to use new DOF system, DOFManager,
and proper constraint elimination instead of old Physics struct API.

- Create elements using new @DOFSet and Element{K,P,S} API
- Use DOFManager for DOF allocation and management
- Apply forces using get_node_dofs API instead of NeumannBC
- Apply boundary conditions using constraint elimination (proper method)
- Solve reduced system (K_ff * u_f = f_f) instead of manipulating full matrix
- Reconstruct full solution from reduced solution
- Remove old Physics struct, DirichletBC, NeumannBC usage
- Update step numbering and comments for clarity
2025-12-12 23:50:09 +02:00
Jukka Aho 5feb8c0dfb test: add test suites for new DOF-based architecture
Add test includes for new architecture components: fields, physics,
element interpolation, materials, topology, and validation.

- Add LocalField type test
- Add fields test suite (test_local_field.jl)
- Add physics test suite (test_strain.jl)
- Add element interpolation test suite (test_interpolate_local_fields.jl)
- Add material test suites (state variables, traits, global cache, plasticity, workspace)
- Add topology test suites (segments, triangles, quadrilaterals, entities, etc.)
- Add validation test (test_plasticity_simple.jl)
- Comment out obsolete topology type extraction test
2025-12-12 23:49:41 +02:00
Jukka Aho 2dcadd85e9 test(physics): update tests for new physics category types
Replace tests for old Physics struct with tests for new physics
category types and trait-based dispatch.

- Remove tests for Physics struct, DirichletBC, NeumannBC, Constraint
- Add tests for Elasticity{Dim} and Thermal{Dim} category types
- Add tests for required_field_type trait function
- Test type stability and dispatch behavior
- Verify dimension-dependent field type mapping
2025-12-12 23:49:05 +02: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 ff3c26d2c3 chore: remove obsolete and legacy files
Major cleanup: remove obsolete files that have been replaced or
moved to new locations. Files removed include legacy assembly
implementations, old API files, and deprecated test files.

Removed files:

Assemblers and assembly:
- src/assemblers/nodal_based.jl
- src/assemblers/nodal_cache.jl
- src/assemblers/node_based_coo.jl
- src/assembly/assembly.jl
- src/assembly/element_structures.jl
- src/assembly/framework.jl
- src/assembly/nodal_structures.jl
- src/assembly/problems.jl
- src/element_assembly_structures.jl
- src/nodal_assembly_structures.jl

Legacy API and structure files:
- src/beams/api.jl
- src/formulations/api.jl
- src/gpu_elasticity.jl
- src/io.jl
- src/materials_plasticity.jl
- src/postprocess_utils.jl
- src/preprocess.jl
- src/quadrature.jl
- src/readers.jl
- src/shells/api.jl
- src/trusses/api.jl

Elements and domains:
- src/domains/continuum/assemble_v2.jl
- src/elements/integrate.jl

Quadrature legacy files:
- src/quadrature/gauss_points.jl
- src/quadrature/integration.jl

Test files:
- test/runtests_new.jl
- test/runtests.jl.old
- test/test_problems_elasticity_assemble_3d_seg3.jl
2025-12-12 22:45: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 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