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

limit variable

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

Like Tree1Likes
  • 1 Post By alberto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 16, 2010, 08:15
Default limit variable
  #1
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 150
Rep Power: 16
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: Germany
Posts: 1,377
Rep Power: 29
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: 150
Rep Power: 16
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: 150
Rep Power: 16
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: Germany
Posts: 1,377
Rep Power: 29
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: 150
Rep Power: 16
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: 150
Rep Power: 16
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: Germany
Posts: 1,377
Rep Power: 29
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: 150
Rep Power: 16
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,912
Rep Power: 36
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 in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541)
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.
alberto is offline   Reply With Quote

Old   September 17, 2010, 03:44
Default
  #11
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 150
Rep Power: 16
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: Germany
Posts: 1,377
Rep Power: 29
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: 150
Rep Power: 16
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,912
Rep Power: 36
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
Luttappy likes this.
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541)
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.
alberto is offline   Reply With Quote

Old   February 19, 2019, 14:54
Default
  #15
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
Dear Alberto
I add simple energy equation to icoFluid solver in OF-ext4.0 as:
Quote:
fvScalarMatrix TEqn
(
fvm::ddt(T_)
+ fvm::div(phi_, T_)
- fvm::laplacian(DT_, T_)
);
TEqn.solve();
and I want to limit temperature. I uses T_.min(300.0) for limitation, but all data will be 300K. Other option,
Quote:
scalar Lup= 350.0;
scalar Llo= 300.0;

forAll(T_,i)
{
if (T_[i]<Llo){T_.replace(i,Llo);}
if (T_[i]>Lup){T_.replace(i,Lup);}

}
give all data 300K.
I also use
Quote:
forAll(mesh.cellZones(), zoneI)
{
const cellZone& cz = mesh.cellZones()[zoneI];
const labelList& cells = cz;
Info<< "banana0" << endl;
forAll(cells, iCells)
{
const label cellId = cells[iCells];
Info<< "banana1" << endl;
if (T_[cellId] < 300)
{
Info<< "bananaIf" << endl;
T_[cellId]=300;
}
}
}
It is go to two loops, but not in if. maybe it need other argument instead of [cellId]. So I change the code to
Quote:
forAll(mesh.cellZones(), zoneI)
{
const cellZone& cz = mesh.cellZones()[zoneI];
const labelList& cells = cz;
Info<< "banana0" << endl;
forAll(cells, patchID)
{
const label cellId = cells[patchID];
Info<< "banana1" << endl;
if (T_[cellId] < 300.0)
{
Info<< "bananaif" << endl;
T_[cellId]=300.0;
}
if (T_[cellId] > 350.0)
{
Info<< "bananaif2" << endl;
T_[cellId]=350.0;
}
}
}
Info<< "Min/max T: after if" << min(T()).value() << ' '
<< max(T()).value() << endl;
Now, the code goes to if but final temperature doesn't change. The other idea was using fvOption, but it doesn't exist in OF-ext4.0. Do you have any idea for this problem? thanks
Also I should note:
Quote:
const volScalarField& icoFluid::T() const
{
return T_;
}

Last edited by Hgholami; February 20, 2019 at 01:55.
Hgholami is offline   Reply With Quote

Old   February 23, 2019, 00:11
Default
  #16
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
I also test
Quote:
max(T()).value() = 350.0;
min(T()).value() = 300.0;
but nothing happen.
Hgholami is offline   Reply With Quote

Old   February 23, 2019, 00:13
Default
  #17
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
Dear Chrisi1984
Did you solve this problem?

Last edited by Hgholami; February 23, 2019 at 05:02.
Hgholami is offline   Reply With Quote

Old   March 5, 2019, 09:00
Default
  #18
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 17
olivierG is on a distinguished road
hello,
Now (2 year old...) you can use energyTransport function object on incompressible flow (see https://www.openfoam.com/releases/op...nd-physics.php) and also from even more years, limit T in fvOption file with "limitTemperature" type.

Code:
limitT
    {
        type            limitTemperature;
        active          yes;
        selectionMode   all;
        min             200;
        max             500;
        phase           gas; //optional
    }
regards,
olivier
olivierG is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
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 COMSOL 1 May 30, 2008 04:35
limit for a variable Luis CFX 5 February 12, 2008 05:55
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 04:27
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


All times are GMT -4. The time now is 12:51.