|
[Sponsors] |
April 17, 2011, 11:55 |
Fixed Temperature Cell in Solution
|
#1 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
April 17, 2011, 12:38 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
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 |
|
April 23, 2011, 12:08 |
|
#3 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
April 23, 2011, 12:13 |
|
#4 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
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 |
|
April 23, 2011, 12:29 |
|
#5 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
April 23, 2011, 12:44 |
|
#6 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
Hi Jeff
The important part is Code:
epsEqn().setValues ( p.faceCells(), epsilon_.boundaryField()[patchi].patchInternalField() ); 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 |
|
April 23, 2011, 13:01 |
|
#7 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
April 23, 2011, 13:18 |
|
#8 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
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 |
|
April 26, 2011, 06:01 |
|
#9 | |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
hi,
A labelList is... a list of labels...labels are the "numbers" of the cells/faces/volumes. This is why you need to have to define a scalarField of the same size of the the labelList, where the values are the required temperatures (tVals). 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 |
||
April 26, 2011, 06:11 |
|
#10 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
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; int cellcenter=mesh.findNearestCell(Foam::point(P1,P2,P3)); to find the label next to your favored point. |
|
April 28, 2011, 16:46 |
|
#11 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) ); Code:
TEqn().setValues ( T.faceCells(), T_.boundaryField()[patchi].patchInternalField() ); Code:
TEqn.setValues(tCells, tVal); Thanks for sticking through with me though! Jeff |
|
April 28, 2011, 17:58 |
|
#12 |
Senior Member
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22 |
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; scalar TRefValue = 0.0; setRefCell(T, mesh.solutionDict().subDict("SIMPLE"), TRefCell, TRefValue); Hope this information is helpful Martin |
|
April 28, 2011, 17:59 |
|
#13 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
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 ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) ); Code:
solve ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) ); You wrote Code:
TEqn().setValues ( T.faceCells(), T_.boundaryField()[patchi].patchInternalField() ); 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 |
|
April 28, 2011, 18:02 |
|
#14 | |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
Quote:
How is this approach making it possible to set specific cell values? Did i miss smth.? |
||
April 28, 2011, 18:11 |
|
#15 |
Senior Member
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22 |
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 |
|
April 28, 2011, 18:21 |
|
#16 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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 |
|
April 28, 2011, 18:33 |
|
#17 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
I tried Martin's suggestion, it didn't work. Here was the final few lines of my createFields.H file
Code:
label pRefCell = 0; scalar pRefValue = 0.0; setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); label TRefCell = 0; scalar TRefValue = 0.0; setRefCell(T, mesh.solutionDict().subDict("PISO"), TRefCell, TRefValue); Code:
PISO { nCorrectors 2; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 0; TRefCell 0; TRefValue 1000; } Cheers Jeff |
|
April 28, 2011, 18:35 |
|
#18 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
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.
|
|
April 28, 2011, 19:55 |
|
#19 |
Senior Member
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 22 |
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:
/* solve ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) ); */ { fvScalarMatrix tEqn ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT,T) ); tEqn.setReference(TRefCell, TRefValue); tEqn.solve(); } Code:
TRefPoint (0 0 0); TRefValue 1000; In the thread above you can find hints how to set multiple cell values, too... post #25 ff... Martin |
|
April 30, 2011, 11:24 |
|
#20 |
Senior Member
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16 |
Hi Martin,
Okay, I think I've fudged a solution. I made my TEqn.H file like this: Code:
{ fvScalarMatrix TEqn ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT,T) ); TEqn.setReference(0, 1000); TEqn.solve(); } Code:
{ fvScalarMatrix TEqn ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT,T) ); TEqn.setReference(TRefCell, TRefValue); TEqn.solve(); } Code:
In file included from icoPeriodicScalarTransportFixedFoam.C:126: TEqn.H: In function ‘int main(int, char**)’: TEqn.H:16: error: ‘TRefCell’ was not declared in this scope TEqn.H:16: error: ‘TRefValue’ was not declared in this scope Thanks again Jeff |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cell Reynolds Number | laliong | Main CFD Forum | 12 | September 17, 2019 04:18 |
incorrect temperature in pressure based solution | Kian | FLUENT | 1 | July 6, 2009 06:59 |
Fixed temperature for domain | seojaho | CFX | 8 | June 4, 2009 14:21 |
Ultra high temperature? | bk | Siemens | 2 | July 19, 2005 01:01 |
Cell Temperature using udf | Karthick | FLUENT | 2 | April 19, 2004 07:29 |