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

Adding the Energy Equation to interFoam (OF 2.4.0)

Register Blogs Community New Posts Updated Threads Search

Like Tree22Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 13, 2015, 05:35
Default Adding the Energy Equation to interFoam (OF 2.4.0)
  #1
Pay
New Member
 
Perry Uhlig
Join Date: Oct 2015
Location: Germany
Posts: 13
Rep Power: 10
Pay is on a distinguished road
Dear Foamers,

first of all, this is my first thread, me being new to OF and the forum as well. So I am thankful for any advice regarding anything related to CFD in general and OF and this forum in particular.

Adding the Energy Equation to interFaom makes it necessary to modify the used library (A) and secondly modify the solver itself (B). I am having problems compiling said application, hence I have written this thread.
I am going to describe my steps in detail in this thread. The procedure is inspired by both the documents from Damiano Natali ("interTempFoam") and Qingming Liu ("myinterFoamDiabatic"). The links are given beneath.

http://www.wolfdynamics.com/images/c...erTempFoam.pdf

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

A) Modifcation of the library

1)
Copy the original folder transportModels to the user's directory

cd $WM_PROJECT_USER_DIR/src/
cp -rp $FOAM_SRC/transportModels .

2)
Rename the folders and files which are being modified (namely the libraries incompressibleTwoPhaseMixture and immiscibleIncompressibleTwoPhaseMixture).

cd transportModels/incompressible
mv incompressibleTwoPhaseMixture myIncompressibleTwoPhaseMixture
cd myIncompressibleTwoPhaseMixture
mv incompressibleTwoPhaseMixture.C myIncompressibleTwoPhaseMixture.C
mv incompressibleTwoPhaseMixture.H myIncompressibleTwoPhaseMixture.H

cd ../..
mv immiscibleIncompressibleTwoPhaseMixture myImmiscibleIncompressibleTwoPhaseMixture
cd myImmiscibleIncompressibleTwoPhaseMixture
mv immiscibleIncompressibleTwoPhaseMixture.C myImmiscibleIncompressibleTwoPhaseMixture.C
mv immiscibleIncompressibleTwoPhaseMixture.H myImmiscibleIncompressibleTwoPhaseMixture.H

3)
Change the respective file files corresponding to the the naming and path.
in the folder incompressible/Make for myIncompressibleTwoPhaseMixture:
Code:
myIncompressibleTwoPhaseMixture/myIncompressibleTwoPhaseMixture.C 

LIB = $(FOAM_USER_LIBBIN)/libmyIncompressibleTransportModels
in the folder myImmiscibleIncompressibleTwoPhaseMixture/Make for myImmiscibleIncompressibleTwoPhaseMixture:
Code:
myImmiscibleIncompressibleTwoPhaseMixture.C 

LIB = $(FOAM_USER_LIBBIN)/libmyImmiscibleIncompressibleTwoPhaseMixture
4) Make sure the newly named files are being included with their new name in the respective files:
in myIncompressibleTwoPhaseMixture.C:
Code:
#include "myIncompressibleTwoPhaseMixture.H"
in myImmiscibleIncompressibleTwoPhaseMixture.C
Code:
#include "myImmiscibleIncompressibleTwoPhaseMixture.H"
in myImmiscibleIncompressibleTwoPhaseMixture.H
Code:
#include "myIncompressibleTwoPhaseMixture.H"
5)
In the file myImmiscibleIncompressibleTwoPhaseMixture/Make/options make the adaption as highlighted, so the connection to the new library is made.
Code:
LIB_LIBS = \
    -ltwoPhaseMixture \
    -L$(FOAM_USER_LIBBIN) \
    -lmyIncompressibleTransportModels \
    -linterfaceProperties \
    -ltwoPhaseProperties \
    -lfiniteVolume
6)
Add the new parameters rho and Pr in myIncompressibleTwoPhaseMixture.H.
Code:
	dimensionedScalar rho1_; 
	dimensionedScalar rho2_; 
//-----------modified_start------------//
	dimensionedScalar cp1_; 
	dimensionedScalar cp2_; 
	dimensionedScalar Pr1_; 
	dimensionedScalar Pr2_;
//-----------modified_end------------//
and
Code:
	const dimensionedScalar& rho2() const 
	{ 
	return rho2_; 
	}; 
//-----------modified_start------------// 
        //- Return const-access to phase1 density 
        const dimensionedScalar& cp1() const 
        { 
            return cp1_; 
        } 

        //- Return const-access to phase2 density 
        const dimensionedScalar& cp2() const 
        { 
            return cp2_; 
        }; 

        //- Return const-access to phase1 density 
        const dimensionedScalar& Pr1() const 
        { 
            return Pr1_; 
        } 

        //- Return const-access to phase2 density 
        const dimensionedScalar& Pr2() const 
        { 
            return Pr2_; 
        }; 
//-----------modified_end------------//
also for kappaf
Code:
        tmp<surfaceScalarField> nuf() const; 

//-----------modified_start------------// 
	//- Return the face-interpolated conductivity 
	tmp<surfaceScalarField> kappaf() const; 
//-----------modified_end------------//
7)
In myIncompressibleTwoPhaseMixture.C add the operations for the new parameters.
Code:
   rho2_("rho", dimDensity, nuModel2_->viscosityProperties().lookup("rho")),
//-----------modified_start------------//
    cp1_("cp", dimensionSet(0, 2, -2, -1, 0, 0, 0), nuModel1_->viscosityProperties().lookup("cp")),
    cp2_("cp", dimensionSet(0, 2, -2, -1, 0, 0, 0), nuModel2_->viscosityProperties().lookup("cp")),
    Pr1_("Pr", dimensionSet(0, 0, 0, 0, 0, 0, 0), nuModel1_->viscosityProperties().lookup("Pr")),
    Pr2_("Pr", dimensionSet(0, 0, 0, 0, 0, 0, 0), nuModel2_->viscosityProperties().lookup("Pr")),
//-----------modified_end------------//
and
Code:
            nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
//-----------modified_start--------------------//
	nuModel1_->viscosityProperties().lookup("cp") >> cp1_;
	nuModel2_->viscosityProperties().lookup("cp") >> cp2_;
	nuModel1_->viscosityProperties().lookup("Pr") >> Pr1_;
	nuModel2_->viscosityProperties().lookup("Pr") >> Pr2_;
//-----------modified_end----------------------//
Also add the lines for the calculation of kappaf().
Code:
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleTwoPhaseMixture::nuf() const
{
    const surfaceScalarField alpha1f
    (
        min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1))
    );

    return tmp<surfaceScalarField>
    (
        new surfaceScalarField
        (
            "nuf",
            (
                alpha1f*rho1_*fvc::interpolate(nuModel1_->nu())
              + (scalar(1) - alpha1f)*rho2_*fvc::interpolate(nuModel2_->nu())
            )/(alpha1f*rho1_ + (scalar(1) - alpha1f)*rho2_)
        )
    );
}
//-----------modified_start------------//
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleTwoPhaseMixture::kappaf() const
{
	const surfaceScalarField alpha1f
	(
		min(max(fvc::interpolate(alpha1_), scalar(0)), scalar(1))
	);

	return tmp<surfaceScalarField>
	(
		new surfaceScalarField
		(
			"kappaf",
			(
				alpha1f*rho1_*cp1_*(1/Pr1_)
				*fvc::interpolate(nuModel1_->nu())
				+ (scalar(1) - alpha1f)*rho2_*cp2_
				*(1/Pr2_)*fvc::interpolate(nuModel2_->nu())
			)
		)
	);
}
//-----------modified_end------------//
8)
Compile both libraries from the respective folder. Start with myIncompressibleTwoPhaseMixture, because myImmiscibleIncompressibleTwoPhaseMixture depends on it already being compiled beforehand.

cd incompressible
wclean
wmake libso
cd ..
cd myImmiscibleIncompressibleTwoPhaseMixture
wclean
wmake libso


Compiling works at this stage, which is good for the moment but doesn't necessarily mean to me that I did everything right.



B) Modification of the solver interFoam to interTempFoam


1)
Enter the destination of the new solver and copy the base solver.

cd $WM_PROJECT_USER_DIR/applications/solvers/multiphase
cp -rp $FOAM_APP/solvers/multiphase/interFoam .

2)
Rename the folder and the .C file.

mv interFoam interTempFoam
cd interTempFoam
mv interFoam.C interTempFoam.C

3)
Adapt the file Make/files to the changed naming and path.
Code:
interTempFoam.C 

EXE = $(FOAM_USER_APPBIN)/interTempFoam
4)
In interTempFoam.C adapt the name of the following library being included.
Code:
#include "myImmiscibleIncompressibleTwoPhaseMixture.H"
5)
Add the following lines in the file createFields.H.
Code:
 Info<< "Reading field U\n" << endl; 
    volVectorField U 
    ( 
        IOobject 
        ( 
            "U", 
            runTime.timeName(), 
            mesh, 
            IOobject::MUST_READ, 
            IOobject::AUTO_WRITE 
        ), 
        mesh 
    ); 

//-------------modified_start--------------// 
    Info<< "Reading field T\n" << endl; 
    volScalarField T 
    ( 
        IOobject 
        ( 
            "T", 
            runTime.timeName(), 
            mesh, 
            IOobject::MUST_READ, 
            IOobject::AUTO_WRITE 
        ), 
        mesh 
    ); 
//-------------modified_end--------------//
and
Code:
   const dimensionedScalar& rho2 = mixture.rho2(); 
//-------------modified_start--------------// 
    const dimensionedScalar& cp1 = mixture.cp1(); 
    const dimensionedScalar& cp2 = mixture.cp2(); //not for Pr1 und Pr2 ??? 
//-------------modified_end--------------//
and
Code:
  // Mass flux 
    surfaceScalarField rhoPhi 
    ( 
        IOobject 
        ( 
            "rhoPhi", 
            runTime.timeName(), 
            mesh, 
            IOobject::NO_READ, 
            IOobject::NO_WRITE 
        ), 
        fvc::interpolate(rho)*phi 
    ); 

//-------------modified_start--------------// 
    // Need to store rhoCp for ddt(rhoCp, T) 
    volScalarField rhoCp 
    ( 
        IOobject 
        ( 
            "rhoCp", 
            runTime.timeName(), 
            mesh, 
            IOobject::READ_IF_PRESENT 
        ), 
        alpha1*rho1*cp1 + alpha2*rho2*cp2, 
        alpha1.boundaryField().types() 
    ); 
    rhoCp.oldTime(); 

    // heat flux 
    surfaceScalarField rhoCpPhi 
    ( 
        IOobject 
        ( 
            "rhoCpPhi", 
            runTime.timeName(), 
            mesh, 
            IOobject::NO_READ, 
            IOobject::NO_WRITE 
        ), 
        fvc::interpolate(rhoCp)*phi 
    ); 
//-------------modified_end--------------//
6)
In alphaEqn.H add:
Code:
      // Calculate the end-of-time-step mass flux 
        rhoPhi = phiAlpha*(rho1 - rho2) + phi*rho2; 
//-------------modified_start--------------// 
        // Calculate the end-of-time-step heat flux 
	rhoCpPhi = phiAlpha*(rho1*cp1 - rho2*cp2) + phi*rho2*cp2; 
//-------------modified_end--------------//
and in alphaEqnSubCycle.H add:
Code:
rho == alpha1*rho1 + alpha2*rho2;
//-------------modified_start--------------//
rhoCp == alpha1*rho1*cp1 + alpha2*rho2*cp2;
//-------------modified_end--------------//
7)
Create a file named Teqn.H in the interTempFoam folder containing the Energy Equation:
Code:
surfaceScalarField kappaf = incompressibleTwoPhaseMixture.kappaf();

fvScalarMatrix TEqn
(
	fvm::ddt(rhoCp,T)
	+ fvm::div(rhoCpPhi,T)
	- fvm::laplacian(kappaf,T)
);

TEqn.solve();
8)
Add the command for solving the E-Eqn in interTempFoam.C. The specific location of the added line may be object of discussion. Here is my suggestion:
Code:
        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "alphaControls.H"
            #include "alphaEqnSubCycle.H"

            mixture.correct();

            #include "UEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

//--------------modified_start----------------//
		#include "TEqn.H"
//--------------modified_end------------------//
9)
Adapt the file Make/options to the names and locations of the beforehand modified libraries. The following code is probably not correct and thus object of my questions.
Code:
EXE_INC = \
    -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(WM_PROJECT_USER_DIR)/src/transportModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
    -I$(WM_PROJECT_USER_DIR)/src/transportModels/myImmiscibleIncompressibleTwoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lmyImmiscibleIncompressibleTwoPhaseMixture \
    -L$(FOAM_LIBBIN) \
    -lincompressibleTurbulenceModel \
    -lincompressibleRASModels \
    -lincompressibleLESModels \
    -lfiniteVolume \
    -lfvOptions \
    -lmeshTools \
    -lsampling
9)
Compile the solver from within its directory interTempFoam.

wclean
wmake

<------------------------------------------------------------------------------------------------------------------------->
When I do everything as described I get the following output log:
Code:
~/OpenFOAM/puhlig-2.4.0/applications/solvers/multiphase/interTempFoam$ wmake
Making dependency list for source file interTempFoam.C
SOURCE=interTempFoam.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam240/src/transportModels/twoPhaseMixture/lnInclude -I/opt/openfoam240/src/transportModels -I/home/puhlig/OpenFOAM/puhlig-2.4.0/src/transportModels/incompressible/lnInclude -I/opt/openfoam240/src/transportModels/interfaceProperties/lnInclude -I/opt/openfoam240/src/turbulenceModels/incompressible/turbulenceModel -I/home/puhlig/OpenFOAM/puhlig-2.4.0/src/transportModels/myImmiscibleIncompressibleTwoPhaseMixture/lnInclude -I/opt/openfoam240/src/finiteVolume/lnInclude -I/opt/openfoam240/src/fvOptions/lnInclude -I/opt/openfoam240/src/meshTools/lnInclude -I/opt/openfoam240/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam240/src/OpenFOAM/lnInclude -I/opt/openfoam240/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/interTempFoam.o
In file included from interTempFoam.C:108:0:
TEqn.H: In function ‘int main(int, char**)’:
TEqn.H:1:58: error: expected primary-expression before ‘.’ token
 surfaceScalarField kappaf = incompressibleTwoPhaseMixture.kappaf();
                                                          ^
In file included from interTempFoam.C:64:0:
/opt/openfoam240/src/finiteVolume/lnInclude/readTimeControls.H:38:8: warning: unused variable ‘maxDeltaT’ [-Wunused-variable]
 scalar maxDeltaT =
        ^
make: *** [Make/linux64GccDPOpt/interTempFoam.o] Error 1
Let us prioritize the error over the warning.
Do you have any idea how it comes to that error and how to solve it?

I would very much appreciate comments from your side.

Best Regards
Perry
atulkjoy, katete, mcfdma and 2 others like this.

Last edited by Pay; November 17, 2015 at 04:36.
Pay is offline   Reply With Quote

Old   November 16, 2015, 19:57
Default interTempFoam in OF 2.3.1
  #2
New Member
 
Hannah Dietterich
Join Date: Mar 2015
Posts: 8
Rep Power: 11
hdietterich is on a distinguished road
Hi,
I'm working on the exact same problem. I've used the wolfdynamics page to make nearly same modifications as you to incorporate temperature into OpenFOAM (2.3.1), and I am getting a similar error in the end. The only differences in my procedure are:

Using "mixture" in your step 7: This is used to refer to the other quantities defined in myIncompressibleTwoPhaseMixture, so that's why I've used it. Anything else gives me the error you got.
Code:
surfaceScalarField kappaf = mixture.kappaf();

fvScalarMatrix TEqn
(
        fvm::ddt(rhoCp, T)
        + fvm::div(rhoCpPhi, T)
        - fvm::laplacian(kappaf, T)
);

TEqn.solve();
Then in your step 8: I've added the include call immediately after the Ueqn.H one.
Code:
// --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "alphaControls.H"
            #include "alphaEqnSubCycle.H"

            mixture.correct();

            #include "UEqn.H"

            #include "TEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }
Then in your step 9: I've essentially tried to add any libraries that might help.
Code:
EXE_INC = \
    -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(WM_PROJECT_USER_DIR)/src/transportModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
    -I$(WM_PROJECT_USER_DIR)/src/transportModels/myImmiscibleIncompressibleTwoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
    -ltwoPhaseMixture \
    -linterfaceProperties \
    -ltwoPhaseProperties \
    -L$(FOAM_USER_LIBBIN) \
    -lmyIncompressibleTransportModels \
    -lmyImmiscibleIncompressibleTwoPhaseMixture \
    -lincompressibleTurbulenceModel \
    -lincompressibleRASModels \
    -lincompressibleLESModels \
    -lfiniteVolume \
    -lfvOptions \
    -lmeshTools \
    -lsampling
This then gives me the following error while compiling:
Code:
 In function `main':
interThermalFoam.C:(.text.startup+0x409d): undefined reference to `Foam::incompressibleTwoPhaseMixture::kappaf() const'
collect2: error: ld returned 1 exit status
This is actually an error that has turned up a few times when I search the forums, but the solutions that have worked for people (compiling the libraries before the solver, referencing the modified libraries rather than those in interFoam) are not apparently the problem in this case.

Does anyone have any suggestions?
atulkjoy, katete and tonnykz like this.
hdietterich is offline   Reply With Quote

Old   November 17, 2015, 02:00
Default
  #3
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
Fantastic post Perry, you are a role model for this forum. Anyway, you did some strange things:
1. Your new library has the same name as the old one
2. You include both the new and old library in the Make files, although the old one is completely redundant.
atulkjoy and tonnykz like this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   November 17, 2015, 10:04
Default
  #4
Pay
New Member
 
Perry Uhlig
Join Date: Oct 2015
Location: Germany
Posts: 13
Rep Power: 10
Pay is on a distinguished road
Hi Hannah,

thank you for your reply. I implemented the first line of your TEqn.H file:
Code:
surfaceScalarField kappaf = mixture.kappaf();
For the time being I left the rest as it is, because it succesfully compiled (when one ignores the warning about maxDeltaT).

I just adjusted the given damBreak tutorial case (with its very coarse mesh). It completed the calculation, but with temperature values beneath zero. In consequence I will try a refined mesh and I will probably have to look into fvSchemses and fvSolution in more detail.

Greetings
Perry
katete likes this.
Pay is offline   Reply With Quote

Old   November 17, 2015, 10:16
Default
  #5
Pay
New Member
 
Perry Uhlig
Join Date: Oct 2015
Location: Germany
Posts: 13
Rep Power: 10
Pay is on a distinguished road
Hello Anton,

thanks for your feedback and the compliment.
Quote:
1. Your new library has the same name as the old one
I am guessing with "the old one [library]" you are referring to the directory "incompressible", the path of which is specified in:
Code:
EXE_INC = \
    -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(WM_PROJECT_USER_DIR)/src/transportModels/incompressible/lnInclude \
    - ...
If YES: "incompressible" is not the name of any library, but rather the folder in which the library "incompressibleTwoPhaseMixture" or in my case "myIncompressibleTwoPhaseMixture" is situated in.
If NO: What do you mean?

Quote:
2. You include both the new and old library in the Make files, although the old one is completely redundant.
I think I just gave the answer to that question, too.
Or didn't I?

Greetings
Perry
Pay is offline   Reply With Quote

Old   November 17, 2015, 11:50
Default
  #6
New Member
 
Hannah Dietterich
Join Date: Mar 2015
Posts: 8
Rep Power: 11
hdietterich is on a distinguished road
Hi Perry,

I'm glad that little change worked. I've modified mine to exactly match yours (with the mixture.kappaf) and it now compiles, too! Thanks for your very detailed description of all of your interFoam modifications. Now to see if it actually works...

Hannah
hdietterich is offline   Reply With Quote

Old   November 17, 2015, 12:28
Default
  #7
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Quote:
Originally Posted by Pay View Post
Hi Hannah,

I just adjusted the given damBreak tutorial case (with its very coarse mesh). It completed the calculation, but with temperature values beneath zero. In consequence I will try a refined mesh and I will probably have to look into fvSchemses and fvSolution in more detail.

Greetings
Perry
It will be very difficult to you to obtain solution with conserved energy. Because when you are using interFoam, all properties are advected with volumetric flux. So, you must rewrite equation for temperature for each phase, and then, by summing for all phases, you can get equation for temperature of mixture:
Code:
fvm::ddt(T)
+
fvm::div(phi,T)
+
fvm::SuSp(-fvc::div(phi),T)
-
fvm::laplacian(alpha1*kappa1 / (rho1*Cp1), T)
-
fvm::laplacian((1 - alpha1)*kappa2 / (rho2*Cp2), T)
erinsam likes this.
mkraposhin is offline   Reply With Quote

Old   November 17, 2015, 14:20
Default
  #8
New Member
 
Hannah Dietterich
Join Date: Mar 2015
Posts: 8
Rep Power: 11
hdietterich is on a distinguished road
Unfortunately, I get a segmentation fault when I run my newly compiled interFoam with temperature for a modified damBreak case with temperature. How do I interpret the error message to identify what might be wrong?

Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


PIMPLE: Operating solver in PISO mode

Reading field p_rgh

Reading field U

Reading field T

Reading/calculating face flux field phi

Reading transportProperties

Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  
 at sigaction.c:?
#3   at objectRegistry.C:?
#4  Foam::objectRegistry::checkIn(Foam::regIOobject&) const at ??:?
#5  Foam::regIOobject::checkIn() at ??:?
#6  Foam::regIOobject::regIOobject(Foam::IOobject const&, bool) at ??:?
#7  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&, Foam::dimensioned<double> const&, Foam::word const&) at ??:?
#8  Foam::interfaceProperties::interfaceProperties(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::IOdictionary const&) at ??:?
#9  Foam::immiscibleIncompressibleTwoPhaseMixture::immiscibleIncompressibleTwoPhaseMixture(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#10  
 at ??:?
#11  __libc_start_main at ??:?
#12  
 at ??:?
Segmentation fault
To modify damBreak I have added a T file to the 0 folder, cp and Pr to both phases in the transportProperties,

Code:
    div(rhoCpPhi,T)    Gauss linearUpwind grad(T);
    div(rhoCpPhi)      Gauss linearUpwind;
to fvSchemes,

Code:
    T
    {
        solver          BICCG;
        preconditioner  DILU;
        tolerance       1e-07;
        relTol          0;
    }
to fvSolution, and initial conditions to setFields.

I'd appreciate help identifying where the error might be so that I might know what to do to fix it.

mkraposhin, that's an interesting thought. Once this actually runs, then I'll be interested in getting the best solution possible.

Hannah
hdietterich is offline   Reply With Quote

Old   November 17, 2015, 15:29
Default
  #9
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Quote:
#8 Foam::interfaceProperties::interfaceProperties(Foa m::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::IOdictionary const&) at ??:?
#9 Foam::immiscibleIncompressibleTwoPhaseMixture::imm iscibleIncompressibleTwoPhaseMixture(Foam::Geometr icField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&) at ??:?
#10
from this lines it is seen that you are still using old model
immiscibleIncompressibleTwoPhaseMixture

can you post your createFields.H file?
mkraposhin is offline   Reply With Quote

Old   November 17, 2015, 15:31
Default
  #10
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Also, i think that it would be better to nest child class from mixture model, rather then creating new. Because at next lines OF creates turbulence model, that uses mixture model
mkraposhin is offline   Reply With Quote

Old   November 17, 2015, 16:09
Default
  #11
New Member
 
Hannah Dietterich
Join Date: Mar 2015
Posts: 8
Rep Power: 11
hdietterich is on a distinguished road
Quote:
Originally Posted by mkraposhin View Post
from this lines it is seen that you are still using old model
immiscibleIncompressibleTwoPhaseMixture

can you post your createFields.H file?
Here is the createFields.H.

Code:
    Info<< "Reading field p_rgh\n" << endl;
    volScalarField p_rgh
    (
        IOobject
        (
            "p_rgh",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

    Info<< "Reading field U\n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

    // ADDED
    Info<< "Reading field T\n" << endl;
    volScalarField T
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
    // end ADDED

    #include "createPhi.H"


    Info<< "Reading transportProperties\n" << endl;
    immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);
   
    volScalarField& alpha1(mixture.alpha1());
    volScalarField& alpha2(mixture.alpha2());

    const dimensionedScalar& rho1 = mixture.rho1();
    const dimensionedScalar& rho2 = mixture.rho2();
    
    // ADDED
    const dimensionedScalar& cp1 = mixture.cp1();
    const dimensionedScalar& cp2 = mixture.cp2();
    //const dimensionedScalar& Pr1 = mixture.Pr1();
    //const dimensionedScalar& Pr2 = mixture.Pr2();
    // end ADDED

    // Need to store rho for ddt(rho, U)
    volScalarField rho
    (
        IOobject
        (
            "rho",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT
        ),
        alpha1*rho1 + alpha2*rho2,
        alpha1.boundaryField().types()
    );
    rho.oldTime();

    // ADDED
    // Need to store rhoCp
    volScalarField rhoCp
    (
        IOobject
        (
            "rhoCp",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT
        ),
        alpha1*rho1*cp1 + alpha2*rho2*cp2,
        alpha1.boundaryField().types()
    );
    rhoCp.oldTime();
    // end ADDED

    // Mass flux
    surfaceScalarField rhoPhi
    (
        IOobject
        (
            "rhoPhi",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        fvc::interpolate(rho)*phi
    );

    // ADDED
    surfaceScalarField rhoCpPhi
    (
        IOobject
        (
            "rhoCpPhi",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        fvc::interpolate(rhoCp)*phi
    );
    // end ADDED

    // Construct incompressible turbulence model
    autoPtr<incompressible::turbulenceModel> turbulence
    (
        incompressible::turbulenceModel::New(U, phi, mixture)
    );

    #include "readGravitationalAcceleration.H"

    /*
    dimensionedVector g0(g);

    // Read the data file and initialise the interpolation table
    interpolationTable<vector> timeSeriesAcceleration
    (
        runTime.path()/runTime.caseConstant()/"acceleration.dat"
    );
    */

    Info<< "Calculating field g.h\n" << endl;
    volScalarField gh("gh", g & mesh.C());
    surfaceScalarField ghf("ghf", g & mesh.Cf());

    volScalarField p
    (
        IOobject
        (
            "p",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        p_rgh + rho*gh
    );

    label pRefCell = 0;
    scalar pRefValue = 0.0;
    setRefCell
    (
        p,
        p_rgh,
        mesh.solutionDict().subDict("PIMPLE"),
        pRefCell,
        pRefValue
    );

    if (p_rgh.needReference())
    {
        p += dimensionedScalar
        (
            "p",
            p.dimensions(),
            pRefValue - getRefCellValue(p, pRefCell)
        );
        p_rgh = p - rho*gh;
    }


    fv::IOoptionList fvOptions(mesh);

    // Creating field for thermophysical properties


    // MULES Correction
    tmp<surfaceScalarField> tphiAlphaCorr0;
As in Perry's steps and http://www.wolfdynamics.com/images/c...erTempFoam.pdf, I changed the names of the libraries, but not the names of the definitions within them. For instance, myIncompressibleTwoPhaseMixture.C begins like:

Code:
#include "myIncompressibleTwoPhaseMixture.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"
#include "fvc.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
    defineTypeNameAndDebug(incompressibleTwoPhaseMixture, 0);
}
Therefore, when I'm calling "immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);" that's been defined within the myImmiscibleIncompressibleTwoPhaseMixture library and so should reference the new versions. All the other libraries are left unchanged, so the turbulence model used is the old one stored in $FOAM_SRC. That said, is there a place in the Make/options modifications described in Perry's first post that would link both old and new libraries and create confusion? That could be a source of the problem...
hdietterich is offline   Reply With Quote

Old   November 18, 2015, 00:22
Default
  #12
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
Sorry for the confusion, I just realized I didn't read it properly and indeed you don't have the original immiscibleIncompressibleTwoPhaseMixture in Make/*.

Quote:
Originally Posted by Pay View Post
Hello Anton,

thanks for your feedback and the compliment.

I am guessing with "the old one [library]" you are referring to the directory "incompressible", the path of which is specified in:
Code:
EXE_INC = \
    -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(WM_PROJECT_USER_DIR)/src/transportModels/incompressible/lnInclude \
    - ...
If YES: "incompressible" is not the name of any library, but rather the folder in which the library "incompressibleTwoPhaseMixture" or in my case "myIncompressibleTwoPhaseMixture" is situated in.
If NO: What do you mean?



I think I just gave the answer to that question, too.
Or didn't I?

Greetings
Perry
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   November 18, 2015, 01:22
Default
  #13
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Quote:
Info<< "Reading transportProperties\n" << endl;
immiscibleIncompressibleTwoPhaseMixture mixture(U, phi)
As i expected, you left initialization for old data type of mixture.
So, you need to change immiscibleIncompressibleTwoPhaseMixture to myImmiscibleIncompressibleTwoPhaseMixture

But when you do that, i think, that solver will fail to compile, because turbulence model class depends on mixture class.

Later i can try to explain how to derive your own class from class immiscibleIncompressibleTwoPhaseMixture
mkraposhin is offline   Reply With Quote

Old   November 18, 2015, 01:44
Default
  #14
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
O.k., i'm sorry,

i didn't read untill the end of your post, but nevertheless, turbulence model needs original data type, but not modified, that's why it fails to run

and of course, you must avoid using same data type names for different classes
mkraposhin is offline   Reply With Quote

Old   November 18, 2015, 05:46
Default
  #15
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Hi, i spend ~ 20 minutes and made child class myImmiscibleIncompressibleTwoPhaseMixture, which can do all work without substituting user type instead of original OF

Step 1. Create your new class myImmiscibleIncompressibleTwoPhaseMixture as a sub class of immiscibleIncompressibleTwoPhaseMixture, see attachment files .H and .C.
Please note that for compatibility with OF you need to change all names, for example:
Code:
#ifndef myImmiscibleIncompressibleTwoPhaseMixture_H
#define myImmiscibleIncompressibleTwoPhaseMixture_H
Otherwise, you may get in conflict with OF

Step 2. Adjust files Make/files and Make/options to include all neccesary files from OF
Make/files
Code:
myImmiscibleIncompressibleTwoPhaseMixture.C
LIB = $(FOAM_USER_LIBBIN)/libmyImmiscibleIncompressibleTwoPhaseMixture
Make/options
Code:
EXE_INC = \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/OpenFOAM/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
    -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude

LIB_LIBS = \
    -ltwoPhaseMixture \
    -lincompressibleTransportModels \
    -linterfaceProperties \
    -ltwoPhaseProperties \
    -limmiscibleIncompressibleTwoPhaseMixture \
    -lfiniteVolume
Step 3. Compile with wmake libso

Step 4. Initialize new model in new solver:
- add -I../myImmiscibleIncompressibleTwoPhaseMixture \ line to Make/options EXE_INC section of your solver
- add consequent lines to -L section of Make/options file of your solver
- add #include "myImmiscibleIncompressibleTwoPhaseMixture.H" to solver instead of OF original solver
- add initialization of your myImmiscibleIncompressibleTwoPhaseMixture class instead of OF original class in createFields.H
- use method mixture.lambdaEff() to get mixture heat conduction coefficient
- solve equation for temperature, formulated in volumetric fluxes:
Code:
solve
(
    fvm::ddt(T)
    +
    fvm::div(phi,T)
    +
    fvm::SuSp(-fvc::div(phi),T)
    -
    fvm::laplacian(lambdam, T)
)

Last edited by mkraposhin; November 19, 2015 at 12:00.
mkraposhin is offline   Reply With Quote

Old   November 18, 2015, 12:07
Default
  #16
New Member
 
Hannah Dietterich
Join Date: Mar 2015
Posts: 8
Rep Power: 11
hdietterich is on a distinguished road
Thanks so much for your efforts. I'll go through and change all the internal names as well. Since all the new properties are defined in myIncompressibleTwoPhaseMixture (the immiscible one just calls them), that will need to be adjusted, too.

Edit: I see you've suggested moving all of the definitions into myImmiscibleIncompressibleTwoPhaseMixture. I'll incorporate that.

This doesn't help explain, though, why this isn't needed for Perry and everyone else using these (http://www.wolfdynamics.com/images/c...erTempFoam.pdf, http://www.cfd-online.com/Forums/ope...interfoam.html, etc) instructions.

Hannah
atulkjoy likes this.
hdietterich is offline   Reply With Quote

Old   November 18, 2015, 17:15
Default
  #17
New Member
 
Hannah Dietterich
Join Date: Mar 2015
Posts: 8
Rep Power: 11
hdietterich is on a distinguished road
Well those changes just produced a lot of compiling errors, but continuing to mess around with my original Make/options and #include's produced a version that compiled and ran a test case successfully. I'll look into making mkraposhin's suggested modifications to TEqn.

In the meantime, I'm attaching all of the files in case they might help someone else (using OF 2.3.1).

Hannah
Attached Files
File Type: zip transportModels.zip (73.3 KB, 124 views)
File Type: zip interThermalFoam.zip (11.2 KB, 145 views)
File Type: zip damBreakTemp.zip (120.9 KB, 113 views)
atulkjoy and tonnykz like this.
hdietterich is offline   Reply With Quote

Old   November 19, 2015, 04:27
Default
  #18
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
I will try to compile your code and report what is wrong later.
Regarding previous version of library and solver - i made it for OF 2.4.0, not for 2.3.1
mkraposhin is offline   Reply With Quote

Old   November 19, 2015, 05:28
Default
  #19
Pay
New Member
 
Perry Uhlig
Join Date: Oct 2015
Location: Germany
Posts: 13
Rep Power: 10
Pay is on a distinguished road
Hello Matvey,

first of all, thanks for taking part in the thread.

Quote:
So, you must rewrite equation for temperature for each phase, and then, by summing for all phases, you can get equation for temperature of mixture:
Does it make such a difference? Because the coefficients in my proposed TEqn are being calculated for the mixture beforehand:
in alphaEqn.H:
Code:
        // Calculate the end-of-time-step mass flux
        rhoPhi = phiAlpha*(rho1 - rho2) + phi*rho2;
    }

//-------------modified_start--------------// 
        // Calculate the end-of-time-step heat flux 
	rhoCpPhi = phiAlpha*(rho1*cp1 - rho2*cp2) + phi*rho2*cp2; 
//-------------modified_end--------------//
and in alphaEqnSubCycle.H:
Code:
rho == alpha1*rho1 + alpha2*rho2;
//-------------modified_start--------------//
rhoCp == alpha1*rho1*cp1 + alpha2*rho2*cp2;
//-------------modified_end--------------//
To your proposed TEqn:
I see that you divided the equation by (rho*cp)
viewing the terms separately:
Quote:
fvm::ddt(T)
That is straigt forward

Quote:
-
fvm::laplacian(alpha1*kappa1 / (rho1*Cp1), T)
-
fvm::laplacian((1 - alpha1)*kappa2 / (rho2*Cp2), T)
Here I can see, that you split the single laplacian term in two laplacian terms with each of them having the fitting alpha and parameters in it.

Quote:
fvm::div(phi,T)
+
fvm::SuSp(-fvc::div(phi),T)
Here I see the basic term for the convective temperature transport plus a new term.
What does this new term do? I do not know the operation in there (SuSp(-fvc ...).

Best Regards
Perry
Pay is offline   Reply With Quote

Old   November 19, 2015, 12:35
Default
  #20
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
@ Hannah:

Hi, i looked at your code and i understand that you mixed from all versions

So, i used my approach to create a new class for mixture and mass flux approach for energy equation. It works for OF 2.3.1. You can find source code in the attachment.

To make solver, go into folder interThermalFoam/myImmiscibleIncompressibleTwoPhaseMixture and run
wmake libso

then go one folder up and run
wmake
Attached Files
File Type: gz interThermalFoam.tar.gz (6.7 KB, 276 views)
mkraposhin is offline   Reply With Quote

Reply

Tags
2.4.0, compile problems, interfoam, teqn


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
Source Term due to evaporation in energy transport equation styleworker OpenFOAM Programming & Development 3 September 7, 2022 03:09
Adding Energy Equation for porousSimpleFoam yesaswi92 OpenFOAM Programming & Development 20 April 13, 2018 08:17
Definition of energy equation using UDF aestas Fluent UDF and Scheme Programming 15 April 28, 2015 03:33
help adding the energy equation to porousinterfoam using the enthalpy formulation nadine OpenFOAM Programming & Development 18 June 17, 2014 08:39
Why FVM for high-Re flows? Zhong Lei Main CFD Forum 23 May 14, 1999 13:22


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