In the 14 years since the MFEM software library debuted as open source, the code base has grown dramatically along with the project’s user and developer community. MFEM—Modular Finite Element Methods—does the mathematical heavy lifting for large-scale scientific simulations, providing discretization algorithms that improve simulation performance and efficiency. Now with more than 150 contributors worldwide, the software is downloaded more than 100,000 times per year.

Building on previously successful workshops, the team decided to expand the 2024 event to two and a half days during October, offering a local option at the University of California Livermore Collaboration Center for LLNL staff and participants wishing to visit Livermore. “Interest in MFEM continues to be strong. We like to see the community stepping in to help itself,” stated project lead Tzanio Kolev, noting that more than 200 people around the world registered for the workshop.

MFEM’s functionality has also grown in the past year. Released in May, version 4.7 improvements included enhanced meshing and discretization options, and acceleration of additional numerical methods on different types of GPUs. In August, the team released a new version of the GLVis visualization software, which is specially designed for accurate finite element representation. The workshop showcased new developments in mathematical algorithms; the software’s scalability to next-generation computing architectures; and an expanding application space that includes fluid dynamics, fusion energy, design optimization, structural mechanics, electromagnetics, and more.

Figure 1: MFEM provides discretization and analysis capabilities employed in topology optimization applications. LLNL researcher Mathias Schmidt presented a topology optimization approach that incorporates conformally morphed meshes, winning the workshop’s animation contest with his visualization of a 3D bracket design. Watch the animation (25 seconds).

Alongside Kolev, workshop organizers included LLNL’s Aaron Fisher, Justin Laughlin, Ketan Mittal, Sohail Reddy, and Haley Shuey plus Portland State University Professor Will Pazner. Laughlin, a computational software developer who joined the Lab in 2022, said, “I enjoy being part of a culture where people are enthusiastic about math and programming. I especially love the concept of generalized finite element frameworks like MFEM, and I’m grateful to be part of the team.”

Building a Better Battery

MFEM has inspired many offshoots over the years, particularly in application areas where a research team lacks the resources to build their own finite element library. One workshop presentation introduced Michigan State University’s BESFEM project, developed under the direction of Hui-Cha Yu.

Yu’s team built BESFEM—Battery Electrode Simulation toolkit using MFEM—to model energy storage and electrochemical processes inside different battery types. When a typical lithium-ion battery releases electrical energy, lithium ions move from the anode to the cathode through the electrolyte-filled spaces between sheets made of irregularly shaped graphite particles. “To simulate this electrochemical process, the first difficulty is the complex geometry of the particles,” Yu explained. “The next difficulty is managing the multiphysics equations for ion diffusion, electric field distribution, electro-potential fields, and more.”

According to Yu, materials scientists have access to public datasets of scanning electron microscopy, computed tomography, and x-ray images to analyze these microstructural properties. However, because of the aforementioned complexities, pseudo two-dimensional models assuming uniformly porous structures and spherical particles are prevalent. Yu stated, “In these homogeneous models, you can only obtain an average prediction of your battery’s performance but no insight into its microstructure or complex geometry.”

The BESFEM team improves on this paradigm with 3D simulations that explicitly resolve the complex microstructures. Doing so reveals how well a battery charges and releases energy, which in turn can help inform new designs that use materials more efficiently and increase energy density.

Using MFEM’s solvers for several equations with adaptive mesh refinement as well as nonlinear material parameters, BESFEM simulates a battery’s complicated multiphysics and thus uncovers its optimal capacity and utilization. Furthermore, Yu’s team found that MFEM outperforms their in-house finite difference methods code in accuracy but with increased computational cost. “We achieved a balance between the computational cost and accuracy by using a coarse mesh farther away from the interfaces, then a finer mesh closer to them,” he said.

Figure 2: Building on MFEM’s solvers, Michigan State University’s BESFEM toolkit simulates a high-rate charge process inside a battery anode. Left: The standard thick electrode proves inefficient as the utilization concentrates at the front—high (yellow) to low (blue). Right: By removing active materials to create “tunnels” through the simulated electrode, electrochemical reaction occurs across the entire anode, allowing greater utilization of the electrode when the battery charges.

Beyond C++

Máté Kovács, a software engineer at Braid Technologies, traveled from Tokyo to Livermore for the workshop. He presented his work to develop a Rust “wrapper” that calls the MFEM API, which is written in C++. The wrapper binds the two programming languages together so that software written in one can be used in another. The MFEM community currently maintains a Python wrapper called PyMFEM as well as Python and JavaScript wrappers for GLVis. A Julia wrapper for MFEM is also in initial development.

“The concept of ownership is central to memory correctness, and C++ is unable to capture some of the usage rules around ownership,” Kovács explained. Although in some ways similar to C++, Rust is nevertheless able to encode and automate ownership rules more robustly, thereby reducing memory corruption errors. Kovács, who organizes the Tokyo Rust developer community, noted that this relatively new language can have a steep learning curve. He added, “Learning Rust can take a while and feel unproductive. But I’ve been using C++ since high school and believe that Rust is a new way forward.”

As a small engineering firm, Braid Technologies relies on open-source software like MFEM to augment their proprietary codes. Kovács began using MFEM after a Braid founder discovered it, and he decided to pursue the Rust wrapper as a personal project during Japan’s Golden Week holidays. “I’m happy with the response to my workshop presentation and hope others will contribute to my project,” he said. As a contributor to the MFEM and GLVis Python wrappers, Laughlin pointed out, “MFEM’s code base has a ‘large API surface area,’ as some might say, so building wrappers is no small task. I’m excited to see the community help bring MFEM to other programming languages.”

Figure 3: LLNL postdoctoral researcher Jan Nikl won the workshop’s visualization contest with his simulation of an anisotropic convection-diffusion system—a common partial differential equation in science and engineering applications. The M-F-E-M letters make up the simulation’s initial temperature profile. Nikl presented his framework for hybridizing the finite element discretization of these systems for robustness and speed.

Forward Thinking

The MFEM team will be busy in 2025. The roadmap includes enabling user-friendly differentiable simulations; upgrading the core programming language to C++ version 17; developing robust meshing, discretizations, and solvers for automated workflows; and conducting large-scale performance runs on El Capitan, Livermore’s new exascale supercomputer. The annual workshop tradition will undoubtedly continue as the project and community grow.

MFEM’s development trajectory reflects the team’s responsiveness to user feedback, which comes from GitHub issues, a busy Slack channel, online tutorials, and events like the workshop. “Recent trends indicate that researchers are increasingly interested in capabilities like GPU-accelerated finite element methods, automatic differentiation, and design optimization,” noted Mittal, whose work on MFEM encompasses many aspects of high-order meshes. “MFEM continues to serve as a delivery vehicle for state-of-the-art technology in these areas.”

More Than Math

This year’s longer workshop agenda combined with in-person attendance resulted in meaningful discussions during breaks. The higher number of presentations offered deeper insight into the community’s research directions and application needs. “I’ve learned new things this year. MFEM is being used in ways I didn’t know about,” said Kolev. Mittal added, “I am always impressed by the breadth of the topics and diversity of the participants at the workshop. In the future, perhaps we can add longer plenary talks or tutorials.” Other highlights were the student lightning talks, the open “office hours” session, and the visualization/animation contest.

Finally, the workshop provided an opportunity to acknowledge the recent passing of NVIDIA software engineering manager Stanimire Tomov, who was an original MFEM developer alongside Kolev and Veselin Dobrev in the early days at Texas A&M University. The trio of graduate students brought their finite element research to internships at the Lab more than two decades ago. “We’ve been developing this project for a long time, and Stan was there from the beginning,” Kolev stated. “For a relatively niche mathematical project, MFEM is quite successful. Its continued usefulness is very rewarding.”

—Holly Auten