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

variable rho in interFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 2 Post By kebsiali
  • 1 Post By kebsiali
  • 1 Post By Tushar@cfd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2015, 03:51
Question variable rho in interFoam
  #1
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
Hello Foamers

I'm implementing a varibale phase density in interFoam
I declare the density in createFields.H then have a seperate file rhof.H where i write the whole formula then i include it to my solver.
The library incompressibleTwoPhaseMixture uses lookup command to fetch the value of rhof and i replaced all rho1 inside nuf, muf, mu methods with rhof
I then had to add a boundary condition for rhof (zeroGradient)

my problem now, when i execute a case i have the following error

alkebsi@itd14:~/OpenFOAM/alkebsi-2.3.1/run/heatingwater4$ #0 Foam::error:rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::mag<Foam::Vector<double>, Foam::fvsPatchField, Foam::surfaceMesh>(Foam::GeometricField<Foam::Vect or<double>, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#4 Foam::interfaceProperties::calculateK() at ??:?
#5
at ~/OpenFOAM/alkebsi-2.3.1/applications/solvers/interPolyFoam/alphaEqn.H:98
#6 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#7
at ??:?


that i dont understand

in file alphaEqn.H the line 98 contains original untouched code

80 for (int aCorr=0; aCorr<nAlphaCorr; aCorr++)
81 {
82 surfaceScalarField phir(phic*interface.nHatf());
83
84 tmp<surfaceScalarField> tphiAlphaUn
85 (
86 fvc::flux
87 (
88 phi,
89 alpha1,
90 alphaScheme
91 )
92 + fvc::flux
93 (
94 -fvc::flux(-phir, alpha2, alpharScheme),
95 alpha1,
96 alpharScheme
97 )
98 );

Please help, any suggestions are heartfully wellcome
kebsiali is offline   Reply With Quote

Old   April 22, 2015, 02:25
Default
  #2
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
please dear foamers

does anyone have any idea what this error message means:

#0 Foam::error:rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 in "/lib/x86_64-linux-gnu/libc.so.6"
#3 Foam::tmp<Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::mag<Foam::Vector<double>, Foam::fvsPatchField, Foam::surfaceMesh>(Foam::GeometricField<Foam::Vect or<double>, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#4 Foam::interfaceProperties::calculateK() at ??:?
#5
at ~/OpenFOAM/alkebsi-2.3.1/applications/solvers/interPolyFoam/alphaEqn.H:98
#6 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#7
at ??:?

is it a problem of division by zero?
or a bad unexpected variable type?

please i need your help
kebsiali is offline   Reply With Quote

Old   April 26, 2015, 08:50
Default
  #3
New Member
 
Nicolas Thiers
Join Date: Mar 2015
Posts: 17
Rep Power: 11
nthiers is on a distinguished road
Hello ali, one question, did you compile the library before compile the solver?
nthiers is offline   Reply With Quote

Old   April 26, 2015, 10:12
Question
  #4
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
Dear Nicolas,

Yes.
library, then solver both are compiled good with no error message appearing.
when i complie the case however, that error message appears

I have checked the file interfaceProperties.C or .H in the library but it doesnt use rho1 or rho2. The calculateK() method is as defined below:
and this is a default file

void Foam::interfaceProperties::calculateK()
{
const fvMesh& mesh = alpha1_.mesh();
const surfaceVectorField& Sf = mesh.Sf();

// Cell gradient of alpha
const volVectorField gradAlpha(fvc::grad(alpha1_));
// Interpolated face-gradient of alpha
surfaceVectorField gradAlphaf(fvc::interpolate(gradAlpha));
//gradAlphaf -=
// (mesh.Sf()/mesh.magSf())
// *(fvc::snGrad(alpha1_) - (mesh.Sf() & gradAlphaf)/mesh.magSf());
// Face unit interface normal
surfaceVectorField nHatfv(gradAlphaf/(mag(gradAlphaf) + deltaN_));
correctContactAngle(nHatfv.boundaryField(), gradAlphaf.boundaryField());

// Face unit interface normal flux
nHatf_ = nHatfv & Sf;
// Simple expression for curvature
K_ = -fvc::div(nHatf_);
// Complex expression for curvature.
// Correction is formally zero but numerically non-zero.
/*
volVectorField nHat(gradAlpha/(mag(gradAlpha) + deltaN_));
forAll(nHat.boundaryField(), patchi)
{
nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
}
K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
*/
}


and the file alphaEqn.H is as defined in the post
kebsiali is offline   Reply With Quote

Old   April 26, 2015, 10:27
Default
  #5
New Member
 
Nicolas Thiers
Join Date: Mar 2015
Posts: 17
Rep Power: 11
nthiers is on a distinguished road
Could you please show me your solver/Make files, also are you compiling the library in your FOAM_USER_LIBBIN folder??
nthiers is offline   Reply With Quote

Old   April 27, 2015, 05:31
Default
  #6
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
make

interPolyFoam.C

EXE = $(FOAM_USER_APPBIN)/interPolyFoam


options

LIB_USER_SRC= $(WM_PROJECT_USER_DIR)/src

EXE_INC = -ggdb3 \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_USER_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_USER_SRC)/transportModels/myImmiscibleIncompressibleTwoPhaseMixture/lnInclude \

-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-ItwoPhaseMixtureThermo

EXE_LIBS = \
-ltwoPhaseMixture \
-linterfaceProperties \
-ltwoPhaseProperties \
-L$(FOAM_USER_LIBBIN) \
-lmyImmiscibleIncompressibleTwoPhaseMixture \
-lmyIncompressibleTransportModels \

-lincompressibleTurbulenceModel \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lfiniteVolume \
-lmeshTools \
-lfvOptions \
-lsampling \
-ltwoPhaseMixtureThermo \
-lfluidThermophysicalModels \
-lspecie
David* and elham usefi like this.
kebsiali is offline   Reply With Quote

Old   April 27, 2015, 05:34
Default
  #7
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
the solver is in home/OpenFOAM/User.OFversion/applications/solvers as normal
the library is in home/OpenFOAM/User.OFversion/src as normal

the library make file is as following

viscosityModels/viscosityModel/viscosityModel.C
viscosityModels/viscosityModel/viscosityModelNew.C
viscosityModels/Newtonian/Newtonian.C
viscosityModels/powerLaw/powerLaw.C
viscosityModels/rheoLaw/rheoLaw.C
viscosityModels/CrossPowerLaw/CrossPowerLaw.C
viscosityModels/BirdCarreau/BirdCarreau.C
viscosityModels/HerschelBulkley/HerschelBulkley.C

transportModel/transportModel.C
singlePhaseTransportModel/singlePhaseTransportModel.C

myIncompressibleTwoPhaseMixture/myIncompressibleTwoPhaseMixture.C


LIB = $(FOAM_USER_LIBBIN)/libmyIncompressibleTransportModels
kebsiali is offline   Reply With Quote

Old   May 29, 2015, 08:11
Default
  #8
Senior Member
 
Saideep
Join Date: Apr 2015
Location: INDIA
Posts: 203
Rep Power: 11
Saideep is on a distinguished road
Hi all!

I was actually interested to know what does rhoPhi in interFOAM solver's alphaEqn.H mean and where is it really used.

I know this is an old post but just to share my little knowledge regarding this, any corrections are welcome;

surfaceScalarField phic(mixture.cAlpha()*mag(phi/mesh.magSf()));
/*indicates the velocity at the cell face*/

phic is the relative velocity taken as min(cAlpha*phic, max(phic))
phir is the corrected relative velocity at face : by multiplying with the nHat().

Then the for loop states:
flux calculated from the mean velocity (U)*alpha. (second term in the advective transport of interface function.)
+
flux calculated for the artificial compression term. (U_r*(1-alpha)*alpha).

and the nCorrAlpha is just a term to get more precise information regarding your advective transport of the interface.

Saideep
Saideep is offline   Reply With Quote

Old   June 2, 2015, 09:33
Default
  #9
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
dear friend,
this is not an old post, I'm still suffering looking for the problem.

so rhoPhi as i answered you in another post is used in UEqn
kebsiali is offline   Reply With Quote

Old   June 8, 2015, 06:16
Default
  #10
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 17
Tushar@cfd is on a distinguished road
Dear All,

I have a query regarding "rhoPhi" term in the interFoam solver v.2.1..

If you look at the "createField.H" file you will find that, the term is written as:

Code:
     
surfaceScalarField rhoPhi
    (
        IOobject
        (
            "rho*phi",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
    rho1*phi
    );
While in "alphaEqn.H" file it is written as follows:

Code:
        rhoPhi = phiAlpha*(rho1 - rho2) + phi*rho2;
Can anyone relate/elaborate this term?

-
Thanks in Advance!
Tushar@cfd is offline   Reply With Quote

Old   June 8, 2015, 06:21
Default
  #11
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
Hello

Based on my basic knowledge (not sure)

this is just an initiation (declare of dimensions).
the value of rhoPhi that will be used in the solver will be the one defined in the alphaEqn.H

the difficulty is that alpha is not accessible from the solver itself ( you can not interpolate alpha from the cell centers to the faces) since the function interpolate is overloaded and will return a value of 1 if you interpolate alpha
thus when needing to define the full formula for rhoPhi in createfield you will have this problem of unavailability
lth likes this.
kebsiali is offline   Reply With Quote

Old   June 8, 2015, 06:27
Default
  #12
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 17
Tushar@cfd is on a distinguished road
Exactly!!

And one more problem: What will be the rhoPhi away from the interface? Lets, suppose for phase1 or phase2..

Tushar@cfd is offline   Reply With Quote

Old   June 13, 2015, 01:56
Default
  #13
Senior Member
 
T. Chourushi
Join Date: Jul 2009
Posts: 321
Blog Entries: 1
Rep Power: 17
Tushar@cfd is on a distinguished road
Hi all,

I hope the following post might be useful:

http://www.cfd-online.com/Forums/ope...tml#post550201

-
kebsiali likes this.
Tushar@cfd is offline   Reply With Quote

Old   October 14, 2015, 04:12
Default
  #14
Member
 
David GISEN
Join Date: Jul 2009
Location: Germany
Posts: 68
Rep Power: 16
David* is on a distinguished road
Thank you so much kebsiali for sharing your code above:
Quote:
Originally Posted by kebsiali View Post
EXE_LIBS = \
...
-lfvOptions
it helped me to find a missing library entry I was searching for hours!

For future reference:
Code:
undefined reference to `Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&)'
after implementing a volScalarField is resolved by
Code:
EXE_LIBS = \
    -L$(FOAM_LIBBIN) \
    -lOpenFOAM \
    -lfiniteVolume \
    -lfvOptions
Cheers, David
David* is offline   Reply With Quote

Old   March 10, 2017, 00:18
Default OpenFOAM-3.0.1 (interFoam solver) adding energy equation
  #15
New Member
 
Sarath Raj
Join Date: Nov 2016
Posts: 3
Rep Power: 9
Aadithya is on a distinguished road
Friends,

For adding energy equation using OpenFOAM 3.0.1 I followed the steps mentioned in the pdf (pdf is available in the below mentioned link)..but doing all the editing process and compiling process the following error is showing.Pls help me

email id:- srsnit2013@gmail.com


http://www.tfd.chalmers.se/~hani/kur...gLIU-final.pdf

dmee16241@cfd17:..OpenFOAM-Old/sarathraj-3.0.1$ cd applications/
dmee16241@cfd17:..sarathraj-3.0.1/applications$ cd myTempinterFoam/
dmee16241@cfd17:..applications/myTempinterFoam$ wclean
dmee16241@cfd17:..applications/myTempinterFoam$ wmake
Making dependency list for source file myTempinterFoam.C
g++ -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/transportModels/twoPhaseMixture/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/transportModels -I/home/dmee16241/OpenFOAM/dmee16241-3.0.1/src/transportModels/incompressible/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/transportModels/incompressible/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/transportModels/interfaceProperties/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/TurbulenceModels/turbulenceModels/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/TurbulenceModels/incompressible/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/fvOptions/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/sampling/lnInclude -IlnInclude -I. -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude -fPIC -c myTempinterFoam.C -o Make/linux64GccDPInt32Opt/myTempinterFoam.o
In file included from myTempinterFoam.C:68:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:62:41: error: ‘class Foam::immiscibleIncompressibleTwoPhaseMixture’ has no member named ‘cp1’
const dimensionedScalar& cp1 = mixture.cp1();
^
createFields.H:63:42: error: ‘class Foam::immiscibleIncompressibleTwoPhaseMixture’ has no member named ‘cp2’
const dimensionedScalar& cp2 = mixture .cp2();
^
In file included from myTempinterFoam.C:125:0:
TEqn.H:1:37: error: ‘class Foam::immiscibleIncompressibleTwoPhaseMixture’ has no member named ‘kappaf’
surfaceScalarField kappaf = mixture.kappaf();
^
/home/dmee16241/OpenFOAM/OpenFOAM-3.0.1/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/myTempinterFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/myTempinterFoam.o] Error 1
Aadithya is offline   Reply With Quote

Old   March 10, 2017, 08:00
Default
  #16
New Member
 
Hasan Shetabivash
Join Date: Jan 2017
Location: Montreal
Posts: 17
Rep Power: 12
hasan_shetabivash is on a distinguished road
Dear Aadithya.

It seems that you've not implemented the energy equation correctly. As I can understand from the errors you're using immiscibleIncompressibleTwoPhaseMixture which is inherited from incompressibleTwoPhaseMixture and interfaceProperties where kappaf, cp1, and cp2 are not defined. One of your options is defining another class (e. g. immiscibleIncompressibleNewTwoPhaseMixture ) instead of immiscibleIncompressibleTwoPhaseMixture which inherits from the newly implemented two phase mixture (e. g. incompressibleNewTwoPhaseMixture ). In case you couldn't resolve the problem you can post your code so that I can tell you more details.

Cheers,
hasan_shetabivash is offline   Reply With Quote

Old   March 15, 2017, 00:42
Default
  #17
New Member
 
Sarath Raj
Join Date: Nov 2016
Posts: 3
Rep Power: 9
Aadithya is on a distinguished road
Sir,

I have followed the steps as such mentioned in the pdf given in this link
http://www.tfd.chalmers.se/~hani/kur...gLIU-final.pdf.. Sir can i have your mail id???
Aadithya is offline   Reply With Quote

Old   July 19, 2022, 04:07
Default
  #18
Member
 
sadra mahmoudi
Join Date: Feb 2021
Location: Austria
Posts: 39
Rep Power: 5
sadra2003 is on a distinguished road
Dear Hasan Shetabivash,

I would have a question about the same topic. I would be appreciative if you help me. Its really important for my PhD.
I am simulating a bubbly flow in a solution of water and sugar. Sugar is dissolved in water and it is a passive scalar in my simulations. I would like to make the density of liquid as a function of sugar concentration (C). I have done it but the results are not correct.
I would like to ask whether I need to change rho1 to rho1(C) in the immiscibleIncompressibleTwoPhaseMixture or not?
In the current version of my solver, I introduced the rho1(C) in the time loop of my solver which is after the #include immiscibleIncompressibleTwoPhaseMixture in the main body of the solver.


Best regrds,
Sadra

Quote:
Originally Posted by hasan_shetabivash View Post
Dear Aadithya.

It seems that you've not implemented the energy equation correctly. As I can understand from the errors you're using immiscibleIncompressibleTwoPhaseMixture which is inherited from incompressibleTwoPhaseMixture and interfaceProperties where kappaf, cp1, and cp2 are not defined. One of your options is defining another class (e. g. immiscibleIncompressibleNewTwoPhaseMixture ) instead of immiscibleIncompressibleTwoPhaseMixture which inherits from the newly implemented two phase mixture (e. g. incompressibleNewTwoPhaseMixture ). In case you couldn't resolve the problem you can post your code so that I can tell you more details.

Cheers,
sadra2003 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
rho Constructor interFoam for creating a varying rho field kebsiali OpenFOAM Programming & Development 4 April 16, 2016 20:28
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 03:34
emag beta feature: charge density charlotte CFX 4 March 22, 2011 09:14
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas COMSOL 1 May 30, 2008 04:35
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


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