
[Sponsors] 
February 9, 2011, 06:04 
Residual definition of OpenFoam

#1 
New Member
......
Join Date: Jan 2011
Posts: 2
Rep Power: 0 
Hi Dear Foamers,
I am a new guy of OpenFOAM, and I just run the test case of pitzDaily in the OpenFoam tutorial, but with 20000 iterations, Because it does not reach the tolerance 1e6 yet. Anyway, I found that the initial residual has huge oscillation before it reach the tolerance(actually somewhere about 3e5). So I want to figure out i) what is the type of the initial residual ii) why it behaves like this. The first thing I do is to check the code (instead of searching answers from the form......). I went directly to the solver PCG and find the definition of the initial residual and finial residual, which will be like this: solverPerf.initialResidual() = gSumMag(rA)/normFactor; solverPerf.finalResidual() = solverPerf.initialResidual(); Then I found the definition of the norm Factor: // Foam::scalar Foam::lduMatrix::solver::normFactor ( const scalarField& psi, const scalarField& source, const scalarField& Apsi, scalarField& tmpField ) const { //  Calculate A dot reference value of psi matrix_.sumA(tmpField, interfaceBouCoeffs_, interfaces_); tmpField *= gAverage(psi); return gSum(mag(Apsi  tmpField) + mag(source  tmpField)) + matrix_.small_; // At convergence this simpler method is equivalent to the above // return 2*gSumMag(source) + matrix_.small_; } // and also the MACRO definitioin of gSumMag: // #define G_UNARY_FUNCTION(returnType, gFunc, func, rFunc) \ \ template<template<class> class Field, class Type> \ returnType gFunc(const FieldField<Field, Type>& f) \ { \ returnType res = func(f); \ reduce(res, rFunc##Op<Type>()); \ return res; \ } \ TMP_UNARY_FUNCTION(returnType, gFunc) G_UNARY_FUNCTION(Type, gMax, max, max) G_UNARY_FUNCTION(Type, gMin, min, min) G_UNARY_FUNCTION(Type, gSum, sum, sum) G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum) #undef G_UNARY_FUNCTION // Actually I got stuck here....... literally speaking, what I want is just to figure out what kind of norm does PCG (or other solvers ) use, and now I messed all the things up...... I GUESS it was L2 norm or Root Mean Square (RMS) because to my knowledge, only L2 norm is defined as SumFunc()/OtherSumFunc, but I do not know if it was correct. So my question will be what is the initial residual does PCG use? And why after 20000 iterations, oscillation occurs? Of couse I also want to understand what does these codes do, especially the macro part, which is really hard for me to understand. If someone can explain sth. about this, I'd really appreciate it! Thanks for any scanner forward! BR,  bodyouareboy 

March 13, 2011, 14:30 

#2 
New Member
Join Date: Feb 2011
Posts: 20
Rep Power: 6 
Hi all!
Does anyone has an answer regarding the question of boddyouareboy? I'm also interested to figure out what type of residual is actually being calculated by OF. Thank you! L1011 

March 14, 2011, 05:39 

#3  
Senior Member
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 1,014
Rep Power: 18 
Quote:


March 15, 2011, 04:08 

#4 
New Member
Join Date: Feb 2010
Posts: 7
Rep Power: 8 
Hello together,
as far as I understood it, it is a the L1nrom since the magnitudes of the residualvector are summed up. But what still is a kind of miracle to me is the role of the normfactor. I don't see what it is necessary for. 

May 13, 2011, 08:24 

#5 
Senior Member

The normalization is required, because you variables can vary in different ranges, so it is a kind of unifying the residuals for different scales in your equations.
But actually a found an issue, when the tol parameter is not so representative than relTol. For example in my case, for RANS simulation when I switch to the 2nd order, for some equations a strong source terms are produced due to nonorthogonal corrections in sqewed cells. If you analyze the line: Code:
// At convergence this simpler method is equivalent to the above // return 2*gSumMag(source) + matrix_.small_; I tried to get from Code:
gSum(mag(Apsi  tmpField) + mag(source  tmpField)) + matrix_.small_; Code:
// At convergence this simpler method is equivalent to the above // return 2*gSumMag(source) + matrix_.small_; The solution is either to set tol to something around 1e8...1e10 with relTol 0, or use tol 1e12 for all equations tuning the level of accuracy by e.g. relTol 0.001. So thus you define to improve your residuals for 3 orders. relTol can vary base are you making steady or transient calculations.
__________________
Best regards, Dr. Alexander VAKHRUSHEV Christian Doppler Laboratory for "Advanced Process Simulation of Solidification and Melting" Simulation and Modelling of Metallurgical Processes Department of Metallurgy University of Leoben FranzJosefStr. 18 A  8700 Leoben Österreich / Austria Tel.: +43 3842  402  3125 http://smmp.unileoben.ac.at Last edited by makaveli_lcf; May 13, 2011 at 11:38. 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
transsonic nozzle with rhoSimpleFoam  Unseen  OpenFOAM Running, Solving & CFD  7  April 16, 2014 03:38 
How to write k and epsilon before the abnormal end  xiuying  OpenFOAM Running, Solving & CFD  8  August 27, 2013 15:33 
Floating point exception error  Alan  OpenFOAM Running, Solving & CFD  10  April 6, 2012 14:02 
Computational time  sunnysun  OpenFOAM Running, Solving & CFD  5  March 16, 2009 04:32 
Differences between serial and parallel runs  carsten  OpenFOAM Bugs  11  September 12, 2008 11:16 