CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to retrieve nu1 and nu2 (https://www.cfd-online.com/Forums/openfoam-programming-development/220384-how-retrieve-nu1-nu2.html)

elsebaer September 5, 2019 09:19

How to retrieve nu1 and nu2
 
Hi everybody,
I need to retrieve nu1 and nu2 for the calculation of mu1 and mu2 (adapting interFoam). I added the following code into the createFields.H file, to the section "Reading transport properties".

Code:

const viscosityModel& nu1 = mixture.nuModel1();
const viscosityModel& nu2 = mixture.nuModel2();

dimensionedScalar mu1 = nu1 * rho1;
dimensionedScalar mu2 = nu2 * rho2;

Compilation says among others:

Quote:

note: cannot convert ‘nu2’ (type ‘const Foam::viscosityModel’) to type ‘const Foam::zeroField&’
...
note: ‘const dimensionedScalar {aka const Foam::dimensioned<double>}’ is not derived from ‘const Foam::fvMatrix<Type>’
Do you know the problem or some other way to get nu1 and nu2 or mu1 and mu2?

Andrea1984 September 12, 2019 10:54

Hi Elisabeth,

the nuModel1() method does not return a scalar, but a reference to a viscosityModel. The compiler is telling you that you cannot multiply two variables of different type. nu1 is a constant reference to a Foam::viscosityModel object, whilst rho1 is referring to a const Foam::zeroField.

Easiest way I can think of to access the values of the kinematic viscosity of your phases is to read them directly from the transportProperties file, something like:

dimensionedScalar nu1 ("nu", dimensionSet(0, 2, -1, 0, 0), 0);
(
nu1 = transportProperties.subDict("fluid1").lookup("nu")
);

where "fluid1" is the name of the first phase. You can probably avoid to manually insert the name by replacing "fluid1" with something like mixture.phase1Name(). Did not test it, but it should work.

Andrea

Andrea

elsebaer September 12, 2019 15:24

Hi Andrea,
thank you very much for your helpful answer!

It worked for me when I additionally insert the following to declare transportProperties:

Code:

IOdictionary transportProperties
(
    IOobject
    (
    "transportProperties",
    runTime.constant(),
    mesh,
    IOobject::MUST_READ,
    IOobject::NO_WRITE
    )
);


Andrea1984 September 13, 2019 03:35

Yes, I assumed you had already instantiated your transport properties dictionary.

Glad to know it worked ;)

Andrea


All times are GMT -4. The time now is 05:42.