Commit Graph

1348 Commits

Author SHA1 Message Date
Jukka Aho fd430a3b70 refactor(assemblers): Create generic assembler type hierarchy
- Define AbstractAssembler and AbstractAssemblerCache base types
- Define ElementBasedAssembler and NodalBasedAssembler strategies
- Define concrete assembler types: COOAssembler, CSCAssembler, NodalAssembler
- Define AbstractKernel interface for domain-specific assembly
- Create ElementCache and NodeCache workspace structures
- Implement create_element_cache() and create_node_cache() functions
- Extract topology type from Mesh{N,T} type parameters at runtime
- 267 lines of type definitions and cache creation logic

Separation of concerns:
- Assemblers define HOW to assemble (traversal, matrix format)
- Kernels define WHAT to assemble (physics-specific computations)

Performance targets:
- COOAssembler: Baseline (1.0x), moderate memory
- CSCAssembler: 4.1x faster, 16.6x less memory
- NodalAssembler: Future GPU implementation (2-10x on GPU)
2025-11-18 18:02:29 +02:00
Jukka Aho 919186dbfb test(physics): Add physics module test suite runner
- Create unified test runner for physics module
- Include test_types.jl for type construction tests
- Include test_boundary_conditions.jl for BC method tests
- Include test_validation.jl for validation tests
- Total: 60 tests passing across 15 test sets
- Test coverage: 41% (264 test lines / 646 implementation lines)
2025-11-18 16:08:36 +02:00
Jukka Aho 217c821035 test(physics): Add validation and multiphysics pattern tests
- Test mesh reference semantics (not copying)
- Verify multiple physics can share same mesh
- Test type parameter specialization for dispatch
- Validate concrete type generation
- Test multiple materials with shared mesh
- Verify BC independence between physics instances
- Document multiphysics coupling patterns
- 13 additional test assertions for edge cases
2025-11-18 16:08:36 +02:00
Jukka Aho 263926a3f3 test(physics): Add unit tests for boundary condition methods
- Test add_dirichlet! with single and multiple nodes
- Test partial DOF constraints (e.g., only z-direction)
- Test BC accumulation across multiple calls
- Test add_neumann! with single and multiple surfaces
- Test different traction values and vectors
- Test combined Dirichlet and Neumann BCs
- Verify BC independence between physics instances
- 149 lines with 47 test assertions
2025-11-18 16:08:36 +02:00
Jukka Aho eb385eb22a test(physics): Add comprehensive unit tests for Physics types
- Test DirichletBC, NeumannBC, Constraint construction
- Test Physics construction with various mesh topologies
- Verify type parameter inference and specialization
- Test with Hex8 and Segment mesh types
- Validate concrete type parameters for dispatch optimization
- 100 lines covering all type construction scenarios
2025-11-18 16:08:36 +02:00
Jukka Aho 72e22ec4cb refactor(physics): Update module includes for new structure
- Include physics/abstract.jl for AbstractPhysics type
- Include physics/api.jl for interface functions
- Include physics/types.jl for concrete Physics struct
- Include physics/boundary_conditions.jl for BC implementations
- Update exports: AbstractPhysics, Physics, Constraint, DirichletBC, NeumannBC
- Maintain backward compatibility with existing code
- Remove old single-file physics.jl include
2025-11-18 16:08:35 +02:00
Jukka Aho ae9e7e3727 feat(physics): Implement boundary condition methods
- Implement add_dirichlet! for essential BCs (prescribed values)
- Implement add_neumann! for natural BCs (forces/tractions)
- Support multiple nodes and DOF components in single call
- Store BCs in physics.bc_dirichlet and physics.bc_neumann
- Add usage examples for common BC patterns
- 86 lines with complete method implementations
2025-11-18 16:08:35 +02:00
Jukka Aho 90d9f52bf6 refactor(physics): Implement Physics struct with 4 type parameters
- Define Physics{Formulation, Field, Mesh, Material} <: AbstractPhysics
- Implement type parameter validation in inner constructor
- Add DirichletBC for essential boundary conditions
- Add NeumannBC for natural boundary conditions
- Add Constraint placeholder for future constraint handling
- Provide keyword constructor with automatic type inference
- Document dispatch-optimized type parameter order
- 205 lines including comprehensive docstrings
2025-11-18 16:08:35 +02:00
Jukka Aho 8479b06cac refactor(physics): Define clean Physics API interface
- Remove duplicate AbstractPhysics definition (now in abstract.jl)
- Define interface functions: assemble!, solve!, add_dirichlet!, add_neumann!
- Document dispatch strategies for formulation × field combinations
- Add implementation method documentation (elimination, penalty, Lagrange)
- Include comprehensive usage examples for each interface function
- Specify must-include-after dependencies in header comments
- 246 lines of interface documentation
2025-11-18 16:08:35 +02:00
Jukka Aho 6243e4fe1e refactor(physics): Create consolidated AbstractPhysics definition
- Define AbstractPhysics abstract type in dedicated file
- Consolidate documentation from previous duplicate definitions
- Document type as coupling of Mesh, Material, Field, and Formulation
- Add comprehensive examples for 3D solid, heat, and beam physics
- Include multiphysics pattern documentation
- Remove duplicate AbstractPhysics definitions across codebase
- 109 lines of documentation and abstract type definition
2025-11-18 16:08:35 +02:00
Jukka Aho 43539f2441 Implement Hex8 longest-edge refinement
- Introduce AbstractRefineStrategy and LongestEdgeBisection
- Split Hex8 elements per axis with midpoint deduplication
- Preserve mesh metadata while iterating refinement levels
2025-11-18 15:21:41 +02:00
Jukka Aho 17635fa816 Add structured Hex8 mesh builders
- Create general box mesher with boundary node/element sets
- Provide convenience wrappers for unit cubes, cantilevers and thin plates
- Document usage examples for convergence and application setups
2025-11-18 15:21:39 +02:00
Jukka Aho 18f23c8fc2 Add polar circular plate mesh generator
- Generate Tri3 rings parameterized by radius, radial and angular counts
- Populate connectivity for central fan and radial bands
- Define default node/element sets for center and outer boundary conditions
2025-11-18 15:21:26 +02:00
Jukka Aho 1d5bd996b9 Introduce parametric Mesh core type
- Define Mesh{N,T} structure with validated connectivity and sets
- Provide APIs for node/element lookup, colors, ghost ownership and IDs
- Implement permutation, adjacency and utility helpers for assembly workflows
2025-11-18 15:19:30 +02:00
Jukka Aho 744b0de04e test(runtests): Reduce default test entrypoint to fast smoke checks + validation case
- Replace long list of legacy `include(...)` tests with small smoke checks asserting core types exist
- Add a single validation include: `validation/test_cantilever_regression.jl`
- Note legacy tests moved to `test/broken/` for later migration

This reduces CI turn-around time while keeping a lightweight verification of core functionality. Full integration tests can be run explicitly.
2025-11-18 15:09:51 +02:00
Jukka Aho 468c786926 docs(physics): Fix fenced code block formatting and escape interpolation in examples
- Replace language-tagged code fences and add proper blank lines to satisfy Markdown lint rules
- Escape `$` in example error string to avoid accidental interpolation (`error("No assembly method for formulation \$Fm with field \$F")`)

Formatting-only changes to improve generated documentation and prevent lint failures; no runtime behavior altered.
2025-11-18 15:09:46 +02:00
Jukka Aho 22a1dbfd8a chore(io): Limit IO module imports to only Element and Mesh
- Removed unused imports (`add_node!`, `add_element_to_element_set!`, `add_node_to_node_set!`) from the `using ..JuliaFEM:` line
- Keep `Preprocess` re-exported for convenience

This reduces namespace pollution and lowers the chance of circular import issues; no functional changes expected.
2025-11-18 15:09:37 +02:00
Jukka Aho 6ee2a3b3ff feat(basis): Add ndofs interface to query DOF counts for basis types
- Add `ndofs(::AbstractBasis)` / `ndofs(::Type{<:AbstractBasis})` with docstring and examples
- Default implementation: `ndofs == nnodes` for standard Lagrange bases
- Export `ndofs` alongside `Lagrange` and `nnodes`

This provides a stable API for callers to preallocate element-local buffers and supports plate elements that have multiple DOFs per node.
2025-11-18 15:09:27 +02:00
Jukka Aho 06d6be33df docs(api): Reflow API design documentation and add spacing for readability
- Insert blank lines around headings and list items for better rendering
- Clarify pattern notes: zero-duplication, domain ownership, minimal core
- Improve example spacing so code fences render correctly in generated docs

No code changes; only formatting and readability improvements to the API documentation.
2025-11-18 15:09:09 +02:00
Jukka Aho 9efae115e8 refactor(module): Reorganize includes and re-exports to new modular layout
- Replace `include("formulations/api.jl")` with `include("domains/continuum/formulations.jl")`
- Move domain API includes under `domains/*` (beams, shells, trusses, plates)
- Add plate formulations and plate basis includes (DKT, plate elements)
- Rework quadrature includes to load tables from `quadrature/*` and export `get_quadrature_points`
- Consolidate legacy modules under `legacy/` and adjust includes accordingly
- Consolidate mesh readers under `readers/*` and move GMSH reader into `io/gmsh_reader.jl`
- Replace older assembly includes with `assembly/framework.jl` and `assembly/*` structures
- Export new API symbols and add compatibility re-exports where needed

This change reorganizes the package file structure and wiring to make the new modular architecture (domains, quadrature tables, plate elements, and legacy shims) loadable from the top-level `src/JuliaFEM.jl`.
2025-11-18 15:09:01 +02:00
Jukka Aho 6743aa0d72 deps(manifest): Pin LinearOperators in Manifest.toml
- Added: `LinearOperators` to the `deps` list for the `JuliaFEM` project entry

Reason: The project requires linear-operator abstractions for matrix-free and operator-based solvers/benchmarks. Pinning here documents the dependency and helps maintain reproducible builds.
2025-11-18 15:08:38 +02:00
Jukka Aho a92a7ad083 chore(git): Add common local and editor files to .gitignore
- Added: `.env` to avoid committing local environment variables
- Added: `.vscode/` to ignore editor workspace settings and launch configs
- Added: `trash` to ignore developer temporary files

These entries reduce noisy diffs and help prevent accidental leakage of local secrets or editor-specific files.
2025-11-18 15:08:27 +02:00
Jukka Aho d9fc071304 Move src/solvers_modal.jl to src/legacy/solvers_modal.jl 2025-11-18 14:16:02 +02:00
Jukka Aho 2dc58661ff Move src/solvers.jl to src/legacy/solvers.jl 2025-11-18 14:16:02 +02:00
Jukka Aho 939f107846 Move src/problems_truss.jl to src/legacy/problems_truss.jl 2025-11-18 14:16:02 +02:00
Jukka Aho f4af828583 Move src/problems_mortar_3d.jl to src/legacy/problems_mortar_3d.jl 2025-11-18 14:16:01 +02:00
Jukka Aho e6c37a5287 Move src/problems_mortar.jl to src/legacy/problems_mortar.jl 2025-11-18 14:16:01 +02:00
Jukka Aho 54ba785b1e Move src/problems_heat.jl to src/legacy/problems_heat.jl 2025-11-18 14:16:01 +02:00
Jukka Aho 47a8304682 Move src/problems_elasticity_2d.jl to src/legacy/problems_elasticity_2d.jl 2025-11-18 14:16:01 +02:00
Jukka Aho 66fc03d2b6 Move src/problems_elasticity.jl to src/legacy/problems_elasticity.jl 2025-11-18 14:16:01 +02:00
Jukka Aho 10f99f071a Move src/problems_dirichlet.jl to src/legacy/problems_dirichlet.jl 2025-11-18 14:16:01 +02:00
Jukka Aho 6e278ee5a7 Move src/problems_contact_3d.jl to src/legacy/problems_contact_3d.jl 2025-11-18 14:16:01 +02:00
Jukka Aho 7462a853d1 Move src/problems_contact.jl to src/legacy/problems_contact.jl 2025-11-18 14:16:00 +02:00
Jukka Aho 7d60567d63 Move src/physics_api.jl to src/legacy/physics_api.jl 2025-11-18 14:16:00 +02:00
Jukka Aho d019839b58 Move src/integration/integration.jl to src/quadrature/integration.jl 2025-11-18 14:16:00 +02:00
Jukka Aho e005775ceb Move src/graph/graph_ordering.jl to src/mesh/graph_ordering.jl 2025-11-18 14:16:00 +02:00
Jukka Aho c00f9e0efa Move src/gmsh_reader.jl to src/io/gmsh_reader.jl 2025-11-18 14:16:00 +02:00
Jukka Aho d25bb109b6 Move src/integration/gauss_points.jl to src/quadrature/gauss_points.jl 2025-11-18 14:16:00 +02:00
Jukka Aho 6f65fccb8d Move src/integration/gauss.jl to src/quadrature/gauss.jl 2025-11-18 14:16:00 +02:00
Jukka Aho 725552a88a Move src/fembase_compat.jl to src/legacy/fembase_compat.jl 2025-11-18 14:15:59 +02:00
Jukka Aho ec05018590 Move src/deprecations.jl to src/legacy/deprecations.jl 2025-11-18 14:15:59 +02:00
Jukka Aho 5655e204c9 Move src/deprecated_fembase.jl to src/legacy/deprecated_fembase.jl 2025-11-18 14:15:59 +02:00
Jukka Aho 62afc0e904 Move src/core_types.jl to src/legacy/core_types.jl 2025-11-18 14:15:59 +02:00
Jukka Aho 42e2ce9518 Move src/analysis.jl to src/legacy/analysis.jl 2025-11-18 14:15:58 +02:00
Jukka Aho 9d91733a2b refactor(tests): Reorganize test suite into subdirectories
Remove 71 flat test files from test/ root (all test_*.jl files):
- 22 elasticity tests (1D, 2D, 3D, plane stress/strain, various loads)
- 10 heat transfer tests (2D, 3D, convection)
- 11 mortar contact tests (2D, 3D, mesh tie, contact)
- 7 modal analysis tests
- 4 elasticplastic tests (finite strain, 2D, 3D)
- 3 assembly tests (element, nodal, comparison)
- 14 other tests (jacobian, strain, dirichlet, gpu, etc.)

These tests have been reorganized into subdirectories:
- test/assembly/ - Assembly method tests
- test/basis/ - Basis function tests
- test/backend/ - Backend-specific tests
- test/elements/ - Element-specific tests
- test/geometry/ - Geometry operation tests
- test/integration/ - Integration scheme tests
- test/io/ - Input/output tests
- test/laboratory/ - Material laboratory tests
- test/materials/ - Material model tests
- test/mesh/ - Mesh operation tests
- test/performance/ - Performance benchmarks
- test/physics/ - Physics coupling tests
- test/problems/ - Complete problem tests
- test/solvers/ - Solver tests
- test/topology/ - Topology tests
- test/validation/ - Validation against references
- test/deprecated_tests/ - Deprecated/commented-out tests

Improves test organization: domain-based structure instead of flat file list.
See test/deprecated_tests/README.md for deprecation reasoning.
2025-11-15 18:55:01 +02:00
Jukka Aho 77eebcc666 feat(core): Integrate modular API architecture into main JuliaFEM module
Update src/JuliaFEM.jl to include all domain api.jl files:
- Include api.jl as documentation guide (no type definitions)
- Include formulations/api.jl → export AbstractFormulation, continuum theories
- Include fields/api.jl → export Displacement, Temperature, DisplacementRotation
- Include materials/api.jl → export AbstractMaterial, compute_stress, elasticity_tensor
- Include mesh/api.jl → export AbstractMesh, node-to-elements mapping
- Include beams/shells/trusses/api.jl → export structural formulations
- Include physics.jl → export Physics, DirichletBC, NeumannBC
- Include topology/api.jl → export AbstractTopology{N}, interface functions

Proper dependency order enforced:
1. Core (api.jl documentation)
2. Formulations (HOW to discretize)
3. Fields (WHAT to solve)
4. Materials (constitutive laws)
5. Mesh (topology ownership)
6. Structural (beams/shells/trusses)
7. Physics (coupling all components)
8. Topology (element geometry)

Export statements organized by domain, immediately after each include.
Completes systematic modular API architecture integration.
2025-11-15 18:45:53 +02:00
Jukka Aho 096199af20 docs(api): Create documentation-only core API guide for modular architecture
Create src/api.jl as pure documentation (196 lines, NO type definitions):
- Documents the complete modular API architecture
- Lists all 9 domain api.jl files in dependency order
- Explains design philosophy: zero duplication, domain ownership, minimal core
- Shows type hierarchy across all domains
- Demonstrates assembly dispatch pattern (formulation × field)
- Lists 7 advantages of modular architecture

This file is the architectural guide - all actual type definitions live in
domain-specific api.jl files:
- formulations/api.jl (AbstractFormulation, continuum theories)
- fields/api.jl (Displacement, Temperature, DisplacementRotation)
- materials/api.jl (AbstractMaterial, elastic/plastic)
- mesh/api.jl (AbstractMesh, node-to-elements mapping)
- beams/shells/trusses/api.jl (structural formulations)
- topology/api.jl (AbstractTopology{N}, 17 element types)

Completes systematic modular API refactoring - every domain owns its
abstractions, core is documentation-only.
2025-11-15 18:45:06 +02:00
Jukka Aho 1b18af15a1 refactor(topology): Move interface to topology/api.jl, keep helpers in topology.jl
Refactor src/topology/topology.jl from 173 to 12 lines:
- Remove all AbstractTopology{N} interface definitions (161 lines removed)
- Remove nnodes(), dim(), reference_coordinates(), edges(), faces() stubs
- Interface now defined in src/topology/api.jl (included first)
- Keep file as placeholder for future helper functions
- Add note referencing topology/api.jl for interface

This completes separation of interface (api.jl) from implementations.
Topology/topology.jl previously mixed interface and helpers - now
clean separation following systematic modular architecture pattern.

Part of systematic modular API refactoring.
2025-11-15 18:44:48 +02:00
Jukka Aho 000dee3994 feat(physics): Add physics coupling API with multiphysics support
Create src/physics/api.jl defining physics problem abstractions:
- AbstractPhysics base type for all physics problems
- assemble!() interface for building global system (K, f)
- solve!() interface for solving physics problems
- add_dirichlet!() for essential BCs (prescribed displacements/temperatures)
- add_neumann!() for natural BCs (surface tractions/heat flux)

Physics couples four components: Mesh (where), Material (constitutive law),
Field (what we solve), Formulation (how we discretize). Physics references
Mesh (does not own it) enabling multiphysics: multiple Physics can share
one Mesh for memory efficiency and coupling.

Dispatch specialization via formulation × field type parameters:
  assemble!(::Physics{ContinuumFormulation{FullThreeD}, Displacement{3}, M, Mat})
  assemble!(::Physics{BeamFormulation{Timoshenko}, DisplacementRotation{3}, M, Mat})

Comprehensive documentation with multiphysics examples, dispatch patterns,
and interface contracts. Assembly implementations in src/assembly/.

Part of systematic modular API architecture.
2025-11-15 18:42:03 +02:00
Jukka Aho 2e41f9502d feat(topology): Add element topology API with 17 reference element types
Create src/topology/api.jl defining element topology abstractions:
- AbstractTopology{N} base type (N = node count from mesh connectivity)
- Interface: nnodes(), dim(), reference_coordinates(), edges(), faces()
- 7 shape families: Segment, Triangle, Quadrilateral, Tetrahedron, Hexahedron, Pyramid, Wedge
- 17 concrete types: Seg2/3, Tri3/6/7, Quad4/8/9, Tet4/10, Hex8/20/27, Pyr5, Wedge6/15

Key design: Topology defines SHAPE (triangle), not node count. Node count
comes from basis order: Triangle + Lagrange{Triangle,1} → 3 nodes (Tri3),
Triangle + Lagrange{Triangle,2} → 6 nodes (Tri6). This enables clean
separation: Topology (shape) ≠ Basis (interpolation) ≠ Integration (quadrature).

Reference element coordinates defined for all topologies. Zero-allocation
API using tuples. Backward compatibility: Tri3/Quad4/Tet10 aliased to
shape names with implied basis.

Comprehensive documentation with theory and examples.
Part of systematic modular API architecture.
2025-11-15 18:41:34 +02:00