Section 9.7 of Chapter 9: 2D Stress Analysis: Finite Element Types, Linear Case

Isoparametric 8-Node Quadrilateral: Fast Solver

A vectorized Q8 solver that evaluates all nine Gauss-point contributions simultaneously and assembles the global sparse stiffness matrix directly.

Q8 elementNine Gauss pointsVectorized assemblyMATLAB R2026a

01

Purpose and benchmark model

plane2d8_fast is the vectorized alternative to the standard plane2d8 routine presented in Section 9.6. It follows the same general strategy as the Q4 fast solver in Section 9.5: simultaneous element computations with multiprod and direct sparse assembly with MATLAB sparse.

The benchmark uses the plane-stress cantilever of Section 9.6. The mesh has nHn_H Q8 elements through the height and nLn_L elements along the length, so that:

nel=nHnL.n_{el}=n_Hn_L.

Each element has eight nodes and two displacement degrees of freedom per node: 16 element displacement degrees of freedom. The strain–displacement matrix B\boldsymbol B is 3×163\times16 and the element stiffness matrix kel\boldsymbol k_{el} is 16×1616\times16. The Q8 interpolation and plane-stress formulation remain those of Section 9.6; the present section concerns their computational implementation.

Q8 cantilever mesh, boundary conditions and free-end loading
Figure 1. Q8 cantilever model of Section 9.6. The two performance meshes refine this same geometry; nHn_H and nLn_L denote the numbers of elements through the height and along the length.

02

Nine Gauss-point contributions

Each Q8 finite element is integrated with a 3×33\times3 Gauss rule, giving nine Gauss points. The number of vectorized integration contributions is therefore:

nel9=9nel.n_{el9}=9n_{el}.

The strain–displacement and constitutive matrices are stored for every Gauss-point contribution in three-dimensional arrays:

B:3×16×(9nel),\boldsymbol B:\quad3\times16\times(9n_{el}),
D:3×3×(9nel).\boldsymbol D:\quad3\times3\times(9n_{el}).

Thus, the nine terms BgTDgBg\boldsymbol B_g^T\boldsymbol D_g\boldsymbol B_g belonging to each finite element are evaluated vectorially. The integration factor hwgdetJgh\,w_g|\det\boldsymbol J_g| is included in the stored constitutive array. During sparse assembly, their entries have the same element connectivity and are naturally summed at the corresponding global matrix positions.

03

Vectorized element computation

The nodal coordinate arrays are first repeated for the nine Gauss points of every element. The Q8 shape-function derivatives in natural coordinates are evaluated for all these points and stored in dNst, with dimensions 2×8×(9nel)2\times8\times(9n_{el}). The coordinate array xyel has dimensions 8×2×(9nel)8\times2\times(9n_{el}).

The Jacobian matrices, their inverses, and the derivatives with respect to the Cartesian coordinates are then evaluated simultaneously for all 9nel9n_{el} contributions:

plane2d8_fast.m — Jacobians
J=multiprod(dNst,xyel);

Each 2×22\times2 inverse Jacobian is formed from its determinant and four entries. The Cartesian derivatives are then obtained page-wise:

plane2d8_fast.m — Cartesian derivatives
br=multiprod(J1,dNst);

The Q8 strain–displacement matrix has sixteen columns. Its implementation therefore uses the explicit preallocation:

plane2d8_fast.m — Q8 preallocation
B=zeros(3,16,nel9);

The constitutive matrices include the Gauss weight, the absolute Jacobian determinant, and the element thickness. The simultaneous matrix products are:

plane2d8_fast.m — Gauss-point stiffness contributions
DB=multiprod(DHooke,B);
kelt=reshape(multiprod(permute(B,[2 1 3]),DB),ngel^2,nel9);

Here DB stores the products DgBg\boldsymbol D_g\boldsymbol B_g for all Gauss points, while each column of kelt contains the 256 entries of one 16×1616\times16 Gauss-point stiffness contribution. multiprod performs a matrix product on each page of the arrays: page gg of one array is multiplied by the corresponding page of the other array. These are matrix products for all Gauss points of all elements, not element-by-element scalar products.

04

Sparse global assembly

The connectivity arrays are expanded to the nine Gauss-point contributions. MATLAB sparse then assembles the global stiffness matrix directly and sums coincident entries:

plane2d8_fast.m — Global sparse assembly
K=sparse(ipos1,ipos2(:),kelt(:),neq,neq);

This avoids the element-by-element stiffness-assembly loop. Both the nine contributions of each element and the contributions of adjacent elements are added at their common global positions. After applying the constraints and loads, the global linear system is solved in the standard form:

plane2d8_fast.m — Linear system
S=K\F;

The MATLAB variable S contains the global nodal displacement vector u\boldsymbol u. After the solution, DHooke is restored to the unweighted 3×33\times3 plane-stress constitutive matrix used by the stress-plotting routine.

05

Use with Section 9.6

Start from the complete MATLAB programs provided in Section 9.6, add plane2d8_fast.m and multiprod.m, and replace the call plane2d8 in main.m with plane2d8_fast. The geometry, material, loading, constraints, and result-plotting routines remain unchanged.

main.m
clear
gen
plane2d8_fast
plot_disp
plot_stress

06

MATLAB R2026a benchmark

Benchmark procedure

For each of the two meshes, both routines received one unrecorded warm-up run followed by three measured runs. The table reports arithmetic means measured in MATLAB 26.1.0 (R2026a) Update 4 on the same computer. Only the meshes 60 × 150 and 80 × 200 were used.

The assembly interval includes element-matrix generation, loads, constraints, and global stiffness assembly. The linear solution K\F\boldsymbol K\backslash\boldsymbol F was measured separately. Total time is the sum of these two directly measured intervals; mesh generation and plotting are excluded.

speed-up=tstandardtfast.\boxed{\text{speed-up}=\frac{t_{\rm standard}}{t_{\rm fast}}}.
nH×nLn_H\times n_LElementsNodesEquationsStandard
assembly (s)
Standard
solve (s)
Standard
total (s)
Fast
assembly (s)
Fast
solve (s)
Fast
total (s)
Overall
speed-up
60 × 1509,00027,42154,84231.1340.42031.5540.6200.4131.03330.5×
80 × 20016,00048,56197,122104.5310.985105.5161.3661.1192.48542.5×

The vectorized Gauss-point calculations and direct sparse assembly substantially reduce the assembly interval. The overall acceleration is smaller because the sparse linear-system solution remains essentially the same operation in both implementations.

Both meshes were also checked against the standard Q8 solution. For 60 × 150 and 80 × 200, respectively, SfastSstandard2\|\boldsymbol S_{\rm fast}-\boldsymbol S_{\rm standard}\|_2 is 3.400e-9 mm and 1.541e-8 mm; the relative differences are 1.626e-10 and 5.542e-10. The largest differences between the nodally recovered stress components and von Mises stresses are 3.213e-8 MPa and 1.224e-7 MPa. These differences are consistent with floating-point round-off from the different operation ordering.

The distinction is important: Q4Q8\boxed{\text{Q4}\rightarrow\text{Q8}} improves the finite-element approximation, particularly for bending, whereas standard Q8fast Q8\boxed{\text{standard Q8}\rightarrow\text{fast Q8}} improves the computational implementation without changing the FEM formulation. The two Q8 programs solve the same problem and must produce the same solution.

07

Programs and downloads

Verification status

The standard and fast Q8 solvers were executed in MATLAB R2026a on both published benchmark meshes. The package contains the complete fast-solver example, the standard solver for comparison, multiprod, its BSD license, and a README.

multiprod.m is by Paolo de Leva and is redistributed under the included BSD-style license. Its distribution page is the MATLAB Central File Exchange entry.