From 9efae115e85eee02caf0272847a0c6c1057714d1 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Tue, 18 Nov 2025 15:09:01 +0200 Subject: [PATCH] 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`. --- src/JuliaFEM.jl | 111 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 37 deletions(-) diff --git a/src/JuliaFEM.jl b/src/JuliaFEM.jl index 17cc0c6..4cc6e04 100644 --- a/src/JuliaFEM.jl +++ b/src/JuliaFEM.jl @@ -129,7 +129,7 @@ end include("api.jl") # Documentation-only (no type definitions) # Formulation domain API (discretization strategies) -include("formulations/api.jl") +include("domains/continuum/formulations.jl") export AbstractFormulation, ContinuumFormulation export AbstractContinuumTheory, FullThreeD, PlaneStress, PlaneStrain, Axisymmetric @@ -151,15 +151,22 @@ export get_elements_for_node, get_element_set, get_node_set export refine # Subdomain API files (define their own abstractions and formulations) -include("beams/api.jl") # AbstractBeamTheory, BeamFormulation{Theory}, EulerBernoulli, Timoshenko +include("domains/beams/api.jl") # AbstractBeamTheory, BeamFormulation{Theory}, EulerBernoulli, Timoshenko export AbstractBeamTheory, BeamFormulation, EulerBernoulli, Timoshenko -include("shells/api.jl") # AbstractShellTheory, ShellFormulation{Theory}, ReissnerMindlin, KirchhoffLove +include("domains/shells/api.jl") # AbstractShellTheory, ShellFormulation{Theory}, ReissnerMindlin, KirchhoffLove export AbstractShellTheory, ShellFormulation, ReissnerMindlin, KirchhoffLove -include("trusses/api.jl") # AbstractTrussTheory, TrussFormulation{Theory}, SimpleTruss +include("domains/trusses/api.jl") # AbstractTrussTheory, TrussFormulation{Theory}, SimpleTruss export AbstractTrussTheory, TrussFormulation, SimpleTruss +# Plate formulations +include("domains/plates/api.jl") +export AbstractPlateFormulation, DKTFormulation, PlateDisplacement +export constitutive_matrix_plate, get_thickness + +# Note: domains/plates/dkt.jl is included later after Mesh is defined (line ~430) + # Physics domain API (abstract type and interface functions) include("physics/api.jl") export AbstractPhysics, assemble!, solve!, add_dirichlet!, add_neumann! @@ -226,20 +233,25 @@ export Wedge6, Wedge15 # → Wedge # Quadrilateral + Lagrange{Quadrilateral, 2} → 9 nodes (Quad9 → Quadrilateral) # ============================================================================ -# QUADRATURE: Low-level integration point data (consolidated from FEMQuad.jl) +# QUADRATURE: Integration schemes and quadrature rules # ============================================================================ -include("quadrature.jl") +include("quadrature/integration.jl") # Abstract integration interface, IntegrationPoint -# ============================================================================ -# INTEGRATION: High-level integration schemes (NEW - separation of concerns) -# ============================================================================ -include("integration/integration.jl") # Abstract integration interface, IntegrationPoint -include("integration/gauss.jl") # Gauss-Legendre quadrature -include("integration/gauss_points.jl") # NEW: Compile-time integration points (zero-allocation) +# Gauss-Legendre quadrature point tables (must be loaded before gauss.jl) +include("quadrature/quaddata.jl") # Quadrature data constants (needed by glquad.jl) +include("quadrature/gltet.jl") # Tetrahedron quadrature points +include("quadrature/gltri.jl") # Triangle quadrature points +include("quadrature/glwed.jl") # Wedge quadrature points +include("quadrature/glpyr.jl") # Pyramid quadrature points +include("quadrature/glquad.jl") # Quadrilateral quadrature points + +include("quadrature/gauss.jl") # Gauss-Legendre quadrature +include("quadrature/gauss_points.jl") # Compile-time integration points (zero-allocation) export AbstractIntegration, IntegrationPoint, integration_points, npoints export Gauss -export get_gauss_points! # NEW: Zero-allocation integration point API +export get_gauss_points! # Zero-allocation integration point API +export get_quadrature_points # Export quadrature point tables # ============================================================================ # GEOMETRY: Jacobian computation and coordinate transformations @@ -265,10 +277,16 @@ include("basis/basis_api.jl") # New API: get_basis_functions, get_basi include("basis/lagrange_generator.jl") include("basis/lagrange_generated.jl") # Auto-generated by: julia --project=. src/basis/lagrange_generator.jl +# Plate element basis functions (DKT, DST, etc.) +include("basis/plate_elements.jl") # AbstractPlateBasis, DKT + # Export basis types and functions (OLD API) export AbstractBasis, Lagrange, Serendipity export nnodes, get_reference_element_coordinates, eval_basis!, eval_dbasis! +# Export plate basis types (NEW - November 2025) +export AbstractPlateBasis, DKT, dof_types, ndofs + # Export new API functions (NEW API - November 2025) export get_basis_functions, get_basis_derivatives export get_basis_function, get_basis_derivative @@ -286,31 +304,41 @@ include("basis/nurbs.jl") # Consolidate FEMBase.jl into src/ (Phase 1 continued) # Order matters: fields → types → sparse → elements → integrate → problems → assembly include("fields/fields.jl") # Field system (DCTI, DVTI, etc.) -include("core_types.jl") # Node, IP, IntegrationPoint +include("legacy/core_types.jl") # Node, IP, IntegrationPoint (LEGACY - Dict-based) # Compatibility shim: Create FEMBase module for vendor packages EARLY -# This must come before preprocess.jl or any code that uses FEMBase.something -include("fembase_compat.jl") +# NOTE: The compatibility shim file was removed to avoid a missing-file +# include during package load. If a full FEMBase compatibility layer is +# required later, add a proper shim file and include it here. include("sparse/sparse.jl") # SparseMatrixCOO, SparseVectorCOO include("elements/elements.jl") # Element type and interface include("elements/elements_lagrange.jl") # OLD - uses AbstractBasis{0} (Poi1) # include("elements/integrate.jl") # OLD - references NSeg, Poi1, etc. -include("assembly/problems.jl") # Problem types -include("assembly/assembly.jl") # Assembly framework +include("legacy/assembly_problems.jl") # Problem types (LEGACY) +include("assembly/framework.jl") # Assembly framework include("solvers/solvers_base.jl") # Base solver types -include("analysis.jl") # Analysis and AbstractResultsWriter -include("deprecated_fembase.jl") # Deprecated/legacy methods from FEMBase (length, size, etc.) +include("legacy/analysis.jl") # Analysis and AbstractResultsWriter (LEGACY) +include("legacy/deprecated_fembase.jl") # Deprecated/legacy methods from FEMBase (LEGACY) # GPU Physics (new architecture - pure GPU, all BCs in device code) # Note: CUDA is loaded by the demo script, not here # The gpu_physics_elasticity.jl module should be included directly by demos # Mesh readers (consolidated from AbaqusReader.jl and AsterReader.jl) -include("readers.jl") +# AbaqusReader - ABAQUS .inp file format +include("readers/keyword_register.jl") +include("readers/parse_mesh.jl") +include("readers/parse_model.jl") +include("readers/create_surface_elements.jl") +include("readers/abaqus_download.jl") + +# AsterReader - Code Aster .med file format (requires HDF5) +# include("readers/read_aster_mesh.jl") +# include("readers/read_aster_results.jl") # Graph algorithms (RCM bandwidth minimization from GraphOrdering.jl) -include("graph/graph_ordering.jl") +include("mesh/graph_ordering.jl") # TODO: Consolidate these vendor packages later # using AbaqusReader # Consolidated into src/readers.jl @@ -325,7 +353,7 @@ include("graph/graph_ordering.jl") # export Elasticity # include("materials_plasticity.jl") # Requires ForwardDiff for automatic differentiation # export plastic_von_mises -include("problems_dirichlet.jl") +include("legacy/problems_dirichlet.jl") # LEGACY export Dirichlet export assemble!, postprocess! @@ -361,12 +389,12 @@ include("materials/neo_hookean.jl") export NeoHookean # Assembly structures (element and nodal) -include("element_assembly_structures.jl") +include("assembly/element_structures.jl") export ElementAssemblyData, ElementContribution export scatter_to_global!, compute_residual!, apply_dirichlet_bc! export matrix_vector_product, get_dof_indices -include("nodal_assembly_structures.jl") +include("assembly/nodal_structures.jl") export NodeToElementsMap, get_node_spider # Backend abstraction (CPU/GPU selection) @@ -379,16 +407,16 @@ export NodeToElementsMap, get_node_spider # CPU backend (fallback for now) # include("backend/cpu.jl") -# Assembly module (NEW API) -include("assembly/continuum_3d.jl") -include("assembly/continuum_3d_v2.jl") # Ferrite-style two-pointer merge +# Assembly module (NEW API - moved to domains/continuum/) +include("domains/continuum/assemble.jl") +include("domains/continuum/assemble_v2.jl") # Ferrite-style two-pointer merge export compute_element_stiffness # For testing and advanced use # GPU backend is now loaded via extension (ext/JuliaFEMCUDAExt.jl) # Extension automatically loads when user does 'using CUDA' # No need to manually include anymore! -include("solvers.jl") +include("legacy/solvers.jl") # LEGACY export AbstractSolver, Solver, Nonlinear, NonlinearSolver, Linear, LinearSolver, get_unknown_field_name, get_formulation_type, get_problems, get_field_problems, get_boundary_problems, @@ -400,9 +428,9 @@ export AbstractSolver, Solver, Nonlinear, NonlinearSolver, Linear, LinearSolver, # Re-export Analysis and related types from FEMBase (needed by tests) export Analysis, AbstractAnalysis, add_problems!, run! -include("problems_contact.jl") -include("problems_contact_3d.jl") -#include("problems_contact_3d_autodiff.jl") +include("legacy/problems_contact.jl") # LEGACY +include("legacy/problems_contact_3d.jl") # LEGACY +#include("legacy/problems_contact_3d_autodiff.jl") # LEGACY export Contact module Preprocess @@ -413,6 +441,9 @@ using SparseArrays, LinearAlgebra # NEW: Include modern parametric Mesh{T<:AbstractTopology} infrastructure include("mesh/mesh.jl") export Mesh, topology_type, nnodes_per_element, nelements, nnodes_total + +# Now that Mesh is defined, include plate elements that depend on it +include("domains/plates/dkt.jl") export get_elements_for_node, connectivity_matrix, get_node export find_nearest_nodes, find_nearest_node export get_element_set, get_elements_in_set @@ -433,6 +464,10 @@ include("mesh/structured.jl") export create_structured_box_mesh, create_unit_cube_mesh export create_cantilever_mesh, create_thin_plate_mesh +# Polar/circular mesh utilities +include("mesh/circular.jl") +export create_circular_plate_mesh + # OLD: Comment out Dict-based Mesh (conflicts with new Mesh{T}) # include("preprocess.jl") # export create_elements, Mesh, add_node!, add_nodes!, @@ -442,6 +477,7 @@ export create_cantilever_mesh, create_thin_plate_mesh # IO submodule for mesh readers and result writers include("io/io.jl") +include("io/gmsh_reader.jl") # GMSH reader (moved from root) using .IO export abaqus_read_mesh, create_surface_elements, create_nodal_elements export aster_read_mesh # Requires HDF5 - add when optional deps are set up @@ -451,12 +487,13 @@ export aster_read_mesh # Requires HDF5 - add when optional deps are set up module Postprocess end -include("postprocess_utils.jl") -export calc_nodal_values!, get_nodal_vector, get_nodal_dict, copy_field!, - calculate_area, calculate_center_of_mass, calculate_second_moment_of_mass, - extract +# Postprocess utilities (moved to trash - needs refactoring) +# include("postprocess_utils.jl") +# export calc_nodal_values!, get_nodal_vector, get_nodal_dict, copy_field!, +# calculate_area, calculate_center_of_mass, calculate_second_moment_of_mass, +# extract -include("deprecations.jl") +include("legacy/deprecations.jl") # LEGACY export SparseMatrixCOO, SparseVectorCOO, optimize!, resize_sparse export DCTI, DVTI, DCTV, DVTV, CCTI, CVTI, CCTV, CVTV, Increment