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

Change Temperature boundary by a solver (rhoPimpleFoam)

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes
  • 1 Post By fredo490
  • 2 Post By Chris Lucas
  • 1 Post By fredo490

Reply
 
LinkBack Thread Tools Display Modes
Old   May 10, 2013, 11:47
Default Change Temperature boundary by a solver (rhoPimpleFoam)
  #1
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
fredo490 is on a distinguished road
Hello everybody,
I would like to link the temperature of a boundary (a wall patch) with the solver solution. In other word, the solver has be able to change the value of the patch temperature.

In rhoPimpleFoam, the temperature field is created by a sub function and not by the createfield.h. Therefor, I cannot access/change directly the temperature field in the solver.

I can read the temperature field by using:
Code:
thermo.T()
Or by using a lookupObject:
Code:
const volScalarField& T = db().lookupObject<volScalarField>("T");
However, with those two methods, I cannot change the value of the temperature.

My dream is to get something like:
Code:
label patchWall = mesh.boundaryMesh().findPatchID("wall"); //patchID = id of the patch wall
const fvPatch& cPatch = mesh.boundary()[patchWall];

    forAll(cPatch, facei) //facei = id of the face
    {
    T.boundaryField()[patchWall][facei] = .......... ;
    };
Does anybody know a smart way to solve this problem ?
fredo490 is offline   Reply With Quote

Old   May 11, 2013, 10:57
Default
  #2
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
fredo490 is on a distinguished road
I've just found another topic talking about my problem: Get access to temperature in Openfoam

But if anybody has a solution, I'm still open.
fredo490 is offline   Reply With Quote

Old   May 13, 2013, 03:51
Default
  #3
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
fredo490 is on a distinguished road
As told in the other topic, I'm getting close to the solution BUT I HAVE A BUG WITH THE THERMO MODEL.

Here is the procedure I used:
1) open a text editor in admin by writing in the terminal: "sudo gedit"
2) with this text editor, open: "basicThermo.C" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
3) Add the following line in the Member Functions (I put it at line 396 after the "basicThermo::T()" ):
Code:
// Add this
           //- Temperature [K]
            //  Non-const access allowed
            Foam::volScalarField& Foam::basicThermo::T()
            {
                return T_;
            }
4) with this text editor (still admin), open: "basicThermo.H" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
5) Add the following line after the comment "Fields derived from thermodynamic state variables" (I put it at line 316 after the other Temperature member ):
Code:
// Add this
            //- Temperature [K]
            //  Non-const access allowed for transport equations
            virtual volScalarField& T();
6) Save the two files (To check if it was saved: look at the top of the editor, if the star remains it means that you didn't have the admin / root access).
7) Go to /opt/openfoam220/src/thermophysicalModels and open a terminal
8) With the terminal located in this folder, we now want to get the full root access. To do so, write: "sudo -s". After typing your password, you will see that the command line will start with "root".
9) We need to recompile the thermo model of openfoam. To do so, simply write "./Allwmake". This step might take few minutes depending of your system (for me with virtualization, it took about 1 or 2 minutes).

But I think there is a problem with the new compilation because even a simple rhoSimplecFoam doesn't work anymore.
mm.abdollahzadeh likes this.
fredo490 is offline   Reply With Quote

Old   May 13, 2013, 07:09
Default
  #4
Senior Member
 
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 198
Rep Power: 8
Chris Lucas is on a distinguished road
Hi,

an easy solution might be.

Define the temperature field in basicThermo as mutable (so that can change the field in a constant function)

Add a function that changes the values in the temperature field in the file called by the solver when the thermo class is constructed (basicPsiThermo in OF 2.1)

Regards,
Christian
fredo490 and mm.abdollahzadeh like this.
Chris Lucas is offline   Reply With Quote

Old   May 13, 2013, 10:43
Question
  #5
Senior Member
 
Join Date: Nov 2012
Posts: 168
Rep Power: 4
hz283 is on a distinguished road
I also used that method, but I had the similar problem:

#0 Foam::error:rintStack(Foam::Ostream&) in "/home/hz283/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/home/hz283/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 in "/lib64/libc.so.6"
#3 Foam::hPsiThermo<Foam:ureMixture<Foam::sutherlan dTransport<Foam::specieThermo<Foam::hConstThermo<F oam:erfectGas> > > > >::Cv() const in "/home/hz283/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libbasicThermophysicalModels.so"
#4 Foam::compressible::LESModel::muEff() const in "/home/hz283/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libcompressibleLESModels.so"
#5 Foam::compressible::LESModels::GenEddyVisc::divDev RhoBeff(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&) const in "/home/hz283/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libcompressibleLESModels.so"
#6 Foam::compressible::LESModel::divDevRhoReff(Foam:: GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&) const in "/home/hz283/OpenFOAM/OpenFOAM-2.1.1/platforms/linux64GccDPOpt/lib/libcompressibleLESModels.so"
#7
in "/home/hz283/OpenFOAM/hz283-2.1.1/platforms/linux64GccDPOpt/bin/cmcSgasFoam-0DCMC"
#8 __libc_start_main in "/lib64/libc.so.6"
#9
at /usr/src/packages/BUILD/glibc-2.11.3/csu/../sysdeps/x86_64/elf/start.S:116
Segmentation fault

In my stuff, I calculate the density and temperature from my own model. That means I did not use rho=P_*psi() to update the density in Openfoam. Besides, I use the following thermoynamic models:

thermoType hPsiThermo<pureMixture<sutherlandTransport<specieT hermo<hConstThermo<perfectGas>>>>>;

In hPsiThermo.C, I comment the line 48:

TCells[celli] = mixture_.TH(hCells[celli], TCells[celli]);

but I have the same problem as I mentioned in the beginning. I am working on it and keep you posted. Thanks.

Quote:
Originally Posted by fredo490 View Post
As told in the other topic, I'm getting close to the solution BUT I HAVE A BUG WITH THE THERMO MODEL.

Here is the procedure I used:
1) open a text editor in admin by writing in the terminal: "sudo gedit"
2) with this text editor, open: "basicThermo.C" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
3) Add the following line in the Member Functions (I put it at line 396 after the "basicThermo::T()" ):
Code:
// Add this
           //- Temperature [K]
            //  Non-const access allowed
            Foam::volScalarField& Foam::basicThermo::T()
            {
                return T_;
            }
4) with this text editor (still admin), open: "basicThermo.H" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
5) Add the following line after the comment "Fields derived from thermodynamic state variables" (I put it at line 316 after the other Temperature member ):
Code:
// Add this
            //- Temperature [K]
            //  Non-const access allowed for transport equations
            virtual volScalarField& T();
6) Save the two files (To check if it was saved: look at the top of the editor, if the star remains it means that you didn't have the admin / root access).
7) Go to /opt/openfoam220/src/thermophysicalModels and open a terminal
8) With the terminal located in this folder, we now want to get the full root access. To do so, write: "sudo -s". After typing your password, you will see that the command line will start with "root".
9) We need to recompile the thermo model of openfoam. To do so, simply write "./Allwmake". This step might take few minutes depending of your system (for me with virtualization, it took about 1 or 2 minutes).

But I think there is a problem with the new compilation because even a simple rhoSimplecFoam doesn't work anymore.
hz283 is offline   Reply With Quote

Old   May 13, 2013, 11:33
Default
  #6
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
fredo490 is on a distinguished road
Quote:
Originally Posted by Chris Lucas View Post
Hi,

an easy solution might be.

Define the temperature field in basicThermo as mutable (so that can change the field in a constant function)

Add a function that changes the values in the temperature field in the file called by the solver when the thermo class is constructed (basicPsiThermo in OF 2.1)

Regards,
Christian
I didn't know this C++ function ! It looks really nice. I will try it tomorrow.
Thx
fredo490 is offline   Reply With Quote

Old   May 14, 2013, 03:33
Default
  #7
Senior Member
 
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 198
Rep Power: 8
Chris Lucas is on a distinguished road
Hi,

another possibility is to use a second temperature field (let’s say “realTemperature”). This field is defined in hPsiThermo similar to the enthalpy (sorry, I'm still using an older OF Version). However, the new field must read the file (boundary's) from the 0 folder of the case (unlike the enthalpy field). Then you need to change the calculate function in hPsiThermo . Additionally, a dummy function that later returns the “realTemperature” must be defined in basicPsiThermo (so that the solver can access the new temperature field). The function must be redefined (now correctly) in hPsiThermo so that it really returns “realTemperature”.

Then you must define a non-constant pointer “realTemperature” to in the solver (like the pointer for enthalpy). You can change the temperature field using this pointer (as done with enthalpy field).

The problem (or unpleasant side effect) is that you need to include a dummy temperature file "T" in your case folder

Regards,
Christian
Chris Lucas is offline   Reply With Quote

Old   May 15, 2013, 11:11
Default
  #8
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
fredo490 is on a distinguished road
Thx Chris for your advices ! But the solution was much simplier than a complicated C++ function. The problem was simply that we had to recompile all OpenFoam and not only the thermo model.

So after all this, here is the final procedure (tested and approved !):
1) open a text editor in admin by writing in the terminal: "sudo gedit"
2) with this text editor, open: "basicThermo.C" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
3) Add the following line in the Member Functions (I put it at line 396 after the "basicThermo::T()" ):
Code:
// Add this
           //- Temperature [K]
            //  Non-const access allowed
            Foam::volScalarField& Foam::basicThermo::T()
            {
                return T_;
            }
4) with this text editor (still admin), open: "basicThermo.H" located in /opt/openfoam220/src/thermophysicalModels/basic/basicThermo
5) Add the following line after the comment "Fields derived from thermodynamic state variables" (I put it at line 316 after the other Temperature member ):
Code:
// Add this
            //- Temperature [K]
            //  Non-const access allowed for transport equations
            virtual volScalarField& T();
6) Save the two files (To check if it was saved: look at the top of the editor, if the star remains it means that you didn't have the admin / root access).
7) Go to /opt/openfoam220/ and open a terminal
8) With the terminal located in this folder, we now want to get the full root access. To do so, write: "sudo -s". After typing your password, you will see that the command line will start with "root".
9) We need to recompile all OpenFoam. To do so, simply write "./Allwmake". This step might take few minutes depending of your system (for me it took about 45 minutes).
mm.abdollahzadeh likes this.
fredo490 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
domain imbalance for enrgy equation happy CFX 14 September 6, 2012 01:54
Solver not "seeing" temperature change. Canesin OpenFOAM 0 October 20, 2011 17:06
Domain Imbalance HMR CFX 3 March 6, 2011 21:10
increasing mesh quality is leading to poor convergence tippo CFX 2 May 5, 2009 10:55
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 15:37.