
[Sponsors] 
July 13, 2005, 05:55 
I would like to use residuals

#1 
New Member
Juergen Almanstoetter
Join Date: Mar 2009
Posts: 10
Rep Power: 8 
I would like to use residuals to observe the convergence behaviour of the SIMPLE segregated solver.
A measure for the residual R in finitevolume method nomenclature is: Single cell: R_P = a_P * u_P + \sum_nb a_nb * u_nb  b_P R = \sum_cells R_P Can the methods .A() and .H() be used for the calculation of R ? For example for the velocities from the momentum equation in a fashion like this: volVectorField b = 1.*fvc::grad(pd)+fvc::grad(rho)*gh; vector R = (sum(UEqn().A()*U)).value()(sum(UEqn().H())).value()(sum(b)).value(); Info <<mag(R.x())<< " "<<mag(R.y()))<< " "<< mag(R.z())<<endl; I know, the magnitude should be taken of R_P not of R like in the above equations. How to formulate this correctly ? Juergen 

July 13, 2005, 08:04 
The solver returns a solverPer

#2 
Senior Member
Join Date: Mar 2009
Posts: 854
Rep Power: 13 
The solver returns a solverPerformance class which may have everything you need:
// Class returned by the solver // containing performance statistics class solverPerformance { word solverName_; word fieldName_; scalar initialResidual_; scalar finalResidual_; label noIterations_; bool converged_; bool singular_; ... which you can get access to simply be keeping it after solution e.g. lduMatrix::solverPerformance sp = solve(... or lduMatrix::solverPerformance sp = xEqn.solve(); then you can use the access functions to get hold of the residuals etc. e.g. sp.initialResidual() 

September 13, 2005, 08:47 
Hi
Can somebody please tel

#3 
Member
Duderino
Join Date: Mar 2009
Posts: 40
Rep Power: 8 
Hi
Can somebody please tell me how the residuals (initial and final) are defined and where I can find the definition! Thanks! 

September 13, 2005, 15:07 
Me too.

#4 
Senior Member
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 8 
Me too.


September 14, 2005, 07:17 
For matrix
A x = b,
resi

#5 
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,769
Rep Power: 21 
For matrix
A x = b, residual is defined as res = b  Ax We then apply residual scaling with the following normalisation factor procedure: Type xRef = gAverage(x); wA = A x; pA = A xRef; normFactor = gSum(cmptMag(wA  pA) + cmptMag(source  pA)) + matrix.small_; and the scaled residual is: residual = gSum(cmptMag(source  wA))/normFactor; I will save you from complications with vectors and tensors in my block solver. :) Enjoy, Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

September 14, 2005, 16:45 
Thanks Dr. Jasak
but it is

#6 
Member
Duderino
Join Date: Mar 2009
Posts: 40
Rep Power: 8 
Thanks Dr. Jasak
but it is not clear to me what is: 1. gAverage What means the g? 2. gSum What means the g 3. matrix.small_ 4. is source Best regards jens 

September 14, 2005, 17:04 
1. gAverage is like average, b

#7 
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,769
Rep Power: 21 
1. gAverage is like average, but if you're running in parallel, you do average over all processors
2. gSum is like sum, but if in parallel you sum up over all processors 3. matrix.small: lduMatrix.C const scalar lduMatrix::small_ = 1.0e20; 4. source is b Have a look at the code, always instructive :) Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

April 18, 2006, 08:48 
hello
I need to compare the r

#8 
New Member
Aurelia Cure
Join Date: Mar 2009
Location: Lund, Sweden
Posts: 18
Rep Power: 8 
hello
I need to compare the residual of an analytical solution with the residual of the solution computed by simpleFoam after one iteration. actually, i need rA (=sourcewA) in each cell. the solverperformance returned in BIccG.C,are average of the residual in the domain but in my case, I would like to create a vectorField R where the scalarField Rx=R.x() is the residuals computed when soving Ux, R.y() corresponds to Uy and R.z() corresponds to Uz. My problem is that I am not able to access to the different step (solve ux, solve uy and solve Uz) in "solve UEqn" Thanks for your help! Aurelia 

January 25, 2007, 11:05 
Hi all and sorry for posting i

#9 
Member

Hi all and sorry for posting in this old thread but I found it very inherent with what I'm searching.
Quote from Jasak's post:  For matrix A x = b, residual is defined as res = b  Ax We then apply residual scaling with the following normalisation factor procedure: Type xRef = gAverage(x); wA = A x; pA = A xRef; normFactor = gSum(cmptMag(wA  pA) + cmptMag(source  pA)) + matrix.small_; and the scaled residual is: residual = gSum(cmptMag(source  wA))/normFactor;  I got this problem: InitialResidual goes very low (10e7 and more) after few iteration when x gets very high values only in a small zone of domain (like turbulent specific dissipation [omega] at the wall) meaning that xRef is almost as big as xMax (most of the domain is basically not contributing) very different from the "mean" value. (Hope I have been clear enough) It follows that pA differs a lot from wA and finally the normalization factor is too big. My idea is so to do something like: residual = gSum(cmptMag((source  wA)/wA)) I have no need to change directly lduMatrix::solverPerformance.initialResidual() I just want to use this variable to monitor convergence properties but I'm not sure if I have undersood correctly how the following methods and classes work: 1) Let xEqn be a fvScalarMatrix then volScalarField xEqn.residuals() = source  wA (without scaling) 2) lduMatrix::solverPerformance sp = xEqn().solve() scalar sp.initialResidual() = gSum(cmptMag(source  wA))/normFactor (with normFactor like in Jasak's post) 3) errorEstimate<scalar> eE(x_,x_.dimensions(),xEqn().residuals(),x.interna lField()); eE.error()= gSum(cmptMag(source  wA)/cmptMag(wA)) Is it true? I'm in the need for sharing my thoughts to be sure not have misunderstood everything. Thanks a lot for comment on these. Best Regards Cosimo
__________________
Cosimo Bianchini Ergon Research s.r.l. Via Panciatichi, 92 50127 Florence  ITALY Tel: +39 055 0763716 Mob: +39 320 9460153 email: cosimo.bianchini@ergonresearch.it URL: www.ergonresearch.it 

July 24, 2008, 06:04 
(1) In Ferziger and Peric book

#10 
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9 
(1) In Ferziger and Peric book,
they say that sometimes the residuals can be small even when the error is large and that this is even worse for poorly conditioned matrix. How does the poorly conditioning cause that? (2) In case we choose our residual criterion based on Tol, is such argument valid here. I ask because in the documention it was mentioned that the objective of normalization is to make the residuals independent of problem scale (not to condition the matrix). (3) They recommend that we should use residual drop to be 12 order of magnitude for inner iterations (that is the pressure equation) and 35 for outer iterations (that would be the difference between the initial residual in pressure correction 1 compared to its value at pressure correction n). What do you think? Any experience with that. Thanks. Best regards, Maka. 

February 24, 2009, 17:21 
Dear All,
Is it possible to

#11 
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 8 
Dear All,
Is it possible to access the residuals from the turbulence model object? I've rewritten (just for fun) simpleFoam to use a do...while loop which exits when the p and U residuals drop below specified values. I would like to be able to monitor the solution of the k and epsilon equations, but can't see how to do this (other than rewriting the whole of RASmodels). Gavin 

April 16, 2009, 14:59 
"checkConvergence()" for fvVectorMatrix??

#12 
New Member
Maria
Join Date: Apr 2009
Posts: 12
Rep Power: 8 
Hi!
I would like to check "UEqn" convergence inside an internal loop of my own solver. [...] > I fixed it! I missed that UEqn was defined as a tmp! Now it works fine. tmp<fvVectorMatrix> UEqn ( fvm::div(phi, U)  fvm::Sp(fvc::div(phi), U) + turbulence> divRhoR(U) ); lduMatrix::solverPerformance spU = UEqn().solve(); > For more info about checking convergence have a look at: ~/OpenFOAM/OpenFOAM1.5dev/applications/solvers/compressible/rhoSimpleFoam :) Last edited by mgc; April 28, 2009 at 13:32. 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Block matrices vs segregated solvers  fisher  OpenFOAM Running, Solving & CFD  9  June 13, 2010 04:15 
convergence of segregated solver  Bill  Main CFD Forum  2  March 7, 2009 03:15 
Segregated flow solver and no convergence  Ankit Purohit  CDadapco  0  June 15, 2007 09:22 
Convergence Definition of Segregated Solver  Amir  FLUENT  0  April 18, 2006 06:21 
coupled solver vs segregated solvers  RajaniKumar  Main CFD Forum  0  December 3, 2001 07:15 