CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Where do we read relaxationFactors in fvSolution in the codes? (https://www.cfd-online.com/Forums/openfoam/88702-where-do-we-read-relaxationfactors-fvsolution-codes.html)

kaifu May 24, 2011 05:34

Where do we read relaxationFactors in fvSolution in the codes?
 
Hi Foamers,

I am curious about where do we read relaxationFactors in system/fvSolution in the solvers? For example, in simpleFoam, I can not see any dictionary is defined to look up those numbers. I guess it may read those numbers when we are trying to solve eqns. For example, in "UEqn.H", does the line
Code:

UEqn.relax();
read the relaxation factor for U?

Thx

// Kai

kaifu May 24, 2011 11:13

It is said "The user can specify the relaxation factor for a particular field by specifying first the word associated with the field, then the factor. The user can view the relaxation factors used in a tutorial example of simpleFoam for incompressible, laminar, steady-state flows."

It is not clear how to update the field during calculation although it seems that the relaxation factor is connected with the particular field automatically.

For example, if I create a field Gamma, and it will be updated every interation, say,
Code:

Gamma=a value
Then how does the solver deal with the updated Gamma and its relaxation factor?

Even for the alpha, U, p, k, epsilon, after solving the PDEs,
Code:

alphaEqn.solve();
will they be relaxed with the factor implicitly and automatically?

// Kai

marupio May 24, 2011 13:41

I was just reading up on that myself.

Relaxation factors are specified in the controlDict file, under a subdictionary called 'relaxationFactors'. It contains a list of field names, with the associated relaxation factors.

eg. (and I'm guessing a little here):

Code:

relaxationFactors
{
    U    0.7;
    T    0.5;
}

If the field name is not found, no relaxation is applied.

kaifu May 24, 2011 15:45

Quote:

Originally Posted by marupio (Post 309052)
I was just reading up on that myself.

But when do you use those numbers? For example to solve UEqn, you will use
Code:

UEqn.relax();UEqn.solve();
I dont see any relax factor is used.

// Kai

marupio May 24, 2011 15:54

fvMatrix::relax is overridden. If you provide it with a scalar - relax(factor) - it will relax the matrix with the given factor. If you don't, here's what it does:

From fvMatrix.C:

Code:

template<class Type>
void Foam::fvMatrix<Type>::relax()
{
    if (psi_.mesh().relax(psi_.name()))
    {
        relax(psi_.mesh().relaxationFactor(psi_.name()));
    }
}

It calls the overridden relax(factor) function, feeding it a scalar that was looked up in the controlDict. psi_.mesh().relaxationFactor(word) is a function in the solution class, which is part of the mesh. solution holds all the relaxation factors, which it reads from controlDict in the format I specified above.

You could figure this out from reading the source code, which is a little tricky until you get used to it. From a practical perspective, you can use relax by either putting:

Code:

PEqn.relax()  // Look up factor from controlDict
PEqn.relax(factor)  // Use the factor provided

If using the first one, the user has to have a relaxationFactors subdictionary in the controlDict to get it to work.

Am I answering the question?

kaifu May 24, 2011 16:07

That's great! Thanks


All times are GMT -4. The time now is 09:07.