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

Adding Temperature variations to Density in interFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By floquation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2017, 12:26
Default Adding Temperature variations to Density in interFoam
  #1
New Member
 
Suffolk
Join Date: Nov 2015
Posts: 26
Rep Power: 10
spitchers is on a distinguished road
Hi all,

I have recently added a temperature equation to interFoam with success and have verified the results on a few test cases. I got very good convergence, speed, and accuracy.

I then have moved on to try and add temperature variations to the density equation:

Current Equation: rho = alpha1*rho1 + (1.0 - alpha1)*rho2;

New Equation needed: rho = alpha1*rho1*(1 - beta1*(T_TRef1)) + (1.0 - alpha1)*rho2*(1 - beta2*(T_TRef2));

However I am unable to get this to work.

I kept getting errors, so I have tried to trace this error back. It seems to be coming from the incompressibleTwoPhaseMixture libraries.

I tried to update these libraries to read the files I need from the transportProperties dictionary... but it fails every time!

I have just copied and pasted the same method that worked to correctly read in the cp1, cp2, Pr1, Pr2 from both phases. I compile it all fine, then go to run my code (even with the same equations that worked before I updated the twophase libraries) and I get an error.

Code:
GAMGPCG:  Solving for pcorr, Initial residual = 1, Final residual = 5.102515963e-06, No Iterations 8
time step continuity errors : sum local = 5.72136875e-12, global = 4.063542116e-13, cumulative = 4.063542116e-13
[0] #0  Foam::error::printStack(Foam::Ostream&)[3] #0  Foam::error::printStack(Foam::Ostream&)[2] #0  Foam::error::printStack(Foam::Ostream&)[4] #0  Foam::error::printStack(Foam::Ostream&)[1] #0  Foam::error::printStack(Foam::Ostream&) at ??:?
[2] #1  Foam::sigSegv::sigHandler(int) at ??:?
[3] #1  Foam::sigSegv::sigHandler(int) at ??:?
[4] #1  Foam::sigSegv::sigHandler(int) at ??:?
 at ??:?
[2] #[0] #1  Foam::sigSegv::sigHandler(int)2  ? at ??:?
[4] #2  ? at ??:?
[3] #2  ? at ??:?
[1] #1  Foam::sigSegv::sigHandler(int) in "/lib/x86_64-linux-gnu/libc.so.6"
[2] #3  Foam::objectRegistry::getEvent() const in "/lib/x86_64-linux-gnu/libc.so.6"
[4] #3  Foam::objectRegistry::getEvent() const in "/lib/x86_64-linux-gnu/libc.so.6"
[3] #3  Foam::objectRegistry::getEvent() const at ??:?
[1] #2  ? at ??:?
[0] #2  ? at ??:?
[4] #4  Foam::regIOobject::regIOobject(Foam::IOobject const&, bool) in "/lib/x86_64-linux-gnu/libc.so.6"
[1] #3  Foam::objectRegistry::getEvent() const at ??:?
[2] #4  Foam::regIOobject::regIOobject(Foam::IOobject const&, bool) in "/lib/x86_64-linux-gnu/libc.so.6"
[0] #3  Foam::objectRegistry::getEvent() const at ??:?
 at ??:?
[4] #5  [3] #4  Foam::regIOobject::regIOobject(Foam::IOobject const&, bool) at ??:?
[2] #5  Foam::DimensionedField<double, Foam::volMesh>::DimensionedField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, bool) at ??:?
[1] #4  Foam::regIOobject::regIOobject(Foam::IOobject const&, bool)Foam::DimensionedField<double, Foam::volMesh>::DimensionedField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, bool) at ??:?
[0] #4  Foam::regIOobject::regIOobject(Foam::IOobject const&, bool) at ??:?
[4] #6   at ??:?
[2] #6   at ??:?
[3] #5  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, Foam::word const&)Foam::DimensionedField<double, Foam::volMesh>::DimensionedField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, bool)Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, Foam::word const&) at ??:?
[0] #5   at ??:?
[1] #5   at ??:?
[4] #7   at ??:?
[3] #6  Foam::DimensionedField<double, Foam::volMesh>::DimensionedField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, bool) at ??:?
[2] #7  Foam::DimensionedField<double, Foam::volMesh>::DimensionedField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, bool)Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, Foam::word const&)Foam::reuseTmpGeometricField<double, double, Foam::fvPatchField, Foam::volMesh>::New(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::word const&, Foam::dimensionSet const&) at ??:?
[1] #6   at ??:?
[0] #6  Foam::reuseTmpGeometricField<double, double, Foam::fvPatchField, Foam::volMesh>::New(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::word const&, Foam::dimensionSet const&)Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, Foam::word const&) at ??:?
[3] #7   at ??:?
[4] #8  Foam::reuseTmpGeometricField<double, double, Foam::fvPatchField, Foam::volMesh>::New(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::word const&, Foam::dimensionSet const&)Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensionSet const&, Foam::word const&)Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
[2] #8   at ??:?
[3] #8   at ??:?
[0] #7   at ??:?
[4] #9  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(double const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)Foam::reuseTmpGeometricField<double, double, Foam::fvPatchField, Foam::volMesh>::New(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::word const&, Foam::dimensionSet const&) at ??:?
[1] #7   at ??:?
[2] #9  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(double const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
[3] #9  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(double const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)Foam::reuseTmpGeometricField<double, double, Foam::fvPatchField, Foam::volMesh>::New(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::word const&, Foam::dimensionSet const&) at ??:?
[0] #8   at ??:?
[4] #10  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F2() const at ??:?
[2] #10  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F2() const at ??:?
[3] #10  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F2() constFoam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
[1] #8   at ??:?
[4] #11  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F23() const at ??:?
[2] #11  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F23() const at ??:?
[3] #11  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F23() const at ??:?
[0] #9  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(double const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&) at ??:?
[4] #12  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::correctNut() at ??:?
[3] #12  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::correctNut() at ??:?
[0] #10   at ??:?
[1] #9  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator*<double, Foam::fvPatchField, Foam::volMesh>(double const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::F2() const at ??:?
[2] #12  Foam::kOmegaSST<Foam::eddyViscosity<Foam::RASModel<Foam::IncompressibleTurbulenceModel<Foam::transportModel> > >, Foam::IncompressibleTurbulenceModel<Foam::transportModel> >::correctNut() at ??:?

--------------------------------------------------------------------------
mpirun noticed that process rank 2 with PID 29483 on node shaun-VirtualBox exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
This is very frustrating!!

Could someone please point me in the right direction. If you are able to help me successfully read the values from transportProperties, I feel like I could take it from there.

Any help would be much appreciated.
spitchers is offline   Reply With Quote

Old   June 15, 2017, 10:19
Default interTempFoam
  #2
New Member
 
Cláudio Corrêa
Join Date: Jun 2017
Location: Brazil
Posts: 14
Rep Power: 9
claudiocor is on a distinguished road
Dear Spitchers

I'm have a problem with interTempFoam implementation. I'm used tutorials from openfoam 2.3 but my OF is 17.02. Do you can help me?
claudiocor is offline   Reply With Quote

Old   June 15, 2017, 11:27
Default
  #3
New Member
 
Suffolk
Join Date: Nov 2015
Posts: 26
Rep Power: 10
spitchers is on a distinguished road
Quote:
Originally Posted by claudiocor View Post
Dear Spitchers

I'm have a problem with interTempFoam implementation. I'm used tutorials from openfoam 2.3 but my OF is 17.02. Do you can help me?
Hi claudiocor,

What problem are you having? have you first successfully updated and compiled the TwoPhaseMixture .H and .C files?

If you could share your error code I might be able to help.
spitchers is offline   Reply With Quote

Old   June 15, 2017, 11:32
Default interTempFoam
  #4
New Member
 
Cláudio Corrêa
Join Date: Jun 2017
Location: Brazil
Posts: 14
Rep Power: 9
claudiocor is on a distinguished road
Hi Spitchers

No, I don't have sucess in to compile initially the code. But I modified incompressibleTwoPhaseMixture.H and .C.

In attached the print results compile.
Attached Images
File Type: jpg print result.jpg (161.3 KB, 67 views)
claudiocor is offline   Reply With Quote

Old   June 15, 2017, 11:40
Default
  #5
New Member
 
Suffolk
Join Date: Nov 2015
Posts: 26
Rep Power: 10
spitchers is on a distinguished road
It seems that you have typo's in your code from what I can see. I can't spend all day fixing these. Start from the original IncompressibleTwoPhaseMixture files and go SLOWLY through the tutorial. You may notice that the code is slightly different if you have a different version of OpenFOAM to the one in the tutorial - then you'll have to look through your files and see what differences there are. Look for similarities and copy, paste and edit. Don't just through in the code into your files.
spitchers is offline   Reply With Quote

Old   June 15, 2017, 11:42
Default
  #6
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 21
floquation will become famous soon enough
Quote:
Originally Posted by spitchers View Post
Current Equation: rho = alpha1*rho1 + (1.0 - alpha1)*rho2;

New Equation needed: rho = alpha1*rho1*(1 - beta1*(T_TRef1)) + (1.0 - alpha1)*rho2*(1 - beta2*(T_TRef2));
Just as a note, we usually only apply the linearisation of the temperature dependency of density to the gravity term, which we call the Boussinesq approximation.
For your purpose, do you really want to apply the linearisation everywhere?

Quote:
Originally Posted by spitchers View Post
However I am unable to get this to work.

I kept getting errors, so I have tried to trace this error back. It seems to be coming from the incompressibleTwoPhaseMixture libraries.

I tried to update these libraries to read the files I need from the transportProperties dictionary... but it fails every time!

I have just copied and pasted the same method that worked to correctly read in the cp1, cp2, Pr1, Pr2 from both phases. I compile it all fine, then go to run my code (even with the same equations that worked before I updated the twophase libraries) and I get an error.

Code:
(...)
kOmegaSST
(...)
exited on signal 11 (Segmentation fault).
This is very frustrating!!

Could someone please point me in the right direction. If you are able to help me successfully read the values from transportProperties, I feel like I could take it from there.
How exactly did you "update the library"?

From your error I see you have a segmentation fault (typically memory corrupted), in your kOmegaSST class.
This seems like an arbitrary location that has nothing to do with rho, does it?
That would imply that your memory is indeed corrupted and it just-so-happens to go wrong in the kOmegaSST class. That's pure chance. This typically implies a pointer mistake...

However, I have had a quite similar problem recently which was not merely a pointer mistake:
I had modified a library (libinterfaceProperties.so) in perfectly good C++, but still I got a Segmentation fault.
By chance I managed to fix my problem... And after Googling, I found a fairly good explanation on SO by user268396.
Put in simple terms, if you modify your library, the location of variables and functions inside the binary (.so) will shift. It is the job of the linker to find out where these reside, such that an executable knows where to look inside that binary. Therefore, if you modify a library in a certain manner, you must relink your executable (interFoam) with the new library version. For safety, just always relink.

Hence I asked "How exactly did you "update the library"?"--> Did you also relink (or just recompile) your solver?
Ramzy1990 likes this.
floquation is offline   Reply With Quote

Old   June 15, 2017, 11:53
Default
  #7
New Member
 
Cláudio Corrêa
Join Date: Jun 2017
Location: Brazil
Posts: 14
Rep Power: 9
claudiocor is on a distinguished road
Quote:
Originally Posted by spitchers View Post
It seems that you have typo's in your code from what I can see. I can't spend all day fixing these. Start from the original IncompressibleTwoPhaseMixture files and go SLOWLY through the tutorial. You may notice that the code is slightly different if you have a different version of OpenFOAM to the one in the tutorial - then you'll have to look through your files and see what differences there are. Look for similarities and copy, paste and edit. Don't just through in the code into your files.
Thanks for your help. I will follow your guideline and post the results later. Best regards!
claudiocor is offline   Reply With Quote

Old   June 15, 2017, 11:55
Default
  #8
New Member
 
Suffolk
Join Date: Nov 2015
Posts: 26
Rep Power: 10
spitchers is on a distinguished road
Quote:
Originally Posted by floquation View Post
Just as a note, we usually only apply the linearisation of the temperature dependency of density to the gravity term, which we call the Boussinesq approximation.
For your purpose, do you really want to apply the linearisation everywhere?


How exactly did you "update the library"?

From your error I see you have a segmentation fault (typically memory corrupted), in your kOmegaSST class.
This seems like an arbitrary location that has nothing to do with rho, does it?
That would imply that your memory is indeed corrupted and it just-so-happens to go wrong in the kOmegaSST class. That's pure chance. This typically implies a pointer mistake...

However, I have had a quite similar problem recently which was not merely a pointer mistake:
I had modified a library (libinterfaceProperties.so) in perfectly good C++, but still I got a Segmentation fault.
By chance I managed to fix my problem... And after Googling, I found a fairly good explanation on SO by user268396.
Put in simple terms, if you modify your library, the location of variables and functions inside the binary (.so) will shift. It is the job of the linker to find out where these reside, such that an executable knows where to look inside that binary. Therefore, if you modify a library in a certain manner, you must relink your executable (interFoam) with the new library version. For safety, just always relink.

Hence I asked "How exactly did you "update the library"?"--> Did you also relink (or just recompile) your solver?
Hi,

Thank you for your help with the segmentation fault explanation I will look into that for future errors I come across! However, I solved my problem a few days after making this post. Your initial questions were right, Do I really need linearization everywhere? the answer was no. I just added it to the momentum term like in the bouyantBoussinesq solvers. It ran just fine and the results were great. I realized after a while that my density variations are so small that a Boussinesq approximation is valid and a complete update of rho each iteration is not needed.

Thank you for your help.

Regards,

Shaun
spitchers is offline   Reply With Quote

Reply

Tags
incompressible two phases, interfoam, openfoam, temperature, transportproperties


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding the Energy Equation to interFoam (OF 2.4.0) Pay OpenFOAM Programming & Development 42 July 17, 2023 08:54
conjugateHeatFoam + interFoam farhagim OpenFOAM Programming & Development 15 July 19, 2016 08:55
adding density eqn"Mille and Poisson" in pisoFoam sinatahmooresi OpenFOAM Programming & Development 2 April 30, 2016 03:57
Strange temperature behaviour with interFoam tayo OpenFOAM 9 July 11, 2014 08:28
Adding temperature field to InterFoam yapalparvi OpenFOAM Running, Solving & CFD 8 October 14, 2009 21:18


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