MOLE Mimetic Operators Library Enhanced
MOLE Mimetic Operators Library Enhanced
MOLE Mimetic Operators Library Enhanced
1¶
Johnny Corbino , Miguel A. Dumett2 , and Jose E. Castillo2
1 Computational Research Division, Lawrence Berkeley National Laboratory, Berkeley, California, 94720,
USA. 2 Computational Science Research Center, San Diego State University, 5500 Campanile Dr, San
Diego, California, 92182, USA. ¶ Corresponding author
DOI: 10.21105/joss.06288
Software
• Review Summary
• Repository
• Archive MOLE is an open-source library that implements high-order mimetic operators. It provides
discrete analogs of the most common vector calculus operators: divergence, gradient, curl,
and Laplacian. These operators act on functions discretized over staggered grids (uniform,
Editor: Jed Brown
nonuniform, and curvilinear), and they satisfy local and global conservation laws (Dumett &
Castillo, 2022a, 2023a). MOLE’s operators can be utilized to develop code for solving partial
Reviewers:
differential equations (PDEs).
• @jakelangham
• @victorapm The mathematics are based on the work of Corbino & Castillo (2020). In addition, the user
may find useful previous publications such as J. E. Castillo & Grone (2003), in which similar
Submitted: 01 November 2023 operators are derived using a matrix analysis approach.
Published: 17 July 2024
License
Authors of papers retain copyright
Mimetic operators
and release the work under a
Creative Commons Attribution 4.0
Mimetic operators, divergence (D), gradient (G), curl (C), and Laplacian (L), are discrete
International License (CC BY 4.0). analogs of their corresponding continuum operators. These operators satisfy in the discrete
sense the vector identities that the continuum ones do (Dumett & Castillo, 2023b), making
them more faithful to the physics in specific contexts.
The basis of higher-dimensional operators, as well as more sophisticated operators such as the
Laplacian or the biharmonic operator, are the one-dimensional mimetic G and D operators,
together with high-order mimetic interpolation operators (Dumett & Castillo, 2022b), which
are also contained in the library. These finite-dimensional operators can be reused throughout
the mathematical model and they provide a higher level of abstraction at the time of solving
PDEs.
These operators have been used to write codes to solve PDEs of different types (Abouali &
Castillo, 2013; Bazan et al., 2011; Boada et al., 2020; Brzenski & Castillo, 2023; Puente et
al., 2014; Rojas et al., 2008; Velazco et al., 2020; Villamizar et al., 2021). For an overview of
mimetic methods of different types see the book by Castillo and Miranda and the references
therein (José E. Castillo & Miranda, 2013).
Statement of need
Implementing mimetic operators, particularly in three dimensions, presents significant challenges,
yet MOLE streamlines this process, allowing users to focus their efforts on their specific problems.
For instance, solving equations like the Poisson equation −∇2 𝑢 = 𝑓 becomes straightforward
with MOLE, as users can employ its well-tested mimetic operators with just a few lines of code.
This versatility extends to a diverse user base, including physicists, engineers, and numerical
analysts, who benefit from MOLE’s comprehensive library. Moreover, the library’s flexibility
Corbino et al. (2024). MOLE: Mimetic Operators Library Enhanced. Journal of Open Source Software, 9 (99), 6288. https://doi.org/10.21105/joss. 1
06288.
enables users to seamlessly transition between grids, resolutions, and discretization orders,
enhancing their ability to tailor solutions to their unique needs.
The library
MOLE was designed to be an intuitive software package to construct mimetic operators based
on the method of Corbino & Castillo (2020). MOLE is implemented in C++ and in MATLAB
(these are two independent flavors) and every function in MOLE returns a sparse matrix of the
requested mimetic operator. For information on the installation or usage of the library, please
read the documentation included in the repository.
Mimetic operators can be easily used to build codes to solve PDEs with a few lines of code.
For example, if the user wants to get a one-dimensional k-order mimetic Laplacian, they just
need to invoke:
lap(k, m, dx);
where k is the desired order of accuracy, m is the number of cell centers (of the spatial grid),
and dx is the distance between consecutive cell centers. All functions in MOLE are quite
consistent with this syntax, and more information regarding the signature of the function can
be accessed via the help command. The C++ version of the library depends on Armadillo,
which is an open-source package for dense and sparse linear algebra (Sanderson & Curtin,
2016), SuperLU for LU factorization (Li, 2005), and OpenBLAS for parallel matrix-vector and
matrix-matrix operations (Zhang et al., 2020).
It is important to mention that MOLE’s main role is the construction of matrices that represent
spatial derivative operators and boundary conditions; other components such as solvers and
time steppers are only provided via self-contained examples.
The following code snippet shows how easy is to solve a 1D Poisson problem (with Robin’s
boundary conditions) through MOLE:
% File: elliptic1D.m
addpath('../mole_MATLAB') % Add path to library
Corbino et al. (2024). MOLE: Mimetic Operators Library Enhanced. Journal of Open Source Software, 9 (99), 6288. https://doi.org/10.21105/joss. 2
06288.
a = 1; % Dirichlet coefficient
b = 1; % Neumann coefficient
L = L + robinBC(k, m, dx, a, b); % Add BCs to Laplacian operator
% 1D Staggered grid
grid = [west west+dx/2 : dx : east-dx/2 east];
% RHS
U = exp(grid)';
U(1) = 0; % West BC
U(end) = 2*exp(1); % East BC
% Plot result
plot(grid, U, 'o-')
title('Poisson''s equation with Robin BC')
xlabel('x')
ylabel('u(x)')
Concluding remarks
In this short article we introduced MOLE, an open-source library that implements the mimetic
operators from Corbino & Castillo (2020). For conciseness purposes, we showed a one-
dimensional Poisson problem as an example. However, MOLE includes over 30 examples that
span a wide range of applications, from the one-way wave equation to highly nonlinear and
computationally demanding problems, including the Navier-Stokes equation for fluid dynamics
and Richard’s equation for unsaturated flow in porous media. The user can find such examples
in the Examples folder.
Corbino et al. (2024). MOLE: Mimetic Operators Library Enhanced. Journal of Open Source Software, 9 (99), 6288. https://doi.org/10.21105/joss. 3
06288.
Acknowledgements
We acknowledge contributions from Dr. Angel Boada, and Jared Brzenski, whose dedicated
efforts and insightful discussions significantly enhanced the development of the software tool.
References
Abouali, M., & Castillo, J. E. (2013). Stability and performance analysis of the Castillo-Grone
mimetic operators in conjunction with RK3 time discretization in solving advective equations.
Procedia Computer Science, 18, 465–472. https://doi.org/10.1016/j.procs.2013.05.210
Bazan, C., Abouali, M., Castillo, J., & Blomgren, P. (2011). Mimetic finite difference
methods in image processing. Computational & Applied Mathematics, 30(3), 701–720.
https://doi.org/10.1590/S1807-03022011000300012
Boada, A., Paolini, C., & Castillo, J. E. (2020). High-order mimetic finite differences for
anisotropic elliptic equations. Computers & Fluids, 213, 104746. https://doi.org/10.1016/
j.compfluid.2020.104746
Brzenski, J., & Castillo, J. E. (2023). Solving Navier–Stokes with mimetic operators. Computers
& Fluids, 254, 105817. https://doi.org/10.1016/j.compfluid.2023.105817
Castillo, J. E., & Grone, R. D. (2003). A matrix analysis approach to higher-order approxima-
tions for divergence and gradients satisfying a global conservation law. Matrix Analysis
and Applications, 25. https://doi.org/10.1137/S0895479801398025
Castillo, José E., & Miranda, G. F. (2013). Mimetic discretization methods. CRC Press.
https://doi.org/10.1201/b14575
Corbino, J., & Castillo, J. E. (2020). High-order mimetic finite-difference operators satisfying
the extended Gauss divergence theorem. Computational and Applied Mathematics, 364.
https://doi.org/10.1016/j.cam.2019.06.042
Dumett, M., & Castillo, J. E. (2022a). Energy conservation of second-order mimetic difference
schemes for the 1D advection equation (No. CSRC2022-03). San Diego State University
Computational Science Research Center. https://doi.org/10.13140/RG.2.2.19919.25767
Dumett, M., & Castillo, J. E. (2022b). Interpolation operators for staggered grids (No.
CSRC2022-02). San Diego State University Computational Science Research Center.
https://doi.org/10.13140/RG.2.2.31741.95204
Dumett, M., & Castillo, J. E. (2023a). Energy conservation and convergence of high-
order mimetic schemes for the 3D advection equation (CSRC2023-05, submitted for
publication). San Diego State University Computational Science Research Center. https:
//doi.org/10.13140/RG.2.2.28307.86561
Dumett, M., & Castillo, J. E. (2023b). Mimetic analogs of vector calculus identities (CSRC2023-
01, submitted for publication). San Diego State University Computational Science Research
Center. https://doi.org/10.13140/RG.2.2.26630.14400
Li, X. S. (2005). An overview of SuperLU: Algorithms, implementation, and user interface.
ACM Trans. Math. Softw., 31(3), 302–325. https://doi.org/10.1145/1089014.1089017
Puente, J. de la, Ferrer, M., Hanzich, M., Castillo, J. E., & Cela, J. M. (2014). Mimetic
seismic wave modeling including topography on deformed staggered grids. Geophysics,
79(3), T125–T141. https://doi.org/10.1190/geo2013-0371.1
Rojas, O., Day, S., Castillo, J., & Dalguer, L. A. (2008). Modelling of rupture propagation
using high-order mimetic finite differences. Geophysical Journal International, 172(2),
631–650. https://doi.org/10.1111/j.1365-246X.2007.03651.x
Corbino et al. (2024). MOLE: Mimetic Operators Library Enhanced. Journal of Open Source Software, 9 (99), 6288. https://doi.org/10.21105/joss. 4
06288.
Sanchez, E. J., Paolini, C. P., & Castillo, J. E. (2014). The mimetic methods toolkit: An
object-oriented api for mimetic finite differences. Journal of Computational and Applied
Mathematics, 270, 308–322. https://doi.org/10.1016/j.cam.2013.12.046
Sanderson, C., & Curtin, R. (2016). Armadillo: A template-based C++ library for linear
algebra. Journal of Open Source Software, 1. https://doi.org/10.21105/joss.00026
Velazco, A. B., Corbino, J., & Castillo, J. (2020). High order mimetic difference simulation of
unsaturated flow using Richards equation. Mathematics in Applied Sciences and Engineering,
1(4), 401–409. https://doi.org/10.5206/mase/10874
Villamizar, J., Calderón, G., Carrillo, J., Bautista Rozo, L., Carrillo, J., Rueda, J., & Castillo, J.
(2021). Mimetic finite difference methods for restoration of fundus images for automatic
detection of glaucoma suspects. Computer Methods in Biomechanics and Biomedical
Engineering: Imaging & Visualization, 1–8. https://doi.org/10.1080/21681163.2021.
1914733
Zhang, X., Zhao, Q., Wang, H., Zhu, C., & Liu, J. (2020). OpenBLAS: An optimized BLAS
library. ACM Transactions on Mathematical Software (TOMS), 46(3), 34:1–34:19.
Corbino et al. (2024). MOLE: Mimetic Operators Library Enhanced. Journal of Open Source Software, 9 (99), 6288. https://doi.org/10.21105/joss. 5
06288.