CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to retrieve nu1 and nu2

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 5, 2019, 09:19
Question How to retrieve nu1 and nu2
  #1
New Member
 
Elisabeth Diehl
Join Date: Jun 2019
Posts: 8
Rep Power: 6
elsebaer is on a distinguished road
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?
elsebaer is offline   Reply With Quote

Old   September 12, 2019, 10:54
Default
  #2
Senior Member
 
Andrea
Join Date: Feb 2012
Location: Leeds, UK
Posts: 179
Rep Power: 16
Andrea1984 is on a distinguished road
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
Andrea1984 is offline   Reply With Quote

Old   September 12, 2019, 15:24
Post
  #3
New Member
 
Elisabeth Diehl
Join Date: Jun 2019
Posts: 8
Rep Power: 6
elsebaer is on a distinguished road
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
    )
);
elsebaer is offline   Reply With Quote

Old   September 13, 2019, 03:35
Default
  #4
Senior Member
 
Andrea
Join Date: Feb 2012
Location: Leeds, UK
Posts: 179
Rep Power: 16
Andrea1984 is on a distinguished road
Yes, I assumed you had already instantiated your transport properties dictionary.

Glad to know it worked

Andrea
Andrea1984 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



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