# Elmer for PDEs

Elmer is an open-source multiphysics simulation software that has been around since 1995. It is developed by the CSC — IT Center for Science Ltd. This group is administered by the Ministry of Education, Science and Culture in Finland. With Elmer, you can model physical systems, such as fluid dynamics, electromagnetism, heat transfer and acoustics. All of those problem areas have one thing in common—they are all described by partial differential equations (PDEs).

A PDE is a differential equation that depends on more than one variable, usually more than one space variable. For example, an equation that describes how heat gets transferred across a metal plate, where a is the thermal diffusivity of the metal plate, would look like the formula shown in Figure 1.

Figure 1. Sample Equation

Very simple PDEs have exact solutions, but anything more complex that describes more physical situations just can't be solved exactly. This is where numerical solutions come into play. There are three widely used methods: finite element, finite volume and finite difference methods. Elmer uses the finite element method. The basic idea is to break up the problem space into some kind of a mesh of smaller spaces, and then either eliminate the PDE completely, by reworking it into a steady state problem on the mesh, or approximating the PDE with a system of ordinary differential equations that then are integrated using standard methods, like Euler's method or Runge-Kutta.

Elmer is distributed under the GPL, so you always can download the source and compile your very own version. Binaries are available for all those poor users still stuck on Windows. Packages should be available for most Linux distributions. For Ubuntu-based distros, you simply can use the following to install Elmer and all the necessary libraries:

```
sudo apt-get install elmer
```

Elmer is broken into several parts. ElmerSolver is the part that actually takes the input files and does the calculations to evolve the PDE you are interested in. ElmerPost is the visualization and post-processing tool. With this tool, you actually can see the results of your calculations. ElmerGrid is the meshing tool that can create simple 1-D, 2-D and 3-D meshes that will be used to evolve your PDE. It also can be used to import meshes generated using other software packages, such as those created using the Ansys tools.

There also is a GUI interface called ElmerGUI. ElmerGUI allows you to define and generate input files for ElmerSolver, as well as import external meshes from other software (Figure 2).

Figure 2. ElmerGUI

Looking at all of this, you may be thinking, "This is perfect!" So, I also should mention some of Elmer's downsides. Elmer actually is a suite of tools, and those tools are not always at the same development level. The documentation tends to lag behind the newest features, and ElmerGUI may be missing some of the more esoteric methods and models that ElmerSolver can use. Elmer is a huge system, and like any large software package, it has a steep learning curve. The tools available (ElmerGrid) can handle generating only relatively simple meshes. This means that if you have a very complicated system, you likely will need to use some other tool to generate the mesh and then import it into Elmer. If you can work around these possible deficiencies, Elmer may be exactly the right solution for you.

ElmerGUI is likely to be what most people prefer using. You can import element mesh files in various formats, generate element partitionings for geometry input files, set up the PDE systems you want to solve, and export model data to hand in to ElmerSolver. Most conveniently, ElmerGui also provides an interface to the parallel version of the solver, ElmerSolver.mpi. There also is a built-in post-processor that allows you to view your results right there from ElmerGUI. The menus in ElmerGUI are fully programmable as well, so you can tune the interface to match your specific problem area better.

A user forum, wiki and other resources are available at http://www.elmerfem.org, and a very good tutorial is available from the main Elmer Web site. Along with the tutorial documentation, sample files are available for each of the cases. Those files can be great starting points for your own calculations and help you as you are learning the system. As an example, let's look at the sample "Computation of fringe capacitance". Once you have downloaded the sample files and unpacked them, you can load the project with File→Load Project... from the menu. Once it is loaded, all the input data also is loaded. A project is simply a directory containing all the files required to do a computation. The actual mesh is defined by the files mesh.header, mesh.nodes, mesh.elements and mesh.boundary. The current settings and state are stored in the file egproject.xml. There also is a solver input file called case.sif that is handed in to ElmerSolver when you actually are ready to do your calculations. You can edit this file via Sif→Edit... (Figure 3).

Figure 3. Solver Input File

You can edit the model details (like physical constants) via Model→Setup.... When you are ready to run your calculation, you can use Run→Start Solver. This opens a log window and shows its progress. A convergence monitor shows how quickly Elmer converges on the results (Figure 4).

Figure 4. Convergence Monitor

This creates a new file named case.ep in your project directory containing the results of your calculation. You can view it using either Run→Start Postprocessor or Run→Postprocessor (VTK)... (Figure 5).

Figure 5. Viewing the Results

As you can see, several tools are available to help you visualize the results of your calculation.

Now that you have seen a basic example of running one of the tutorials, what else can Elmer do for you? The solver can handle solving linear systems. It can do this by using direct methods, through the LAPACK library, for example. You can use a set of Krylov subspace methods to do iterative solutions. In order to get rapid convergence though, you usually need to use some form of preconditioning. A class of iterative methods called multilevel methods are used for large linear systems. Elmer provides two options: geometric multigrid and algebraic multigrid.

More complex, and hence more physically accurate, problems tend to be nonlinear. This nonlinearity may be as simple as what you see in the full equation for pendulum motion to the Navier-Stokes equations for fluid flow to the equations of General Relativity. Elmer deals with nonlinear systems by first linearizing the equations at each iteration step. How the equations are linearized depends on exactly which solver method is being used. For example, the Navier-Stokes solver can use either the Picard linearization or the Newton linearization.

There are methods for solving time-dependent systems. First-order time derivatives can be discretized using either the Crank-Nicolson method or the Backward Differences Formulae. You also can solve eigenvalue problems with Elmer. These tend to crop up in structural analysis problems, including factors like elasticity and damping.

For really large problems, you likely will want to look into running your computation in parallel. Elmer uses MPI as the parallelization technique, along with domain decomposition as the method of dividing up the work. The first step is to take the mesh and subdivide it into chunks or partitions, which, depending on the actual calculation to perform, will divide the load evenly across all the CPUs. These chunks then are sent out to individual CPUs, and the calculation is done. At the end of the run, the results are combined back into a single result. Because of the work involved in partitioning and so forth, most users likely will take advantage of ElmerGUI's parallelization tool.

The last of Elmer's selling points is its modular nature. The solver is written in FORTRAN 90. This means if you want to add your own user functions or a complete solver, it is simply a matter of writing a FORTRAN module and including it in Elmer. The main Elmer site provides good documentation covering the steps involved.

Hopefully, this introduction has given you some ideas of what you can do with Elmer. If you are studying multiphysics problems, Elmer probably is a very good tool to learn. It also might be a good tool to introduce in a numerical physics course, because you can model so much. If you do end up using it in your research or studies, I would love to hear about it.

### Limited Time Offer

Take *Linux Journal* for a test drive. Download our September issue for FREE.