Files
JuliaFEM.jl/docs
Jukka Aho ee02f9f37a feat: Separation of concerns architecture with zero-allocation foundation
**Architecture Decision: Element = Topology + Interpolation + Integration + Fields**

This commit establishes the architectural foundation for separating orthogonal concerns
in finite element implementation, preventing Abaqus-style combinatorial explosion.

## New Modules (Not Yet Integrated)

### src/topology/
Reference element geometries (pure mathematical objects):
- topology.jl: Abstract interface for reference elements
- tri3.jl: 3-node triangle reference element
- quad4.jl: 4-node quadrilateral reference element

**Zero-allocation design:**
- reference_coordinates() → NTuple{N, NTuple{D, Float64}}
- edges() → NTuple{Ne, Tuple{Int, Int}}
- faces() → NTuple{Nf, NTuple{Nn, Int}}

All topology queries return compile-time sized tuples (stack allocated, no heap).

### src/integration/
High-level integration scheme abstraction:
- integration.jl: Abstract types and IntegrationPoint struct
- gauss.jl: Gauss-Legendre quadrature wrapper around existing src/quadrature/

**Zero-allocation design:**
- integration_points() → Tuple{Vararg{IntegrationPoint{D}}}
- IntegrationPoint.ξ → NTuple{D, Float64}

**Key Insight:** Integration rules already exist in src/quadrature/ (consolidated from
FEMQuad.jl). New code is a thin architectural wrapper, not reimplementation.

## Documentation

### docs/book/element_architecture.md (NEW - 650+ lines)
Complete book chapter explaining:
- What is an Element? (composition of 4 orthogonal concerns)
- The Abaqus anti-pattern (C3D8, C3D8R, C3D8I explosion)
- JuliaFEM approach: Topology + Interpolation + Integration separation
- Type system enforcement
- Performance implications (100× speedup from type stability)
- Extending the system (adding new topologies/bases/quadrature)
- Comparison with Gridap.jl, Ferrite.jl, Deal.II

### llm/ARCHITECTURE.md (UPDATED)
Added "Architectural Decision: Separation of Concerns" section at top:
- Problem statement
- Anti-pattern example
- JuliaFEM solution
- Directory structure rationale
- Type system design
- Migration strategy

### scripts/generate_lagrange_basis.jl (UPDATED)
Added architectural context explaining Lagrange bases are INTERPOLATION SCHEMES
(not topologies, not integration rules).

## Performance: Zero-Allocation Foundation

**Why tuples matter:**
1. **Zero heap allocations** - All data stack-allocated
2. **Compile-time sizes** - Compiler can unroll loops
3. **Cache friendly** - Contiguous memory layout
4. **Type stable** - Concrete tuple types enable optimization
5. **Immutable** - No accidental mutation, thread-safe

**Example impact:**
```julia
# Compiler knows at compile time:
# - Tri3 has exactly 3 edges
# - Each edge has exactly 2 nodes
# → Loop unrolling, no bounds checks, SIMD vectorization

for edge in edges(Tri3())  # Tuple iteration, fully unrolled!
    node1, node2 = edge
    # ... assembly code (zero allocations)
end
```

**Principle from Roadmap to HPC:**
> "Zero allocations in hot paths" - Strategic Decision #2

Topology/integration queries happen billions of times in assembly loops.
Even small Vector allocations accumulate to GC pressure and cache misses.

**Rule:** If size known at compile time → use Tuple, not Vector

## Benefits

 Clear separation of mathematical concepts
 Mix-and-match: Tri3 + Lagrange + Gauss, Tri3 + Hierarchical + Lobatto, etc.
 Type system enforces correctness at compile time
 Compiler generates specialized code for each combination → 100× speedup
 Zero allocations in topology/integration queries
 No code duplication (each concern in one place)
 Educational: teaches proper software engineering

## Status

- **NOT YET INTEGRATED**: New modules not included in src/JuliaFEM.jl
- **SAFE**: Package loads successfully (verified with `using JuliaFEM`)
- **READY**: Architecture documented, zero-alloc foundation established

## Next Steps

1. Create remaining topology files (Tet4, Tet10, Hex8, Hex20, etc.)
2. Update src/JuliaFEM.jl to include new modules
3. Refactor existing Element to use new separation
4. Run generation script with new architecture
5. Integrate with existing codebase

## References

- Abaqus documentation (anti-pattern example)
- Gridap.jl (alternative approach)
- Ferrite.jl (mixed approach)
- Deal.II (C++ template approach)
- llm/ROADMAP_TO_HPC.md (performance philosophy)

See: docs/book/element_architecture.md for complete rationale and examples.
2025-11-09 05:46:34 +02:00
..
2018-04-23 15:37:03 +03:00
2017-08-23 15:53:01 +03:00
2017-08-05 12:08:46 +03:00
2015-07-06 18:16:04 +03:00
2015-08-25 21:32:43 +03:00
2015-07-06 18:16:04 +03:00
2015-11-12 07:17:03 +02:00
2015-07-08 23:47:29 +03:00
2019-04-08 21:35:13 +03:00
2019-04-08 21:35:13 +03:00

title, description, date, author, categories, keywords, type
title description date author categories keywords type
JuliaFEM Documentation Three-tier documentation structure for users, contributors, and researchers 2025-11-09 Jukka Aho
documentation
guide
juliafem
finite element
documentation
manual
index

JuliaFEM Documentation

Welcome! JuliaFEM documentation is organized into three manuals for three different audiences:


📘 User Manual - "Just Get It Done"

For: End users, engineers, students who want to run simulations.

Style: Simple, practical, step-by-step.

Contents:

  • Quick start and installation
  • Tutorials and examples
  • API reference
  • Troubleshooting

Philosophy: Show me how to solve my problem, skip the lectures.

👉 Start Here if you want to run simulations.


🔧 Contributor Manual - "Show Me the Code"

For: Developers, contributors, advanced users who want to extend JuliaFEM.

Style: Technical, detailed, design rationale.

Contents:

  • Testing philosophy
  • Code style and architecture
  • Performance guidelines
  • How to add elements
  • CI/CD and git workflow

Philosophy: Explain HOW the code works and WHY we made these choices.

👉 Start Here if you want to contribute code.


📖 The JuliaFEM Book - "Let Me Show You How I Think"

For: Advanced researchers, theory nerds, those who want to understand deeply. And Jukka.

Style: Comprehensive, educational, opinionated, personal.

Contents:

  • Mathematical foundations (Lagrange basis, contact mechanics, etc.)
  • Design philosophy and technical vision
  • Strategic mistakes and lessons learned (2015-2019)
  • Research directions (nodal assembly, matrix-free, etc.)
  • Personal reflections on the journey

Philosophy: Mix theory, software design, and personal experience. Teach FEM through implementation.

👉 Start Here if you love deep dives and want to understand the "why" behind everything.


Quick Navigation

I want to...


Documentation Philosophy

Why Three Manuals?

Different readers have different needs:

  1. Users don't care about implementation details - they just want working code.
  2. Contributors need technical depth but not necessarily all the theory.
  3. Researchers (and Jukka) want to understand everything from first principles.

Mixing these audiences in one manual makes it too complex for users and too shallow for researchers.

Design Principles

  • User Manual: Optimize for time-to-first-result
  • Contributor Manual: Optimize for correctness and maintainability
  • Book: Optimize for understanding and education

Cross-References

Manuals link to each other when appropriate:

  • User manual links to theory when deeper understanding helps
  • Contributor manual links to book for design rationale
  • Book links to code examples and practical guides

Contributing to Documentation

Documentation improvements are always welcome!

  • User docs: Fix errors, add examples, improve clarity
  • Contributor docs: Update for new features, clarify architecture
  • Book: Add theory, share insights, document research

See Contributor Manual for guidelines.


License: MIT (same as code)
Questions? Open an issue or discussion on GitHub