# what exactly does the linear solver do?

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 June 24, 2012, 10:16 what exactly does the linear solver do? #1 Member   Join Date: May 2012 Posts: 64 Rep Power: 7 I've never really quite fully understood this - what exactly does the linear solver do? Code: ``` ---------------------------------------------------------------------- COEFFICIENT LOOP ITERATION = 1 CPU SECONDS = 6.591E+05 ---------------------------------------------------------------------- | Equation | Rate | RMS Res | Max Res | Linear Solution | +----------------------+------+---------+---------+------------------+ | U-Mom | 0.96 | 1.1E-04 | 8.1E-03 | 1.7E-04 OK| | V-Mom | 0.99 | 7.3E-04 | 6.5E-02 | 9.9E-04 OK| | W-Mom | 0.99 | 7.3E-04 | 6.5E-02 | 9.7E-04 OK| | P-Mass | 0.99 | 2.7E-04 | 2.0E-02 | 5.2 1.1E-03 OK| +----------------------+------+---------+---------+------------------+``` It is my understanding that the first part of in a typical output file, it solves for the RANS equations, but I've never really have a firm grasp on trying to understand what the linear solution does. Why is it there? Why is it important? What's the significance of it? If someone can please explain it to me and try and help me understand it, that would be greatly appreciated.

 June 24, 2012, 19:28 #2 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 14,195 Rep Power: 109 This is best explained by a general CFD textbook such as Anderson. But in short, the non-linear NS equations are linearised (and the accuracy of the linearised equations to the non-linear ones is the residual), and the linear solver solves the linear equations.

June 24, 2012, 21:53
#3
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks This is best explained by a general CFD textbook such as Anderson. But in short, the non-linear NS equations are linearised (and the accuracy of the linearised equations to the non-linear ones is the residual), and the linear solver solves the linear equations.
I'm sorry, but that doesn't really actually tell me anything.

Isn't that kind of stating the obvious?

(That's like if I was to ask why is a McIntosh apple called a McIntosh apple - your answer is like "a McIntosh apple is an apple of the McIntosh kind." It's the kind of answers that politicians give where they answer, but they haven't really actually said anything of real importance (or usefulness).)

Is the linearization of the second order NS PDE just by doing a substitution so that it's reduced to first order? And if so, why don't they just solve just the linearized equations rather than both the RANS and the linear equations?

 June 24, 2012, 22:05 #4 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 14,195 Rep Power: 109 I hope you are not expecting me to write CFD textbook on this thread. That is why I referred you to CFD texts. I do not know what you mean by "second order NS PDE". The NS equations are linearised by the discretisation scheme, the linear solvers the linear eqns and it is iterated to get the non-linear bits to converge.

June 24, 2012, 22:10
#5
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks I hope you are not expecting me to write CFD textbook on this thread. That is why I referred you to CFD texts. I do not know what you mean by "second order NS PDE". The NS equations are linearised by the discretisation scheme, the linear solvers the linear eqns and it is iterated to get the non-linear bits to converge.
No, but of the commercial CFD codes, CFX is the only one that I've seen that uses (or mentions) a linear solver explicitly. Fluent, as far as I know, doesn't have/use one (though I could be wrong). And neither does Star-CFD nor COMSOL Multiphysics.

And I've tried reading the CFX documentation on it, but didn't really quite fully understand what it was talking about.

The fundamental Navier-Stokes equations is a second order partial differential equation.

I remember when I was taking my ODE class that we were presented with a second order ODE, and we had to do a subsitution so that the 2nd order ODE can be represented as a 1st order ODE. And once you do that, then you can use the various different methods available to you to solve said 1st order ODE.

What's the name of the Anderson CFD textbook?

 June 24, 2012, 22:53 #6 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 14,195 Rep Power: 109 I see you have a bit to learn about CFD All the major CFD codes (Fluent, Star-CD, CFX) have linear solvers. The only ones which don't are the Lattice Boltzmann style solvers and they don't solver the NS equations anyway. The linear solver in CFX is complicated by it being a coupled solver, meaning the linear solution includes several equations. The traditional linear solver just solves one variable field at a time. FYI - "Multigrid Solvers", AMG and similar things are just a type of linear solver. Your comment about 2nd order ODEs is not relevant to the NS equations. Again, I will refer you to CFD textbooks. For CFD textbooks look here: http://www.cfd-online.com/Books/

June 24, 2012, 22:58
#7
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks I see you have a bit to learn about CFD All the major CFD codes (Fluent, Star-CD, CFX) have linear solvers. The only ones which don't are the Lattice Boltzmann style solvers and they don't solver the NS equations anyway. The linear solver in CFX is complicated by it being a coupled solver, meaning the linear solution includes several equations. The traditional linear solver just solves one variable field at a time. FYI - "Multigrid Solvers", AMG and similar things are just a type of linear solver. Your comment about 2nd order ODEs is not relevant to the NS equations. Again, I will refer you to CFD textbooks. For CFD textbooks look here: http://www.cfd-online.com/Books/
Well, there's a difference between just using the CFD programs like CFX and Star vs. actually knowing what I'm doing.

And seeing as how I've had problems with CFX's linear solver before, learning something about what it is that they do probably wouldn't kill me.

Hence why I'm asking...

Do I need to understand it enough to write my own solvers? No. But, it would be nice to know what it is doing and causes of failures (and why some failures will still allow the run to continue while others will cause the program to bomb out).

 June 24, 2012, 23:02 #8 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 14,195 Rep Power: 109 Hopefully this thread and the textbooks can help you work out what is going on. So on your final point - obviously it is preferred for both the linear solver and the coefficient loops to converge nicely, but if the linear solver does not fully converge that is not always a disaster. As you will be doing another coefficient loop then another go of the linear solver straight afterwards some failed linear solver goes early on is not bad. But as you progress to convergence you want it to converge nicely. The final solution is intended to have all equations solved adequately, and that requires converged linear solvers.

June 24, 2012, 23:07
#9
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks Hopefully this thread and the textbooks can help you work out what is going on. So on your final point - obviously it is preferred for both the linear solver and the coefficient loops to converge nicely, but if the linear solver does not fully converge that is not always a disaster. As you will be doing another coefficient loop then another go of the linear solver straight afterwards some failed linear solver goes early on is not bad. But as you progress to convergence you want it to converge nicely. The final solution is intended to have all equations solved adequately, and that requires converged linear solvers.
I think that in one of my current CFX runs, it bombs out on the 4th coefficient loop iteration. I forget what (if any) error messages are (other than it died).

But being that it dies in the middle of a step, it makes trying to figure out what happened or what caused it difficult. (Right now, all I'm doing is setting the run to stop right before the point of failure so that I can try and post-process the series of transient results to see if it might give me clues/indicators as to what's going on here).

I've also never really quite fully understood what the numbers mean too.

Code:
``` ----------------------------------------------------------------------
COEFFICIENT LOOP ITERATION =    1              CPU SECONDS = 6.591E+05
----------------------------------------------------------------------
|       Equation       | Rate | RMS Res | Max Res |  Linear Solution |
+----------------------+------+---------+---------+------------------+
| U-Mom                | 0.96 | 1.1E-04 | 8.1E-03 |       1.7E-04  OK|
| V-Mom                | 0.99 | 7.3E-04 | 6.5E-02 |       9.9E-04  OK|
| W-Mom                | 0.99 | 7.3E-04 | 6.5E-02 |       9.7E-04  OK|
| P-Mass               | 0.99 | 2.7E-04 | 2.0E-02 |  5.2  1.1E-03  OK|
+----------------------+------+---------+---------+------------------+```

I know that the RMS residuals, the Max residuals, and the linear residuals are pretty self explanatory, but what's the "5.2" mean?

June 24, 2012, 23:13
#10
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks I see you have a bit to learn about CFD All the major CFD codes (Fluent, Star-CD, CFX) have linear solvers. The only ones which don't are the Lattice Boltzmann style solvers and they don't solver the NS equations anyway. The linear solver in CFX is complicated by it being a coupled solver, meaning the linear solution includes several equations. The traditional linear solver just solves one variable field at a time. FYI - "Multigrid Solvers", AMG and similar things are just a type of linear solver. Your comment about 2nd order ODEs is not relevant to the NS equations. Again, I will refer you to CFD textbooks. For CFD textbooks look here: http://www.cfd-online.com/Books/
P.S. No kidding. If I wasn't trying to learn about it, then what the hell am I doing here?

Maybe not everybody is meant to be educators and helpers. And that some are only suited to talking to like-minded Ph.D.'s only while they continually lament on how dumb everybody else is, how sad that makes them, and how little they do to rectify that situation. Now....if only there was a way to correct/fix that....hmm....I wonder what it could be???

June 25, 2012, 18:10
#11
Senior Member

OJ
Join Date: Apr 2012
Location: United Kindom
Posts: 475
Rep Power: 13
Quote:
 Originally Posted by alpha754293 P.S. No kidding. If I wasn't trying to learn about it, then what the hell am I doing here? Maybe not everybody is meant to be educators and helpers. And that some are only suited to talking to like-minded Ph.D.'s only while they continually lament on how dumb everybody else is, how sad that makes them, and how little they do to rectify that situation. Now....if only there was a way to correct/fix that....hmm....I wonder what it could be???
I believe it's fair to expect the basic homework done before one posts in these forums, since not everyone may have time or patience to answer basic queries. Besides, I don't think such rather aggressive stance offers a friendly gesture for those who want to help either

I can attempt to answer few of your questions that I could understand.

Quote:
 ...I've never really have a firm grasp on trying to understand what the linear solution does.
In discretized form of momentum NS equations, pressure appears implicitly. Since CFX uses coupled solver, it needs to perform series of corrections in velocity and pressure, to obtain the new values of both till convergence criteria is honoured for continuity equation. Eventually, this corrections imply linear equations to be solved. That is what is done by linear solver. While CFX uses implicit coupled method for pressure and velocity correction (SIMPLEC) solving mass-momentum equations simultaneously, the other solvers like Fluent use semi implicit methods involving few approximations and assumptions in solution of pressure and velocity (SIMPLE, by default) and solve the mass-momentum equations sequentially. Yet, they need the solution of linear equations as well in the process and hence employ the linear solvers. You may want to read this for more details:

http://www.lboro.ac.uk/departments/c...dices/appd.pdf

Quote:
 ...but what's the "5.2" mean?
5.2 represents the average no. of iterations the linear solver had gone through, to obtain the convergence for linear equations for that loop, within the minimum and maximum no. of coefficient loops specified by user. And since it uses an iterative method, few initial "F's" should be ok as Glenn mentions; as long as you have subsequent coefficient loops ensuring you converge at each time step; which you should for legitimate solution.

Regards
OJ

June 25, 2012, 19:01
#12
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by oj.bulmer I believe it's fair to expect the basic homework done before one posts in these forums, since not everyone may have time or patience to answer basic queries. Besides, I don't think such rather aggressive stance offers a friendly gesture for those who want to help either I can attempt to answer few of your questions that I could understand. In discretized form of momentum NS equations, pressure appears implicitly. Since CFX uses coupled solver, it needs to perform series of corrections in velocity and pressure, to obtain the new values of both till convergence criteria is honoured for continuity equation. Eventually, this corrections imply linear equations to be solved. That is what is done by linear solver. While CFX uses implicit coupled method for pressure and velocity correction (SIMPLEC) solving mass-momentum equations simultaneously, the other solvers like Fluent use semi implicit methods involving few approximations and assumptions in solution of pressure and velocity (SIMPLE, by default) and solve the mass-momentum equations sequentially. Yet, they need the solution of linear equations as well in the process and hence employ the linear solvers. You may want to read this for more details: http://www.lboro.ac.uk/departments/c...dices/appd.pdf 5.2 represents the average no. of iterations the linear solver had gone through, to obtain the convergence for linear equations for that loop, within the minimum and maximum no. of coefficient loops specified by user. And since it uses an iterative method, few initial "F's" should be ok as Glenn mentions; as long as you have subsequent coefficient loops ensuring you converge at each time step; which you should for legitimate solution. Regards OJ

OJ:

Thank you.

That was actually very helpful. I didn't know that CFX uses SIMPLEC.

Well...in one of the combustion runs that I'm doing right now, it runs upto and thru a simulation time of 1.935e-4 [s] (with a timestep of 1e-7 [s]).

There are no 'F's that show up in the linear solver, but the maximum Mach number does go up to 6.029e+9 (and the preceeding timestep, the maximum Mach number 8.442e+7 and the one before that is 1.182e+6). In the next timestep (at 1.936e-4 [s]), after the fourth coefficient loop iteration, that's when I get the 'F' and the run bombs out entirely and "suddenly" (as in there were no preceeding 'F's in the linear solver).

Now, obviously, with the maximum Mach number taking off like that, there's probably something else that's indicative of a failure, (which is also why I had another thread asking how I would track the maximum Mach number so that I would be able to plot the same number that's shown in the output file, for this multi-domain run), but this is what really prompted me to try and finally learn once and for all, what the linear solver is, and what it does.

And that helps. I think. Not really sure how I can use that information to address the issue that I'm having, but I'll have to go back and think about it some more.

Like I said, I did try reading the CFX documentation (solver and theory guides) and I didn't really understand what it was saying. It's one thing to be doing the homework. It's another to actually understand what the homework means and what I'm really doing.

 June 25, 2012, 19:05 #13 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 14,195 Rep Power: 109 CFX does not use SIMPLEC. It uses a coupled P-V algorithm. If youa re getting linear solver "F"s and huge max mach numbers then your simulation is diverging. You need to improve the numerical stability - better mesh, double precision, smaller time steps, better intial guess.

June 25, 2012, 19:11
#14
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks CFX does not use SIMPLEC. It uses a coupled P-V algorithm. If youa re getting linear solver "F"s and huge max mach numbers then your simulation is diverging. You need to improve the numerical stability - better mesh, double precision, smaller time steps, better intial guess.
Tried that already, and that, and that, and that too.

And yes, I realize that it's diverging, but the most important question is why/how come?

Just one 'F'. The majority of the run is well within the subsonic region.

The first maximum Mach number notice message doesn't come up until timestep # 1409 (@1.409e-4 [s]) so before that, it seems to be fine. And then it will continue on for another 526 steps before it finally errors out on the 527th step.

June 25, 2012, 19:14
#15
Super Moderator

Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 14,195
Rep Power: 109
Quote:
 the most important question is why/how come?
I answered that - something has gone numerically unstable. You have not described what you are modelling so cannot suggest reasons for exactly what has gone unstable.

The obvious question is - what physically happens at 1.4e-4s. Does a BC change? Does some flow event happen (eg fluid X reaches point A)?

June 25, 2012, 19:29
#16
Member

Join Date: May 2012
Posts: 64
Rep Power: 7
Quote:
 Originally Posted by ghorrocks I answered that - something has gone numerically unstable. You have not described what you are modelling so cannot suggest reasons for exactly what has gone unstable. The obvious question is - what physically happens at 1.4e-4s. Does a BC change? Does some flow event happen (eg fluid X reaches point A)?
Thank you for stating the obvious, null solution.

It's a spark ignition combustion run. This is actually the third part of it.

The first part consisted of the fuel injection sequence and because I was getting a similar problem before, I thought that I would give it some more time to let the fuel and air mix first before trying to ignite it (which was the second part).

So, the total run is actually 0.063 [s].

The first part of the run is from 0 [s] to 0.053 [s] with timesteps of 1e-4 [s] for 530 steps. The second part is from 0.053 [s] to 0.0533 [s] with timesteps of 1e-5 [s] for an additional 30 steps. The third part is the part that I'm currently working on. The run is defined to run from 0.0533 [s] to 0.063 [s] for 0.0097 [s] with a timestep of 1e-7 [s] for 97000 steps, but it's failing right now at 0.0534936 [s].

Spark ignition occurs at 0.0532 [s], so everything after that is just flame propagation.

Domain fluid model is reacting mixture (gasoline/n-heptane).

Mass fraction of C8H18 for the fuel is 0.87 and the remainder is C7H16.

Oxidizer is air, with an N2 mass fraction of 0.767 and the remainder O2.

Combustion model is ECFM. Reaction model is CFX-RIF (using the built-in gasoline/n-heptane reactions list).

Spark energy I left it at the default of 0.2 [J], electrode efficiency is 1.

Initial volume is 0.2 [mm^3], transition radius is at 3 [mm].

I've tried a run already where I had a homogenous mixture (mixture fraction 0.1) and the combustion worked for that one. But when I have the fuel injected, I get this sort of error.

So, I set up another run where I set the end time to be the timestep right before the run bombed out to try and see if there's anything I can catch as the flame/combustion progresses that's causing the instability and thereby, the divergence.

June 25, 2012, 19:37
#17
Senior Member

OJ
Join Date: Apr 2012
Location: United Kindom
Posts: 475
Rep Power: 13
Quote:
 Originally Posted by ghorrocks CFX does not use SIMPLEC. It uses a coupled P-V algorithm.
Thanks for the clarification, Glenn. I realised this after little search. As I understand from my university notes; SIMPLEC had been a default in CFX 4x. But they later changed to fully coupled solver; perhaps from CFX 5x or CFX10+.

 June 25, 2012, 20:42 #18 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 14,195 Rep Power: 109 CFX4 used all the SIMPLE based solvers, with SIMPLEC as a default. CFX5 and later used a coupled solver.

 July 3, 2012, 22:02 #19 New Member   Haipeng Wang Join Date: Mar 2010 Posts: 9 Rep Power: 9 no mater what scheme you use, the NS equations are always solved as linear equations, that what linear solve used for.

 May 25, 2016, 07:43 #20 Member   Marcel Jay Join Date: Jun 2014 Location: Berlin Posts: 53 Rep Power: 5 Sorry for digging this out, but does somebody know the difference between an "OK" in capital letters and a "ok" in the iteration log?

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post vkrastev OpenFOAM Running, Solving & CFD 5 September 4, 2012 11:58 Attila CFX 1 April 13, 2012 22:22 bearcat Main CFD Forum 1 February 5, 2010 08:11 ztdep Main CFD Forum 7 May 24, 2007 14:14 fanzhong Meng CFX 4 March 21, 2006 21:16

All times are GMT -4. The time now is 16:10.

 Contact Us - CFD Online - Privacy Statement - Top