CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   declaration of an empty fvScalarMatrix (

linch November 11, 2011 11:32

declaration of an empty fvScalarMatrix
Hi fellows,

I want to underrelax some equation, so I have to declare fvScalarMatrix someEqn outside of my loop to prevent it from being deleted after each loop cycle right? But I can't use rubbish for initialization, because then it will be used for under-relaxation. So I need some kind of "empty" matrix, which will not be used for the relaxation. Is it possible? If not, can I prevent the under-relaxation in the first iteration?

best regards,

stevenvanharen November 14, 2011 07:28

Under-relaxation is already implemented in OpenFOAM.

See for instance pisoFOAM.

The amount of under-relaxtion can be controlled in fvSolution. Look for relaxtionFactors specified in fvSolution of some of the tutorials.

linch November 17, 2011 08:09

Well, I know that the under-relaxation is already there, but my problem is that i have two loops, say i and j (j is the inner one) and I want to relax a matrix A in each j-iteration with the same value from the last i-iteration. Simplified:

for (i=0; i<n; i++)
  for (j=0; j>m;j++)
    A_new=fRel*A_new + (1-fRel)*A_old;  // relaxation

in other words, I want to update A_old in each outer but not in inner iteration. And relaxation implemented in OF takes the last available value of A_new, no matter where does it come from, right?

So either I could implement the relaxation by hand, or I could overwrite the previous value of A_new (how?) with A_old stored separately.

Which variant would you suggest me? Or do somebody have another ideas?


linch November 22, 2011 10:11

another question,

for a transient simulation, is F.oldTime() the same as F.prevIter(), where F is some vol...Field?

Are both of these fields stored? If so, can F.prevIter() be overwritten simply by using F.storePrevIter();? Where both of them are being stored per default: at runTime.write(), runTime++ or somewhere else?

In GeometricField.C I saw additional outputs while using storePrevIter() and storeOldTime() inside of if(debug){}. How the debug mode can be switched on?

best regards,

All times are GMT -4. The time now is 18:29.