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

Heat source in a particular region inside the fluid domain

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 2, 2010, 02:31
Default Heat source in a particular region inside the fluid domain
  #1
Member
 
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 7
robingilbert is on a distinguished road
Hi i want to add a heat source inside a small region in a fluid domain. i added a heat source term in TEqn.H and it works fine for the whole region. But i want to impose a condition that the heat source gets activated inside a small control volume. i have been reading up a lot but cant figure out how to go about doing it. if atleast someone can tell me where to start, I will figure it out. how do i give an if-else condition to check if it is solving the domain i need to add the source term.

i tried the following in the createFields.H

Code:
volScalarField x = mesh.C().component(vector::X);
volScalarField y = mesh.C().component(vector::Y);
volScalarField z = mesh.C().component(vector::Z);

forAll(x,celli)
{
    if(x[celli] >= 1 && y[celli] >= 1 && z[celli] >= 2.2 && x[celli] <= 1.5 && y[celli] <= 1.5 && z[celli] <= 2.5)
    {
       dimensionedScalar Q
    (
    "Q",
    dimensionSet(1,-1,-3,0,0,0,0),
    scalar(5000)
    );
    }else
    {
       dimensionedScalar Q
    (
    "Q",
    dimensionSet(1,-1,-3,0,0,0,0),
    scalar(1000)
    );
    }
}
unfortunately the Q value is not set by this method.

Thanks.
robingilbert is offline   Reply With Quote

Old   September 2, 2010, 03:32
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
You are just storing a single value for Q, so it will be either 1000 or 5000 depending if your conditions in the last cell are met or not. Additionally, you are declaring Q right within the curly brackets, so it will not be valid outside of the forAll loop.

What I think you want is to have a volScalarField Q, and then assign values to Q[celli].
akidess is offline   Reply With Quote

Old   September 2, 2010, 03:36
Default
  #3
Member
 
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 7
robingilbert is on a distinguished road
Thank you so much for your reply.

I will try it and let you know what happens.
Thanks once again.
robingilbert is offline   Reply With Quote

Old   September 2, 2010, 04:16
Default
  #4
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 10
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
It seems you didn't set Q value, just declare a local Q. You can achieve it in a more compact form like the following code

point mint(1.0,1.0,2.2);
point max(1.5, 1.5, 2.5);
boundBox box(min, max);

forAll(Q, cellI)
{
if(box.contains(mesh.C()[cellI]))
Q[cellI]=5000;
else
Q[cellI]=1000;
}
su_junwei is offline   Reply With Quote

Old   September 2, 2010, 04:53
Default
  #5
Member
 
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 7
robingilbert is on a distinguished road
Hi junwei,

i tried your suggestion but i am getting the following error:

Code:
In file included from simpleFoam.C:44:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:117: error: ‘Q’ was not declared in this scope
In file included from simpleFoam.C:62:
UEqn.H:16: error: no match for call to ‘(Foam::point) (Foam::scalar&, Foam::scalar&)’
In file included from simpleFoam.C:63:
pEqn.H:22: error: no match for call to ‘(Foam::point) (Foam::scalar&, Foam::scalar&)’
In file included from simpleFoam.C:64:
TEqn.H:14: error: ‘Q’ was not declared in this scope
TEqn.H:21: error: no match for call to ‘(Foam::point) (Foam::scalar&, Foam::scalar&)’
when compiling. do you know why that happens?
robingilbert is offline   Reply With Quote

Old   September 2, 2010, 05:02
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Robin, in junwei's code Q is not created, you'll have add that before calling the code. See other forum threads or the wiki how to make a new volScalarField with a certain size.

Also, if Q doesn't change over time and is just determined by the spatial coordinates, you could use setFields (this is used eg. in interFoam / damBreak to preset a volScalarField gamma) instead of including the setup in your solver code.
akidess is offline   Reply With Quote

Old   September 2, 2010, 12:15
Default
  #7
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 10
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Yes, You have to declare a volScalarField for store source term for your temperature equation in your solver
su_junwei is offline   Reply With Quote

Old   September 2, 2010, 14:39
Default
  #8
Member
 
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 7
robingilbert is on a distinguished road
akidess and junwei,

thank you so much guys, for the suggestions. i defined Q as volScalarField and ran a test case with setFieldsDict and looks like its working the way i wanted. I will try it on the real case and see if it works.

thank you once again.
robingilbert is offline   Reply With Quote

Reply

Tags
heat source, if-else

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
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
Simulation of a single bubble with a VOF-method Suzzn CFX 18 October 2, 2009 04:18
How can I increase Heat Transfer at Domain Interf? B.Simon CFX 3 October 28, 2008 19:53
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 16:55


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