CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   limit variable (http://www.cfd-online.com/Forums/openfoam/79195-limit-variable.html)

Chrisi1984 August 16, 2010 08:15

limit variable
 
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

akidess August 16, 2010 08:45

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;
}


Chrisi1984 August 16, 2010 09:02

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 September 1, 2010 03:08

problem is solved
 
My problem is still existing. Any ideas?

akidess September 1, 2010 04:04

Would you share it so that people can learn from this thread?

Chrisi1984 September 1, 2010 06:47

Sorry!

I am wrong. I did not solve the problem.


I wanted to write this below an other thread!!

Regards Chrisi

Chrisi1984 September 6, 2010 05:04

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

akidess September 6, 2010 08:34

Why loop through the cellZones within the cellZone loop?

Chrisi1984 September 7, 2010 08:33

You are right off course the loop over the cell zones is unnecessary!

Regards Chrisi

alberto September 17, 2010 00:53

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 :-)

Chrisi1984 September 17, 2010 03:44

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

akidess September 17, 2010 04:02

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).

Chrisi1984 September 17, 2010 04:39

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

alberto September 17, 2010 10:29

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 :)


All times are GMT -4. The time now is 10:52.