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

limit variable

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 16, 2010, 08:15
Default limit variable
  #1
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
Hi all,

I want to limit the temperature. That mean that every value where T is smaller than 300K, should be set to 300K after every iteration.

I thought something like this:

Quote:
forAll(fluidRegions[i].cellZones(), zoneI)
{
const cellZone& cz = fluidRegions[i].cellZones()[zoneI];
const labelList& cells = cz;



if (T < 300)
{
forAll(cells, iCells)
{
const label cellId = cells[iCells];
T[cellId]=300;

}
}
}
But this results in errors during compiling.

Can anyone help me?

Best regards Chrisi
Chrisi1984 is offline   Reply With Quote

Old   August 16, 2010, 08:45
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
Without mentioning your error, you are looking for someone with psychic powers to help you... Anyways, I think the following code fragment would make more sense:
Code:
forAll(cells, iCells)
{
    const label cellId = cells[iCells];
    if (T[cellId] < 300) T[cellId]=300;
}
akidess is offline   Reply With Quote

Old   August 16, 2010, 09:02
Default
  #3
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
Hi,

sorry I forgot the error message!

Here it is:

Quote:
invalid types error: '<unresolved overloaded function type>[const Foam::label]' for array subscript
Regards Chrisi
Chrisi1984 is offline   Reply With Quote

Old   September 1, 2010, 03:08
Default problem is solved
  #4
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
My problem is still existing. Any ideas?

Last edited by Chrisi1984; September 1, 2010 at 06:46.
Chrisi1984 is offline   Reply With Quote

Old   September 1, 2010, 04:04
Default
  #5
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
Would you share it so that people can learn from this thread?
akidess is offline   Reply With Quote

Old   September 1, 2010, 06:47
Default
  #6
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
Sorry!

I am wrong. I did not solve the problem.


I wanted to write this below an other thread!!

Regards Chrisi
Chrisi1984 is offline   Reply With Quote

Old   September 6, 2010, 05:04
Default
  #7
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
Hi,

Now I really found a possibility to limit the temperature.

Quote:
forAll(mesh.cellZones(), zoneI)
{

const cellZone& cz = mesh.cellZones()[zoneI];
const labelList& cells = cz;


forAll(mesh.cellZones(), zoneI)
{

const cellZone& cz = mesh.cellZones()[zoneI];
const labelList& cells = cz;


forAll(cells, iCells)
{
const label cellId = cells[iCells];

if (thermo.T()[cellId] > 1400.0)
{
h[cellId] = 1006*1400;
}

if (thermo.T()[cellId] < 400.0)
{
h[cellId] = 1006*400;
}
}


}


}
Where in 1006 is the value for cp.

I did this because h is approximately cp*T.

Perhabs it helps somebody.

Regardy Chrisi
Chrisi1984 is offline   Reply With Quote

Old   September 6, 2010, 08:34
Default
  #8
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
Why loop through the cellZones within the cellZone loop?
akidess is offline   Reply With Quote

Old   September 7, 2010, 08:33
Default
  #9
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
You are right off course the loop over the cell zones is unnecessary!

Regards Chrisi
Chrisi1984 is offline   Reply With Quote

Old   September 17, 2010, 00:53
Default
  #10
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
Hmm, why not a simple

T.max(300);

P.S. Yes, max, it is not a typo. The max method is equivalent to max(T,300) looped over all cells.

P.P.S. I have no idea why you are doing this, but it might make your energy equation unhappy :-)
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Old   September 17, 2010, 03:44
Default
  #11
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
Thank you for your suggestion.

But with T.max(300);

I get this error:

Quote:
hEqn.H:39: error: ‘Foam::T’ does not have class type
Regards Chrisi
Chrisi1984 is offline   Reply With Quote

Old   September 17, 2010, 04:02
Default
  #12
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
From your previous post I'm guessing you don't have an object T, since you used thermo.T. So you could try using thermo.T.max(300).
akidess is offline   Reply With Quote

Old   September 17, 2010, 04:39
Default
  #13
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 130
Rep Power: 7
Chrisi1984 is on a distinguished road
Hi

I tried this too,

but this also results in errors during compiling.

Quote:
error: ‘thermo->Foam::basicThermo::T’ does not have class type
Regards Chrsi
Chrisi1984 is offline   Reply With Quote

Old   September 17, 2010, 10:29
Default
  #14
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,894
Rep Power: 26
alberto will become famous soon enoughalberto will become famous soon enough
The correct syntax would be

thermo().T().max(300)

but T is returned only as const, so it cannot be modified at this stage.

You can either define a second method to return T without the const qualifier, or edit the thermo code and introduce the limitation there. Both solutions see quite messy
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as live DVD/USB, hard drive image and virtual image.
OpenQBMM - An open-source implementation of quadrature-based moment methods
alberto is offline   Reply With Quote

Reply

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
How to limit a variable ash OpenFOAM Running, Solving & CFD 1 June 26, 2008 20:32
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas Main CFD Forum 1 May 30, 2008 04:35
limit for a variable Luis CFX 5 February 12, 2008 06:55
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 05:27
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


All times are GMT -4. The time now is 05:23.