Jukka Aho 85900fe680 feat(mesh): add structured Quad4/Seg2/Cook meshes and face-aware extract_surface
Structured mesh helpers now cover 2D quads in the xy plane, a 1D Seg2 chain
embedded in R^3, and Cook’s membrane on a bilinear Quad4 map, so plane tests
and benchmarks can build reference geometry without ad hoc connectivity.
extract_surface gains an explicit volume-local face index and uses faces(T)
when the face vertex count matches the surface topology, which avoids picking
the wrong face by default for low-order hex meshes that list true face corners.

- structured.jl: SPDX header; add create_structured_line_mesh(Seg2; x0,x1,nx,y,z)
- structured.jl: add create_structured_box_mesh(Quad4; xmin,xmax,…,z) with :xmin/:xmax/:ymin/:ymax node sets
- structured.jl: add create_cook_membrane_mesh(Quad4, nx, ny; scale) with classical Cook corner map and same node-set convention
- mesh.jl: extract_surface(mesh, set; local_face=1) selects vol_faces[local_face]; build face_conn from face vertex indices when length matches n_face_nodes, else keep first-n legacy fallback for high-order volume/surface mismatch
- README.md: document Quad4/Seg2/Cook entry points; clarify mesh I/O is not in core load path (see src/io/README.md)
2026-05-11 02:26:23 +03:00
2026-05-09 16:30:27 +03:00
2026-05-09 16:30:28 +03:00
2025-12-12 21:34:59 +02:00
2026-05-09 16:30:23 +03:00

JuliaFEM.jl

logo

DOI License

JuliaFEM.jl is an open-source finite element framework written in Julia. The package is still 0.x; the repository is in the middle of a deliberate architectural reset toward a stable 1.0 with a type-stable, zero-allocation, GPU-friendly assembly pipeline. Many older READMEs and tutorials still describe the previous API; when in doubt, trust the code and AGENTS.md. Contributions (bug reports, docs, tests, and features) are welcome.

Status

Current focus areas:

  • Element{K, P, S, N} template with compile-time DOF layout.
  • DOFHandler and DOFBasedCOOAssembler (zero-allocation hot paths).
  • Microkernel-style physics in src/domains/{continuum, heat, thermo_elastic}/.
  • Matrix-free apply_K!, apply_M!, Dirichlet, multipoint constraints, IC(0) / Jacobi / block-Jacobi preconditioners and a generalized eigensolver in src/assemblers/.
  • A KernelAbstractions backend for the matrix-free path with a Float32 Metal smoke test in test/backend/metal/.

The legacy element-based API (Problem, update!, Analysis, …) is still present under src/legacy/ for backward compatibility but is not the recommended entry point.

Installing

using Pkg
Pkg.add("JuliaFEM")

A modern minimal example

using JuliaFEM

mesh = create_structured_box_mesh(Hex8;
    xmin = 0.0, xmax = 1.0, nx = 4,
    ymin = 0.0, ymax = 1.0, ny = 4,
    zmin = 0.0, zmax = 1.0, nz = 4,
)

S  = @DOFSet{u::DOF{Displacement{3}, Vertex}}
ET = Element{Hex8, Lagrange{1}, S}
elements, handler = create_elements!(mesh, ET)

material = LinearElastic(E = 210e9, ν = 0.3)
kernel   = ContinuumKernel(ContinuumFormulation{FullThreeD}(),
                           material, Displacement{3}())

asm   = DOFBasedCOOAssembler()
cache = create_cache(asm, elements, handler, mesh, kernel)
assemble!(cache, asm, kernel, mesh)
K, f  = extract_system(cache)

The same block is parsed from this file in test/docs/readme_example.jl, so it stays copy-pasteable as the API evolves.

For a matrix-free Krylov solve, see test/assemblers/test_dof_based_apply_K.jl and test/assemblers/test_eigensolve.jl.

Documentation

Contributing

Please read docs/CONTRIBUTING.md before opening a pull request: fork and branch, keep changes review-sized, run tests, and describe what you changed.

Git commits. Keep history easy to read: small commits, usually one file; two files in one commit is fine when they are inseparable (e.g. a helper and its only caller). An optional hook (.githooks/, set core.hooksPath) caps staged paths at two. If that workflow feels unfamiliar, open your PR with tests passing and ask for help splitting history in review.

Code expectations. Assembly hot paths must stay type-stable and allocation-free after warmup; CI and test/assemblers/test_dof_based_zero_alloc.jl guard that. The full suite:

julia --project=. -e 'using Pkg; Pkg.test()'

Use that locally before opening a PR; CI runs the same tests.

Citing

If you use JuliaFEM.jl in academic work, please cite

@article{frondelius2017juliafem,
  title   = {Julia{FEM} - open source solver for both industrial and academia usage},
  volume  = {50},
  url     = {https://rakenteidenmekaniikka.journal.fi/article/view/64224},
  doi     = {10.23998/rm.64224},
  number  = {3},
  journal = {Rakenteiden Mekaniikka},
  author  = {Frondelius, Tero and Aho, Jukka},
  year    = {2017},
  pages   = {229-233}
}
S
Description
Languages
Julia 98%
Python 1.7%
Shell 0.3%