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

Isoparametric 4-Node Quadrilateral: Fast Solver

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

Q4 elementFour Gauss pointsVectorized assemblyMATLAB R2026a

01

Purpose and benchmark model

plane2d_fast is the vectorized alternative to the standard plane2d routine presented in Section 9.4. It follows the same general strategy as the CST fast solver in Section 9.2: simultaneous element computations with multiprod and direct sparse assembly with MATLAB sparse.

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

nel=nHnLn_{el}=n_Hn_L
Quadrilateral finite element mesh of the cantilever benchmark
Figure 1. Q4 mesh used for the performance benchmark; nHn_H and nLn_L denote the numbers of elements through the height and along the length.

02

Four Gauss-point contributions

Each Q4 finite element is integrated with four Gauss points. The number of vectorized integration contributions is therefore:

nel4=4neln_{el4}=4n_{el}

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

B:3×8×(4nel)\boldsymbol{B}:\quad 3\times8\times(4n_{el})
D:3×3×(4nel)\boldsymbol{D}:\quad 3\times3\times(4n_{el})

Thus, the four terms BgTDgBg\boldsymbol{B}_g^T\boldsymbol{D}_g\boldsymbol{B}_g belonging to each finite element are evaluated vectorially. 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 four Gauss points of every element. The Jacobian matrices, their inverses, and the derivatives with respect to the Cartesian coordinates are then evaluated simultaneously for all 4nel4n_{el} contributions.

The Q4 strain-displacement matrix has eight columns. Its public implementation therefore uses the explicit preallocation

plane2d_fast.mQ4 preallocation
B=zeros(3,8,nel4);

The constitutive matrices include the Gauss-point Jacobian determinant and the element thickness. The simultaneous matrix products are

plane2d_fast.mGauss-point stiffness contributions
DB=multiprod(DHooke,B);
kelt=reshape(multiprod(permute(B,[2 1 3]),DB),ngel^2,nel4);

Here DB stores the products DgBg\boldsymbol{D}_g\boldsymbol{B}_g for all Gauss points, while each column of kelt contains the 64 entries of one 8×88\times8 Gauss-point stiffness contribution.

04

Sparse global assembly

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

plane2d_fast.mGlobal sparse assembly
K=sparse(ipos1,ipos2(:),kelt(:),neq,neq);

This avoids the element-by-element stiffness-assembly loop. After applying the constraints and loads, the global linear system is solved in the standard form

plane2d_fast.mLinear system
S=K\F;

05

Use with Section 9.4

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

06

MATLAB R2026a benchmark

Benchmark procedure

For each mesh, both routines received one unrecorded warm-up run followed by three measured runs. The table reports arithmetic means obtained on an Intel Core i7-14700 @ 2.10 GHz computer with 32 GB RAM, Windows 11, and MATLAB 26.1.0 (R2026a) Update 4.

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.

Soverall=tplane2dtplane2d_fastS_{\mathrm{overall}}=\frac{t_{\mathrm{plane2d}}}{t_{\mathrm{plane2d\_fast}}}
Sassembly=tassembly,standardtassembly,fastS_{\mathrm{assembly}}=\frac{t_{\mathrm{assembly,standard}}}{t_{\mathrm{assembly,fast}}}
nH×nLn_H\times n_LQ4 elementsEquationsStandardtotal (s)Fasttotal (s)Fast K\F(s)Overallspeed-upStandardassembly (s)Fastassembly (s)Assemblyspeed-up
80 × 20016,00032,56219.2420.3650.19152.7×19.0360.174109.3×
100 × 25025,00050,70253.8050.5080.282105.9×53.5180.227236.1×

The vectorized Gauss-point calculations and direct sparse assembly reduce the pre-solve interval by more than two orders of magnitude for these meshes. The overall acceleration is smaller because the sparse linear-system solution is essentially the same operation in both implementations.

07

Numerical equivalence

The nodal displacement vectors and recovered element-node stresses were compared before accepting the timings.

nH×nLn_H\times n_LMaximum displacement
difference
Relative displacement
difference
Maximum stress
difference
Relative stress
difference
80 × 2001.28×10111.28\times10^{-11}5.04×10115.04\times10^{-11}5.81×1095.81\times10^{-9}3.75×10113.75\times10^{-11}
100 × 2509.85×10119.85\times10^{-11}3.86×10103.86\times10^{-10}7.07×1087.07\times10^{-8}4.35×10104.35\times10^{-10}

The differences are consistent with floating-point round-off caused by the different operation ordering.

08

Large-mesh comparison

For a much larger mesh with nH=500n_H=500 and nL=1250n_L=1250, corresponding to 1,253,502 global equations, plane2d_fast required 10.251 s for generation and assembly and 21.082 s for the solution of the global system.

Fast formulationAssembly(s)K\F(s)
Section 9.2 — CST2.55321.487
Section 9.5 — Q410.25121.082

For the same number of global equations, the 4-node quadrilateral formulation requires a longer generation-and-assembly time than the CST formulation because each Q4 element contributes an 8×88\times8 stiffness matrix rather than a 6×66\times6 matrix. This produces more nonzero couplings and therefore a denser global stiffness matrix. The Q4 generation-and-assembly interval is approximately 10.251/2.5534.0210.251/2.553\approx4.02 times longer, while the linear-system solution times for this case are of the same order.

09

Programs and downloads

Verification status

The standard and fast Q4 solvers were executed in MATLAB R2026a on both published benchmark meshes. The package contains only the fast routine, multiprod, its BSD license, and a README.

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