Fixed Temperature Cell in Solution
Hey all,
I have a simple transient channel flow problem with heat transfer from the walls but what I want to do is set one cell in my solution domain to have a fixed temperature. This is just to test something out with a code, not for any real application. Is there any way that I can set one arbitrarily located cell in my solution domain to have a fixed temperature? Thanks Jeff |
Hi Jeff
You could e.g. consider the setValue functionality for fvMatrix<Type>. You can find an example here: ~/OpenFOAM/OpenFOAM-1.5-dev/src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H The function simply put a fixed value in the given cell label(s). I do not know whether (i) the equation is removed from the matrix system or (ii) the off-diagonals are set to 0, the diagonal to 1 and the right hand side to the provided value? I do, however, suspect that the latter is the case, as the other approach seems to produce a lot of extra work in terms of necessary changes in the data structure. Good luck Niels |
Hi Niels,
Thanks your reply, I'm still pretty confused about how I would go about this. I checked out the kOmegaSST.H file but it makes no mention of a setValue function. Do you have any other suggestions for how I can go about doing this? I'm still relatively new to OF so am unfamiliar with a fair amount of the source code. Thanks Jeff |
Hi Jeff
I can see that the structure has changed from version 1.5-dev, which I am currently using. Do Code:
find ./ | xargs grep setValues Best regards Niels |
Hi,
Okay, I found a mention of setValues in : ~/OpenFOAM/src/turbulenceModels//incompressible/RAS/lnInclude/wallDissipationI.H the entry is as follows: { const fvPatchList& patches = mesh_.boundary(); forAll(patches, patchi) { const fvPatch& p = patches[patchi]; if (isA<wallFvPatch>(p)) { epsEqn().setValues ( p.faceCells(), epsilon_.boundaryField()[patchi].patchInternalField() ); } } } This is all there is. I am still extremely lost, what would I need to do to be able to fix a value at a cell in my domain? Thanks again, Jeff |
Hi Jeff
The important part is Code:
epsEqn().setValues Recapitulating in your case: (i) Give a labelList with the labels of the cells (tCells), where you would like to predefine the temperature. (ii) Define a scalarField of the same size of the the labelList, where the values are the required temperatures (tVals). (iii) Having a fvScalarMatrix probably called TEqn, then do Code:
TEqn.setValues(tCells, tVal); Code:
TEqn.solve(); Good luck Niels |
Hi Neils,
You're going to have to be really patient with me here, I am really new with OF and have never done anything outside of changing case files around. i) What is a labelList and how do I create one? ii) How do I define a scalarField? iii) What is a fvScalarMatrix and how do I create it? If you have any examples of where this is done that would be awesome. Am I going to be changing around the source code or is this done in the case directory? Thanks a lot for your help and I apologize for not really understanding what's going on haha. Jeff |
Hi Jeff
I can unfortunately not help any further, as I am very shortly turning in my PhD-thesis, so I would not be able to focus on helping you out. I hope other people read this thread, and otherwise search the forum and use the "find" and "grep" in combination. The latter can get you far. Good luck Niels |
hi,
Quote:
You can create it from the patch where you want to have the temperatur fixed. Code:
ii) How do I define a scalarField? Code:
iii) What is a fvScalarMatrix and how do I create it? With the .setValues you change the entries in this matrix.... that is why you need to tell the memberfunction what you want to change (entries in Teqn) and where (p.faceCells) to what (in your case a fixed integer e.g. 293 K). Quote:
And YES.... you will have to mess around with the source code... so get yourself a local copy, change the resulting executable to Code:
EXE = $(FOAM_USER_APPBIN)/WhateverFoam neewbie |
ah... read the first post again... since you want to force one entire cell to have a fix temperature try
Code:
double P1, P2, P3; to find the label next to your favored point. |
Thanks neewbie, I'm beginning to understand some things. Of course I'm still having some difficulties so if you could help me a little bit more that'd be fantastic. I really appreciate it, I've had no training with OF and am just trying to keep up really.
My concern now is that I can't seem to find any mention of Code:
TEqn.solve Code:
solve Code:
TEqn().setValues Code:
TEqn.setValues(tCells, tVal); Thanks for sticking through with me though! Jeff |
Hi Jeff,
without knowing your solver (it's not attached so far, is it?), here is my proposal: In "createFields.H" there should be the creation of T. A value for DT is read from transportProperties there, too. Your scalar field T must be defined in your 0 time folder, i.e. 0/T must exist. You can define boundary conditions in that file, for example zeroGradient to all walls. Now with these lines similar to simpleFoam's createFields.H you can set your reference temperature: Code:
label TRefCell = 0; Hope this information is helpful Martin |
hi,
nop. You cannot find it since it is implemented a little bit different. TEqn.solve is simply using the solve function on a fvScalarMAtrix object,namely Teqn. Code:
fvScalarMatrix TEqn Code:
solve You wrote Code:
TEqn().setValues Code:
TEqn.setValues(tCells, tVal); So that´s a matter of taste. Read post from .ngj April 23, 2011 15:44 again. But i suppose you don´t want to use the internal field (which makes sence for the turbulent dissipation epsilon); instead you want to give a fixed number like 293K e.g. if i got you right so far. neewbie |
Quote:
How is this approach making it possible to set specific cell values? Did i miss smth.? |
Hi Matthias,
since this is a way to set a fixed value for the pressure to a specific cell, I would give it a try to use it for a temperature, too. It will not work, if there are more cells to be specified, but with a single cell, it should work... May be Jeff could post his solver and a test case completely? Martin |
Oops, my bad. Sorry guys. The file was too large for this forum so I've uploaded it here:
http://www.2shared.com/file/i2tqQurk...sportFoam.html I'll check out what you just wrote and let you know anything else I find out. Thanks again, you guys rock for all the help! Jeff |
I tried Martin's suggestion, it didn't work. Here was the final few lines of my createFields.H file
Code:
label pRefCell = 0; Code:
PISO Cheers Jeff |
1 Attachment(s)
Also, attached is a test case that I'm using. This isn't what I'm actually working on but it's what I'm playing around with right now. Simple channel flow with heat transfer case.
|
Hi Jeff,
I found something useful in this thread: http://www.cfd-online.com/Forums/ope...ne-cell-2.html Change your TEqn.H like this: Code:
/* Code:
TRefPoint (0 0 0); In the thread above you can find hints how to set multiple cell values, too... post #25 ff... Martin |
Hi Martin,
Okay, I think I've fudged a solution. I made my TEqn.H file like this: Code:
{ Code:
{ Code:
In file included from icoPeriodicScalarTransportFixedFoam.C:126: Thanks again Jeff |
Hi Jeff,
add this snippet to an appropriate place in your code, for example in createFields.H: Code:
label TRefCell = 0; Code:
PISO |
Update to this old thread:
Upon playing with this it didn't do it quite as i wanted. I'm not sure what it was doing but it wasn't keeping my temperature at 1 value, it was changing in time. So what I did is made my TEqn.H file read as follows: Code:
/************************** Jeff |
Hi there,
I am writing since I am facing the problem you had and discussed about in this thread. I am running a simulation and - in a certain area of my domain - I want to impose a fixed temperature. Let's say that I want to impose a boundary condition in a volume and not on a surface. The solver I am using is buoyantSimpleFoam and I do not know which is the file that I need to edit. Thanks a lot, Samuele |
All times are GMT -4. The time now is 10:33. |