Commit Graph

997 Commits

Author SHA1 Message Date
Jukka Aho 75735ea63c refactor(topology): Implement Wedge{N} with type parameter
Update Wedge to use node count type parameter per ADR-002.

Changes:
- struct Wedge → struct Wedge{N} <: AbstractTopology{N}
- Aliases: Wedge6 = Wedge{6}, Wedge15 = Wedge{15}
- Simplified implementation following same pattern
- Remove old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old files removed: wedge6.jl, wedge15.jl
New file: Single wedges.jl handles all variants via {N}
2025-11-15 04:07:28 +02:00
Jukka Aho a9e31c1ed2 refactor(topology): Implement Pyramid{N} with type parameter
Update Pyramid to use node count type parameter per ADR-002.

Changes:
- struct Pyramid → struct Pyramid{N} <: AbstractTopology{N}
- Alias: Pyr5 = Pyramid{5}
- Simplified implementation following same pattern
- Remove old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old file removed: pyr5.jl
New file: Single pyramids.jl handles all variants via {N}
2025-11-15 03:55:02 +02:00
Jukka Aho 2c6d6dc620 refactor(topology): Implement Tetrahedron{N} with type parameter
Update Tetrahedron to use node count type parameter per ADR-002.

Changes:
- struct Tetrahedron → struct Tetrahedron{N} <: AbstractTopology{N}
- Aliases: Tet4 = Tetrahedron{4}, Tet10 = Tetrahedron{10}
- Simplified implementation following same pattern
- Remove old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old files removed: tet4.jl, tet10.jl
New file: Single tetrahedra.jl handles all variants via {N}
2025-11-15 02:56:52 +02:00
Jukka Aho 568f09090a refactor(topology): Implement Triangle{N} with type parameter
Update Triangle to use node count type parameter per ADR-002.

Changes:
- struct Triangle → struct Triangle{N} <: AbstractTopology{N}
- Aliases: Tri3 = Triangle{3}, Tri6 = Triangle{6}, Tri7 = Triangle{7}, Tri10 = Triangle{10}
- Simplified implementation following same pattern
- Remove old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old files removed: tri3.jl, tri6.jl, tri7.jl
New file: Single triangles.jl handles all variants via {N}
2025-11-15 02:47:04 +02:00
Jukka Aho 4bf21edda8 refactor(topology): Implement Quadrilateral{N} with type parameter
Update Quadrilateral to use node count type parameter per ADR-002.

Changes:
- struct Quadrilateral → struct Quadrilateral{N} <: AbstractTopology{N}
- Aliases: Quad4 = Quadrilateral{4}, Quad8 = Quadrilateral{8}, Quad9 = Quadrilateral{9}
- Simplified implementation following same pattern as Hexahedron and Segment
- Remove 140+ lines of old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old files removed: quad4.jl, quad8.jl, quad9.jl
New file: Single quadrilaterals.jl handles all variants via {N}
2025-11-15 02:29:36 +02:00
Jukka Aho be550320b5 refactor(topology): Implement Segment{N} with type parameter
Update Segment to use node count type parameter per ADR-002.

Changes:
- struct Segment → struct Segment{N} <: AbstractTopology{N}
- Aliases: Seg2 = Segment{2}, Seg3 = Segment{3}
- Add nnodes(), dim() implementations
- reference_coordinates() for Segment{2} and Segment{3}
- Generic edges() and faces() for any N
- Remove 100+ lines of old design documentation

Implements ADR-002 (November 13, 2025): node count from mesh, not basis.

Old files removed: seg2.jl, seg3.jl
New file: Single segments.jl handles all variants via {N}
2025-11-15 02:27:02 +02:00
Jukka Aho 4c49570cec refactor(topology): Implement Hexahedron{N} with type parameter
Update Hexahedron to use node count type parameter per ADR-002.

Changes:
- struct Hexahedron → struct Hexahedron{N} <: AbstractTopology{N}
- Aliases now specify node count: Hex8 = Hexahedron{8}
- Add nnodes() implementation: returns N from type parameter
- Simplify documentation: remove 150+ lines explaining old design
- Keep reference_coordinates() for Hexahedron{8} only
- Generic edges() and faces() work for any N

Benefits:
- Type system encodes node count (compile-time)
- Hex8, Hex20, Hex27 are distinct types (better dispatch)
- Matches mesh file reality (mesh specifies node count)
- Implements ADR-002 decision (November 13, 2025)

Old files removed: hex8.jl, hex20.jl, hex27.jl (separate files)
New file: Single hexahedra.jl handles all variants via {N}
2025-11-15 02:24:53 +02:00
Jukka Aho b2d25e9491 refactor(topology): Add node count type parameter to AbstractTopology
Change AbstractTopology to AbstractTopology{N} where N is node count.

This implements ADR-002 (November 13, 2025) decision: node count comes
from mesh connectivity and should be captured in the type for
compile-time optimization.

Benefits:
- Enables Val(N) for zero-allocation ntuple operations
- Allows loop unrolling for small N (8, 20, 27 nodes typical)
- Type-stable operations based on node count
- Node count known from mesh before basis selection

Documentation updates:
- Add Type Parameter section with examples
- Add Rationale section explaining performance benefits
- Reference ADR-002 for design decision details

Concrete types updated in subsequent commits:
  Hexahedron{N}, Tetrahedron{N}, Triangle{N}, etc.
2025-11-15 02:24:01 +02:00
Jukka Aho 36e0a5fd51 refactor(basis): Update generator to remove OLD API functions
Update src/basis/lagrange_generator.jl to stop generating deprecated

Changes:
- Remove code generation for eval_basis!() (4 function variants)
- Remove code generation for eval_dbasis!() (2 function variants)
- Rename parameter: topology_type::Symbol → topology_type_expr (clearer)
- Update comments: "Generate code for NEW API only"
- Keep NEW API: get_basis_functions(), get_basis_derivatives()

This generator produces src/basis/lagrange_generated.jl (already
committed with updated output).

The OLD API is no longer needed - all code uses NEW API with
Topology + Basis separation architecture.
2025-11-15 02:19:26 +02:00
Jukka Aho 5248f6e470 chore(basis): Regenerate Lagrange basis functions (remove old API)
Regenerate src/basis/lagrange_generated.jl with updated generator.

Changes:
- Remove deprecated eval_basis!() and eval_dbasis!() functions (OLD API)
- Keep NEW API: get_basis_functions() and get_basis_derivatives()
- Add node count to element comments (e.g., "Seg2, 2 nodes")
- Update generation timestamp: 2025-11-13 02:42:16

This is auto-generated code from src/basis/lagrange_generator.jl.
The old API functions are no longer needed as all code now uses
the NEW API (Topology + Basis separation).

Generated: 594 line changes across all 15 Lagrange element types
(Seg2, Seg3, Tri3, Tri6, Tri7, Quad4, Quad8, Quad9, Tet4, Tet10,
Hex8, Hex20, Hex27, Wedge6, Wedge15).
2025-11-15 02:18:27 +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
Jukka Aho 9b22df8d3c refactor(physics): Implement double-dispatch architecture
Major API refactoring: replace mutable ElasticityPhysicsType with
type-parametric Physics struct for compile-time dispatch.

New type hierarchy:
- AbstractField: What we solve (Displacement{3}, Temperature, etc.)
- AbstractFormulation: How we discretize (ContinuumFormulation, BeamFormulation)
- AbstractMaterial: Material behavior (LinearElastic, NeoHookean)
- AbstractMesh: Mesh container

Physics{Formulation, Field, Mesh, Material} enables natural dispatch:
  assemble(::Physics{ContinuumFormulation{FullThreeD}, Displacement{3}, M, Mat})
  assemble(::Physics{BeamFormulation{Timoshenko}, DisplacementRotation{3}, M, Mat})

Type parameter order prioritizes Formulation for dispatch hierarchy.

Breaking changes:
- Old: Physics(Elasticity, "name", 3)
- New: Physics(name=..., mesh=..., field=Displacement{3}(),
               formulation=ContinuumFormulation{FullThreeD}(), material=...)
- Deprecate: add_elements!() - Physics references Mesh, doesn't own elements

Benefits:
- Type stability: All types known at compile time
- Dispatch: Specialized methods for formulation/field combinations
- Extensibility: New formulations/fields without modifying core
- Performance: No runtime type checks, optimal codegen

This is foundation for the NEW API (TDD tests, Nov 14 2025).
2025-11-14 23:22:42 +02:00
Jukka Aho b485886324 fix(integration): Resolve IntegrationPoint name conflict
Add alias IntegrationPointNEW to capture NEW API type before it's
shadowed by legacy core_types.jl definitions.

Update integration_points() to explicitly use IntegrationPointNEW{D}
with dimension parameter, avoiding ambiguity between old and new API
types.

This is a temporary workaround during the old→new API migration phase.
Once legacy code is removed, IntegrationPoint will be the canonical type.
2025-11-14 23:16:48 +02:00
Jukka Aho 0ca159972e feat(backend): Complete tensor-based stiffness computation
Implement full 4th-order elasticity tensor approach in CPU backend:

- Fix topology extraction: extract_topology_type() returns type, then
  instantiate with node count N (was causing crashes)

- Implement basis derivative evaluation: get_basis_derivatives() call
  now works (BLOCKER resolved)

- Complete Jacobian transformation: J = ∑ X_k ⊗ dN_k/dξ using proper
  tensor outer products (Tensors.jl)

- Implement stiffness assembly: K_ij^{αβ} = ∫ (∂N_i/∂x_γ) C_{αβγδ}
  (∂N_j/∂x_δ) detJ dξ with double contractions

- Add basevec() helper for constructing unit vectors

NO B-matrix, NO Voigt notation - pure tensor mathematics following
golden standard (docs/src/book/multigpu_nodal_assembly.md).

This is the foundation for GPU implementation (same math, different backend).
2025-11-14 21:55:22 +02:00
Jukka Aho c40fcdbb91 feat(geometry): Add strain computation function
- Implement compute_strain() for small strain tensor calculation
- Zero allocation with NTuple inputs and Tensors.jl
- Type stable (@inferred passes)
- Complete test suite with 4 test cases (uniaxial, shear, rigid body, performance)
- Performance validated: 0 allocations, ~110ns median
- Add to test suite in runtests.jl
- Export from JuliaFEM module

Resolves user story #0001
2025-11-12 02:19:45 +02:00
Jukka Aho d38a800203 refactor(solvers): Remove push! and fix formatting
- Replace push!(solver.problems, ...) with add_problems!(solver, ...)
- Remove push!(solver, problem) - violated Julia semantics
- Fix spacing in matrix operations (K[I,I] → K[I, I])
- Consistent spacing around operators
- No functional changes to solver logic
2025-11-12 01:11:39 +02:00
Jukka Aho ce8960395f refactor(dirichlet): Simplify initialization check for Dirichlet BCs
- Remove unnecessary initialization for Dirichlet problems
- Dirichlet BCs don't require unknown field (optional)
- Assembly checks haskey() before processing elements
- Fix spacing and formatting (Dict{K,V}, for i=1:n)
- Update comments to explain optional field behavior
2025-11-12 01:11:18 +02:00
Jukka Aho 09aa79b4b0 style(assembly): Fix formatting in problems.jl
- Consistent spacing in type annotations (Dict{K,V} not Dict{K, V})
- Align struct field declarations
- Fix spacing around operators and function calls
- Consistent lambda function formatting
- No functional changes, pure style cleanup
2025-11-12 01:11:04 +02:00
Jukka Aho 3127572b50 refactor(deprecated): Update for immutable Element architecture
- update!() now throws helpful error with migration instructions
- Explains immutable elements: use update() returning new element
- length(element) uses connectivity instead of properties
- size(element) returns (dimension, nnodes) tuple
- Provides OLD vs NEW API examples in error message
- References migration guide documentation
2025-11-12 01:10:52 +02:00
Jukka Aho 68721ce283 docs(basis): Document deprecated and new basis function APIs
- Mark eval_basis!() and eval_dbasis!() as DEPRECATED
- Document why deprecated: topology/basis separation, unclear naming
- Add docstrings for get_basis_functions() and get_basis_derivatives()
- Provide migration examples: OLD vs NEW API side-by-side
- Reference basis_api.jl for full documentation
- Explain topology and basis should be passed separately
2025-11-12 01:10:36 +02:00
Jukka Aho b6f9cd3130 refactor(elements): Update integration points to use new API
- get_integration_points_from_basis() maps Lagrange types to Gauss quadrature
- get_base_topology() maps deprecated names to base topology (Tri6→Triangle)
- Use get_gauss_points!() for zero-allocation integration
- Fix interpolate() to handle both AbstractField and raw data
- Fix Jacobian computation: preserve connectivity order in Dict→Vec conversion
- Support order parameter for increased quadrature accuracy
- Gauss orders 1-5 supported for all topologies
2025-11-12 01:10:22 +02:00
Jukka Aho 3ee3125991 refactor(core): Modernize JuliaFEM.jl module with new architecture
- Update module docstring: contact mechanics focus, GPU acceleration
- Modern API examples: Physics{Elasticity}, immutable Elements
- Separation of concerns: topology, integration, basis, materials
- Export topology types (Segment, Triangle, Quadrilateral, etc.)
- Export deprecated aliases (Tri3→Triangle, Quad4→Quadrilateral)
- Include new modules: geometry/, physics_api.jl, backend/
- Include assembly structures: element and nodal
- CUDA extension support (loaded automatically with 'using CUDA')
- Document nodal assembly architecture and benefits
2025-11-12 01:09:36 +02:00
Jukka Aho 741da90819 feat(io): Add Gmsh mesh reader for tetrahedral meshes
- GmshMesh struct: nodes, elements, physical_groups storage
- read_gmsh_mesh() parses ASCII format 4.1 (.msh files)
- Extracts Tet4 elements (type 4) and node coordinates
- Reads physical groups for boundary conditions
- get_surface_nodes() placeholder for BC node extraction
- 175 lines: Simple mesh I/O for demos and benchmarks
2025-11-12 01:02:02 +02:00
Jukka Aho 2693bdf545 feat(assembly): Add nodal assembly data structures
- NodeToElementsMap: Inverse connectivity (node → elements touching it)
- ElementNodeInfo: Tracks element ID and local node index
- get_node_spider() finds all nodes coupling with given node
- NodalStiffnessContribution: Storage for 3×3 blocks per node
- matrix_vector_product_nodal() computes K_i*u at single node
- print_spider_info() debugging diagnostics
- 234 lines: Infrastructure for node-by-node assembly
2025-11-12 01:01:45 +02:00
Jukka Aho b4673290af feat(assembly): Add traditional element assembly data structures
- ElementAssemblyData: Global sparse matrix and force vectors
- ElementContribution: Local element contributions before scatter
- scatter_to_global!() adds element matrices to global system
- compute_residual!() calculates r = f_int - f_ext
- apply_dirichlet_bc!() penalty method for essential BCs
- get_dof_indices() node connectivity to global DOF mapping
- matrix_vector_product() sparse K*v multiplication
- 341 lines: Traditional element-by-element assembly infrastructure
2025-11-12 01:01:26 +02:00
Jukka Aho c0a0cc679b feat(backend): Add CPU backend with element assembly and CG solver
- ElasticityDataCPU struct wraps ElementAssemblyData
- initialize_backend() assembles global system from immutable Elements
- compute_element_stiffness() uses Tensors.jl (blocked by get_basis_derivatives)
- cg_solve() implements Conjugate Gradient iterative solver
- Supports Dirichlet boundary conditions from Physics API
- 228 lines: Traditional element assembly approach for CPU
2025-11-12 01:01:08 +02:00
Jukka Aho 40de86d4e4 feat(backend): Add abstract backend system with Auto/GPU/CPU selection
New file src/backend/abstract.jl defining backend abstraction:
- AbstractBackend base type for computation backend
- Auto() automatic backend selection (GPU if available, else CPU)
- GPU() force GPU backend (errors if CUDA unavailable)
- CPU(nthreads) force CPU backend with thread count
- select_backend() chooses concrete backend based on hardware
- AbstractElasticityData for backend-specific data structures
- ElasticitySolution struct for solve results
- solve!() dispatch point with backend parameter
- 241 lines with comprehensive API documentation
2025-11-12 00:59:40 +02:00
Jukka Aho 733c72b688 feat(materials): Add FiniteStrainPlasticity with multiplicative decomposition
New file src/materials/finite_strain_plasticity.jl implementing J2 plasticity for large deformations:
- FiniteStrainPlasticityState storing F_p (plastic deformation gradient), α_bar (backstress), κ
- FiniteStrainPlasticity struct with E, ν, σ_y, H parameters
- Hyperelastic stress response using Neo-Hookean
- Exponential map integration for plastic flow
- Pull-back/push-forward operations for intermediate configuration
- Consistent algorithmic tangent for Newton convergence
- 293 lines with comprehensive finite deformation theory
2025-11-12 00:59:18 +02:00
Jukka Aho 0e1f9778e7 feat(materials): Add PerfectPlasticity with radial return mapping
New file src/materials/perfect_plasticity.jl implementing J2 plasticity:
- PlasticityState struct storing plastic strain ε_p, backstress α, and κ
- PerfectPlasticity struct with E, ν, yield stress σ_y, hardening H
- Von Mises yield function: f = √(3/2)||dev(σ-α)|| - σ_y
- Radial return mapping algorithm for plastic updates
- Elastic predictor / plastic corrector scheme
- Kinematic hardening with backstress evolution
- Consistent tangent modulus for Newton convergence
- 357 lines with comprehensive theory and algorithm documentation
2025-11-12 00:58:57 +02:00
Jukka Aho 1a0066dea0 feat(materials): Add NeoHookean hyperelastic material with automatic differentiation
New file src/materials/neo_hookean.jl implementing simplest hyperelasticity:
- NeoHookean struct with shear modulus μ and Lamé parameter λ
- Convenience constructor from E and ν engineering constants
- strain_energy() computes ψ = μ/2·(I₁-3) - μ·ln(J) + λ/2·ln²(J)
- Stress S = 2·∂ψ/∂C via automatic differentiation
- Tangent 𝔻 = 4·∂²ψ/∂C² via automatic differentiation
- Uses Tensors.jl built-in AD (no ForwardDiff dependency)
- Total Lagrangian formulation with 2nd PK stress
- 253 lines with comprehensive theory documentation
2025-11-12 00:58:39 +02:00
Jukka Aho 8f198752ac feat(materials): Add LinearElastic material model with Tensors.jl
New file src/materials/linear_elastic.jl implementing Hooke's law:
- LinearElastic struct with Young's modulus E and Poisson's ratio ν
- Input validation: E > 0, -1 < ν < 0.5
- Helper functions: λ() and μ() compute Lamé parameters
- compute_stress() implements σ = λ·tr(ε)·I + 2μ·ε
- Tangent modulus: 𝔻 = λ·I⊗I + 2μ·��ˢʸᵐ
- Zero-allocation with SymmetricTensor types
- Simplified interface without state management
- 180 lines with comprehensive documentation
2025-11-12 00:58:23 +02:00
Jukka Aho ac071b5d57 feat(materials): Add AbstractMaterial type hierarchy and interface
New file src/materials/abstract_material.jl defining material model architecture:
- AbstractMaterial base type for all materials
- AbstractElasticMaterial for stateless materials (no history)
- AbstractPlasticMaterial for stateful materials (plastic strain, etc.)
- compute_stress() interface: (material, ε, state_old, Δt) → (σ, 𝔻, state_new)
- State management convention for Newton iterations
- Thread-safe and GPU-compatible design principles
- 229 lines with comprehensive documentation and examples
2025-11-12 00:58:06 +02:00
Jukka Aho 184919131e feat(physics): Add backend-agnostic physics API with BC types
New file src/physics_api.jl defining user-facing elasticity API:
- ElasticityPhysicsType (alias Elasticity) for problem configuration
- DirichletBC struct for prescribed displacements
- NeumannBC struct for surface tractions/pressures
- Physics{P} container for problem with elements and BCs
- Works with both CPU and GPU backends
- 183 lines with comprehensive examples
2025-11-12 00:57:33 +02:00
Jukka Aho 84a1bfec4e feat(physics): Add ElasticityPhysics type with geometric/material nonlinearity
New file src/physics/elasticity.jl:
- ElasticityPhysics struct implementing AbstractPhysics interface
- Formulations: plane_stress, plane_strain, continuum (3D)
- finite_strain flag for Green-Lagrange strain (geometric nonlinearity)
- geometric_stiffness flag for buckling analysis
- Field storage control: store_fields (converged), store_iteration_fields (debug)
- Interface methods: get_unknown_field_name, get_formulation_type, get_unknown_field_dimension
- should_store_field() for selective field storage
- 205 lines with comprehensive documentation and GPU design notes
2025-11-12 00:56:58 +02:00
Jukka Aho 628b902bf5 feat(physics): Add deformation gradient computation with strain formulations
New file src/physics/deformation_gradient.jl:
- compute_deformation_gradient() computes F = I + ∇u at integration points
- StrainFormulation types: FiniteStrain() and SmallStrain()
- Uses Tensors.jl for all tensor operations (Vec, Tensor)
- Zero-allocation design with @inline functions
- GPU-ready immutable operations
- Comprehensive mathematical documentation with references
- 243 lines including commented high-level API for future integration
2025-11-12 00:56:40 +02:00
Jukka Aho 258017922e feat(physics): Add assembly helper functions with Tensors.jl
New file src/physics/assembly_helpers.jl with FEM assembly utilities:
- shape_function_gradients() computes ∇N in current configuration
- compute_strain_from_gradients() small strain ε = sym(∇u)
- compute_green_lagrange_strain() finite strain E = ½(C-I)
- accumulate_stiffness!() adds element stiffness contributions
- accumulate_internal_forces!() computes f_int = ∫σ·∇N dV
- accumulate_external_forces!() computes f_ext = ∫N·b dV
- Zero-allocation design with Tensors.jl Vec and SymmetricTensor
- 331 lines with comprehensive performance documentation
2025-11-12 00:56:19 +02:00
Jukka Aho 4440f86691 feat(physics): Add AbstractPhysics base type and interface
New file src/physics/abstract.jl defining physics system architecture:
- AbstractPhysics base type for all physics implementations
- get_unknown_field_name() returns primary field (displacement, temperature, etc.)
- get_formulation_type() returns :incremental, :total, or :rate
- get_unknown_field_dimension() returns DOFs per node
- assemble!() dispatch point for physics-specific assembly
- Comprehensive docstrings covering multi-physics coupling and GPU compatibility
- 138 lines documenting design philosophy and future extension
2025-11-12 00:56:05 +02:00
Jukka Aho bb68e9de84 feat(geometry): Add Jacobian computation with Tensors.jl
New file src/geometry/jacobian.jl implementing geometric transformations:
- compute_jacobian(X, dN_dξ) computes J = ∂x/∂ξ using tensor products
- physical_derivatives(J, dN_dξ) transforms derivatives to physical space
- Full Tensors.jl integration with Vec and Tensor types
- Zero-allocation tuple-based API for performance
- AbstractVector overloads for compatibility
- Comprehensive docstrings with 2D/3D examples
- 169 lines with mathematical definitions and usage patterns
2025-11-12 00:55:10 +02:00
Jukka Aho 57ca301b86 fix(integration): Fix type inference in integration_points conversion
Modified src/integration/gauss.jl to fix IntegrationPoint creation:
- Changed from generator expression to ntuple for proper type inference
- Collect quad_data first (was zip iterator, cannot be indexed)
- Remove explicit type parameter {D} - let Julia infer from arguments
- Fixes type stability issue in integration point generation
- Maintains zero-allocation design with tuple return
2025-11-12 00:54:35 +02:00
Jukka Aho 1e59eb1bbc feat(integration): Add get_gauss_points! function with Tensors.jl Vec types
New file implementing Gauss quadrature point generation:
- get_gauss_points!(topology, scheme) returns tuple of (weight, Vec{D}) pairs
- Supports all 7 topologies: Segment, Triangle, Quadrilateral, Tetrahedron, Hexahedron, Wedge, Pyramid
- Orders 1-3 for each topology (exact integration up to quintic/cubic)
- Uses Tensors.jl Vec types for coordinates (GPU-friendly, zero-allocation)
- Fully inlined (@inline) for compile-time optimization
- 300 lines of quadrature rules from standard FEM references
2025-11-12 00:53:33 +02:00
Jukka Aho 07f1c690d2 refactor(topology): Update AbstractTopology documentation for separation of concerns
Modified src/topology/topology.jl to reflect new architecture:
- Clarify topology defines geometric shape only, not node count
- Document that node count comes from basis functions
- Add examples showing same topology with different bases (Quad4/8/9)
- Update docstring to reference new topology types (Segment, Triangle, etc.)
- Emphasize corner nodes only in topology API
- Remove references to old node-count-baked types (Tri3, Quad4, etc.)
2025-11-12 00:53:02 +02:00
Jukka Aho a4d5b235ca feat(topology): Add Wedge 3D topology with Wedge6/Wedge15 aliases
New file implementing 3D wedge/prism topology:
- Wedge struct with dim=3, 6 corner nodes (triangular prism)
- reference_coordinates() with bottom triangle at z=-1, top at z=1
- edges() returns 9 edges (3 bottom + 3 top + 3 vertical)
- faces() returns 5 faces (2 triangular ends + 3 quadrilateral sides)
- Backward compatibility aliases: Wedge6 (linear), Wedge15 (quadratic)
- Zero-allocation tuple-based design
2025-11-12 00:52:38 +02:00
Jukka Aho f7d778d960 feat(topology): Add Pyramid 3D topology with Pyr5 alias
New file implementing 3D pyramidal topology:
- Pyramid struct with dim=3, 5 corner nodes (square base + apex)
- reference_coordinates() with base at z=0 and apex at (0,0,1)
- edges() returns 8 edges (4 base + 4 to apex)
- faces() returns 5 faces (1 quadrilateral base + 4 triangular sides)
- Backward compatibility alias: Pyr5 (linear)
- Zero-allocation tuple-based design
2025-11-12 00:52:26 +02:00
Jukka Aho 0231b2e33a feat(topology): Add Hexahedron 3D topology with Hex8/Hex20/Hex27 aliases
New file implementing 3D hexahedral topology:
- Hexahedron struct with dim=3, 8 corner nodes (3D tensor product)
- reference_coordinates() in [-1,1]³ cube
- edges() returns 12 edges, faces() returns 6 quadrilateral faces
- Backward compatibility aliases: Hex8, Hex20 (Serendipity), Hex27 (Lagrange)
- Supports trilinear, serendipity (no interior), and full tensor product bases
- Zero-allocation tuple-based design
2025-11-12 00:52:13 +02:00
Jukka Aho 02e40946ef feat(topology): Add Tetrahedron 3D topology with Tet4/Tet10 aliases
New file implementing 3D tetrahedral topology:
- Tetrahedron struct with dim=3, 4 corner nodes (3D simplex)
- reference_coordinates() at (0,0,0), (1,0,0), (0,1,0), (0,0,1)
- edges() returns 6 edges, faces() returns 4 triangular faces
- Backward compatibility aliases: Tet4 (linear), Tet10 (quadratic)
- Zero-allocation tuple-based design
2025-11-12 00:52:00 +02:00
Jukka Aho 6a5a87daef feat(topology): Add Quadrilateral 2D topology with Quad4/Quad8/Quad9 aliases
New file implementing 2D quadrilateral topology:
- Quadrilateral struct with dim=2, 4 corner nodes at (-1,-1), (1,-1), (1,1), (-1,1)
- edges() returns 4 edges, faces() returns element itself
- Backward compatibility aliases: Quad4, Quad8 (Serendipity), Quad9 (Lagrange)
- Supports bilinear, serendipity (no center), and full tensor product bases
- Zero-allocation tuple-based design
2025-11-12 00:51:47 +02:00
Jukka Aho 1ab8f3f30c feat(topology): Add Triangle 2D topology with Tri3/Tri6/Tri7 aliases
New file implementing 2D triangular topology:
- Triangle struct with dim=2, 3 corner nodes
- reference_coordinates() at (0,0), (1,0), (0,1)
- edges() returns 3 edges, faces() returns element itself
- Backward compatibility aliases: Tri3, Tri6, Tri7 (same topology, different basis)
- Zero-allocation tuple-based design
- Separation: topology is geometric shape, basis determines node count
2025-11-12 00:51:25 +02:00
Jukka Aho f547f547e8 feat(topology): Add Segment 1D topology with Seg2/Seg3 aliases
New file implementing 1D line segment topology:
- Segment struct with dim=1, 2 corner nodes
- reference_coordinates() returns (-1.0,) and (1.0,)
- edges() and faces() for topology connectivity
- Backward compatibility aliases: Seg2, Seg3 (same topology, different basis)
- Zero-allocation design using tuples
- Separation of concerns: topology defines shape, basis determines node count
2025-11-12 00:50:58 +02:00
Jukka Aho 269fa9a4ad feat(basis): Add dual-API basis function support (modern + legacy)
- New API: get_basis_functions() returns tuple of functions
- New API: get_basis_derivatives() returns tuple of gradient functions
- basis_api.jl: 210 lines implementing modern functional API
- Re-generated lagrange_generated.jl with 242 new lines
- abstract.jl: Add nnodes() method for Lagrange type
- Backward compatible: old eval_basis! API unchanged
- See ADR-003 for design rationale
2025-11-10 22:26:23 +02:00