Commit Graph

26 Commits

Author SHA1 Message Date
Jukka Aho ec600459a9 refactor(dofs): align fields.jl docs and counting with DOF{Q,E} templates
Bring module prose in line with flat `dof_indices`, `@DOFSet`, and DOFHandler-era
helpers while tightening compile-time DOF arithmetic.

- Refresh docstrings: drop markdown bold noise; document `element_dofs` /
  `field_dof_range` instead of NamedTuple-shaped `dof_indices` accessors.
- Rewrite examples to prefer `@DOFSet`; spell out NamedTuple equivalence and drop
  Tuple-based migration snippets incompatible with DOFHandler.
- Implement `field_ndofs(::Type{<:DOF}, Topo)` / `ndofs(::DOFSet, Topo)` using
  `quantity_type` / `entity_type` and generator-style sums over `fieldtypes(S)`.
- Extend `quantity_type(::Type{<:DOF})` for raw `Float64`, `Vec`, `Tensor`, and
  `SymmetricTensor` fields alongside `AbstractField` wrappers.
- Allow `field_ndofs` on raw-quantity DOFs by sizing `T` directly (pressure on
  cells/faces, etc.).
- Remove `single_field` compatibility helper and duplicate element accessors now
  canonical in `src/elements/elements.jl`.
- Point LICENSE header at LICENSE.md.
2026-05-09 16:48:26 +03:00
Jukka Aho bea37f797e test(dofs): remove misplaced extraction test under src/dofs/test
Delete stray test file from src tree; extraction belongs under test/dofs/.
2026-05-09 16:48:00 +03:00
Jukka Aho fe4fff86f0 refactor(dofs): remove unused mixed.jl placeholder module
Drop stale mixed-field scaffold superseded by @DOFSet multifield specs.
2026-05-09 16:47:53 +03:00
Jukka Aho 77fd030124 test(dofs): remove legacy simple_usage script from src/dofs/examples
Delete obsolete usage demo kept next to removed DOFManager workflows.
2026-05-09 16:47:43 +03:00
Jukka Aho 15c8af87bb test(dofs): remove generated_vs_manual_comparison example under src
Drop unmaintained benchmark-style script from src/dofs/examples; coverage lives
in test/dofs instead.
2026-05-09 16:47:30 +03:00
Jukka Aho efde9de197 refactor(dofs): remove entity_dofs convenience aliases
Drop ScalarDOF/VectorDOF/TensorDOF aliases and canned Lagrange-* constants that
duplicated patterns now expressed via `DOF{Q,E}` and `@DOFSet`.

- Eliminates Vec{1}-based scalar alias layering in favor of explicit quantities.
- Removes unused LagrangeHeat/LagrangeElasticity shorthand blocks tied to old tutorials.
2026-05-09 16:46:29 +03:00
Jukka Aho 8c1bb79659 docs(dofs): point module banner at dof_handler include path
Use LICENSE.md URL, drop decorative bold in prose, and rename the JuliaFEM.jl
late-include comment from dof_manager to dof_handler.
2026-05-09 16:45:51 +03:00
Jukka Aho ccffc984b5 refactor(dofs): remove Dict-based dof_manager.jl
Delete the legacy global numbering implementation that stored DOFs in Dicts and
registered Tuple-shaped field specs at runtime.

- Remove `mutable struct DOFManager` with `node_to_dofs`, `field_specs`, mesh
  reference, and incremental `next_dof` counters at odds with type-stable layouts.
- Drop `register_fields!`, `allocate_dofs!`, `count_field_dofs`, mesh-local
  entity counters, and `_assign_element_dofs!` variants tied to that storage.
- Remove `create_elements!` / `_build_dof_connectivity` definitions superseded by
  `dof_handler.jl` (`DOFHandler`, `_make_element_dofs`, `build_dof_connectivity`).
- Element-set helpers and BC-oriented accessors live on `DOFHandler` now; the
  `DOFManager` identifier remains only as the backward-compatible alias.
2026-05-09 16:45:32 +03:00
Jukka Aho 3af1067aeb feat(dofs): add type-stable DOFHandler implementation
Introduce `DOFHandler{M,S,NF}` with flat `field_starts::NTuple{NF,Vector{Int}}`
per field and entity id, optional `facet_maps` for Edge/Face unknowns, running
`total_dofs`, and a `dof_connectivity` slot populated after element creation.
Reserve `DOFManager` as a backward-compatible alias.

Construction and layout:

- Number DOFs in field-declaration order; within each field walk entities in id
  order (nodes, cells, or facet ids) using compile-time `dof_size` widths.
- Auto-build `AbstractFacetConnectivityMaps` for Hex8/Hex20/Tet4/Tet10/Wedge6/Pyr5
  when the DOFSet references Edge or Face; error on unsupported mesh/topology pairs.

Mixed-field helpers:

- `global_field_ranges` — contiguous global index ranges per declared field,
  checked against `handler.total_dofs`.
- `global_facet_dof` — first global DOF for a Face-owned field given facet gid.
- `saddle_point_blocks` / `saddle_point_matrix_blocks` — named views or CSC
  subblocks for two-field `u`/`p`-style matrices using those ranges.

Hot path:

- `@generated _make_element_dofs` emits an `NTuple{N,UInt64}` from handler tables:
  Vertex via element connectivity, Cell via element id, Edge/Face via
  `elem_edge_gid` / `elem_face_gid`; assert emitted length matches `N`.
- `create_elements!` builds the handler, fills `Vector{Element{K,P,S,N}}`, assigns
  DOFs with `_make_element_dofs`, then replaces `handler.dof_connectivity` via
  `build_dof_connectivity`. Support `Element{K,P,S}` with inferred `N`, and wrap a
  bare single `DOF{Q,E}` into a one-field DOFSet.

Legacy-oriented utilities:

- `get_node_dofs` collects Vertex-field DOFs for one node (allocating helper).
- `get_element_ids` resolves ids from `mesh.element_sets` by name or symbol.
2026-05-09 16:42:13 +03:00
Jukka Aho 2afd7a856a refactor(dofs): slim dof_connectivity.jl to builders + DOFHandler overload
Move struct definitions to dof_connectivity_types.jl; drop GPU matrix layout;
use DOFHandler in docs and convenience build_dof_connectivity overload.
2026-05-09 16:35:59 +03:00
Jukka Aho 0f1a1f2f4c feat(dofs): split DOF connectivity structs into dof_connectivity_types.jl
Add DOFElementConnection/DOFConnectivity definitions and empty-placeholder ctor
for handlers before create_elements!.
2026-05-09 16:35:44 +03:00
Jukka Aho 3a1c931021 docs(dofs): remove stale performance_analysis markdown
Drop superseded DOF extraction benchmark narrative from src/dofs/docs.
2026-05-09 16:34:36 +03:00
Jukka Aho f56c9f2d11 docs(dofs): refresh api.jl DOF docstrings for @DOFSet
Align module docs with flat dof_indices, LICENSE.md link, and NamedTuple caveat.
2026-05-09 16:34:16 +03:00
Jukka Aho ef38a28fb2 docs(dofs): rewrite README for DOFHandler and matrix-free connectivity
Replace outdated DOFManager/@Fields prose with current files, create_elements!,
facet-DOF notes, and assembler pointers.
2026-05-09 16:34:03 +03:00
Jukka Aho 9ee8157c54 test(dofs): add DOF extraction test
New test file for DOF extraction functionality:
- Tests extract_element_dofs() function
- Tests extract_element_dofs_structured() function
- Single-field and multi-field test cases
- Type stability verification

Provides test coverage for DOF extraction from global solution vectors.
2025-12-15 06:20:23 +02:00
Jukka Aho 3090679f85 docs(dofs): add generated vs manual DOF comparison example
New comparison example demonstrating:
- Generated DOF extraction vs manual implementation
- Performance comparison
- Code generation benefits
- Type stability advantages

Provides comparison example for DOF system code generation.
2025-12-15 06:20:06 +02:00
Jukka Aho 418f40a2df docs(dofs): add simple DOF usage example
New example file demonstrating basic DOF system usage:
- Simple single-field and multi-field element creation
- DOFManager usage
- Element creation workflow
- Basic DOF extraction examples

Provides simple usage examples for the DOF system.
2025-12-15 06:19:58 +02:00
Jukka Aho 0f8c013178 docs(dofs): add DOF system performance analysis
New performance analysis documentation for DOF system:
- Performance characteristics of DOF-based operations
- Type stability analysis
- Allocation profiling results
- Optimization strategies

Provides performance documentation for the DOF system.
2025-12-15 06:19:53 +02:00
Jukka Aho 3ee615045b docs(dofs): add comprehensive DOF system documentation
New 205-line DOF system documentation:
- Philosophy: multi-field is fundamental, single-field is special case
- Core concept: DOF{T,E} abstract type for type-level specifications
- Field specifications with @DOFSet macro
- Usage examples for single-field and multi-field elements
- DOFManager and element creation workflow
- DOF connectivity for inverse mapping
- Performance notes and design rationale

Provides complete documentation for the unified DOF system architecture.
2025-12-15 06:19:47 +02:00
Jukka Aho 79233380be feat(dofs): add DOF connectivity for inverse mapping
New 434-line DOF connectivity system:
- DOFElementConnection: GPU-compatible bits type (elem_id, local_dof_idx)
- DOFConnectivity: inverse mapping DOF → elements (CPU version)
- DOFConnectivityGPU: GPU version with fixed-size arrays
- build_dof_connectivity(): build inverse mapping from elements
- build_dof_connectivity_gpu(): build GPU-compatible version
- connection_count(), is_empty(): query functions
- Zero-allocation after initialization
- GPU-compatible data structures (bits types, fixed-size arrays)
- Already integrated in JuliaFEM.jl (line 580)

Provides inverse mapping infrastructure for DOF-based assembly.
2025-12-15 06:10:28 +02:00
Jukka Aho 92fe16f45a feat(dofs): add DOFManager for global DOF numbering
New 495-line DOF management system:
- DOFManager: manages global DOF numbering across mesh entities
- register_fields!(): register fields from DOFSet specifications
- allocate_dofs!(): allocate DOFs for entities (supports multi-field)
- get_node_dofs(): retrieve DOF indices for nodes
- count_field_dofs(): count total DOFs for specific field
- count_entities(): count mesh entities by type (Vertex, Edge, Face, Cell)
- create_elements!(): create elements with DOF assignment
- Supports heterogeneous multi-field specifications
- Builds DOF connectivity during element creation
- Already integrated in JuliaFEM.jl (line 577)

Provides global DOF numbering and element creation infrastructure.
2025-12-15 06:10:15 +02:00
Jukka Aho c4afa8347d feat(dofs): add mixed DOF system for coupled fields
New 95-line file for mixed/coupled DOF systems:
- MixedDOF{DOFs}: composition of multiple entity-based DOF types
- Helper functions: is_mixed(), get_dof_types(), num_fields(), get_field_dof_type()
- Support for Stokes (velocity+pressure), 3-field formulations, Taylor-Hood
- DOF ordering: concatenated in field order
- Display formatting for mixed DOF types

Enables mixed interpolation methods with different DOF types per field.
2025-12-15 06:09:56 +02:00
Jukka Aho ed30a5fa43 feat(dofs): add entity-based DOF convenience types
New 169-line file with convenience types and helpers:
- ScalarDOF{E}: type alias for scalar DOFs at entities
- VectorDOF{D,E}: type alias for D-dimensional vector DOFs
- TensorDOF{D,E}: type alias for tensor DOFs
- Convenience constructors for common DOF patterns
- Helper functions for entity-based DOF operations

Provides convenient type aliases for common DOF patterns using entity-based system.
2025-12-15 06:09:36 +02:00
Jukka Aho d105e3e6fa feat(dofs): add unified multi-field specification system
New 396-line field specification system:
- @DOFSet macro for clean multi-field syntax
- ndofs(): compute total DOFs for field specifications
- field_ndofs(): count DOFs per field
- field_names(), field_count(), is_single_field(): field queries
- quantity_type(), entity_type(): extract field components
- single_field(): convert single-field DOFSet to DOF type
- Support for single-field and multi-field specifications
- Comprehensive documentation with examples

Implements unified multi-field architecture where single-field is special case.
2025-12-15 06:09:17 +02:00
Jukka Aho 2df1072f65 feat(dofs): add DOF API with type-level field specifications
New 230-line API file defining DOF system foundation:
- AbstractDOF: base type for all field specifications
- DOF{T,E}: abstract type for type-level field specs (never instantiated)
- DOFSet: type alias for multi-field specifications (currently NamedTuple)
- dof_size(): utility for counting DOF components (Float64, Vec, Tensor, etc.)
- @DOFSet macro support for clean multi-field syntax
- Comprehensive documentation with examples
- Type-level, compile-time resolved (no runtime overhead)

Provides foundation for unified multi-field DOF system.
2025-12-15 06:08:58 +02:00
Jukka Aho 2c1701e6a5 feat(dofs): add DOF system main entry point
New 40-line main entry point for DOF system:
- Includes api.jl (DOF{T,E} abstract type)
- Includes fields.jl (field specification system)
- Documents multi-field philosophy (single-field is special case)
- Defines module structure and dependencies
- Already integrated in JuliaFEM.jl (line 313)

Provides unified type-level field specification system for finite elements.
2025-12-15 06:08:09 +02:00