CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   problem computing maximum (https://www.cfd-online.com/Forums/openfoam/67919-problem-computing-maximum.html)

Schag August 31, 2009 12:00

problem computing maximum
 
Hi all,

I'm facing a problem computing a maximum value for a time interval on each cell.
I put there my code:

volVectorField Umax (initiated full of (0 0 0))

forAll(times, timeI)
{
forAll(U,cellI)
{
if (mag(U[cellI]) > mag (Umax[cellI])
{
Umax[cellI]=U[cellI];
}
}
}

I get strange results, such as velocity in a cell that is not reach on my interval.
Does anybody has an idea? Any advice would be welcome. Thank you!

niklas August 31, 2009 16:44

so....
in cell2 it can be the value from time=1s
and in cell3 it can be the value from time=2s...for instance

Im just curious why that would be interesting, to mix together the
different times.

Or have you left out pieces of code, like where you read in the U at different times?
Where in that loop is that read?

And why not initiate Umax with the values from the first time, that way you dont have to
check for that time and can skip 1 iteration...not much, but still.


anyways...your code (as it is written) does neither change the time or U in that loop.

Schag September 1, 2009 02:41

Yes, that's the point, I can have U from time 1 in cell 3, and U from time 254 in cell 68957. It is interesting for me because I want to study sediment, so I have to know the maximum velocity in a non steady flow.

I could have initiate Umax with U(t=0), but that's not the point. And of course, I have many pieces of code left, I don't have just these lines, it would be dummy to think it would work!

My base was the vorticity application. So for each time, I read U and it works. I obtain a correct average, it's just the maximum that doesn't work.

I think my problem is the
if (mag(U[cellI]) > mag (Umax[cellI])
{
Umax[cellI]=U[cellI];
}

because when I suppress the if, I get Umax=U at each time step (ouf!)

Any idea?


All times are GMT -4. The time now is 00:39.