|
[Sponsors] |
Change Temperature boundary by a solver (rhoPimpleFoam) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 10, 2013, 12:47 |
Change Temperature boundary by a solver (rhoPimpleFoam)
|
#1 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
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() Code:
const volScalarField& T = db().lookupObject<volScalarField>("T"); 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] = .......... ; }; |
|
May 11, 2013, 11:57 |
|
#2 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
I've just found another topic talking about my problem: http://www.cfd-online.com/Forums/ope...-openfoam.html
But if anybody has a solution, I'm still open. |
|
May 13, 2013, 04:51 |
|
#3 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
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_; } 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(); 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. |
|
May 13, 2013, 08:09 |
|
#4 |
Senior Member
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 202
Rep Power: 18 |
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 |
|
May 13, 2013, 11:43 |
|
#5 | |
Senior Member
Join Date: Nov 2012
Posts: 171
Rep Power: 14 |
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:
|
||
May 13, 2013, 12:33 |
|
#6 | |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
Quote:
Thx |
||
May 14, 2013, 04:33 |
|
#7 |
Senior Member
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 202
Rep Power: 18 |
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 |
|
May 15, 2013, 12:11 |
|
#8 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
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_; } 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(); 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). |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Domain Imbalance | HMR | CFX | 5 | October 10, 2016 06:57 |
domain imbalance for enrgy equation | happy | CFX | 14 | September 6, 2012 02:54 |
Solver not "seeing" temperature change. | Canesin | OpenFOAM | 0 | October 20, 2011 18:06 |
increasing mesh quality is leading to poor convergence | tippo | CFX | 2 | May 5, 2009 11:55 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |