网页 综合 更新时间 2026-11-14 16:52:22

MFEM - Finite Element Discretization Library

自动蜘蛛 mfem.org 正文约 6000 字
This page provides a brief overview of MFEM's example codes and miniapps. For detailed documentation of the MFEM sources, including the examples, see the online Doxygen documentation, or the doc directory in the distribution.
The goal of the example codes is to provide a step-by-step introduction to MFEM in simple model settings. The miniapps are more complex, and are intended to be more representative of the advanced usage of the library in physics/application codes. We recommend that new users start with the example codes before moving to the miniapps.
Select from the categories below to display examples and miniapps that contain the respective feature. All examples support (arbitrarily) high-order meshes and finite element spaces. The numerical results from the example codes can be visualized using the GLVis visualization tool (based on MFEM). See the GLVis website for more details.
Users are encouraged to submit any example codes and miniapps that they have created and would like to share. Contact a member of the MFEM team to report bugs or post questions or comments.
This is the simplest MFEM example and a good starting point for new users. The example demonstrates the use of MFEM to define and solve an $H^1$ finite element discretization of the Poisson equation $$-\Delta u = 1 \quad\text{in } \Omega$$ with homogeneous Dirichlet boundary conditions $$ u = 0 \quad\text{on } \partial\Omega$$
The example illustrates the use of the basic MFEM classes for defining the mesh, finite element space, as well as linear and bilinear forms corresponding to the left-hand side and right-hand side of the discrete linear system.
The example has serial (ex0.cpp) and parallel (ex0p.cpp) versions.
This example code demonstrates the use of MFEM to define a simple isoparametric finite element discretization of the Poisson equation $$-\Delta u = 1$$ with homogeneous Dirichlet boundary conditions. Specifically, we discretize with the finite element space coming from the mesh (linear by default, quadratic for quadratic curvilinear mesh, NURBS for NURBS mesh, etc.) The problem solved in this example is the same as ex0, but with more sophisticated options and features.
The example highlights the use of mesh refinement, finite element grid functions, as well as linear and bilinear forms corresponding to the left-hand side and right-hand side of the discrete linear system. We also cover the explicit elimination of essential boundary conditions, static condensation, and the optional connection to the GLVis tool for visualization.
The example has a serial (ex1.cpp), a parallel (ex1p.cpp), and HPC versions: performance/ex1.cpp, performance/ex1p.cpp. It also has a PETSc modification in examples/petsc , a PUMI modification in examples/pumi and a Ginkgo modification in examples/ginkgo. Partial assembly and GPU devices are supported.
This example code solves a simple linear elasticity problem describing a multi-material cantilever beam. Specifically, we approximate the weak form of $$-{\rm div}({\sigma}({\bf u})) = 0$$ where $${\sigma}({\bf u}) = \lambda\, {\rm div}({\bf u})\,I + \mu\,(\nabla{\bf u} + \nabla{\bf u}^T)$$ is the stress tensor corresponding to displacement field ${\bf u}$, and $\lambda$ and $\mu$ are the material Lame constants. The boundary conditions are ${\bf u}=0$ on the fixed part of the boundary with attribute 1, and ${\sigma}({\bf u})\cdot n = f$ on the remainder with $f$ being a constant pull down vector on boundary elements with attribute 2, and zero otherwise. The geometry of the domain is assumed to be as follows:
The example demonstrates the use of high-order and NURBS vector finite element spaces with the linear elasticity bilinear form, meshes with curved elements, and the definition of piece-wise constant and vector coefficient objects. Static condensation is also illustrated.
The example has a serial (ex2.cpp) and a parallel (ex2p.cpp) version. It also has a PETSc modification in examples/petsc and a PUMI modification in examples/pumi. We recommend viewing Example 1 before viewing this example.
This example code solves a simple 3D electromagnetic diffusion problem corresponding to the second order definite Maxwell equation $$\nabla\times\nabla\times\, E + E = f$$ with boundary condition $ E \times n $ = "given tangential field". Here, we use a given exact solution $E$ and compute the corresponding r.h.s. $f$. We discretize with Nedelec finite elements in 2D or 3D.
The example demonstrates the use of $H(curl)$ finite element spaces with the curl-curl and the (vector finite element) mass bilinear form, as well as the computation of discretization error when the exact solution is known. Static condensation is also illustrated.
The example has a serial (ex3.cpp) and a parallel (ex3p.cpp) version. It also has a PETSc modification in examples/petsc. Partial assembly and GPU devices are supported. We recommend viewing examples 1-2 before viewing this example.
This example code solves a simple 2D/3D $H(div)$ diffusion problem corresponding to the second order definite equation $$-{\rm grad}(\alpha\,{\rm div}(F)) + \beta F = f$$ with boundary condition $F \cdot n$ = "given normal field". Here we use a given exact solution $F$ and compute the corresponding right hand side $f$. We discretize with the Raviart-Thomas finite elements.
The example demonstrates the use of $H(div)$ finite element spaces with the grad-div and $H(div)$ vector finite element mass bilinear form, as well as the computation of discretization error when the exact solution is known. Bilinear form hybridization and static condensation are also illustrated.
The example has a serial (ex4.cpp) and a parallel (ex4p.cpp) version. It also has a PETSc modification in examples/petsc. Partial assembly and GPU devices are supported. We recommend viewing examples 1-3 before viewing this example.
This example code solves a simple 2D/3D mixed Darcy problem corresponding to the saddle point system $$ \begin{array}{rcl} k\,{\bf u} + {\rm grad}\,
访问原文 返回搜索 https://mfem.org/examples/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。