Vectorized implementation of primal hybrid FEM in MATLAB
Harish Nagula Mallesham, Kamana Porwal, Jan Valdman, Sanjib Kumar Acharya
TL;DR
This work delivers a vectorized MATLAB framework for the lowest-order primal hybrid finite element method in 2D, addressing both elliptic and parabolic problems with mixed boundary conditions. By vectorizing edge generation, mesh refinement, and global assembly (including $\mathbb{B}$, $\mathbb{D}$, $\mathbb{M}$, and $\mathbb{C}$), it achieves scalable performance, with Crank-Nicolson time stepping used for parabolic problems. The authors provide detailed algorithmic descriptions and MATLAB implementations ($\texttt{StiffMassConv\_PH.m}$, $\texttt{Lambda\_PH.m}$, $\texttt{load\_t.m}$, etc.), along with numerical results that indicate near-linear time scaling and optimal spatial convergence. This vectorized approach yields a practical, extensible tool for high-performance simulations and sets the stage for extensions to nonlinear problems and 3D domains.
Abstract
We present efficient MATLAB implementations of the lowest-order primal hybrid finite element method (FEM) for linear second-order elliptic and parabolic problems with mixed boundary conditions in two spatial dimensions. We employ the Crank-Nicolson finite difference scheme for the complete discrete setup of the parabolic problem. All the codes presented are fully vectorized using matrix-wise array operations. Numerical experiments are conducted to show the performance of the software.
