CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Function maxvsfvsf (https://www.cfd-online.com/Forums/openfoam-solving/60271-function-maxvsfvsf.html)

 sampaio March 27, 2006 19:08

Hi All Is there such a func

Hi All

Is there such a function?

It gave me no compilation error, but apparently is not doing what I expected it to do:

I thought that if I use vsf1 = max(vsf2, vsf3) it would give the maximum between vsf2 and vsf3 at each control volume. But, when I use vsf3 = to 1 everywhere (actually, I used vsf3=vsf2^0, just to make sure), and print the maximum value of the domain (Info << max(vsf1).value()) it output a number greater than 1 (5.7).

Am I doing something stupid?

Thanks a lot
Luiz

 hjasak March 27, 2006 19:17

In STL, max (well, that would

In STL, max (well, that would be std::max, but you're using namespace std;) is sometimes defined as a stupid template - try Foam::max instead and see if it's any better.

Hrv

 hjasak March 27, 2006 19:19

Forgot to tell you: the functi

Forgot to tell you: the function is defined as a BINARY_FUNCTION(func) macro expansion. For me, it's lnInclude/GeometricFieldFunctions.H, line 260.

Hrv

 sampaio March 28, 2006 00:21

Thanks a lot Prof. Hrvoje, It

Thanks a lot Prof. Hrvoje,
It didnt work.
Here is the piece of code, supposed to print the maximum value as 1. It is outputing 5.7, instead. I even tried to zero the boundary values, as a desperate measure... http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

(what I am trying to do is a v2f turb model, I hope to be my first contribution for this fantastic code... I want to limit v2 to something lower than the total kinetic energy, k)

Thanks again.

volScalarField v2k(v2_/(k_+kSmall_));
v2k = Foam::max((v2_/(k_+kSmall_)),pow(v2k,0));
forAll(v2k.boundaryField(), patchI)
{
v2k.boundaryField()[patchI] = 0.0*v2k.boundaryField()[patchI];
}

nfo << "\nMax de v2/k: "<< max(v2k).value() << endl;

 gschaider March 28, 2006 03:37

Just a stupid thought from my

Just a stupid thought from my side, but maybe 5.7 is the maximum of v2_/(k_+kSmall_)) ?

 hjasak March 28, 2006 08:28

Grrr: pow(v2k,0)! Would not t

Grrr: pow(v2k,0)! Would not that be one? Always one :-) Any number to the power zero is one, right?

Hrv

 sampaio March 28, 2006 08:32

Yes, you are right. It was a s

Yes, you are right. It was a stupid mistake (it was late at night http://www.cfd-online.com/OpenFOAM_D...part/happy.gif ). I should have taken the minimum in the second line. Thanks. (Actually, there is also a physical mistake in the above implementation, and it should be 2, since u2+v2+w2=2*k, but that doesnt matter to this discussion)

 sampaio March 28, 2006 09:02

Yes, I was using a shorter not

Yes, I was using a shorter notation for dimensionedScalar("1",dimensionSet(0, 0, 0, 0, 0),1).

Now that everything is working (except my case is still diverging, I will change it back to this "1". http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Thanks.

 All times are GMT -4. The time now is 03:31.