2025-11-18 16:08:35 +02:00
|
|
|
# This file is a part of JuliaFEM.
|
|
|
|
|
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
|
|
|
|
|
|
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
Physics category types for material trait dispatch.
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Defines abstract physics categories used for:
|
|
|
|
|
- Material trait functions (required_field_type)
|
|
|
|
|
- Material cache generation
|
|
|
|
|
- Physics-based dispatch
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
These are lower-level type tags, not complete FEM problems.
|
2025-11-18 16:08:35 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
Elasticity{Dim} <: AbstractPhysics
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Elasticity physics in Dim dimensions (2D or 3D).
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Used for trait-based dispatch to determine required fields:
|
|
|
|
|
```julia
|
|
|
|
|
required_field_type(Elasticity{3}()) # → Displacement{3}
|
|
|
|
|
```
|
2025-11-18 16:08:35 +02:00
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
struct Elasticity{Dim} <: AbstractPhysics end
|
2025-11-18 16:08:35 +02:00
|
|
|
|
|
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
Thermal{Dim} <: AbstractPhysics
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2026-05-09 18:15:35 +03:00
|
|
|
Thermal physics (heat transfer) in `Dim` dimensions (2 or 3).
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Used for trait-based dispatch:
|
|
|
|
|
```julia
|
|
|
|
|
required_field_type(Thermal{2}()) # → Temperature (2D plane heat)
|
|
|
|
|
required_field_type(Thermal{3}()) # → Temperature (3D heat)
|
|
|
|
|
```
|
2025-11-18 16:08:35 +02:00
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
struct Thermal{Dim} <: AbstractPhysics end
|
|
|
|
|
|
2025-11-18 16:08:35 +02:00
|
|
|
# ============================================================================
|
2025-12-12 23:45:16 +02:00
|
|
|
# TRAIT FUNCTIONS
|
2025-11-18 16:08:35 +02:00
|
|
|
# ============================================================================
|
|
|
|
|
|
|
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
required_field_type(physics::AbstractPhysics)
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Returns the field type required by the given physics.
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Used for compile-time inference of material cache structure and
|
|
|
|
|
field requirements.
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
# Examples
|
2025-11-18 16:08:35 +02:00
|
|
|
```julia
|
2025-12-12 23:45:16 +02:00
|
|
|
required_field_type(Elasticity{3}()) # → Displacement{3}
|
|
|
|
|
required_field_type(Thermal{2}()) # → Temperature (2D)
|
|
|
|
|
required_field_type(Thermal{3}()) # → Temperature (3D)
|
2025-11-18 16:08:35 +02:00
|
|
|
```
|
|
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
Materials can declare their physics requirements:
|
|
|
|
|
```julia
|
|
|
|
|
struct ThermoElasticMaterial <: AbstractMaterial
|
|
|
|
|
# ...
|
|
|
|
|
end
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
# Material supports both elasticity and thermal physics
|
|
|
|
|
supported_physics(::ThermoElasticMaterial) = (Elasticity{3}(), Thermal{3}())
|
2025-11-18 16:08:35 +02:00
|
|
|
|
2025-12-12 23:45:16 +02:00
|
|
|
# System maps this to required field types:
|
|
|
|
|
# Elasticity{3} → Displacement{3}
|
|
|
|
|
# Thermal → Temperature
|
2025-11-18 16:08:35 +02:00
|
|
|
```
|
|
|
|
|
"""
|
2025-12-12 23:45:16 +02:00
|
|
|
function required_field_type end
|
|
|
|
|
|
|
|
|
|
required_field_type(::Elasticity{Dim}) where Dim = Displacement{Dim}
|
|
|
|
|
required_field_type(::Thermal{Dim}) where Dim = Temperature
|
|
|
|
|
# required_field_type(::Fluid{Dim}) where Dim = Velocity{Dim} # Add when Velocity field exists
|