Section 25.2 of Chapter 25: Hexahedral isoparametric finite element. Linear case

Fast program for the 8-node isoparametric hexahedral finite element

01

Introduction

brick3d_fast is the vectorized version of the brick3d program from Section 25.1. The approach is very similar to plane2d_fast in Section 9.5, following the fast implementation approach also used in Section 9.2.

Multidimensional arrays are used to process simultaneously the matrices associated with all elements and Gauss points.

02

Vectorized formulation

For the HEX8 element, the strain–displacement matrix and the three-dimensional constitutive matrix have dimensions:

B∈R6×24,D∈R6×6.\htmlClass{fea-math-bold-italic}{\boldsymbol{B}}\in\mathbb{R}^{6\times24},\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol{D}}\in\mathbb{R}^{6\times6}.

Jacobians, inverse Jacobians, strain–displacement matrices and constitutive matrices are evaluated in vectorized form for all elements and their eight Gauss points. The matrix products are:

DB,BTDB.\htmlClass{fea-math-bold-italic}{\boldsymbol{D}}\htmlClass{fea-math-bold-italic}{\boldsymbol{B}},\qquad\htmlClass{fea-math-bold-italic}{\boldsymbol{B}}^{T}\htmlClass{fea-math-bold-italic}{\boldsymbol{D}}\htmlClass{fea-math-bold-italic}{\boldsymbol{B}}.

multiprod performs multiple matrix products in multidimensional arrays. Global assembly is also vectorized using MATLAB sparse, avoiding element-by-element assembly loops.

03

Linear system

After assembly and imposition of the boundary conditions, the linear system is:

KS=F.\htmlClass{fea-math-bold-italic}{\boldsymbol{K}}\htmlClass{fea-math-bold-italic}{\boldsymbol{S}}=\htmlClass{fea-math-bold-italic}{\boldsymbol{F}}.

K\htmlClass{fea-math-bold-italic}{\boldsymbol{K}} is the global stiffness matrix, F\htmlClass{fea-math-bold-italic}{\boldsymbol{F}} the load vector and S\htmlClass{fea-math-bold-italic}{\boldsymbol{S}} the unknown nodal displacement vector. The direct MATLAB solution is:

Direct solution
S = K\F;

04

Benchmark example

The same cantilever example as in Section 25.1 is used. The coarse mesh has 60×16×1260\times16\times12 elements: 11 520 elements, 13 481 nodes and 40 443 equations. The fine mesh has 90×24×1890\times24\times18 elements: 38 880 elements, 43 225 nodes and 129 675 equations.

Coarse HEX8 cantilever mesh, constraints and applied loading
Figure 1. Coarse mesh: 60×16×1260\times16\times12 HEX8 elements.
Table 1. Standard and fast programs.
MeshProgramGeneration and
assembly [s]
Solution K\F\htmlClass{fea-math-bold-italic}{\boldsymbol{K}}\backslash\htmlClass{fea-math-bold-italic}{\boldsymbol{F}}
[s]
Total time
[s]
60×16×1260\times16\times12brick3d67.8962.82870.724
60×16×1260\times16\times12brick3d_fast1.7582.9654.722
90×24×1890\times24\times18brick3d719.454105.158824.612
90×24×1890\times24\times18brick3d_fast6.884115.459122.343

The benefit of vectorization for generation and assembly becomes more pronounced as the mesh is refined. For the coarse mesh, the total computation time is reduced by approximately a factor of 15. For the fine mesh, generation and assembly take only 6.884 s with brick3d_fast, while the direct linear-system solution takes 115.459 s and becomes the dominant computational cost.

05

Preconditioned conjugate gradient method

For large linear-elastic FE systems, after appropriate boundary conditions are imposed, the stiffness matrix is sparse, symmetric and positive definite, so the preconditioned conjugate gradient method (PCG) is well suited. Preconditioning improves conditioning and reduces the number of iterations [1].

The MATLAB implementation uses incomplete Cholesky factorization followed by pcg [2]:

Incomplete Cholesky and PCG
opts.type    = 'ict';
opts.droptol = 1e-3;

L = ichol(K,opts);
[S,flag,relres,iter] = pcg(K,F,1e-6,200,L,L');

ict selects incomplete Cholesky factorization with threshold dropping; droptol = 1e-3 controls the dropping tolerance. L\htmlClass{fea-math-bold-italic}{\boldsymbol{L}} and LT\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}^{T} are used as the two preconditioner factors for pcg.

The incomplete Cholesky factorization provides a sparse approximation of the stiffness matrix:

K≈LLT.\htmlClass{fea-math-bold-italic}{\boldsymbol{K}}\approx\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}^{T}.

The factors L\htmlClass{fea-math-bold-italic}{\boldsymbol{L}} and LT\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}^{T} are then used as preconditioners in the PCG algorithm. In simplified form, the preconditioned system may be written as:

(LLT)−1K S=(LLT)−1F.(\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}^{T})^{-1}\htmlClass{fea-math-bold-italic}{\boldsymbol{K}}\,\htmlClass{fea-math-bold-italic}{\boldsymbol{S}}=(\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}^{T})^{-1}\htmlClass{fea-math-bold-italic}{\boldsymbol{F}}.

Since LLT\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}\htmlClass{fea-math-bold-italic}{\boldsymbol{L}}^{T} approximates K\htmlClass{fea-math-bold-italic}{\boldsymbol{K}}, the preconditioned system is better conditioned and PCG converges more rapidly.

Table 2. Direct solution and PCG — fine mesh.
Solution procedureGeneration and
assembly [s]
Linear-system
solution [s]
Total time
[s]
brick3d_fast + K\F\htmlClass{fea-math-bold-italic}{\boldsymbol{K}}\backslash\htmlClass{fea-math-bold-italic}{\boldsymbol{F}}6.884115.459122.343
brick3d_fast + ichol + pcg6.5576.70813.265

For the 129 675-equation system, the linear-system solution time drops from about 115.5 s to about 6.7 s, and the total time from about 122.3 s to about 13.3 s. For the present tests, the displacement and stress results from the direct and iterative solvers were identical to the displayed numerical precision.

06

Programs

Use brick3d_fast in place of brick3d with the input and plotting routines from Section 25.1. Keep multiprod.m in the same MATLAB folder. The downloadable program uses the direct solution; the PCG alternative is shown above.

multiprod.m is third-party code by Paolo de Leva and Jinhui Bai; see Section 9.2 and Section 9.5 for source and licensing information.

07

References

  1. Y. Saad, Iterative Methods for Sparse Linear Systems, 2nd ed., SIAM, Philadelphia, 2003.
  2. MATLAB Documentation, pcg and ichol, MathWorks.