CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Adding Temperature variations to Density in interFoam (https://www.cfd-online.com/Forums/openfoam-solving/187940-adding-temperature-variations-density-interfoam.html)

spitchers May 18, 2017 11:26

Adding Temperature variations to Density in interFoam
 
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.

claudiocor June 15, 2017 09:19

interTempFoam
 
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?

spitchers June 15, 2017 10:27

Quote:

Originally Posted by claudiocor (Post 653376)
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.

claudiocor June 15, 2017 10:32

interTempFoam
 
1 Attachment(s)
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.

spitchers June 15, 2017 10:40

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.

floquation June 15, 2017 10:42

Quote:

Originally Posted by spitchers (Post 649425)
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 (Post 649425)
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?

claudiocor June 15, 2017 10:53

Quote:

Originally Posted by spitchers (Post 653391)
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!

spitchers June 15, 2017 10:55

Quote:

Originally Posted by floquation (Post 653394)
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


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