Commit Graph

220 Commits

Author SHA1 Message Date
Jukka Aho a03ecc09be feat(docs): add architecture_layers.md
docs/src/developer/architecture_layers.md | 175 ++++++++++++++++++++++++++++++  1 file changed, 175 insertions(+)
2026-05-09 16:30:25 +03:00
Jukka Aho 7acd3380d0 feat(docs): add assembler_choice.md
docs/src/assembler_choice.md | 35 +++++++++++++++++++++++++++++++++++  1 file changed, 35 insertions(+)
2026-05-09 16:30:25 +03:00
Jukka Aho dc3adc7226 refactor(docs): update api.md
docs/src/api.md | 221 ++++++++++++++++++++++++++------------------------------  1 file changed, 103 insertions(+), 118 deletions(-)
2026-05-09 16:30:25 +03:00
Jukka Aho e5865ee750 feat(docs): add repository_layout.md
docs/repository_layout.md | 5 +++++  1 file changed, 5 insertions(+)
2026-05-09 16:30:25 +03:00
Jukka Aho 2a3b11592f refactor(docs): update make.jl
docs/make.jl | 52 ++++++++++++++++++++++------------------------------  1 file changed, 22 insertions(+), 30 deletions(-)
2026-05-09 16:30:24 +03:00
Jukka Aho 482af34fea feat(docs): add index.md
docs/api/index.md | 3 +++  1 file changed, 3 insertions(+)
2026-05-09 16:30:24 +03:00
Jukka Aho 9d7fc6a972 feat(docs): add api.md
docs/api/api.md | 11 +++++++++++  1 file changed, 11 insertions(+)
2026-05-09 16:30:24 +03:00
Jukka Aho f63279ad73 refactor(docs): update README.md
docs/README.md | 170 ++++++++++++++-------------------------------------------  1 file changed, 40 insertions(+), 130 deletions(-)
2026-05-09 16:30:24 +03:00
Jukka Aho 637f58c342 feat(docs): add NEWS.md
docs/NEWS.md | 19 +++++++++++++++++++  1 file changed, 19 insertions(+)
2026-05-09 16:30:24 +03:00
Jukka Aho 48a6bcad9f docs(repository_layout): describe legacy as optional 0.x-adjacent API
Replace Pre-2.0 wording with legacy module note aligned with 0.x default surface.
2026-05-09 16:28:42 +03:00
Jukka Aho d4fcbad8f1 docs: Add AGENTS entrypoint and repository layout guide
Introduce root-level AGENTS.md as the architecture and workflow summary for
humans and coding agents. Add docs/src/repository_layout.md as a placement
and anti-pattern reference for sources, tests, scripts, and gitignored trees.

- AGENTS.md links deep docs and states 2.0 invariants
- repository_layout.md includes .cursor/ as gitignored local tooling
2026-05-09 16:21:31 +03:00
Jukka Aho 3bdbde3326 docs: Refresh README and contributing guide for post-reset API
Replace outdated badges and roadmap prose with the current 2.0 focus areas,
installation notes, and pointers to AGENTS.md. Rewrite CONTRIBUTING as a
concise fork/test/layer-contract checklist aligned with the repo layout.

- README: drop stale Travis/Gitter stack; document legacy module caveat
- CONTRIBUTING: remove Quarto front matter; link architecture_layers checker
2026-05-09 16:21:06 +03:00
Jukka Aho b4a2caa31e docs(snippet): Add minimal elasticity quickstart source
Runnable 4×4×4 Hex8 linear elasticity assembly used as the Documenter/README
minimal example source of truth; returns (; ndofs, nnz_stiffness).

- Intended for @literalinclude, test/docs, and scripts/verify_docs_quickstart.jl
2026-05-09 16:04:40 +03:00
Jukka Aho 02b41db2e4 chore(docs): add .gitignore for docs directory
Add .gitignore to ignore Manifest.toml in docs directory

- Ignore Manifest.toml (generated file, should not be committed)
2025-12-12 23:05:47 +02:00
Jukka Aho 2b24cbadba docs(index): update documentation landing page
Modernize index page with comprehensive overview and quick start
guide. Replace simple contents page with informative landing page.

- Add overview section describing JuliaFEM.jl
- Add key features section highlighting capabilities
- Add installation instructions
- Add quick start example code
- Update contributing section with GitHub link
- Add license information
- Remove old contents listing
2025-12-12 23:04:39 +02:00
Jukka Aho 108c881687 docs(api): reorganize API documentation structure
Reorganize API documentation with organized sections for better
navigation and discoverability.

- Add structured sections: Elements, Physics, Fields, Formulations,
  Materials, Mesh, Topology, Basis Functions, DOF System, Solvers
- Include key types and functions in each section
- Change title from "API documentation" to "API Reference"
- Keep index at the end for complete reference
2025-12-12 23:04:14 +02:00
Jukka Aho 7125a617f8 refactor(docs): simplify make.jl to modern Documenter.jl build
Simplify documentation build script to generate API docs only.
Remove legacy code for generating examples, packages, and guides.

- Replace complex build system with simple Documenter.jl setup
- Generate markdown output for Quarto integration
- Build directly to juliafem.github.io/api/ directory
- Remove functions: copy_docs, add_page!, generate_* functions
- Use DocumenterMarkdown format instead of HTML
2025-12-12 23:03:50 +02:00
Jukka Aho c7b0283822 chore(docs): add JuliaFEM dependency to Project.toml
Add JuliaFEM package as dependency for documentation build

- Add JuliaFEM to [deps] section
- Add relative path source for JuliaFEM in [sources]
2025-12-12 23:03:21 +02:00
Jukka Aho 038222ce98 chore: remove docs files moved to website repository
Remove documentation files from docs/ directory as they have
been moved to juliafem.github.io/ according to the website
structure. Manual documentation now lives in the website
repository directly.

Removed files:
- docs/book/adr-004-integration-points-api.md
- docs/book/adr-005-element-integration-point-indices.md
- docs/book/deformation_gradient_implementation.md
- docs/book/design/backend_transparent_architecture.md
- docs/book/design/gmres_algorithm_gpu.md
- docs/book/design/matrix_free_dirichlet_bc.md
- docs/book/element_assembly_implementation.md
- docs/book/linear_elastic_implementation.md
- docs/book/migration-guide-basis-api.md
- docs/book/neo_hookean_implementation.md
- docs/book/perfect_plasticity_implementation.md
2025-12-12 22:59:15 +02:00
Jukka Aho f0353699b0 chore: removed files from docs
Removed files from docs directory:

- docs/badges.jl
- docs/book/nodal_assembly_concept.md
- docs/build_api.jl
- docs/build_doctests.jl
- docs/build_lint.jl
- docs/build_notebooks.jl
- docs/build_unittests.jl
- docs/src/contributor/coding_standards.md
- docs/src/contributor/guides/gpu_elasticity_quickstart.md
- docs/src/contributor/guides/gpu_nodal_assembly_quickstart.md
- docs/src/contributor/guides/quick_reference_gpu.md
- docs/src/contributor/README.md
- docs/src/contributor/status.md
- docs/src/contributor/test_fixes_needed.md
- docs/src/contributor/testing_philosophy.md
- docs/src/examples.md
- docs/src/features.md
- docs/src/links.md
- docs/src/user/elasticity_quickstart.md
- docs/src/user/README.md
- docs/src/user/system_architecture.md
2025-12-12 22:01:57 +02:00
Jukka Aho cee336a476 chore: remove docs/src/book directory
Remove docs/src/book directory as it has been moved to another
repository

- Remove docs/src/book/ directory and all contents
- 40 files removed including documentation and design docs
2025-12-12 21:44:34 +02:00
Jukka Aho 64056da96a docs(adr): Revise ADR-002 - topology includes node count parameter
Major revision of ADR-002 based on implementation experience.

Decision change:
- OLD (Nov 9): Topology without node count (pure geometry)
- NEW (Nov 13): Topology with node count type parameter

Rationale:
Node count comes from MESH FILES, not from basis choice. When reading
Abaqus .inp, Code Aster .med, or GMSH .msh files, the mesh explicitly
specifies node count in element connectivity:
  - Hex element (1,2,...,8) → 8 nodes
  - Hex element (1,2,...,20) → 20 nodes
  - Hex element (1,2,...,27) → 27 nodes

The mesh reader knows node count BEFORE basis functions are selected.
Therefore, topology must include node count: Hexahedron{N}.

New design:
  struct Hexahedron{N} <: AbstractTopology end
  const Hex8 = Hexahedron{8}
  const Hex20 = Hexahedron{20}

This maintains type stability (N known at compile time) while
acknowledging that N originates from mesh data, not basis choice.

Supersedes: ADR-002 (November 9, 2025)
2025-11-15 02:21:47 +02:00
Jukka Aho 9bbd9879a8 docs(user): Add linear elasticity quickstart tutorial
- Complete cantilever beam example from mesh to visualization
- Gmsh mesh creation with physical groups for BCs
- Material definition (Young's modulus and Poisson's ratio)
- Dirichlet (fixed) and Neumann (pressure) boundary conditions
- ElasticityPhysics problem setup and solve!() call
- Results visualization with stress and displacement
- 361 lines: Step-by-step user tutorial for beginners
2025-11-12 01:08:41 +02:00
Jukka Aho 753ddcc9e5 docs(design): Add GPU physics architecture documentation
- 4 design documents for GPU implementation (2588 lines total)
- gpu_physics_architecture.md: Physics{Elasticity} GPU-first design
- gpu_cpu_backend_architecture.md: Backend selection and dispatch
- gpu_cpu_migration_guide.md: Migration from old API to new
- gpu_elasticity_refactoring.md: Complete refactoring strategy
- Zero CPU-GPU transfer during solve, matrix-free CG
- Elements store geometry, no mesh dependency
- Breaking changes allowed for GPU performance
2025-11-12 01:08:22 +02:00
Jukka Aho 3208904b73 docs(design): Add backend-transparent architecture proposal
- Design principle: users never see CPU/GPU differences
- Three-layer architecture: User API / Backend Abstraction / Implementations
- Auto() backend selection based on hardware availability
- Physics{ElasticityPhysicsType} as single problem type
- Internal conversion between CPU arrays and GPU arrays
- solve!() with automatic dispatch to CPU or GPU backend
- 611 lines: Complete architecture design proposal
2025-11-12 01:07:53 +02:00
Jukka Aho 6a94155a32 docs(book): Add basis function API migration guide
- get_basis_functions() and get_basis_derivatives() recommended
- Separation of concerns: topology and basis as separate parameters
- Side-by-side examples for all common element types
- Complete assembly example showing migration path
- Type-stable implementation with no performance penalty
- 302 lines: Comprehensive migration documentation
2025-11-12 01:07:24 +02:00
Jukka Aho d07220aa76 docs(book): Add nodal assembly concept and architecture
- Alternative to element-by-element assembly for GPU/matrix-free
- Node-by-node loop eliminates atomic operations on GPU
- Spider pattern: nodes couple with 10-30 neighbors not all N
- NodeToElementsMap: inverse connectivity (node → elements)
- get_node_spider() finds coupled nodes for sparse stiffness
- NodalStiffnessContribution: 3×3 blocks per node
- 307 lines: Experimental architecture with working prototype
2025-11-12 01:07:07 +02:00
Jukka Aho 64b148a9bb docs(book): Add J2 perfect plasticity implementation guide
- von Mises yield criterion with kinematic hardening
- Radial return mapping algorithm for plastic correction
- Additive strain decomposition (elastic + plastic)
- Associative flow rule and consistent tangent
- Performance: 76 ns elastic, 108 ns plastic (4.8× faster than AD)
- Zero-allocation elastic path, minimal plastic allocation
- 668 lines: Complete plasticity implementation documentation
2025-11-12 01:06:49 +02:00
Jukka Aho d610754a06 docs(book): Add NeoHookean hyperelastic implementation guide
- Compressible Neo-Hookean strain energy function
- Automatic differentiation for stress and tangent computation
- Dual constructor: Lamé (μ,λ) or engineering (E,ν)
- Total Lagrangian formulation with 2nd Piola-Kirchhoff stress
- Zero-allocation AD via Tensors.jl
- When to use: rubber, large deformation, contact mechanics
- 571 lines: Complete AD-based material model documentation
2025-11-12 01:05:49 +02:00
Jukka Aho 1e8254909c docs(book): Add LinearElastic material implementation guide
- Complete mathematical foundation of Hooke's law in tensor form
- Lamé parameters derived from Young's modulus and Poisson's ratio
- compute_stress() implementation achieving ~25 ns execution
- Fourth-order elasticity tensor with symmetries
- Zero-allocation SIMD-optimized implementation
- Physical constraints and thermodynamic admissibility
- 736 lines: Authoritative implementation documentation
2025-11-12 01:05:33 +02:00
Jukka Aho dc667b37f7 docs(book): Add traditional element assembly implementation guide
- Reference implementation of element-by-element assembly
- ElementAssemblyData and ElementContribution data structures
- Sparse matrix assembly in COO then CSC format
- scatter_to_global!() adds local to global system
- Penalty method for Dirichlet BCs
- Matrix-vector product interface for GMRES
- 479 lines: Complete documentation with examples and tests
2025-11-12 01:05:16 +02:00
Jukka Aho 8e11ab96ee docs(book): Add deformation gradient implementation analysis
- Mathematical derivation of F = I + ∇u for finite strain
- Zero-allocation implementation achieving 34 ns median
- LLVM IR analysis confirms 0 heap allocations
- 92 SIMD vector operations detected
- Small strain vs finite strain formulations
- Comparison with old deprecated eval_dbasis!() API
- 502 lines: Complete performance analysis with benchmarks
2025-11-12 01:04:52 +02:00
Jukka Aho e2917cdba8 docs: Add ADR-005 on integration point indices architecture
Document decision to store integration point indices instead of data in Element struct.
Key rationale: Elements should store relationships (indices), not data, for memory
efficiency and consistency with node connectivity pattern. Aligns with nodal assembly
approach and GPU-friendly architecture.
2025-11-12 00:49:17 +02:00
Jukka Aho ba0afce933 docs: Add ADR-004 for zero-allocation integration points API
Architectural Decision Record documenting design of integration points
API for high-performance finite element assembly.

Decision: Compile-time function returning tuple of (weight, Vec{D})
matching eval_basis! zero-cost abstraction pattern.

Problem context:
- OLD API: Runtime dispatch with mutable struct containing Dict
- Performance penalty: ~50× slower due to type instability
- Allocations: New struct created every query
- Impact: Millions of calls during assembly

Solution properties:
- Compile-time generation (fully inlined)
- Vec{D} from Tensors.jl for FEM math
- Zero allocation (tuples, stack-only)
- Type-stable (all types known at compile time)
- GPU compatible (no heap allocations)

API signature:
get_gauss_points!(::Type{Topology}, ::Type{Gauss{order}})
  → NTuple{N, Tuple{Float64, Vec{D}}}

Alternatives rejected:
- Plain tuples (less convenient for FEM math)
- Store in element (overhead, less flexible)
- Global constants (not composable)
- Runtime dispatch (type-unstable, slow)

Status: Accepted, implemented in src/integration/ (193 lines)
2025-11-12 00:44:29 +02:00
Jukka Aho 3d5a3d8c1a docs: Remove old blog/ and design/ directories
- Delete docs/blog/ directory (files moved to docs/src/book/blog/)
- Delete docs/design/ directory (files moved to docs/src/book/design/)
- Cleanup after three-tier documentation reorganization
- Old locations no longer needed after migration to docs/src/ structure
2025-11-10 22:22:29 +02:00
Jukka Aho 8c1be1b5a8 docs: Move user manual to docs/src/user/
- Relocate docs/user/ to docs/src/user/
- Contains user-facing documentation:
  - README.md (user manual index)
  - system_architecture.md (system overview)
- Part of three-tier docs reorganization following Documenter.jl standard
- Completes migration to docs/src/ structure
2025-11-10 22:22:00 +02:00
Jukka Aho fb732efd1b docs: Move contributor manual to docs/src/contributor/
- Relocate docs/contributor/ to docs/src/contributor/
- Add three GPU quickstart guides (renamed from UPPERCASE to snake_case):
  - gpu_elasticity_quickstart.md
  - gpu_nodal_assembly_quickstart.md
  - quick_reference_gpu.md
- Part of three-tier docs reorganization following Documenter.jl standard
- All files now under docs/src/ for automatic rendering
2025-11-10 22:21:43 +02:00
Jukka Aho edc4d5f63e docs: Move immutability blog post to docs/src/book/blog/
- Relocate docs/blog/immutability_performance.md to docs/src/book/blog/
- Comprehensive guide on immutable material models with Tensors.jl
- Covers LinearElastic, NeoHookean, PerfectPlasticity implementations
- Includes full benchmarks: 5× speedup for linear, 21× for plasticity
- Zero allocation performance validated
- Part of three-tier docs reorganization under standard docs/src/ structure
2025-11-10 22:21:15 +02:00
Jukka Aho 5bfd30e9a9 docs: Move book README to docs/src/book/ following Documenter.jl standard
- Relocate docs/book/README.md to docs/src/book/README.md
- Follows standard Julia documentation structure where all source files live under docs/src/
- File contains YAML header and book philosophy/structure overview
- Part of three-tier documentation reorganization (user/contributor/book)
2025-11-10 22:20:40 +02:00
Jukka Aho 46b0cd3927 docs(book): Add comprehensive Gmsh to physics tutorial
New file: docs/book/gmsh_tutorial.md (544 lines)

Complete educational resource addressing Issue #183:

Step 1: Mesh Generation with Gmsh
- Why Gmsh (features, academic adoption)
- .geo file syntax and concepts
- Mesh generation commands
- Understanding .msh format

Step 2: Weak Formulation (Theory)
- Strong form → weak form derivation
- Galerkin approximation
- M du/dt + K u = f system

Step 3: FEM Assembly in JuliaFEM
- Loading meshes
- Creating problems and elements
- Boundary conditions (Dirichlet, Neumann)
- Assembly process internals

Step 4: Extracting Matrices (Issue #183 core answer)
- How to get K, M, f after assembly
- Why extract (5 use cases)
- Integration with DifferentialEquations.jl
- Complete working example

Step 5: Method of Lines
- PDE → ODE spatial discretization strategy
- Separation of space/time concerns
- Modularity benefits

Plus: Comparison (built-in vs external), Extensions (nonlinear, 3D,
parallel, GPU), Troubleshooting, References

Demonstrates 'laboratory not fortress' philosophy
2025-11-09 23:24:15 +02:00
Jukka Aho 5f10390a01 docs(design): Add YAML frontmatter to IMMUTABILITY.md
- Converted header metadata to YAML frontmatter format
- Added categories and tags for documentation site compatibility
- Preserved all existing content (only header format changed)
- Status: IMPLEMENTED, Phase: Phase 1B
- Links to benchmark: element_immutability_benchmark.jl
2025-11-09 21:02:49 +02:00
Jukka Aho 7370863806 docs(blog): Add TL;DR version of immutability performance article
New 139-line quick-reference article covering:
- Side-by-side code comparisons (mutable vs immutable)
- 130x speedup summary with key metrics
- Type stability explanation with timing breakdown
- Compiler optimization differences
- Real-world impact table (2.4s → 0.02s)
- Mental model shift (1990s C++ → 2025 modern compilers)
- Quick command to run benchmark
- Links to full article for details
2025-11-09 21:02:21 +02:00
Jukka Aho ad80533334 docs(blog): Add O(n) vs O(1) scaling analysis to immutability article
- Comprehensive section on struct size scaling (1-5000 fields)
- Confirms crossover at 100 fields (800 bytes) for updates
- Shows immutable wins for access/iteration at ALL sizes
- Explains why constants matter more than Big-O
- Typical FEM elements (5-50 fields) well below crossover
- Updated FAQ with scaling questions
- Added references to struct_size_scaling.jl benchmark
- System: Intel Xeon Gold 6326, 32 cores, 503 GB RAM
2025-11-09 21:01:12 +02:00
Jukka Aho 41e09b2c92 feat(compat): Add compatibility shim for old mutable field API
Implements compatibility layer to allow old test code to run with new
immutable element design (though fields won't actually update).

src/elements/elements.jl:
- Replaced has_dfield/get_dfield to work with new fields API
- Fixed get_sfield/get_dfield to handle empty Tuple{} fields
- All dfield functions now map to element.fields (immutable NamedTuple)

src/topology/*.jl (seg2, tri3, quad4, tet4, hex8):
- Added nnodes() implementation for each topology type
- Returns corner node count (backwards compatibility)
- Example: nnodes(::Triangle) = 3, nnodes(::Hexahedron) = 8
- Note: Actual node count depends on basis degree in new architecture

Test Results:
- test_topology_standalone.jl: 36/36 tests passing ✓
- Full test suite: 43 errors (same as before)
- Error breakdown:
  * 40+ tests: Problem types not defined (Elasticity, Heat, Mortar)
  * 2 tests: Mesh readers not defined (aster_read_mesh)
  * 1 test: Tries to mutate empty element (test_elasticity_1d)

Next Steps:
- Tests that create empty elements then mutate need rewriting
- Pattern: Element(Seg2, (1,2)) + update!() → not compatible
- New pattern: Element(..., fields=(geometry=X, displacement=u))
- See docs/design/IMMUTABILITY.md for migration guide
2025-11-09 18:08:39 +02:00
Jukka Aho 32451ed978 docs(design): Add immutability design doc with comprehensive benchmark
Created comprehensive documentation and benchmark demonstrating why immutable
elements with type-stable fields are 40-130x faster than mutable Dict-based
elements.

benchmarks/element_immutability_benchmark.jl:
- Compares mutable (Dict) vs immutable (NamedTuple) implementations
- Measures field access, updates, assembly loops, large-scale meshes
- Results: 40x faster field access, 130x faster assembly, zero allocations

docs/design/IMMUTABILITY.md:
- Explains counterintuitive API change: element = update(element, ...)
- Benchmarks show 40-130x speedup despite 'copying' elements
- Key insight: Type stability >> mutation, compiler optimizes away copies
- Migration guide: old mutable API → new immutable API
- GPU/HPC rationale: Only bits types work on GPU (no pointers)

Key Results:
- Field access: 1ns vs 45ns (40x faster)
- Assembly: 9ns vs 1124ns per element (130x faster)
- Large mesh: 0.01ms vs 1.2ms for 1000 elements (120x faster)
- Memory: 0 allocations vs 70,000 allocations
- GPU: Compatible (bits types) vs Incompatible (pointers)

This documents a fundamental architectural decision for JuliaFEM 1.0.
2025-11-09 17:51:34 +02:00
Jukka Aho 7f4c2b28ce docs: Nodal assembly with immutable element fields
Design for handling both nodal and element fields in nodal assembly:

Architecture:
- Nodes have geometry (immutable)
- Elements have connectivity + fields (immutable struct)
- Nodal fields: displacement, temperature, contact pressure
- Element fields: integration point data (σ, ε_plastic, α, C)

Update pattern:
- Create new field containers (NamedTuples)
- Create new elements with updated fields
- Shallow copy element vector, replace elements
- All immutable (GPU-compatible, thread-safe)

GPU kernel:
- Loops over nodes (nodal assembly)
- Accesses nodal_fields for global quantities
- Accesses element.fields for integration point data
- Gathers from connected elements (node_to_elements)
- No atomic operations (each node owns DOFs)

Material state update:
- Process elements in parallel (Threads.@threads)
- Extract nodal displacements from solution
- Compute strains at integration points
- Run material model (plasticity, damage, etc.)
- Create new elements with updated state
- Return new problem with updated fields

Newton iteration:
- Residual uses element.fields.C (current tangent)
- GMRES with matrix-free matvec (nodal assembly)
- Material update after each iteration
- All data structures immutable throughout

Benchmarks show creating new containers ~1000× faster than deepcopy
2025-11-09 16:18:06 +02:00
Jukka Aho a8495bdc4a docs: Nodal assembly pattern advantages and validation
Explains why JuliaFEM uses nodal assembly instead of element assembly:

Five major advantages:
1. No atomic operations on GPU (each node writes to own DOFs)
2. Contact mechanics is natural (forces at nodes, not elements)
3. Clean domain decomposition (explicit node ownership for MPI)
4. Better cache locality (sequential node processing)
5. Adaptive refinement easier (local node operations)

Key data structure:
- NodeSet contains nodes + elements + node_to_elements connectivity
- Inverse connectivity enables gathering from connected elements
- Fields accessed via node_set.fields (type-stable)

Algorithm:
- Loop over nodes (not elements)
- Each node gathers contributions from connected elements
- Direct write to owned DOFs (no race conditions)
- Perfect for matrix-free Krylov methods

Validated with demo:
- CPU/GPU results match exactly (0.0 relative error)
- Average 3.24 elements per node (efficient gathering)
- Natural integration with contact mechanics

Compares to traditional element assembly:
- Element: scatter to nodes (atomic ops, cache misses)
- Nodal: gather from elements (no atomics, better cache)
2025-11-09 16:17:17 +02:00
Jukka Aho ded16ee1dc docs: Multi-GPU nodal assembly algorithm design
Complete algorithm for GPU-resident FEM solver with nodal assembly:
- Data partitioning by node ownership (domain decomposition)
- GPU-resident data structures (nodes, elements, connectivity, state)
- Three GPU kernels: residual, matvec, state update
- MPI communication patterns for interface nodes
- Full Newton-GMRES loop on GPU (data stays resident)

Architecture:
- Each GPU owns subset of nodes (exclusive ownership)
- Ghost elements copied for gathering during assembly
- node_to_elements connectivity enables nodal assembly
- No atomic operations (each GPU writes to owned DOFs only)

Key features:
- Data moves to GPU once at start, back once at end
- GMRES iterations entirely on GPU (Arnoldi steps)
- Material state updates on GPU (integration points)
- MPI exchanges only for interface DOFs between iterations
- O(N) memory per GPU (matrix-free)

Handles nonlinearity:
- Element state contains σ, ε_plastic, α, C (tangent)
- Residual kernel uses current stress/tangent
- State update kernel after convergence
- Natural for contact mechanics (nodal forces)

Status: Design document for future GPU implementation
2025-11-09 16:16:43 +02:00
Jukka Aho 552d701c5a docs: Matrix-free Krylov pattern with ElementSet
Explains the correct pattern for matrix-vector products in Krylov methods:
- Fields accessed through element_set (not passed separately)
- GPU kernel computes y=K*x (not K itself)
- O(N) memory (vs O(N²) for stored matrix)
- Type-stable field access (compile-time types)

Key insights:
- GMRES needs matvec operation, not the matrix
- ElementSet contains elements + fields together
- Zero allocations with immutable connectivity/fields
- Natural pattern for contact mechanics (nodal updates)
- Material state separate from field parameters

Compares old vs new approach:
- Old: Dict{String,Any} in element (type-unstable)
- New: NamedTuple in ElementSet (type-stable)
- Old: O(N²) matrix storage
- New: O(N) matrix-free operator

Validated with gpu_elementset_matvec_demo.jl:
- GPU/CPU results match exactly
- Fields accessed naturally through element_set
- Returns y vector (what Krylov methods need)
2025-11-09 16:16:13 +02:00
Jukka Aho 38d5749218 docs: Design document for element field architecture
Analyzes field storage patterns and recommends ElementSet approach:
- Element has NO field type parameter (simpler type)
- ElementSet groups elements + shared fields
- Fields can be NamedTuple, struct, any type-stable container
- Embraces immutability (GPU-compatible, thread-safe)
- Separates mutable state from immutable parameters

Design rationale:
- Benchmarks show NamedTuple gives 9-92× speedup vs Dict
- Immutability enables GPU execution without copying
- Creating new containers ~1000× faster than deepcopy
- Matches physical reality (material properties per set)

Compares three options:
1. Fields as type parameter (type proliferation)
2. ElementSet pattern (RECOMMENDED)
3. Hybrid approach (too complex)

Addresses common concerns:
- Time-dependent fields (use interpolation)
- Material state (separate mutable arrays)
- Custom field types (any type-stable container works)

Status: Ready for implementation
2025-11-09 16:15:52 +02:00