## 1. Introduction

Geological systems are often formed by multiphysics processes interacting on many temporal and spatial scales. Moreover, they are heterogeneous and exhibit large material property contrasts. In order to understand and decipher these systems numerical models are frequently employed. Appropriate resolution of the behavior of these heterogeneous systems, without the (over)simplifications of a priori applied homogenization techniques, requires numerical models capable of efficiently and accurately dealing with high-resolution, geometry-adapted meshes. These criterions are usually used to justify the need for special purpose software (commercial finite element method (FEM) packages) or special code development in high-performance compiler languages such as C or FORTRAN. General purpose packages like MATLAB are usually considered not efficient enough for this task. This is reflected in the current literature. MATLAB is treated as an educational tool that allows for fast learning when trying to master numerical methods, e.g., the books by *Kwon and Bang* [2000], *Elman et al.* [2005], and *Pozrikidis* [2005]. MATLAB also facilitates very short implementations of numerical methods that give overview and insight, which is impossible to obtain when dealing with closed black-box routines, e.g., finite elements on 50 lines [*Alberty et al.*, 1999], topology optimization on 99 lines [*Sigmund*, 2001], and mesh generation on one page [*Persson and Strang*, 2004]. However, while advantageous from an educational standpoint, these implementations are usually rather slow and run at a speed that is a fraction of the peak performance of modern computers. Therefore the usual approach is to use MATLAB for prototyping, development, and testing only. This is followed by an additional step where the code is manually translated to a compiler language to achieve the memory and CPU efficiency required for high-resolution models.

This paper presents the outcome of a project called “MILAMIN - MILlion A MINute” aimed at developing a MATLAB-based FEM package capable of preprocessing, processing, and postprocessing an unstructured mesh problem with one million degrees of freedom in two dimensions within one minute on a commodity personal computer. Choosing a native MATLAB implementation allows simultaneously for educational insight, easy access to computational libraries and visualization tools, rapid prototyping and development, as well as actual two-dimensional production runs. Our standard implementation serves to provide educational insight into subjects such as implementation of the numerical method, efficient use of the computer architecture and computational libraries, code structuring, proper data layout, and solution techniques. We also provide an optimized FEM version that increases the performance of production runs even further, but at the cost of code clarity.

The MATLAB code implementing the different approaches discussed here is available from the authors (http://www.milamin.org) and can be downloaded as auxiliary material (see Software S1).