|
[Sponsors] |
How to access nu and nut values for a Turbulent Solver |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 20, 2016, 07:33 |
How to access nu and nut values for a Turbulent Solver
|
#1 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi there,
I am currently running a flow over backward facing step (using LES) in OpenFAOM 2.4.0. I want access to the kinematic viscosity. So in a ".H" file which I include in pisoFoam.C, I write the following just to see if I have access to nu (kinematic viscosity) value: Code:
double k_viscosity; const scalarField& nuCells = nu().internalField(); forAll(mesh.cells(), celli) { k_viscosity = nuCells[celli];; Info<< "nu = " << k_viscosity << endl; } I also want to access the nut values calculated by the solver. Is there a function to access it ? Thanks in advance. |
|
September 21, 2016, 07:59 |
|
#2 |
Senior Member
Join Date: Sep 2013
Posts: 353
Rep Power: 21 |
There is no volScalarField called nu. nu is part of the turbulence model because most of those use calculate an effective viscosity by adding a turbulent one. This is the nut file. Check those on how to access it. The correct way should be
turbulence->nu() and turbulence->nut() for the turbulent viscosity |
|
September 21, 2016, 08:19 |
|
#3 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi,
Thank you for the reply. Will turbulence->nu() return a double value? I was trying out this command only and got an error like : "Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in initialization" Just by printing using: Info<<"\n nu value is"<<turbulence->nu(); I get output: nu value is dimensions [0 2 -1 0 0 0 0]; internalField uniform 0.00035714; How to access only the scalar value ? Last edited by suman91; September 21, 2016 at 08:28. Reason: Update: |
|
September 21, 2016, 09:19 |
|
#4 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Hi again,
Able to access nu(). The "createFields.H" file had a line: singlePhaseTransportModel laminarTransport(U, phi); So it is creating an object named laminartransport of type singlePhaseTransportModel Inside singlePhaseTransportModel.H, there sits a member function virtual tmp<volScalarField> nu() const; So if I write: Code:
const volScalarField k_viscosity = laminarTransport.nu(); double viscosity; forAll(mesh.cells(), celli) { viscosity = k_viscosity[celli]; Info<< "\ncell number in list = " << celli << endl; Info<< "nu = " << viscosity << endl; } |
|
September 21, 2016, 09:53 |
|
#5 |
Member
Suman Chakraborty
Join Date: Sep 2014
Location: Mumbai, India
Posts: 42
Rep Power: 12 |
Better approach:
Using the turbulenceModel object to access the viscosity rather than singlePhaseTransportModel. Code:
const volScalarField k_viscosity = turbulence->nu(); double viscosity; forAll(mesh.cells(), celli) { viscosity = k_viscosity[celli]; Info<< "\ncell number in list = " << celli << endl; Info<< "nu = " << viscosity << endl; } Code:
const volScalarField nu_t = turbulence->nut(); forAll(mesh.cells(), celli) { Info<< "nut = " << nu_t[celli] << endl; } |
|
December 18, 2018, 10:20 |
|
#6 |
Member
Amir
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
Hello,
I am calculating nut from two different ways, but the values are different. Could anybody explain why they give me different values please? 1. volScalarField nu_t (turbulence -> nut()); 2. volScalarField& nut = const_cast<volScalarField&> (mesh.lookupOblect<volScalarField>("nut")); Regards, Amir |
|
December 18, 2018, 21:50 |
|
#7 | |
New Member
Weiliang Zhu
Join Date: Apr 2016
Posts: 11
Rep Power: 11 |
Quote:
In my opinion, the first one calls a copy constructor, which just copy the value of nut. This means the nu_t is an different object with nu, the second is a referrence to nut itself. During the simulation, the nu with be updated with time, so they may have different value. |
||
December 19, 2018, 06:30 |
|
#8 | |
Member
Amir
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
Quote:
Many thanks for your reply. I used these methods in every iteration of my simulation to have access to nut. Could you please let me know which one gives me the correct nut in every iteration? Kind regards, Amir |
||
December 19, 2018, 06:36 |
|
#9 |
New Member
Weiliang Zhu
Join Date: Apr 2016
Posts: 11
Rep Power: 11 |
I think the second one is what you want.
and I think if you write the first one as : Code:
volScalarField& nu_t = turbulence -> nut(); |
|
December 19, 2018, 07:17 |
|
#10 | |
Member
Amir
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
Quote:
based on the error I received, I think this form is correct: Code:
const volScalarField& nu_t = turbulence -> nut(); Amir |
||
|
|