|
[Sponsors] |
September 18, 2016, 13:39 |
Problem with 'operator<'
|
#1 | |||
Member
Lee Jung Hoo
Join Date: Dec 2015
Posts: 37
Rep Power: 10 |
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! |
||||
September 21, 2016, 09:02 |
|
#2 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 14 |
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) { if (c[i] < 0) { c[i] = 0; } } |
|
September 23, 2016, 05:42 |
|
#3 | |||
Member
Lee Jung Hoo
Join Date: Dec 2015
Posts: 37
Rep Power: 10 |
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!! Last edited by Jung hoo; September 23, 2016 at 13:30. |
||||
September 29, 2016, 07:09 |
|
#4 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 14 |
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) { bla } |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF compiling problem | Wouter | Fluent UDF and Scheme Programming | 6 | June 6, 2012 04:43 |
Gambit - meshing over airfoil wrapping (?) problem | JFDC | FLUENT | 1 | July 11, 2011 05:59 |
natural convection problem for a CHT problem | Se-Hee | CFX | 2 | June 10, 2007 06:29 |
Adiabatic and Rotating wall (Convection problem) | ParodDav | CFX | 5 | April 29, 2007 19:13 |
Is this problem well posed? | Thomas P. Abraham | Main CFD Forum | 5 | September 8, 1999 14:52 |