clr() and [a or b ? c]

hi all
does anybody know what these instructions mean?

for_all_points
{
clr(px);clr(py);clr(pp);
}

and also

#define viscous_c(d,mu) ( ((mu==0.0) || (laplace_coeff==0.0)) ? \
1.0e+9 : d/(mu*laplace_coeff) )

thanks a lot in advance
Last edited on
1
2
3
4
for_all_points
 {
 clr(px);clr(py);clr(pp);
 }


It seems that for_all_points is a macro that incloses some for statement. You should see the declaration of it.

1
2
#define viscous_c(d,mu) ( ((mu==0.0) || (laplace_coeff==0.0)) ? \
 1.0e+9 : d/(mu*laplace_coeff) ) 


This is another macro that uses the ternary (or conditional) operator.

( ( mu == 0.0 ) || ( laplace_coeff == 0.0 ) ) ? 1.0e+9 : d / ( mu*laplace_coeff )

It means if mu or laplace_coeff is equal to zero then return 1.0e+9. Otherwize the expression mu*laplace_coeff will be returned.
If viscous_c was written as a function it could be written like this:
1
2
3
4
5
6
7
8
9
10
11
inline double viscous_c(double d, double mu)
{
	if (mu==0.0 || laplace_coeff==0.0)
	{
		return 1.0e+9;
	}
	else
	{
		return d / (mu * laplace_coeff);
	}
}
It looks like it tries to avoid division by zero but it fails to check that mu * laplace_coeff != 0.0 so division by zero can still occur. This happens if mu and laplace_coeff is small enough.

http://ideone.com/YXVzM
Last edited on
Topic archived. No new replies allowed.