CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Fixed Temperature Cell in Solution

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 17, 2011, 10:55
Default Fixed Temperature Cell in Solution
  #1
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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
ozzythewise is offline   Reply With Quote

Old   April 17, 2011, 11:38
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
ngj is offline   Reply With Quote

Old   April 23, 2011, 11:08
Default
  #3
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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
ozzythewise is offline   Reply With Quote

Old   April 23, 2011, 11:13
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
in ~/OpenFOAM/OpenFOAM-<VERSION>/src/turbulenceModels and you will find some files, which uses setValues.

Best regards

Niels
ngj is offline   Reply With Quote

Old   April 23, 2011, 11:29
Default
  #5
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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
ozzythewise is offline   Reply With Quote

Old   April 23, 2011, 11:44
Default
  #6
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Jeff

The important part is

Code:
epsEqn().setValues
            (
                p.faceCells(),
                epsilon_.boundaryField()[patchi].patchInternalField()
            );
This part states that a fv<Type>Matrix with the name epsEqn has predefined values in the cells defined in the labelList p.faceCells(), and the corresponding values are given in the Field<Type> 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);
before

Code:
TEqn.solve();
If this is insufficient to solve the problem, I would recommend that you search the forum or look into the Doxygen documentation, which you find via www.opencfd.co.uk.

Good luck

Niels
ngj is offline   Reply With Quote

Old   April 23, 2011, 12:01
Default
  #7
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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
ozzythewise is offline   Reply With Quote

Old   April 23, 2011, 12:18
Default
  #8
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
ngj is offline   Reply With Quote

Old   April 26, 2011, 05:01
Default
  #9
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
hi,
Quote:
Originally Posted by ozzythewise View Post

i) What is a labelList and how do I create one?
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?
Just like any other field. Check out the createFields.H files from any solver.


Code:
iii) What is a fvScalarMatrix and how do I create it?
Just like above... the fvScalarMatrix for the Temperature will probably been named Teqn and is part of the solver.
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:
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?
There is a wise saying: "The documentation is the source code." which in case of OF is absolutely true. So read the source code of the solver you are working with and spot the fields you want to change (Teqn ??)
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
and compile it once before changing anything for testing.

neewbie
mvoss is offline   Reply With Quote

Old   April 26, 2011, 05:11
Default
  #10
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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));
with p1-p3 beeing coordinates in your mesh-coord.system.
to find the label next to your favored point.
mm.abdollahzadeh likes this.
mvoss is offline   Reply With Quote

Old   April 28, 2011, 15:46
Default
  #11
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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
anywhere in the solver. I've attached the solver if anyone wants to take a look and provide some hints. I did not create this solver, it was made by the person whose work I'm building upon. The TEqn file reads
Code:
solve
(
	fvm::ddt(T)
      + fvm::div(phi, T)
      - fvm::laplacian(DT, T)
);
What I'm guessing is I'm suppose to put
Code:
TEqn().setValues
            (
                T.faceCells(),
                T_.boundaryField()[patchi].patchInternalField()
            );
somewhere before TEqn is solved. And I would also need
Code:
TEqn.setValues(tCells, tVal);
somewhere, no idea where though. Haha, I guess I'm still more confused than I thought.

Thanks for sticking through with me though!
Jeff
mm.abdollahzadeh likes this.
ozzythewise is offline   Reply With Quote

Old   April 28, 2011, 16:58
Default
  #12
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 21
MartinB will become famous soon enough
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);
Add these lines to your createFields.H. This approach assumes that in the SIMPLE dictionary in system/fvSolution appropriate values are defined for TRefCell and TRefValue.

Hope this information is helpful

Martin
mm.abdollahzadeh likes this.
MartinB is offline   Reply With Quote

Old   April 28, 2011, 16:59
Default
  #13
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
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)
        );
is the same as
Code:
solve
(
    fvm::ddt(T)
      + fvm::div(phi, T)
      - fvm::laplacian(DT, T)
);
But the latter is doing it in one "step". Because you want to do a setValues, you need to create the fvScalarMatrix object and then apply the setValues with the correct attributes (the place/cells and the value).
You wrote
Code:
TEqn().setValues
            (
                T.faceCells(),
                T_.boundaryField()[patchi].patchInternalField()
            );
and
Code:
TEqn.setValues(tCells, tVal);
That´s basically the same but in the latter case, you storred the T.faceCells in a variable called tCells; same for tVal and patchInternalField.
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
mvoss is offline   Reply With Quote

Old   April 28, 2011, 17:02
Default
  #14
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
Quote:
Originally Posted by MartinB View Post
...

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);
Add these lines to your createFields.H. This approach assumes that in the SIMPLE dictionary in system/fvSolution appropriate values are defined for TRefCell and TRefValue.
...
hi,
How is this approach making it possible to set specific cell values? Did i miss smth.?
mvoss is offline   Reply With Quote

Old   April 28, 2011, 17:11
Default
  #15
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 21
MartinB will become famous soon enough
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
MartinB is offline   Reply With Quote

Old   April 28, 2011, 17:21
Default
  #16
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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
ozzythewise is offline   Reply With Quote

Old   April 28, 2011, 17:33
Default
  #17
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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);
and my fvSolution read
Code:
PISO
{
    nCorrectors     2;
    nNonOrthogonalCorrectors 0;
    pRefCell        0;
    pRefValue       0;
    TRefCell	    0;
    TRefValue      1000;
}
Nothing in the solution changed. I'll take a look at what Matthias said and get back to you.

Cheers
Jeff
ozzythewise is offline   Reply With Quote

Old   April 28, 2011, 17:35
Default
  #18
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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.
Attached Files
File Type: gz fixedPointFlow.tar.gz (22.9 KB, 23 views)
ozzythewise is offline   Reply With Quote

Old   April 28, 2011, 18:55
Default
  #19
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 21
MartinB will become famous soon enough
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();
}
And as a reference point:
Code:
        TRefPoint       (0 0 0);
    TRefValue      1000;
This should do the trick...

In the thread above you can find hints how to set multiple cell values, too... post #25 ff...

Martin
MartinB is offline   Reply With Quote

Old   April 30, 2011, 10:24
Default
  #20
Senior Member
 
jeff osborne
Join Date: Mar 2010
Posts: 108
Rep Power: 16
ozzythewise is on a distinguished road
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();

}
And it definitely changed the solution. But as you can see I'm just sort of telling it for all cases that cell 0 is 1000K, whereas it would be nice if in fvSolution I could say the point that I want the value to be at whatever Temperature I want. If I make the TEqn.H file like this:
Code:
{
    fvScalarMatrix TEqn
    (
            fvm::ddt(T)
            + fvm::div(phi, T)
            - fvm::laplacian(DT,T)
    );
    TEqn.setReference(TRefCell, TRefValue);
    TEqn.solve();

}
I get an error that reads:
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
How do I get around this?

Thanks again
Jeff
ozzythewise is offline   Reply With Quote

Reply


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
Cell Reynolds Number laliong Main CFD Forum 12 September 17, 2019 03:18
incorrect temperature in pressure based solution Kian FLUENT 1 July 6, 2009 05:59
Fixed temperature for domain seojaho CFX 8 June 4, 2009 13:21
Ultra high temperature? bk Siemens 2 July 19, 2005 00:01
Cell Temperature using udf Karthick FLUENT 2 April 19, 2004 06:29


All times are GMT -4. The time now is 06:56.