Skip to main content
Version: 0.3.1

Solvers

The linear system solver is selected with model.setSolverMethod(solverMethod). If it is not set, FEAScript uses "lusolve".

model.setSolverMethod("frontal");
solverMethodMethodCalled with
"lusolve"Sparse LU decomposition (direct, from math.js)solve()
"jacobi"Jacobi iteration on the CPUsolve()
"frontal"Frontal solver (direct, element by element)solve()
"jacobi-gpu"Jacobi iteration on the GPU with WebGPUawait solveAsync()

Supported combinations​

Model"lusolve""jacobi""frontal""jacobi-gpu"
heatConductionScript✓✓✓✓
generalFormPDEScript, linear✓✓✓
generalFormPDEScript, nonlinear✓✓
frontPropagationScript✓✓✓
creepingFlowScript✓
eulerBernoulliBeamScript✓✓

For the nonlinear models (frontPropagationScript, and generalFormPDEScript with nonlinear: true), the selected method solves the linear system of each Newton–Raphson iteration.

The creeping flow system has zero diagonal entries in its pressure rows, so the Jacobi method cannot be applied to it; use "lusolve".

LU decomposition ("lusolve")​

The default method. The assembled sparse matrix is factorized with the sparse LU decomposition of math.js (with partial pivoting) and the system is solved directly. It works for every model and needs no tuning, so it is a good first choice.

Frontal solver ("frontal")​

The frontal solver assembles and eliminates the equations element by element, so only the equations of the active "front" are kept in memory instead of the whole matrix. Dirichlet conditions and, for heat conduction, convection conditions are applied during the assembly of each element.

Jacobi method ("jacobi")​

An iterative method: at each iteration, every unknown is updated from the values of the previous iteration,

ui(m+1)=1Jii(Ri−∑j≠iJij uj(m)),u_i^{(m+1)} = \frac{1}{\mathcal{J}_{ii}} \left( R_i - \sum_{j \ne i} \mathcal{J}_{ij} \, u_j^{(m)} \right),

starting from uˉ(0)=0\bar{u}^{(0)} = 0. The iterations stop when the Euclidean norm of the change between two iterations is smaller than the tolerance.

The Jacobi method converges only for suitable matrices, for example diagonally dominant ones. Linear elements usually give such matrices; quadratic elements usually do not. If the method does not converge, FEAScript logs an error and returns the last iterate.

OptionDefaultDescription
maxIterations10000Maximum number of Jacobi iterations
tolerance1e-4Convergence tolerance on the update norm

These options can be passed to solve() or setModelConfig() (see FEAScriptModel):

model.setSolverMethod("jacobi");
const result = model.solve({ maxIterations: 200000, tolerance: 1e-8 });

Jacobi method on the GPU ("jacobi-gpu")​

The same Jacobi iteration, run on the GPU with WebGPU through taichi.js, in a separate web worker. It is used through the asynchronous solveAsync method and is currently available for heatConductionScript only:

model.setModelConfig("heatConductionScript");
// ...mesh and boundary conditions...
model.setSolverMethod("jacobi-gpu");
const result = await model.solveAsync();
caution

"jacobi-gpu" runs only in browsers that support WebGPU, and the GPU kernel works on a dense copy of the system matrix, so its memory use grows with the square of the number of nodes.

The GPU computations use single precision (32-bit) floats. The maxIterations (default 10000) and tolerance (default 1e-4) options have the same meaning as for "jacobi", but the stopping criterion is the largest absolute residual, max⁡i∣Ri−∑jJijuj∣\max_i \lvert R_i - \sum_j \mathcal{J}_{ij} u_j \rvert, which is checked every few iterations.

Newton–Raphson method​

Nonlinear models are solved with the Newton–Raphson method (see Finite element method). It starts from uˉ=0\bar{u} = 0 and stops when ∥Δuˉ∥2\lVert \Delta \bar{u} \rVert_2 is smaller than or equal to the tolerance. If the norm of an increment exceeds 10210^2, the iterations are stopped and an error is logged.

OptionDefaultDescription
maxIterations100Maximum number of Newton–Raphson iterations
tolerance1e-4Tolerance on ∥Δuˉ∥2\lVert \Delta \bar{u} \rVert_2

For generalFormPDEScript, these options apply to the Newton–Raphson iterations and the inner linear system uses the defaults of the selected method. For frontPropagationScript, see the model page.