Implementation

Cauchy is a header-only C++20 codebase with 7 core headers, 6 validation entry points, and 19 Google Test cases. The architecture mirrors the LBM-2D solver for consistency across the portfolio.

Module Reference

FileLinesPurposeKey Types
fea_types.hpp216Core types, enums, globals, JSON parserMaterial, Node, Mesh, CaseType, PlaneType
elements.hpp380Element stiffness matricesBarElement, Q4Element, Q8Element, T3Element
sparse.hpp170Sparse matrix formatsCOOMatrix, CSRMatrix, DenseMatrix
solver.hpp173Linear solversCholeskySolver, CGSolver
mesh.hpp400Mesh generationgenerate_structured_quad, generate_structured_quad8, generate_cook_quad8, load_json
postprocess.hpp288Stress recovery, JSON outputElementStress, compute_all_stresses
adaptivity.hpp350ZZ error estimator, adaptive refinementSPRResult, ElementError, refine_mesh, adaptive_loop
convergence.hpp140GCI computation, h-refinement wrapperGCIResult, ConvergenceSample, run_study
fea.hpp240Assembly + solve pipelineassemble, solve, compute_strain_energy

Include Hierarchy

fea.hpp
  fea_types.hpp    (types, enums, globals)
  elements.hpp     (bar + Q4 + Q8 + T3 stiffness matrices)
  sparse.hpp       (COO/CSR sparse matrix)
  solver.hpp       (Cholesky + CG)
  mesh.hpp         (structured quad mesher + Q8 generators + JSON input)
  postprocess.hpp  (stress recovery, Von Mises)
  adaptivity.hpp   (ZZ SPR, error indicators, red-green refinement)
  convergence.hpp  (GCI, h-refinement)

Entry Point Pattern

Each main_*.cpp follows a consistent 7-step pipeline:

  1. Set globals (g_nx, g_ny, g_case, g_analysis)
  2. Generate or load mesh (Q4 or Q8 via --q8 flag)
  3. Assemble global stiffness matrix (COO, OpenMP parallel)
  4. Apply boundary conditions (penalty method, including Q8 midside nodes)
  5. Solve (Cholesky or Conjugate Gradient)
  6. Post-process (stress recovery, energy balance)
  7. Write JSON output, report statistics

Build Instructions

cmake -B build
cmake --build build -j$(sysctl -n hw.ncpu)

Requirements: C++20 compiler, CMake 3.15+, OpenMP (optional), Google Test (auto-fetched)

Adaptive Refinement Pipeline

The adaptivity module (adaptivity.hpp) implements:

  1. SPR Recovery: Weighted average of Gauss-point stresses at nodes from surrounding elements
  2. Error Indicators: Element-wise = integral of |recovered - FE stress|^2
  3. Marking: "Largest first" strategy with threshold theta (0.5 default)
  4. Red-Green Refinement: Split marked Q4 elements into 4 (red) or 2 (green), add midside nodes
  5. Adaptive Loop: Solve -> recover -> estimate -> mark -> refine -> repeat

./build/FEA_AdaptHole 8 --iters 4
Runs 4 adaptive iterations on the plate-with-hole case, writing
output/adapt_hole_adaptive_convergence.json for visualization.

22 Google Test cases across 10 test suites:

SuiteTestsWhat It Validates
BarElementTest2Stiffness matrix correctness, symmetry
Q4ElementTest4Shape functions, Jacobian, stiffness symmetry, negative Jacobian detection
Q8ElementTest3Shape functions, 3x3 Gauss, 16x16 stiffness symmetry
SparseMatrixTest3COO-to-CSR conversion, SpMV, duplicate merging
CholeskyTest2Identity and diagonal system solves
CGTest2Diagonal system convergence, real FE system convergence
MeshTest3Node counts, coordinates, element connectivity
PatchTest1Constant stress recovery (element verification)
EnergyBalanceTest1Strain energy == work done (U == W)
SolverComparisonTest1Cholesky and CG produce identical results

CI Pipeline

GitHub Actions runs on every push: builds on Ubuntu and macOS, runs the full Google Test suite. Matrix configuration ensures cross-platform compatibility.