A modern Fortran finite element library designed for ease of use, inspired by FreeFEM and FEniCS.
- FEniCS-style API: Natural mathematical notation inspired by FEniCS/FreeFEM
- Simple Forms Syntax: Define weak forms using
inner(grad(u), grad(v))*dx
- One-line plotting:
call plot(uh, title="Solution", colormap="viridis")
- Support for various element types:
- P1 Lagrange: Linear elements with optimal convergence
- Nédélec edge elements: H(curl) conforming for electromagnetic problems
- Vector problems: Curl-curl equations with GMRES iterative solver
- Built-in visualization: Automatic plotting with fortplotlib integration
- Minimal code: Solve PDEs in ~10 lines of meaningful code
- Test-driven development with comprehensive test suite
# Build the library
fpm build
# Run tests
fpm test
# Run examples
fpm run --example simple_poisson
FortFEM provides a clean, FEniCS-inspired API for defining finite element problems:
program poisson_example
use fortfem_api
! Create mesh and function space
mesh = unit_square_mesh(20)
Vh = function_space(mesh, "Lagrange", 1)
! Define trial and test functions
u = trial_function(Vh)
v = test_function(Vh)
f = constant(1.0_dp)
! Define weak form using natural mathematical notation
a = inner(grad(u), grad(v))*dx ! Bilinear form: ∫ ∇u·∇v dx
L = f*v*dx ! Linear form: ∫ f v dx
! Solve and plot in one line
uh = function(Vh)
bc = dirichlet_bc(Vh, 0.0_dp)
call solve(a == L, uh, bc)
call plot(uh, title="Poisson Solution", colormap="viridis")
end program
Explore the examples/ directory for complete working examples:
- Simple Poisson solver - FEniCS-style API demonstration with plotting
- Curl-curl electromagnetic - Vector problems with Nédélec elements and GMRES solver
- Plotting demonstration - Comprehensive plotting API showcase
- Mesh plotting - Mesh visualization examples
src/
- Core library modulestest/
- Comprehensive test suiteexample/
- Example programsdoc/
- Documentationapp/
- Main applications
- API Documentation - Detailed module and procedure documentation
- Source Files - Browse the source code
- Program Structure - Main programs and procedures
- Design Documentation - Architecture and design decisions
- Getting Started - Build and run your first FE simulation
- Examples - Complete working examples
- Module Reference - Complete API reference
- Check the GitHub Issues for current development priorities
- Follow strict TDD: write tests first
- See CLAUDE.md for development guidelines
See LICENSE for details.