Commit Graph

55 Commits

Author SHA1 Message Date
Jukka Aho 955b59c839 feat(materials): add element-wise scalar diffusion coefficient cache
Support piecewise-constant per-element κ fields for nonlinear diffusion assembly.

- Implement `ElementWiseScalarDiffusion` behavior trait and evaluation hooks.
2026-05-09 18:34:41 +03:00
Jukka Aho cd60d89407 feat(materials): add hydraulic conductivity for Darcy flow
Wire `HydraulicConductivity` into potential-based Darcy kernels.

- Provide permeability-driven flux linearizations with documented traits.
2026-05-09 18:34:40 +03:00
Jukka Aho 5b99a7a427 feat(materials): add moisture diffusion conductivity tag
Introduce `MoistureDiffusivity` for scalar moisture transport kernels.

- Declare physics traits and constant diffusion tensors/scalars as appropriate.
2026-05-09 18:34:40 +03:00
Jukka Aho ac3675cd3c feat(materials): add thermal conductivity material law
Provide Fourier heat flux linear map with `HeatKernel` trait hooks.

- Implement `HeatConductivity` constants and stress/tangent analogues for diffusion.
2026-05-09 18:34:40 +03:00
Jukka Aho 9d533353ee feat(materials): add eigenstrain-augmented linear elasticity
Support prescribed eigenstrain tensors updated outside `compute_stress`.

- Add `LinearElasticWithEigenstrain` and matching state-variable declarations.
2026-05-09 18:34:40 +03:00
Jukka Aho 13b6c67597 feat(materials): add Norton–Bailey creep coupled to elasticity
Introduce explicit creep strain increment updates with elastic tangent returns.

- Wire `CreepStrain` state requirements and trait classification.
2026-05-09 18:34:40 +03:00
Jukka Aho 5adc180f2f feat(materials): add Chaboche nonlinear kinematic hardening J2 model
Extend J₂ plasticity with Armstrong–Frederick backstress slots using compositional state tags.

- Add `ChabocheJ2Plasticity` plus `compute_stress` integration.
2026-05-09 18:34:40 +03:00
Jukka Aho c19b0aaf00 feat(materials): add scalar damage wrapper on linear elasticity
Provide staggered scalar damage evolution with explicit tangent omissions documented in traits.

- Implement `ScalarDamageLinearElastic` stress/tangent updates.
2026-05-09 18:34:39 +03:00
Jukka Aho ccc2f113b2 feat(materials): add St. Venant–Kirchhoff J2 finite-strain plasticity
Combine Green–Lagrange kinematics with J₂ return mapping on the elastic predictor.

- Override `continuum_kinematics` and declare required IP state variables.
2026-05-09 18:33:56 +03:00
Jukka Aho ea506e2b14 feat(materials): add J2 isotropic hardening plasticity
Introduce classic radial-return J₂ plasticity with NamedTuple IP state.

- Wire traits, consistent tangent assembly, and `compute_stress` updates.
2026-05-09 18:33:56 +03:00
Jukka Aho cf5a29aed3 feat(materials): add Mooney–Rivlin, Yeoh, and Gent hyperelastic laws
Provide additional `StatelessStrainDependent` models alongside Neo-Hookean.

- Implement strain-energy densities and `compute_stress` bridges for common hyperelastic forms.
2026-05-09 18:33:56 +03:00
Jukka Aho dff07f812e feat(materials): add orthotropic linear elasticity model
Implement rotation-aware orthotropic Hooke law with trait hooks for continuum assembly.

- Add `OrthotropicLinearElastic` plus stress/tangent evaluation utilities.
2026-05-09 18:33:56 +03:00
Jukka Aho b93faf8624 feat(materials): add GlobalMaterialCache and material_state_type
Implement the NamedTuple-backed integration-point workspace used across kernels,
including zero-state construction, getters/setters, and trait-driven sizing.

- Introduce `GlobalMaterialCache{StateType}` with paired current/old IP state matrices.
- Wire `material_state_type`, `create_global_material_cache`, and helpers that map
  `required_state_variables` into concrete state tuples.
2026-05-09 18:33:08 +03:00
Jukka Aho 06eb9864a7 feat(materials): add continuum kinematics trait tags
Introduce `SmallStrainKinematics` vs `GreenLagrangeKinematics` hooks so
`update_material_cache!` can pick the strain measure per material.

- Define `AbstractContinuumKinematics`, concrete tags, and default
  `continuum_kinematics(::AbstractMaterial)` dispatch.
2026-05-09 18:32:40 +03:00
Jukka Aho ec8efd52dd feat(materials): add symmetric fourth-order identity helper
Provide the Lamé-style symmetric identity tensor builder shared by elastoplastic
material implementations.

- Add `symmetric_identity_tensor()` returning `SymmetricTensor{4,3}` with SPDX header.
2026-05-09 18:32:29 +03:00
Jukka Aho 561fcfbcd0 refactor(materials): drop Type-instance forwarding for state traits
Remove the `required_state_variables(::Type{<:AbstractMaterial})` shim that
instantiated materials just to query traits; callers should pass instances or
specialize on concrete types directly.

- Delete the default `required_state_variables(::Type{T}) = …` definition from
  `traits.jl`.
2026-05-09 17:36:16 +03:00
Jukka Aho bc82a60228 feat(materials): extend compositional state-variable registry
Add typed slots for damage equivalent strain, eigenstrain, creep strain, and
indexed Chaboche backstress components so advanced models can declare IP state
without ad hoc symbols.

- Define `DamageEquivalentStrain`, `Eigenstrain`, `CreepStrain`, and
  `ChabocheAlpha{N}` with `state_variable_type` / `default_symbol` hooks.
2026-05-09 17:36:07 +03:00
Jukka Aho 98d08b6bc9 refactor(materials): dedupe PerfectPlasticity fourth-order helper
Stop defining `symmetric_identity_tensor` inside `perfect_plasticity.jl` now
that `materials/symmetric_fourth_identity.jl` provides the shared definition.

- Remove `include(\"abstract_material.jl\")`.
- Delete the local `symmetric_identity_tensor` implementation (call sites keep
  resolving against the earlier include in `JuliaFEM.jl`).
2026-05-09 17:35:41 +03:00
Jukka Aho 14f3baf24e feat(materials): wire NeoHookean traits and NamedTuple stress dispatch
Expose physics/state-variable traits for hyperelastic assembly and accept
`NamedTuple` IP states alongside `nothing` while sharing one implementation.

- Drop the stale `abstract_material.jl` include.
- Declare `supported_physics` / `required_state_variables` for 3D elasticity.
- Factor `_compute_stress_neo_hookean` and add a `compute_stress` path for
  `state_old::NamedTuple`.
- Normalize `where {T}` clauses on public stress APIs.
2026-05-09 17:35:22 +03:00
Jukka Aho 5d8a821be5 refactor(materials): drop LinearElastic abstract include and state_type
`AbstractElasticMaterial` already comes from `materials/api.jl`, and IP state
is inferred via `required_state_variables`, so drop the stale include and
`state_type` hook.

- Remove `include(\"abstract_material.jl\")` and redundant trait comments.
- Delete `state_type(::Type{LinearElastic}) = EmptyState`.
2026-05-09 17:34:38 +03:00
Jukka Aho 1482fe1b5e docs(materials): expand trait docs and align SPDX header
Replace the legacy banner with SPDX lines and document how each
`MaterialBehavior` maps to assembly and `GlobalMaterialCache`, dropping the
unused `AbstractMaterialState` / `state_type` surface in favor of
`material_state_type` NamedTuples.

- Switch the file banner to `SPDX-FileCopyrightText` /
  `SPDX-License-Identifier: MIT`.
- Remove `AbstractMaterialState`, `EmptyState`, and `state_type`; point readers
  at `material_state_type` / `required_state_variables`.
- Enlarge `StatelessConstantTangent`, `StatelessStrainDependent`, and
  `StatefulStrainDependent` docstrings with representative models, tangent
  caveats, and explicit coverage gaps.
2026-05-09 17:33:27 +03:00
Jukka Aho a31ff772ba chore(materials): remove superseded material_cache.jl
Delete the older compositional cache draft now replaced by
`global_material_cache.jl` + assembler-local workspaces.

- Drop `src/materials/material_cache.jl`.
2026-05-09 17:26:40 +03:00
Jukka Aho 580b566c61 chore(materials): delete unfinished finite-strain plasticity prototype
Remove the unused multiplicative-decomposition J2 sketch that was never wired
into `JuliaFEM.jl` includes.

- Drop `src/materials/finite_strain_plasticity.jl`.
2026-05-09 17:26:31 +03:00
Jukka Aho da5eea0586 chore(materials): remove duplicate abstract material module
Delete the stale `AbstractMaterial` hierarchy file that duplicated the trait
surface now defined alongside concrete models.

- Drop `src/materials/abstract_material.jl` (unused include target).
2026-05-09 17:25:18 +03:00
Jukka Aho d1fb022fcc feat(materials): add material trait system foundation
New 88-line material trait system:
- supported_physics(): returns tuple of supported physics types
- required_field_types(): returns tuple of required field types
- required_state_variables(): returns tuple of state variable types
- Type-level dispatch support for @generated functions
- Extensible trait system for material implementations
- Already integrated in JuliaFEM.jl (line 430)

Provides foundation for compositional material trait system.
2025-12-15 06:17:34 +02:00
Jukka Aho e8c832ac6e feat(materials): add compositional state variable system
New 91-line state variable trait system:
- AbstractStateVariable: base type for state variables
- state_variable_type(), default_symbol(): state variable traits
- PlasticStrain, Backstress, EquivalentPlasticStrain: example implementations
- Compositional design: state variables are independent building blocks
- Already integrated in JuliaFEM.jl (line 425)

Provides extensible state variable system for material state management.
2025-12-15 06:17:30 +02:00
Jukka Aho 56d4a5ae70 feat(materials): add global material cache for state variables
New 362-line material cache system:
- GlobalMaterialCache{StateType}: stores state variables at all IPs/elements
- material_state_type(): infer state NamedTuple type from material traits
- create_global_material_cache(): factory function with automatic type inference
- create_zero_state(): zero-initialize state NamedTuples
- Supports stateless (empty NamedTuple) and stateful materials
- Type-stable NamedTuple-based storage
- Zero-allocation state updates (functional style)
- Already integrated in JuliaFEM.jl (line 437)

Provides persistent state storage for time-stepping and material state management.
2025-12-15 06:16:16 +02:00
Jukka Aho e293e74eae feat(materials): add material field trait system
New 140-line material field trait system:
- required_material_fields(): define fields required by physics (Elasticity, Thermal)
- material_field_type(): infer field NamedTuple type from material's supported physics
- compose_field_types(): compose multiple NamedTuple types for multi-physics
- Supports Elasticity (σ, 𝔻) and Thermal (q, k) physics
- Type-stable field type inference
- Already integrated in JuliaFEM.jl (line 431)

Provides compositional field design for material-physics coupling.
2025-12-15 06:15:49 +02:00
Jukka Aho d2031036d9 refactor(materials): streamline perfect plasticity documentation
Removed verbose documentation sections:
- Removed extensive theory documentation (yield function, flow rule, hardening law, consistency condition)
- Removed detailed algorithm step-by-step explanations (radial return mapping)
- Removed type hierarchy, construction examples, and derived properties
- Removed performance notes and timing information
- Removed detailed function documentation with algorithm steps

Simplified docstrings to essential information about material parameters and function signatures.
2025-12-15 03:18:27 +02:00
Jukka Aho a682e964b4 refactor(materials): streamline Neo-Hookean documentation
Removed verbose documentation sections:
- Removed detailed theory explanations and strain energy formulas from module docstring
- Removed type hierarchy, properties, and construction examples
- Removed detailed function documentation with usage examples
- Removed performance notes and automatic differentiation explanations
- Removed stress conversion formulas and notes

Simplified docstrings to essential formulas (strain energy, stress computation) and function signatures.
2025-12-15 03:18:17 +02:00
Jukka Aho 8b1bc18124 refactor(materials): streamline linear elastic documentation
Removed verbose documentation sections:
- Removed detailed theory explanations and formulas from module docstring
- Removed type hierarchy and properties sections
- Removed usage examples from function docstrings
- Removed performance notes and implementation details
- Simplified docstrings to essential formulas (Hooke's law, elasticity tensor)

Kept core mathematical formulas and function signatures.
2025-12-15 03:18:07 +02:00
Jukka Aho 1a8927c8f6 refactor(materials): streamline finite strain plasticity documentation
Removed verbose documentation sections:
- Removed detailed theory references (Simo & Hughes)
- Removed algorithm step-by-step explanations
- Removed performance notes and timing information
- Removed detailed field descriptions and invariants
- Simplified docstrings to essential information about fields and function signatures

Kept core information about multiplicative decomposition and material parameters.
2025-12-15 03:17:57 +02:00
Jukka Aho a6d77d4705 refactor(materials): streamline API documentation by removing verbose sections
Removed extensive documentation from material API docstrings:
- Removed detailed interface requirements sections
- Removed type hierarchy explanations
- Removed design philosophy sections
- Removed usage examples and 'See Also' references
- Kept only essential type and function descriptions

This simplifies the API documentation while maintaining core information
about material types and their behavior traits.
2025-12-15 03:17:44 +02:00
Jukka Aho 04b7eff2a2 refactor(materials): migrate PerfectPlasticity to compositional state design
Replace monolithic PlasticityState struct with compositional NamedTuple
state system and add new material trait system support.

- Remove PlasticityState struct (now using NamedTuple composition)
- Add supported_physics trait (Elasticity{3})
- Add required_state_variables trait (PlasticStrain, Backstress, EquivalentPlasticStrain)
- Change compute_stress to use NamedTuple for state_old and state_new
- Use get() with defaults for state extraction (handles empty initial state)
- Update state creation to use NamedTuple syntax (ε_p, α, κ)
- Remove state_type trait (replaced by required_state_variables)
2025-12-12 23:44:26 +02:00
Jukka Aho 6f0dd71d2e refactor(materials): update LinearElastic for new trait system and compositional state
Update LinearElastic to support new material trait system and
compositional state design with NamedTuple instead of Nothing.

- Add supported_physics trait (Elasticity{3})
- Add required_state_variables trait (empty tuple for stateless)
- Change state_old parameter to Union{Nothing,NamedTuple}
- Return NamedTuple() instead of nothing for state update
- Support compositional state system in compute_stress
2025-12-12 23:43:51 +02:00
Jukka Aho 87d79f15b1 docs(materials): update docstrings for AssemblyMaterialWorkspace API
Update AbstractMaterialState and EmptyState docstrings to reference
new AssemblyMaterialWorkspace and GlobalMaterialCache instead of
old MaterialStateCache API.
2025-12-12 23:42:02 +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 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 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
Jukka Aho 56b8f25682 feat(materials): Add trait-based material behavior system
- Define MaterialBehavior abstract type for material classification
- Add StatelessConstantTangent trait for linear elastic materials
- Add StatelessStrainDependent trait for hyperelastic materials
- Add StatefulStrainDependent trait for plastic materials
- Implement material_behavior() trait function interface
- Add needs_deformation() and needs_state() helper queries
- Document trait system with comprehensive examples
- Enable generic integration without material-specific code duplication
- 148 lines of trait definitions and documentation

Why: Solves the problem of replicating compute_block! for each material type.
With 100 materials, we'd have 100 copies of integration code. Traits provide
a standardized interface that integration code can query at compile time.
2025-11-19 10:03:44 +02:00
Jukka Aho 7589b345e8 fix(materials): Return SymmetricTensor{4,3} from elasticity_tensor
- Change return type from Tensor{4,3} to SymmetricTensor{4,3}
- Construct full 81-component tensor then convert to symmetric form
- Matches NeoHookean return type for API consistency
- Properly encodes material symmetry (C_ijkl = C_jikl = C_ijlk = C_klij)
2025-11-19 02:13:31 +02:00
Jukka Aho 7ec65dd1bf perf(materials): Use @generated for zero-allocation elasticity tensor
Convert elasticity_tensor() to compile-time generation.

Before (672 bytes in test context):
- Runtime array comprehension for 81 tensor components
- Tuple conversion caused allocations
- Type instability from generic Tensor{4,3} constructor

After (0 bytes):
- @generated function pre-computes all 81 components at compile time
- Returns concrete Tensor{4,3,Float64,81} type
- Zero runtime allocations

Algorithm:
- Compute symbolic expressions for C_{ijkl} at compile time
- Generate optimized code with only λ_val, μ_val runtime parameters
- Tensor construction happens entirely at compile time

Result: 672 bytes → 0 bytes (100% reduction)

Note: This was part of the optimization but not the primary fix.
The main issue was ips::Any type instability in ElementCache.
2025-11-18 20:47:11 +02:00
Jukka Aho 2be68f3bf3 feat(materials): Add material model API with elastic and plastic abstractions
Create src/materials/api.jl defining material-specific abstractions:
- AbstractMaterial base type for all material models
- AbstractElasticMaterial for stateless materials (no history)
- AbstractPlasticMaterial for stateful materials (history-dependent)
- compute_stress() interface (strain → stress + tangent + updated state)
- elasticity_tensor() for elastic constitutive relations

Material models use Tensors.jl (no Voigt notation). Elastic materials
are stateless (LinearElastic, NeoHookean). Plastic materials have internal
state (plastic strain εᵖ, backstress α, hardening κ, damage).

Interface returns (σ, 𝔻, state_new) where 𝔻 is the material tangent ∂σ/∂ε.

Part of systematic modular API architecture.
2025-11-15 18:39:20 +02:00
Jukka Aho 5ee4f2d86b feat(materials): Add elasticity_tensor() for LinearElastic
Add elasticity_tensor(material::LinearElastic) function that returns
the 4th-order elasticity tensor C_{ijkl} for assembly.

Formula: C_{ijkl} = λ δ_{ij} δ_{kl} + μ (δ_{ik} δ_{jl} + δ_{il} δ_{jk})

Returns Tensor{4,3,Float64} for direct use in stiffness assembly:
  K_ij^{αβ} = ∫ (∂N_i/∂x_γ) C_{αβγδ} (∂N_j/∂x_δ) dV

This eliminates need for Voigt notation and B-matrices in assembly,
enabling pure tensor mathematics (Tensors.jl).

Used by CPU backend (src/backend/cpu.jl) in compute_element_stiffness().
Foundation for GPU implementation (same tensor approach).
2025-11-15 02:17:00 +02:00
Jukka Aho 6722716ac3 refactor(materials): Move abstract types to api.jl for include order
Comment out AbstractMaterial, AbstractElasticMaterial, and
AbstractPlasticMaterial definitions in abstract_material.jl.

These types are now defined in src/api.jl which is included first,
avoiding forward reference and circular dependency issues.

Documentation and concrete implementations remain in this file.

This fixes include order problems where materials needed to be defined
before physics_api.jl but physics_api.jl needed the abstract types.
2025-11-15 02:16:23 +02:00