Recent from talks
Nothing was collected or created yet.
FEniCS Project
View on Wikipedia| FEniCS Project | |
|---|---|
| Stable release | 0.9.0 (October 10, 2024[1]) [±] |
| Operating system | Linux, OS X, Unix, WSL |
| Available in | C++, Python |
| Type | Scientific simulation software |
| License | GNU Lesser General Public License |
| Website | www |
The FEniCS Project is a collection of free and open-source software components with the common goal to enable automated solution of differential equations. The components provide scientific computing tools for working with computational meshes, finite-element variational formulations of ordinary and partial differential equations, and numerical linear algebra.[2][3]
Design and components
[edit]The FEniCS Project is designed as an umbrella project for a collection of interoperable components. The core components are[4]

- UFL (unified form language), a domain-specific language embedded in Python for specifying finite element discretizations of differential equations in terms of finite element variational forms;
- FIAT (finite element automatic tabulator), the finite element backend of FEniCS, a Python module for generation of arbitrary order finite element basis functions on simplices;
- FFC (fenics form compiler), a compiler for finite element variational forms taking UFL code as input and generating UFC output;
- UFC (unified form-assembly code), a C++ interface consisting of low-level functions for evaluating and assembling finite element variational forms;
- Instant, a Python module for inlining C and C++ code in Python;
- DOLFIN, a C++/Python library providing data structures and algorithms for finite element meshes, automated finite element assembly, and numerical linear algebra.
DOLFIN, the computational high-performance C++ backend of FEniCS, functions as the main problem-solving environment (in both C++ and Python) and user interface. Its functionality integrates the other FEniCS components and handles communication with external libraries such as PETSc, Trilinos and Eigen for numerical linear algebra, ParMETIS and SCOTCH for mesh partitioning, and MPI and OpenMP for distributed computing.
As of May 2022, DOLFINx is the recommended user-interface of the FEniCS project.[5]
History
[edit]The FEniCS Project was initiated in 2003 as a research collaboration between the University of Chicago and Chalmers University of Technology. The following institutions are currently, or have been, actively involved in the development of the project
DOLFINx
[edit]Since 2019, the core components of the FEniCS project have received a major refactoring.[7] resulting in DOLFINx.[8] DOLFINx supports many new features not available in the old DOLFIN interface, including:
- Arbitrary degree finite elements on interval, triangle, quadrilateral, tetrahedral and hexahedral cells, including unstructured meshes without special ordering;
- Meshes with flat or curved cells;
- Custom partitioning of cells across multiple processes;
- Parallel IO via Gmsh, VTK, PyVista, and ADIOS2;
- Assembly and solvers using different floating point scalar types, including complex types;
- Assembly of custom element kernels written using Numba;
- Interpolation of functions into arbitrary function spaces;
- Interpolation between function spaces built on different (non-matching) meshes, including meshes using non-affine geometry;
- Ability to non-intrusively support different linear algebra backends, e.g., NumPy, PETSc, Trilinos, and Eigen;
- User-defined finite elements.
See also
[edit]- List of finite element software packages
- List of numerical analysis software
- Using the FEATool Multiphysics GUI to set up and solve FEniCS multiphysics models[9][10]
- DefElement: An encyclopedia of finite element definitions
References
[edit]- ^ https://github.com/FEniCS/dolfinx/releases/tag/v0.9.0
- ^ "The FEniCS Project page". The FEniCS Project. Retrieved 28 July 2016.
- ^ Anders Logg; Kent-Andre Mardal; Garth N. Wells, eds. (2011). Automated Solution of Differential Equations by the Finite Element Method. Springer. ISBN 978-3-642-23098-1.
- ^ "Core components of the FEniCS Project". The FEniCS Project. Archived from the original on 4 November 2011. Retrieved 8 December 2011.
- ^ "The new DOLFINx solver is now recommended over DOLFIN". fenicsproject.discourse.group.
- ^ a b FEniCS Governance documents. Retrieved 28 July 2016.
- ^ "Roadmap 2019-2020 – FEniCS Project". fenicsproject.org. Archived from the original on 2019-06-07.
- ^ "DOLFINx: The next generation FEniCS problem solving environment". Retrieved 2024-04-04.
- ^ "Python FEM and Multiphysics Simulations with FEniCS and FEATool". featool.com. Retrieved 2017-06-28.
- ^ Abali, Bilen Emek (2017). Computational Reality | SpringerLink. Advanced Structured Materials. Vol. 55. doi:10.1007/978-981-10-2444-3. ISBN 978-981-10-2443-6.
External links
[edit]FEniCS Project
View on GrokipediaIntroduction
Overview
The FEniCS Project is an open-source computing platform designed for solving partial differential equations (PDEs) using the finite element method (FEM). It enables users to translate scientific models into efficient finite element code through high-level Python and C++ interfaces, making it accessible to both beginners and experienced programmers. The platform supports computations ranging from laptops to high-performance computing clusters and is collaboratively developed by researchers worldwide.[1] Initiated in 2003 by Anders Logg and Johan Hoffman at the Chalmers University of Technology, with contributions from Ridgway Scott based on prior work like the Analysa system, FEniCS aims to automate the process of computational mathematical modeling, particularly for finite element discretizations of PDEs. Its philosophy emphasizes intuitive, efficient, and flexible tools that allow high-level descriptions of mathematical structures, reducing error-prone low-level coding. Key components include DOLFINx, a high-performance C++ library for meshes, function spaces, and assembly; the Unified Form Language (UFL) for variational formulations; FFCx, a form compiler; and Basix for basis functions.[6][2] FEniCS has significantly impacted fields such as biomedical computing, including simulations of blood flow and cardiac mechanics at institutions like Simula Research Laboratory. The project received the 2015 Wilkinson Prize for Numerical Software through its collaboration on dolfin-adjoint, highlighting its contributions to automatic differentiation in PDE solvers. It continues to evolve, with its stable release, FEniCSx version 0.1 in October 2025, representing the latest iteration and offering improved support for diverse cell types and integration with libraries like PETSc for scalable solvers.[2][6][3]Goals and Philosophy
The FEniCS Project aims to establish a new standard in computational mathematical modeling (CMM) by automating the solution of partial differential equations (PDEs) using the finite element method (FEM), emphasizing generality, efficiency, and simplicity in both methodology and implementation.[7] This automation encompasses key stages of the FEM workflow, including the generation of finite element discretizations, evaluation of variational forms, mesh adaptation, assembly of discrete systems, and error control, enabling users to translate mathematical models into efficient code with minimal manual intervention.[8] By providing high-level interfaces in Python and C++, the project targets scientists and engineers, from novices to experts, facilitating rapid prototyping on diverse platforms ranging from laptops to high-performance computing systems.[1] Philosophically, FEniCS draws inspiration from Gottfried Wilhelm Leibniz's principle of the "best possible of worlds," seeking maximal generality in problem-solving through minimal foundational principles, akin to natural selection in computational tools.[7] The project views automation as essential for advancing scientific discovery and societal progress, reducing environmental impact by optimizing simulations and democratizing access to advanced numerical methods via open-source licensing under the GNU Lesser General Public License (LGPL) version 3.[7][9] This commitment to openness fosters international collaboration among institutions such as the University of Chicago, Chalmers University of Technology, and Simula Research Laboratory, under the fiscal sponsorship of NumFOCUS, promoting reusable components and community-driven development.[8][10] Core to its design is a balance of simplicity and power: users express problems in a high-level, intuitive domain-specific language, while underlying compilers like the Form Compiler (FFC) generate optimized, low-level code for efficiency, such as reducing operations in tensor contractions from 16 to 11 in non-trivial cases.[8] The project prioritizes correctness through adaptive error estimation and automatic verification, ensuring reliable results without exhaustive manual tuning, and supports extensions like parallelization and optimization of cost functionals to handle complex, real-world applications.[7] Overall, FEniCS seeks to transform FEM from a labor-intensive craft into an automated, accessible science, impacting both academic research and industrial simulations.[1]History
Founding and Early Development
The FEniCS Project was founded in 2003 as a collaborative effort to develop open-source software for the automated solution of partial differential equations using the finite element method. The initiative brought together researchers from Chalmers University of Technology in Sweden, the University of Chicago, and the Toyota Technological Institute at Chicago, with key founders including Todd Dupont, Johan Hoffman, Claes Johnson, Robert Kirby, Mats Larson, Anders Logg, and Ridgway Scott. This partnership built on earlier prototypes, notably the DOLFIN library initiated in 2002 at Chalmers by Logg and collaborators to provide an adaptive finite element computation platform, and FIAT, developed by Kirby at the University of Chicago for automatic tabulation of finite element basis functions. The project's vision emphasized generality, efficiency, and simplicity in computational mathematical modeling, aiming to bridge the gap between mathematical formulation and efficient code generation.[7][11][2] Early development focused on integrating these initial components to create a unified framework for automating finite element computations. DOLFIN served as the computational kernel, handling mesh generation, assembly, and solving, while FIAT provided the basis function computations necessary for variational formulations. An additional prototype, Analysa—a Scheme-based problem-solving environment for PDEs—was incorporated to support high-level scripting. By 2005, the project had advanced to include the Form Compiler (FFC), which automated the generation of efficient code from variational forms, and the Unified Form Language (UFL), a domain-specific language for expressing weak forms of PDEs. These additions enabled users to specify mathematical models declaratively, with the software handling discretization and optimization automatically. Workshops, such as the 2005 FEniCS event at the Toyota Technological Institute, facilitated collaboration and refinement among developers.[7][2][12] The project's open-source philosophy, adopted from the outset, encouraged contributions from a growing international community, leading to rapid iterations in the mid-2000s. Initial releases, including version 0.9 around 2005, demonstrated the framework's potential through benchmarks on standard PDE problems like Poisson's equation, showcasing performance comparable to hand-coded solvers while reducing development time. By 2008, FEniCS had evolved to support complex multiphysics simulations, with publications highlighting its role in advancing automated scientific computing. This period solidified FEniCS as a foundational tool in computational science, influencing subsequent tools like Firedrake.[2][13][14]Key Milestones and Evolution
Early development accelerated with the introduction of key technologies, including the Unified Form Language (UFL) in 2005 for high-level expression of variational forms and the FEniCS Form Compiler (FFC) for just-in-time code generation. The first FEniCS conference was held in 2005, marking the project's growing community engagement with 15 participants. FEniCS 1.0 was released in 2011, followed by the publication of the seminal book Automated Solution of Differential Equations by the Finite Element Method in 2012, which documented the project's philosophy and components like DOLFIN, FFC, FIAT, Instant, UFC, and UFL. In 2015, version 1.5 enhanced parallel performance and mixed finite element support, enabling scalable simulations on distributed systems. The project became affiliated with NumFOCUS in 2016, providing fiscal sponsorship to support open-source sustainability.[15][16][17][10] The project's evolution culminated in the legacy series' final release, 2019.1.0, in April 2019, which incorporated improvements in linear algebra backends and just-in-time compilation. Recognizing limitations in the original architecture, such as dependencies on outdated technologies, development shifted in 2021 to FEniCSx, a complete redevelopment emphasizing modularity, performance, and modern standards like C++17 and PETSc 3.15+. FEniCSx introduced components like DOLFINx for core functionality, Basix for element definition, and FFCx for form compilation, supporting advanced features such as mixed-dimensional problems and GPU acceleration. An alpha release, version 0.9.0, was issued in October 2024, featuring native Windows compatibility, data-independent form compilation, and enhanced MPI support. The first stable release of FEniCSx, version 0.1, followed in October 2025, further improving modularity and integration with contemporary high-performance computing applications. This transition ensures long-term maintainability while preserving the project's core goal of automating finite element computations.[18][19][20][3]Design and Architecture
Core Design Principles
The FEniCS Project is founded on the vision of automating computational mathematical modeling (CMM) to achieve generality, efficiency, and simplicity in solving partial differential equations (PDEs) via the finite element method (FEM). Generality is pursued through support for arbitrary PDEs, meshes, finite elements, and open-standard input/output formats, enabling broad applicability without restricting users to specific problem classes. Efficiency is emphasized via adaptive discretization, optimization techniques, and parallelization, reflecting a principle of selecting the most effective computational strategies akin to natural selection. Simplicity is realized through a modular structure and an intuitive application programming interface (API), including a high-level scripting language that abstracts complex implementation details.[7] Correctness forms another cornerstone, ensured by adaptive error control mechanisms and automated code generation that minimizes human-induced errors in FEM implementations. The project adopts an open-source ethos under the GNU General Public License, promoting stability, community-driven improvements, and widespread dissemination of tools for scientific computing. These principles guide the automation of key CMM steps, from problem formulation in variational form to code generation and solution assembly.[7] In its evolution to FEniCSx, the core library—DOLFINx—refines these foundations with a data-oriented and functional-style design, prioritizing pure functions over heavy object-oriented encapsulation to enhance performance, parallel consistency, and hardware adaptability, such as GPU acceleration. This approach reduces the public API surface while maintaining extensibility, allowing custom kernels and user-injected functions without core modifications. Modularity is amplified through separation of concerns, with components like the Unified Form Language (UFL) for abstractions, FFCx for just-in-time (JIT) kernel generation, and Basix for basis function evaluation, resulting in a compact codebase under 30,000 lines of C++ that supports multiple linear algebra backends (e.g., PETSc, Eigen) and language interfaces (C++20 and Python via NumPy/Numba). The design ensures high-level mathematical abstractions coexist with low-level control for optimized, scalable simulations, as demonstrated in benchmarks scaling to 412 billion cells on 131,072 cores.[21][22][19]Unified Form Language (UFL)
The Unified Form Language (UFL) is a domain-specific language designed for the declarative representation of finite element discretizations of variational forms and functionals in the solution of partial differential equations (PDEs).[23] It enables users to express weak formulations in a syntax closely resembling mathematical notation, facilitating the automated generation of efficient finite element code without requiring low-level implementation details.[24] Developed as a core component of the FEniCS Project, UFL was introduced to improve the expressiveness and portability of variational problem descriptions across different finite element libraries and compilers.[23] UFL's design emphasizes simplicity, generality, and extensibility, allowing for the specification of complex PDE systems involving multi-field function spaces, differential operators, tensor algebra, and automatic differentiation.[23] Key features include support for a wide range of finite element families (such as Lagrange, discontinuous Galerkin, and Raviart-Thomas elements), mixed and tensor-valued function spaces, and integration over cells, boundaries, and interior facets.[25] The language processes expressions into abstract syntax trees, which are then compiled by tools like the FEniCS Form Compiler (FFC) into Unified Form-assembly Code (UFC) for runtime assembly in solvers such as DOLFIN.[24] This separation of form definition from assembly ensures that UFL remains independent of specific numerical implementations, promoting reuse and optimization.[23] In UFL, variational forms are constructed using atomic expressions and operators imported from the UFL Python module (from ufl import *). Finite element spaces are defined via elements like FiniteElement("Lagrange", [triangle](/page/Triangle), 1) for scalar fields or VectorElement("Lagrange", [triangle](/page/Triangle), 1) for vectors, with mixed spaces formed by * (e.g., V * Q).[25] Trial and test functions are declared as u = TrialFunction(V) and v = TestFunction(V), while coefficients represent known functions or data. Common operators include inner(a, b) for tensor inner products, grad(u) for gradients, div(u) for divergence, and curl(u) for curls in 3D. Integrals are specified with measures such as dx for cell volumes, ds for boundaries, and dS for interior facets, often with restrictions like v('+') for positive facets in discontinuous Galerkin methods.[25] Indexing supports component extraction (e.g., u[i]), and implicit summation follows Einstein convention for repeated indices.[25]
Representative examples illustrate UFL's application to standard PDEs. For the Poisson equation on a domain with Dirichlet boundary conditions, the bilinear form is a = inner(grad(u), grad(v)) * dx and the linear form is L = f * v * dx, where u and v are trial and test functions on a Lagrange space V.[26] In linear elasticity, the strain tensor yields a bilinear form a = inner(epsilon(u), epsilon(v)) * dx on a vector space.[26] For time-dependent problems like the heat equation , UFL supports forms such as a = v * u1 * dx + inner(grad(v), k * grad(u1)) * dx (bilinear) and L = v * u0 * dx + v * f * dx (linear), where u0 and u1 denote previous and current time steps.[26] These forms are assembled into matrices and vectors within FEniCSx, the modern iteration of FEniCS, enabling scalable solutions on parallel architectures.[24]
UFL's algorithms handle form manipulation, including symbolic differentiation for nonlinear problems (e.g., via derivative(a, u, du)), expression tree optimization, and estimation of computational costs for code generation.[27] Initially proposed in 2012 by Alnæs, Logg, Ølgaard, Rognes, and Wells, UFL has evolved through ongoing development in the open-source FEniCS ecosystem, with versions like 2025.2.0 (as of October 2025) supporting advanced features such as custom elements and facet-oriented integrals.[23][28] Its adoption extends beyond FEniCS to other projects, underscoring its role in democratizing high-performance finite element computing.[23]
Components
Legacy Components
The legacy components of the FEniCS Project form the foundational software stack of the original FEniCS releases, culminating in version 2019.1.0, which was made available in April 2019 and remains installable for backward compatibility, though it receives no further updates or maintenance.[3] These components—DOLFIN, FFC, FIAT, and the legacy version of UFL—collaborate to automate the finite element solution of partial differential equations (PDEs), enabling users to define problems at a high mathematical level while generating optimized low-level code for computation.[29] Their design emphasizes modularity, with UFL handling problem specification, FFC performing compilation, FIAT supplying basis function data, and DOLFIN managing numerical execution, thus streamlining the workflow from variational formulation to solved systems.[30] DOLFIN functions as the central problem-solving environment and computational backend, implemented primarily in C++ with Python bindings for accessibility. It processes unstructured meshes, constructs finite element function spaces, assembles discrete variational forms into linear systems, and solves them using a range of sparse linear algebra backends, such as PETSc or Trilinos, supporting both stationary and time-dependent problems.[31] This component abstracts complex numerical operations, allowing seamless integration of mesh generation tools like mshr and visualization via libraries such as Paraview, while providing interfaces for boundary conditions, subdomains, and adaptive refinement. FFC, or the FEniCS Form Compiler, is a just-in-time compiler that translates abstract variational forms from UFL into performant, element-specific C++ code for assembly within DOLFIN. By analyzing the mathematical structure of forms—such as bilinear forms for stiffness matrices or linear forms for load vectors—it applies optimizations like tensor representation and quadrature rule selection to minimize computational overhead, supporting arbitrary-order elements and mixed finite element spaces.[32] This compilation step ensures that the generated code is tailored to the problem's geometry and discretization, avoiding generic implementations that could sacrifice efficiency.[33] FIAT, the Finite element Automatic Tabulator, is a Python library dedicated to the symbolic and numerical generation of finite element basis functions and their derivatives for diverse families, including Lagrange, discontinuous Galerkin, and vector elements like Raviart-Thomas or Nédélec, on simplicial cells in one, two, or three dimensions. It computes tabulations of basis values at quadrature points and supports high-order polynomials, providing essential data to FFC during form compilation without requiring manual derivation of these functions.[34] FIAT's extensibility allows for the inclusion of new element types through algebraic definitions, enhancing the project's adaptability to specialized applications in electromagnetics or fluid dynamics.[35] The legacy UFL, or Unified Form Language, serves as the high-level interface for expressing PDE weak formulations in a syntax resembling mathematical notation, embedded within Python scripts. Users define trial and test function spaces over meshes, specify integrals over domains and boundaries using symbolic operations like dot products or gradients, and incorporate coefficients or material properties, all of which are parsed to ensure mathematical consistency before compilation.[36] Compatible only with the legacy FEniCS stack due to API changes in later versions, UFL legacy facilitates rapid prototyping by abstracting finite element details, such as degree-of-freedom mapping, into concise code.[37] Together, these components enable a streamlined pipeline: a variational problem authored in UFL is parsed and compiled by FFC, which queries FIAT for basis evaluations, producing assembly kernels executed in DOLFIN to yield numerical solutions. This architecture, while superseded by the FEniCSx suite for modern hardware and parallel computing, continues to support legacy codes in research and education, particularly for problems in solid mechanics, heat transfer, and electromagnetism.[30]FEniCSx Components
FEniCSx represents the next-generation implementation of the FEniCS project, designed as a collection of modular, high-performance libraries that enable the automated solution of partial differential equations (PDEs) using the finite element method (FEM). Unlike its predecessor, FEniCSx emphasizes modern programming practices, parallel computing support, and improved efficiency through just-in-time compilation. It comprises four core libraries—UFL, Basix, FFCx, and DOLFINx—that work in tandem to handle everything from variational form definition to numerical assembly and solving.[6][3] The Unified Form Language (UFL) serves as the high-level interface for specifying variational formulations of PDEs. It provides a symbolic, math-like syntax that allows users to define integrals, function spaces, and operators in a concise and intuitive manner, abstracting away low-level implementation details. For instance, a user can express the weak form of the Poisson equation using expressions likeinner(grad(u), grad(v)) * dx, where u and v are trial and test functions, respectively. UFL is implemented in Python and supports extensions for custom operators, making it extensible for advanced users while remaining accessible for beginners. Its role is pivotal as it acts as the input layer for the entire FEniCSx pipeline, translating mathematical intent into compilable code.[6][3]
Basix functions as the finite element backend, responsible for generating and tabulating basis functions, degrees of freedom, and quadrature rules for a wide range of finite element families, including Lagrange, Nédélec, Raviart-Thomas, and discontinuous Galerkin elements. Written primarily in C++ for performance, Basix precomputes reference element data and supports dynamic loading of element tables, enabling efficient runtime evaluation without redundant calculations. This library ensures numerical accuracy and flexibility in mesh adaptations, such as handling mixed or hybrid elements in complex geometries. By decoupling basis function computations from the rest of the system, Basix allows FEniCSx to scale across different element types and dimensions seamlessly. The Python interface to Basix is provided by the fenics-basix package, which can be installed via pip install fenics-basix (with pre-built binary wheels available for Python 3.8–3.12 on Linux x86-64 and aarch64, macOS x86-64 and arm64, and Windows x86-64) or via conda install -c conda-forge fenics-basix. For advanced or source builds, see the official documentation.[38][6][39][40]
FFCx is the form compiler that transforms UFL expressions into optimized, low-level C code for finite element assembly. It performs just-in-time (JIT) compilation using tools like TSFC (a domain-specific compiler) to generate kernel code tailored to the specific variational form, incorporating optimizations such as loop unrolling, expression simplification, and tensor contraction. This process minimizes overhead in assembling stiffness matrices and load vectors, particularly for nonlinear problems or multiphysics simulations. FFCx supports parallel assembly and integrates with external libraries for further code generation, ensuring that the compiled kernels are executable on both CPU and GPU architectures where applicable. Its efficiency is demonstrated in benchmarks where assembly times are reduced by orders of magnitude compared to interpretive methods.[6][3]
DOLFINx forms the computational core of FEniCSx, implementing the high-level problem-solving environment in both C++ and Python. It manages mesh generation, function spaces, and discretization; performs finite element assembly by integrating FFCx-generated kernels; and solves the resulting linear or nonlinear systems via interfaces to libraries like PETSc, SLEPc, and Hypre for scalable linear algebra. DOLFINx supports distributed-memory parallelism through MPI, adaptive mesh refinement, and I/O operations compatible with formats like XDMF and VTK. For example, it can handle multiphysics couplings by composing multiple UFL forms into a unified solver. This library's design prioritizes modularity, allowing users to extend functionality for custom boundary conditions or multigrid preconditioners while maintaining high performance on large-scale HPC systems.[6][41]
Applications and Usage
Typical Use Cases
The FEniCS Project is primarily employed for solving partial differential equations (PDEs) in various scientific and engineering domains through the finite element method (FEM), enabling rapid prototyping and high-performance simulations.[1] Typical applications span linear elliptic problems, time-dependent diffusion equations, and nonlinear systems, often integrated with multiphysics modeling to simulate coupled phenomena.[6] Researchers and engineers use FEniCS to translate mathematical formulations directly into code, facilitating studies in fields like mechanics, electromagnetics, and fluid dynamics without low-level implementation details.[42] In solid mechanics, FEniCS is commonly applied to elasticity problems, such as modeling the deformation of a clamped beam under gravitational load in three dimensions, which demonstrates linear elasticity PDEs with Dirichlet and Neumann boundary conditions. More advanced uses include elastodynamic simulations for non-destructive evaluation, like ultrasound wave propagation in materials, leveraging time-dependent wave equations solved via FEniCSx.[43] Structural analysis examples also encompass stress prediction in perforated plates, combining FEM with machine learning for efficient engineering design.[43] Fluid dynamics represents another key area, where FEniCS supports the solution of the Navier-Stokes equations for incompressible flows, including nonlinear time-dependent cases like blood flow in patient-specific brain aneurysms with slip boundary conditions.[6][43] Applications extend to computational fluid dynamics (CFD) for environmental engineering, such as simulating tidal turbine wakes using arbitrary Lagrangian-Eulerian methods on moving domains.[44] Electromagnetics simulations utilize FEniCS for solving Maxwell's equations, particularly in device design and nanophotonics, where custom boundary conditions enable modeling of waveguides and scattering problems.[43] In heat transfer and diffusion, the heat equation serves as a foundational example, applied to transient thermal problems across materials.[6] Biomedical and geophysical applications highlight FEniCS's versatility in multiphysics contexts. For instance, continuum models of brain tumor growth incorporate reaction-diffusion PDEs coupled with tissue mechanics, using patient-specific MRI data for personalized simulations.[43] In nuclear fusion research, FEniCS-based tools like FESTIM model hydrogen isotope transport in reactor blankets via diffusion-reaction equations.[43] These cases underscore FEniCS's role in high-impact, interdisciplinary research, often scalable to high-performance computing environments.[45]Integration and Examples
FEniCS integrates with the broader Python ecosystem to facilitate efficient scientific computing workflows. In the legacy FEniCS, components like DOLFIN rely on NumPy for array manipulations, such as extracting vertex values for error computations, and SymPy for symbolic differentiation in manufactured solution verification.[46] FEniCSx extends this by incorporating mpi4py for parallel computing via MPI, enabling distributed simulations across multiple processes, and petsc4py for interfacing with PETSc's linear algebra backends, which handle assembly and solution of sparse systems.[47] Variational forms are defined using UFL, which compiles to efficient code via FFCx, ensuring high-performance evaluation without manual kernel implementation. For mesh generation, FEniCS supports built-in functions likecreate_unit_square in DOLFINx for simple domains, while complex geometries are handled through integration with Gmsh via the dolfinx.io.gmshio module, allowing import of tagged meshes for boundary conditions and multiphysics problems. Visualization options include Matplotlib for 2D plots in legacy versions, such as contour plots of solutions, and pyvista in FEniCSx for interactive 3D rendering of function data on meshes.[46] Outputs are commonly saved in XDMF format for post-processing in ParaView, supporting time-dependent visualizations and scalar/vector field rendering.[47]
Solvers in FEniCS leverage PETSc for both linear and nonlinear problems, with options for preconditioners like hypre_amg or lu decomposition specified via PETSc parameters.[47] Nonlinear solvers, such as Newton's method, are automated through high-level interfaces like NonlinearProblem, integrating seamlessly with PETSc's SNES for convergence control. For eigenvalue problems, SLEPc provides spectral solvers, often used in modal analysis.
A representative example is the solution of the Poisson equation in a rectangular domain with Dirichlet boundary conditions, demonstrating core integration of meshing, form assembly, and solving in FEniCSx. The following code creates a triangular mesh, defines a Lagrange function space, assembles the bilinear form and linear form , applies boundary conditions using topological location, and solves via PETSc's LinearProblem:
from mpi4py import MPI
from petsc4py.PETSc import ScalarType
import [numpy](/page/NumPy) as np
import ufl
from dolfinx import fem, io, [mesh](/page/Mesh)
from dolfinx.fem.petsc import LinearProblem
msh = [mesh](/page/Mesh).create_rectangle(comm=MPI.COMM_WORLD, points=((0.0, 0.0), (2.0, 1.0)), n=(32, 16),
cell_type=[mesh](/page/Mesh).CellType.[triangle](/page/Triangle))
V = fem.FunctionSpace(msh, ("Lagrange", 1))
facets = [mesh](/page/Mesh).locate_entities_boundary(msh, dim=(msh.[topology](/page/Topology).dim - 1),
marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 2.0))
dofs = fem.locate_dofs_topological(V=V, entity_dim=1, entities=facets)
bc = fem.dirichletbc(value=ScalarType(0), dofs=dofs, V=V)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
x = ufl.SpatialCoordinate(msh)
f = 10 * ufl.exp(-((x[0] - 0.5)**2 + (x[1] - 0.5)**2) / 0.02)
g = ufl.sin(5 * x[0])
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx
L = ufl.inner(f, v) * ufl.dx + ufl.inner(g, v) * ufl.ds
problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()
with io.XDMFFile(msh.comm, "poisson.xdmf", "w") as file:
file.write_mesh(msh)
file.write_function(uh)
from mpi4py import MPI
from petsc4py.PETSc import ScalarType
import [numpy](/page/NumPy) as np
import ufl
from dolfinx import fem, io, [mesh](/page/Mesh)
from dolfinx.fem.petsc import LinearProblem
msh = [mesh](/page/Mesh).create_rectangle(comm=MPI.COMM_WORLD, points=((0.0, 0.0), (2.0, 1.0)), n=(32, 16),
cell_type=[mesh](/page/Mesh).CellType.[triangle](/page/Triangle))
V = fem.FunctionSpace(msh, ("Lagrange", 1))
facets = [mesh](/page/Mesh).locate_entities_boundary(msh, dim=(msh.[topology](/page/Topology).dim - 1),
marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 2.0))
dofs = fem.locate_dofs_topological(V=V, entity_dim=1, entities=facets)
bc = fem.dirichletbc(value=ScalarType(0), dofs=dofs, V=V)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
x = ufl.SpatialCoordinate(msh)
f = 10 * ufl.exp(-((x[0] - 0.5)**2 + (x[1] - 0.5)**2) / 0.02)
g = ufl.sin(5 * x[0])
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx
L = ufl.inner(f, v) * ufl.dx + ufl.inner(g, v) * ufl.ds
problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()
with io.XDMFFile(msh.comm, "poisson.xdmf", "w") as file:
file.write_mesh(msh)
file.write_function(uh)
uh is visualized using pyvista, which maps function values to a VTK grid for warping and scalar plotting, or exported to XDMF for ParaView analysis.[47]
Another common application is linear elasticity, modeling the displacement field in a 3D domain under body forces, as in the cantilever beam problem. In FEniCSx, this involves a vector function space, definition of the strain tensor , stress , and variational form , solved with PETSc's CG solver and GAMG preconditioner for efficiency on unstructured meshes. Boundary conditions fix displacements on one face, and post-processing computes derived quantities like von Mises stress using dolfinx.fem.Expression. The solution is saved to XDMF, with pyvista enabling visualization of displacement vectors and stress contours. This example highlights integration with PETSc for scalable solving and Gmsh for importing refined 3D meshes if needed.[48]