Skip to content

lazy-fortran/fortfem

Repository files navigation

CI codecov Documentation

A modern Fortran finite element library designed for ease of use, inspired by FreeFEM and FEniCS.

Features

  • 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

Quick Start

# Build the library
fpm build

# Run tests
fpm test

# Run examples
fpm run --example simple_poisson

Usage Example

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

Examples

Explore the examples/ directory for complete working examples:

Project Structure

  • src/ - Core library modules
  • test/ - Comprehensive test suite
  • example/ - Example programs
  • doc/ - Documentation
  • app/ - Main applications

Navigation

Quick Links

Contributing

  1. Check the GitHub Issues for current development priorities
  2. Follow strict TDD: write tests first
  3. See CLAUDE.md for development guidelines

License

See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •