
[Sponsors] 
June 24, 2012, 10:16 
what exactly does the linear solver do?

#1 
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
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  ++++++  UMom  0.96  1.1E04  8.1E03  1.7E04 OK  VMom  0.99  7.3E04  6.5E02  9.9E04 OK  WMom  0.99  7.3E04  6.5E02  9.7E04 OK  PMass  0.99  2.7E04  2.0E02  5.2 1.1E03 OK ++++++ 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: 11,293
Rep Power: 88 
This is best explained by a general CFD textbook such as Anderson.
But in short, the nonlinear NS equations are linearised (and the accuracy of the linearised equations to the nonlinear ones is the residual), and the linear solver solves the linear equations. 

June 24, 2012, 21:53 

#3  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
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: 11,293
Rep Power: 88 
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 nonlinear bits to converge. 

June 24, 2012, 22:10 

#5  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
And I've tried reading the CFX documentation on it, but didn't really quite fully understand what it was talking about. The fundamental NavierStokes 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: 11,293
Rep Power: 88 
I see you have a bit to learn about CFD
All the major CFD codes (Fluent, StarCD, 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.cfdonline.com/Books/ 

June 24, 2012, 22:58 

#7  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
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: 11,293
Rep Power: 88 
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  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
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 postprocess 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  ++++++  UMom  0.96  1.1E04  8.1E03  1.7E04 OK  VMom  0.99  7.3E04  6.5E02  9.9E04 OK  WMom  0.99  7.3E04  6.5E02  9.7E04 OK  PMass  0.99  2.7E04  2.0E02  5.2 1.1E03 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  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
Maybe not everybody is meant to be educators and helpers. And that some are only suited to talking to likeminded 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: 11 
Quote:
I can attempt to answer few of your questions that I could understand. Quote:
http://www.lboro.ac.uk/departments/c...dices/appd.pdf Quote:
Regards OJ 

June 25, 2012, 19:01 

#12  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
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.935e4 [s] (with a timestep of 1e7 [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.936e4 [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 multidomain 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: 11,293
Rep Power: 88 
CFX does not use SIMPLEC. It uses a coupled PV 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  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
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.409e4 [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: 11,293
Rep Power: 88 
Quote:
The obvious question is  what physically happens at 1.4e4s. Does a BC change? Does some flow event happen (eg fluid X reaches point A)? 

June 25, 2012, 19:29 

#16  
New Member
Join Date: May 2012
Posts: 22
Rep Power: 5 
Quote:
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 1e4 [s] for 530 steps. The second part is from 0.053 [s] to 0.0533 [s] with timesteps of 1e5 [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 1e7 [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/nheptane). 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 CFXRIF (using the builtin gasoline/nheptane 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: 11 
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: 11,293
Rep Power: 88 
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: 7 
no mater what scheme you use, the NS equations are always solved as linear equations, that what linear solve used for.


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Dealing with BC's in OF 1.6  vkrastev  OpenFOAM Running, Solving & CFD  5  September 4, 2012 11:58 
ERROR #004100018; Fatal overflow in linear solver  Attila  CFX  1  April 13, 2012 22:22 
What's the difference between a linear and a nonlinear solver?  bearcat  Main CFD Forum  1  February 5, 2010 08:11 
free C code for large sparse matrix linear solver  ztdep  Main CFD Forum  7  May 24, 2007 14:14 
linear solver failure when using SST model  fanzhong Meng  CFX  4  March 21, 2006 21:16 