In this paper, we introduce a new vectorized MATLAB-based algorithm for efficient serial computation of global matrix/force arising from finite element method (FEM) for meshes of any type and approximation order in linear elasticity. Because for-loops in MATLAB are very slow, we propose a modified process that takes advantage of vectorization and sparse assembly to achieve good performance while using the same memory as the standard algorithm. For this purpose, by using good programming practices, the implementation of this scheme is succinctly described and can be integrated into any MATLAB package dealing with FEM. Specifically, attention is paid to the calculation of the triplet (row index, column index, matrix components) as well as the assembly of the global stiffness matrix, mass matrix and force vector. Additionally, an extension of the proposed approach for Mindlin plate theory and functionally graded materials is outlined. Finally, the accuracy of this strategy is verified on selected numerical tests after comparing the obtained results with those of ABAQUS. In terms of performance, the study conducted on a set of meshes considering the standard algorithm and two other well-known MATLAB vectorized algorithms revealed that: (i) for a 2D beam problem meshed with P1\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$P_{1}$$\\end{document}-triangle elements, a speedup of about 8 and 15 is achieved with sparse and fsparse, respectively. (ii) for a 3D plate problem meshed with P1\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$P_{1}$$\\end{document}-tetrahedral elements, a speedup of about 4 and 8 is achieved with sparse and fsparse, respectively. When compared to ABAQUS performance, the proposed scheme results in a computational time that is about five times smaller.
Read full abstract