Problem with 'operator<'
Hello, foamers. I'm making a new boundary using ParabolicVelocity as base code.
In my equation, there is sqrt function. for example, Quote:
Everything is Okay, but the calculating process is stopped in case of 'b>a'. I think that it is because the value in the sqrt can't be negative. So, I modified the code as below. Quote:
The error message is Quote:
Can anyone explain me how to make that 'if' function feasible? Thanks! |
You are correct that (a-b) can't be negative when using sqrt(a-b). You could also use sqrt(max((a-b), 0)) to make sure your smalles value below the sqrt is a "0".
For your if statement you should maybe put some whitespaces in there. The problem is maybe arising, because you are trying to compare a whole field to one single scalar value. If you want to compare all the values in the field to "0" maybe go like this: Code:
forAll(c, i) |
Hi, Pete. Thank you for your kind reply.
I modified the code like below Quote:
Quote:
Quote:
my purpose is to avoid negative value in the sqrt, and zero value in denominator. The 'if' function seems to be successful in sqrt, but not in denominator. Thank you for your help!! |
Small numbers that are not exactly zero, but very small (1e-300) will also produce a floating point exception. Your if condition "a[i] == 0" is not sufficient in this case. Maybe you should do something like
Code:
if (mag(a[i]) < VSMALL) |
All times are GMT -4. The time now is 04:14. |