# FreeFEM

**FreeFEM** 是一款自由、开源的软件，用于以有限元法数值求解偏微分方程（PDE），其核心是自有的高级编程语言，用户可直接在该语言中书写问题的变分形式。它能处理一维、二维、三维以及三维边界区域（如曲面和曲线）上的非线性多物理场系统。<sup>[1](https://doc.freefem.org/introduction/)</sup><sup> • </sup><sup>[2](https://doc.freefem.org/documentation/index.html)</sup> 它并非例程库，而是一个集成产品：用 FreeFEM 语言编写的脚本经编译执行后产生完整的模拟。<sup>[2](https://doc.freefem.org/documentation/index.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 性质 | 基于有限元法的自由软件（LGPL 3.0）PDE 求解器，配有自有的带类型、多态脚本语言<sup>[2](https://doc.freefem.org/documentation/index.html)</sup><sup> • </sup><sup>[3](https://doc.freefem.org/references/index.html)</sup><sup> • </sup><sup>[4](https://doc.freefem.org/introduction/history.html)</sup> |
| 适用区域 | 一维、二维、三维及三维边界区域（曲面和曲线）<sup>[1](https://doc.freefem.org/introduction/)</sup> |
| 起源 | 由弗雷德里克·赫克特（Frédéric Hecht）与奥利维耶·皮罗诺（Olivier Pironneau）、雅克·莫里斯（Jacques Morice）、安托万·勒亚里（Antoine Le Hyaric）和大塚浩司（Kohji Ohtsuka）在巴黎雅克-路易·利翁实验室开发<sup>[5](https://arxiv.org/abs/1205.1293)</sup> |
| 谱系 | MacFem/PCFem（Pascal，1987）→ FreeFem（1992）→ FreeFem+（1996）→ FreeFem++（1998）→ v3（2008）→ 并行版本（2014）→ v4（2018）<sup>[4](https://doc.freefem.org/introduction/history.html)</sup> |
| 当前版本 | v4.17，7 月 13 日发布于 GitHub<sup>[6](https://github.com/FreeFem/FreeFem-sources/releases)</sup> |
| 网格自适应 | 先进的自动网格生成器，可通过 `adaptmesh` 命令进行后验网格自适应<sup>[5](https://arxiv.org/abs/1205.1293)</sup><sup> • </sup><sup>[7](https://doc.freefem.org/documentation/mesh-generation.html)</sup> |
| 耦合库 | ARPACK、BLAS、OpenBLAS、FFTW、Ipopt、Gmm++、METIS、MUMPS、PETSc、UMFPACK、SuperLU、TetGen 等<sup>[1](https://doc.freefem.org/introduction/)</sup><sup> • </sup><sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup> |

## 语言及问题的描述方式

本质上，FreeFEM 是一个编译器：其语言带类型、支持多态、支持异常，且可重入。每个变量都必须声明类型，语句之间以分号分隔。<sup>[3](https://doc.freefem.org/references/index.html)</sup> 该语言可操作整数（`int`）、实数（`real`）、字符串、诸如 `real[int]` 的数组、二维网格（`mesh`）、有限元空间（`fespace`）、解析函数（`func`）、线性与双线性算子、稀疏矩阵和向量。<sup>[3](https://doc.freefem.org/references/index.html)</sup>

用户通过书写问题的变分（弱）形式来描述问题，软件则利用有限元生成离散线性系统。一个关键优势是，只需几行代码即可在内置选项之间更换有限元近似和求解器。<sup>[9](https://etheses.whiterose.ac.uk/id/eprint/34267/7/Walton_GB_Computing_PhD_2023.pdf)</sup> 典型的脚本会声明网格、在其上定义有限元空间、书写变分问题、求解并绘制结果；例如，`mesh Th = square(10, 10);` 构建一个单位正方形网格，`fespace Vh(Th, P1);` 在其上定义一个 P1 拉格朗日空间。<sup>[3](https://doc.freefem.org/references/index.html)</sup>

该语言采用 C++ 惯用法，FreeFEM 本身也用 C++ 编写。<sup>[1](https://doc.freefem.org/introduction/)</sup> FreeFem++ 之名源于该软件两次完全的 C++ 重写，一次在 2002 年，另一次在 2010 年，两次重写都大量依赖运算符重载和模板——这种技术称为泛型编程。<sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup> 这种设计使得添加复数和三维矢量问题（如斯托克斯流）变得直接，因为其语法与热方程相同。<sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup>

## 网格与有限元

FreeFEM 拥有先进的自动网格生成器，能够进行后验网格自适应。<sup>[5](https://arxiv.org/abs/1205.1293)</sup> `adaptmesh` 命令构建一个适应于一个或多个给定函数的新网格；其默认参数 `err` 指定所需精度，因此用户可手动使新网格更细或更粗。其底层方法在弗雷德里克·赫克特（Frédéric Hecht）1998 年的一篇论文中有述。<sup>[7](https://doc.freefem.org/documentation/mesh-generation.html)</sup>

该语言中存在多种网格类型：二维用 `mesh`，体用 `mesh3`，曲面用 `meshS`，曲线用 `meshL`。网格可通过 `movemesh` 系列命令变换，这些命令通过几何变换对网格进行平移、旋转或变形；`trunc` 命令则用布尔判据限制网格，并可将每个单元分裂为给定数量的子单元。<sup>[7](https://doc.freefem.org/documentation/mesh-generation.html)</sup>

有限元库包括不连续 P0 元、线性 P1 和二次 P2 拉格朗日元、不连续 P1 元和 Raviart–Thomas 元，以及气泡元等其他类型；SIAM 的综述还列出了一个大型三角形单元库，从 P0 到 P4、RT、HCT 和 Edge 元，适用于不连续伽辽金法和后验加密。<sup>[4](https://doc.freefem.org/introduction/history.html)</sup><sup> • </sup><sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup> 自 FreeFEM v4.13 起，引入了复合有限元空间，以推广耦合问题的变分形式定义，使得混合不同网格或网格类型的问题能够以对脚本的最小改动来定义和求解。<sup>[10](https://doc.freefem.org/documentation/composite.html)</sup>

## 多网格插值与耦合问题

许多现象涉及多个耦合系统，如流固耦合、铝铸造中的洛伦兹力以及海洋-大气问题。这些问题需要采用不同的有限元近似和多项式阶数，可能还要使用不同的网格，并在同一程序内在这些网格之间进行数据插值。FreeFEM 包含快速插值算法以及操作多网格数据的语言支持。<sup>[1](https://doc.freefem.org/introduction/)</sup><sup> • </sup><sup>[2](https://doc.freefem.org/documentation/index.html)</sup>

插值问题并不简单：将函数从一个非结构网格移动到另一个必须快速且非扩散，并且对每个点都必须找到包含它的三角形，这是计算几何的一个基本问题。FreeFEM 的实现运行时间为 \( \mathcal{O}(n \log n) \)，基于四叉树。<sup>[4](https://doc.freefem.org/introduction/history.html)</sup>

## 求解器与并行执行

FreeFEM 提供与许多知名数值库连接的接口，包括 BLAS、MPI、ARPACK、GSL、PETSc、MUMPS、UMFPACK、SuperLU、CMAES 和 IPOPT 等优化模块，以及三维网格生成器 TetGen。<sup>[1](https://doc.freefem.org/introduction/)</sup><sup> • </sup><sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup> 并行求解器作为动态库加载到脚本中；例如，在 `.edp` 文件中写入 `load "MUMPS_FreeFem"` 即可启用 MUMPS 并行直接求解器。<sup>[11](https://doc.freefem.org/documentation/parallelization.html)</sup>

并行版本随 FreeFem++ v3.34 于 2014 年出现。<sup>[4](https://doc.freefem.org/introduction/history.html)</sup> 文档描述了一种区域分解工作流程：用 METIS 图划分器对全区域的粗网格进行划分，构建重叠子区域，并通过 `trunc` 函数分裂每个子网格获得最终的细网格；所得的局部问题可在多个 MPI 进程上组装和求解。<sup>[11](https://doc.freefem.org/documentation/parallelization.html)</sup> 专用框架 ffddm 支持区域分解方法，其中全局网格上的全局有限元空间被分解为定义在局部网格上的局部有限元空间。<sup>[12](https://doc.freefem.org/documentation/ffddm/introduction-to-the-domain-decomposition-method.html)</sup>

## 历史

该项目在 30 多年间从 MacFem 和 PCFem 演变而来，这两款软件由奥利维耶·皮罗诺（Olivier Pironneau）于 1987 年用 Pascal 编写（非自由软件）。第一个 C 版本产生了 `freefem` 3.4，仅提供单网格上的网格自适应。一次彻底的 C++ 重写产生了 `freefem+`（最后版本为 1.2.10），增加了多网格插值；该软件已不再维护，但仍在使用，因为它使用 PDE 的强形式来处理问题描述。<sup>[4](https://doc.freefem.org/introduction/history.html)</sup>

官方历史给出的里程碑时间线为：1992 年，FreeFem 用 C++ 重写，在单一网格上支持 P1 和 P0 元（O. Pironneau、D. Bernardi、F. Hecht、C. Prudhomme）；1996 年，FreeFem+ 支持多网格；1998 年，FreeFem++ 采用新的有限元内核和新语言（F. Hecht、O. Pironneau、K. Ohtsuka）；1999 年，基于虚拟区域法的首个三维版本（S. Del Pino）；2008 年，FreeFem++ v3 采用覆盖一维、二维和三维的多维有限元内核；2014 年，并行版本；2018 年，FreeFem++ v4 采用新矩阵类型、曲面单元和新的并行工具。<sup>[4](https://doc.freefem.org/introduction/history.html)</sup>

## 范围、优势与比较

正如 2012 年的综述论文所述，该平台仅限于允许变分形式的问题。<sup>[5](https://arxiv.org/abs/1205.1293)</sup> 与其商业竞争对手 COMSOL 相比，FreeFEM 在图形方面较为原始，但可与 ParaView 及其他工具对接，并且能做 COMSOL 做不到的事情；两者均可在 macOS、Windows 和 Linux 上运行，而得益于安托万·勒亚里（Antoine Le Hyaric），FreeFEM 还能在智能手机上运行。<sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup> 它可在所有 UNIX 操作系统（需 g++ 3.3 或更高版本及 OpenGL）、Windows XP 至 11，以及 Intel 和 ARM 处理器的 macOS 10 上运行。<sup>[2](https://doc.freefem.org/documentation/index.html)</sup>

SIAM 的综述称 FreeFem++ 与同类软件 FEniCS 一样，是协作开发的开源项目，但指出弗雷德里克·赫克特（Frédéric Hecht）完成了 95% 的开发工作，且代码库包含约 130,000 行代码。同一综述强调其网格自适应模块是最好的开源模块，并赞扬了对流项的特征伽辽金法的稳健实现。<sup>[8](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)</sup>

该软件在各研究领域均有使用：已发表的应用包括求解二维布西涅斯克系统、蒸汽发生器的涡流无损检测、流固耦合基准（在 FreeFem++ 中实现并比较了六种 FSI 方法）、通过 iceFEM 包进行冰架振动建模，以及通过 AutoFreeFem 代码生成器进行形状与拓扑优化。<sup>[13](https://arxiv.org/abs/1205.3147)</sup><sup> • </sup><sup>[14](https://arxiv.org/abs/1602.03207)</sup><sup> • </sup><sup>[15](https://freefem.org/)</sup><sup> • </sup><sup>[16](https://joss.theoj.org/papers/10.21105/joss.02939)</sup><sup> • </sup><sup>[17](https://arxiv.org/abs/2407.11713)</sup>

## References

1. [FreeFEM Documentation, Introduction](https://doc.freefem.org/introduction/)
2. [FreeFEM Documentation, Documentation index](https://doc.freefem.org/documentation/index.html)
3. [FreeFEM Documentation, Language references](https://doc.freefem.org/references/index.html)
4. [FreeFEM Documentation, History](https://doc.freefem.org/introduction/history.html)
5. [Georges Sadaka (2012). FreeFem++, a tool to solve PDEs numerically. arXiv:1205.1293](https://arxiv.org/abs/1205.1293)
6. [Releases, FreeFem/FreeFem-sources, GitHub](https://github.com/FreeFem/FreeFem-sources/releases)
7. [FreeFEM Documentation, Mesh Generation](https://doc.freefem.org/documentation/mesh-generation.html)
8. [FreeFem++: A High Level MultiPhysics Finite Element Software, SIAM News](https://www.siam.org/publications/siam-news/articles/freefem-a-high-level-multiphysics-finite-element-software/)
9. [G. Walton (2023). 2.5 FreeFEM software, PhD thesis, White Rose eTheses](https://etheses.whiterose.ac.uk/id/eprint/34267/7/Walton_GB_Computing_PhD_2023.pdf)
10. [FreeFEM Documentation, Composite finite element spaces](https://doc.freefem.org/documentation/composite.html)
11. [FreeFEM Documentation, Parallelization](https://doc.freefem.org/documentation/parallelization.html)
12. [FreeFEM Documentation, Introduction to the domain decomposition method (ffddm)](https://doc.freefem.org/documentation/ffddm/introduction-to-the-domain-decomposition-method.html)
13. [Solution of 2D Boussinesq systems with FreeFem++: The flat bottom case. arXiv:1205.3147](https://arxiv.org/abs/1205.3147)
14. [A Fast Eddy-current Non Destructive Testing Finite Element Solver in Steam Generator. arXiv:1602.03207](https://arxiv.org/abs/1602.03207)
15. [FreeFEM, An open-source PDE Solver using the Finite Element Method](https://freefem.org/)
16. [Kalyanaraman et al. (2021). iceFEM: A FreeFem package for wave induced ice-shelf vibrations. Journal of Open Source Software, 6(59), 2939](https://joss.theoj.org/papers/10.21105/joss.02939)
17. [AutoFreeFem: Automatic code generation with FreeFEM++ and LaTeX output for shape and topology optimization. arXiv:2407.11713](https://arxiv.org/abs/2407.11713)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 物理学 › 物理学方法、实践与学术共同体 › Applied and interdisciplinary physics › Computational and simulation physics › Physics simulation software and engines › Scientific simulation packages › Finite-element analysis suites

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/freefem

English original: https://www.edgepedia.org/freefem
