-
On a vectorized basic linear algebra package for prototy** codes in MATLAB
Authors:
Alexej Moskovka,
Talal Rahman,
Jan Valdman,
Jon Eivind Vatne
Abstract:
When writing high-performance code for numerical computation in a scripting language like MATLAB, it is crucial to have the operations in a large for-loop vectorized. If not, the code becomes too slow to use, even for a moderately large problem. However, in the process of vectorizing, the code often loses its original structure and becomes less readable. This is particularly true in the case of a…
▽ More
When writing high-performance code for numerical computation in a scripting language like MATLAB, it is crucial to have the operations in a large for-loop vectorized. If not, the code becomes too slow to use, even for a moderately large problem. However, in the process of vectorizing, the code often loses its original structure and becomes less readable. This is particularly true in the case of a finite element implementation, even though finite element methods are inherently structured. A basic remedy to this is the separation of the vectorization part from the mathematics part of the code, which is easily achieved through building the code on top of the basic linear algebra subprograms that are already vectorized codes, an idea that has been used in a series of papers over the last fifteen years, develo** codes that are fast and still structured and readable. We discuss the vectorized basic linear algebra package and introduce a formalism using multi-linear algebra to explain and define formally the functions in the package, as well as MATLAB pagetime functions. We provide examples from computations of varying complexity, including the computation of normal vectors, volumes, and finite element methods. Benchmarking shows that we also get fast computations. Using the library, we can write codes that closely follow our mathematical thinking, making writing, following, reusing, and extending the code easier.
△ Less
Submitted 15 March, 2024;
originally announced April 2024.
-
Minimization of energy functionals via FEM: implementation of hp-FEM
Authors:
Miroslav Frost,
Alexej Moskovka,
Jan Valdman
Abstract:
Many problems in science and engineering can be rigorously recast into minimizing a suitable energy functional. We have been develo** efficient and flexible solution strategies to tackle various minimization problems by employing finite element discretization with P1 triangular elements [1,2]. An extension to rectangular hp-finite elements in 2D is introduced in this contribution.
Many problems in science and engineering can be rigorously recast into minimizing a suitable energy functional. We have been develo** efficient and flexible solution strategies to tackle various minimization problems by employing finite element discretization with P1 triangular elements [1,2]. An extension to rectangular hp-finite elements in 2D is introduced in this contribution.
△ Less
Submitted 22 September, 2023;
originally announced September 2023.
-
MATLAB implementation of hp finite elements on rectangles
Authors:
Alexej Moskovka,
Jan Valdman
Abstract:
A simple MATLAB implementation of hierarchical shape functions on 2D rectangles is explained and available for download. Global shape functions are ordered for a given polynomial degree according to the indices of the nodes, edges, or elements to which they belong. For a uniform p-refinement, the hierarchical structure enables an effective assembly of mass and stiffness matrices. A solution of a b…
▽ More
A simple MATLAB implementation of hierarchical shape functions on 2D rectangles is explained and available for download. Global shape functions are ordered for a given polynomial degree according to the indices of the nodes, edges, or elements to which they belong. For a uniform p-refinement, the hierarchical structure enables an effective assembly of mass and stiffness matrices. A solution of a boundary value problem is approximated for various levels of uniform h and p refinements.
△ Less
Submitted 10 May, 2022;
originally announced May 2022.
-
Fast MATLAB evaluation of nonlinear energies using FEM in 2D and 3D: nodal elements
Authors:
Alexej Moskovka,
Jan Valdman
Abstract:
Nonlinear energy functionals appearing in the calculus of variations can be discretized by the finite element (FE) method and formulated as a sum of energy contributions from local elements. A fast evaluation of energy functionals containing the first order gradient terms is a central part of this contribution. We describe a vectorized implementation using the simplest linear nodal (P1) elements i…
▽ More
Nonlinear energy functionals appearing in the calculus of variations can be discretized by the finite element (FE) method and formulated as a sum of energy contributions from local elements. A fast evaluation of energy functionals containing the first order gradient terms is a central part of this contribution. We describe a vectorized implementation using the simplest linear nodal (P1) elements in which all energy contributions are evaluated all at once without the loop over triangular or tetrahedral elements. Furthermore, in connection to the first-order optimization methods, the discrete gradient of energy functional is assembled in a way that the gradient components are evaluated over all degrees of freedom all at once. The key ingredient is the vectorization of exact or approximate energy gradients over nodal patches. It leads to a time-efficient implementation at higher memory-cost. Provided codes in MATLAB related to 2D/3D hyperelasticity and 2D p-Laplacian problem are available for download and structured in a way it can be easily extended to other types of vector or scalar forms of energies.
△ Less
Submitted 10 May, 2022; v1 submitted 22 August, 2021;
originally announced September 2021.
-
Minimization of p-Laplacian via the Finite Element Method in MATLAB
Authors:
Ctirad Matonoha,
Alexej Moskovka,
Jan Valdman
Abstract:
Minimization of energy functionals is based on a discretization by the finite element method and optimization by the trust-region method. A key tool is a local evaluation of the approximated gradients together with sparsity of the resulting Hessian matrix. We describe a vectorized MATLAB implementation of the p-Laplace problem in one and two space-dimensions, however it is easily applicable to oth…
▽ More
Minimization of energy functionals is based on a discretization by the finite element method and optimization by the trust-region method. A key tool is a local evaluation of the approximated gradients together with sparsity of the resulting Hessian matrix. We describe a vectorized MATLAB implementation of the p-Laplace problem in one and two space-dimensions, however it is easily applicable to other energy formulations.
△ Less
Submitted 16 May, 2021; v1 submitted 2 March, 2021;
originally announced March 2021.