Linear Solver:BiCGStab/CG/CGS related question

Numerical methods and mathematical models of Elmer
Post Reply
Posts: 8
Joined: 06 May 2020, 02:06
Antispam: Yes

Linear Solver:BiCGStab/CG/CGS related question

Post by peavinepeak » 23 Jun 2020, 07:18

Hello everyone,

I have a question concerning usage of CG (or CGS) linear solver instead of BiCGStab. BiCGStab is the default one setup in Elmer and I have not changed the default settings. However, I wanted to explore if CG or CGS would be a better solver for my simulation in terms of better convergence:

I am trying to get converged results for following tolerance:
Linear System Convergence Tolerance < 10^-13
if possible.

However, with BiCGStab, Linear System Residual diverges when I set the tolerance < 10^-12.

My problem:
A cylinder of air with linear (permeability) materials of rectangular and cylindrical shapes at its center. I use the surfaces of the cylinder to set uniform B-flux boundary condition. I am trying to get estimates for B-flux gradients around the materials which are made out of copper and sapphire. There are no other sources: charge density or current density in the problem. It is a magnetostatic problem.

I am using WhitneyAV solver in 3D. I tested the accuracy that can be attained with FEM method implemented by Elmer with a simple problem for which analytical result exists. The agreement is quite good, but I want to improve it further, if possible, by setting lower "Linear System Convergence Tolerance".

Disclaimer: I have very rudimentary knowledge of numerical methods


1. Would CG or CGS method work for my problem? In the Elmer Solver Manual it says: "The CG method is an ideal solution algorithm for cases where the coefficient matrix A is symmetric and positive definite.", where Ax=b as described in the manual is the matrix reduction of the associated PDE. I may be incorrect about this.

I am not sure if the "A" matrix in this case is symmetric and positive definite. Does the symmetry of A depend just on the PDE itself or PDE + boundary conditions or the discretization process?

2. Is it possible to check properties of matrix "A" in Elmer explicitly by displaying the matrix or by some other indirect measure before one can choose which linear solver to use?

I blindly used CG method once in my simulations and it seems to converge even when I set the tolerance criteria as low as 1E-14.

Please let me know if my question is not clear.

Thank you,

Site Admin
Posts: 3697
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland

Re: Linear Solver:BiCGStab/CG/CGS related question

Post by raback » 23 Jun 2020, 09:27

Hi sunil,

CG could work, but probably it is not nearly as robust. Our favorites for AV are BiCGStabl, Idrs, and GCR.

The linear system tolerance hardly has anything to do with accuracy. For AV we are often happy with 1e-8 or even less. Rather increase mesh resolution or try to use the "Quadratic Approximation" for the Hcurl basis.


Posts: 8
Joined: 06 May 2020, 02:06
Antispam: Yes

Re: Linear Solver:BiCGStab/CG/CGS related question

Post by peavinepeak » 26 Jun 2020, 03:30

Hello Peter,

Thank you for the advice. I am currently implementing some of them. I have two questions in the meantime:

1. If the coefficient matrix "A" for my problem is not symmetric and/or positive definite, would Elmer raise an error if I use CG as the linear solver?

2. Is it incorrect to use CG for problems where "A" is not symmetric or positive definite, or is it that it will be inefficient?


Posts: 155
Joined: 15 Sep 2009, 07:44

Re: Linear Solver:BiCGStab/CG/CGS related question

Post by mika » 26 Jun 2020, 13:43

1. No, Elmer just tries to solve the linear system with CG without exploring the properties of A.

2. In Elmer the stopping criterion for solving A x = b with CG is computed by default in terms of the true residual as || b - Ax || / || b || < TOL , so the matrix-vector product is really performed in this connection. Thus, if CG converges for a reasonably small TOL, the residual is truly small and the iterated solution can be expected to be a proper solution candidate. If CG converges although the matrix A doesn't have all properties it should have, it has anyhow solved the system (possibly inefficiently).

-- Mika

Post Reply