Preventing infinite fields?
I'm working on a foam project in which I need to define a new field based on several other parameters (k, e, nut).
I've done this so far using something of the form
volScalarField B ("B", 2*k/(nut*e))
My problem is that there are points in my field inw hcih either nut or e are equal to zero. Therefore, the code compiles but upon running it in my case I receive a core dump. I assume this is due to the computer running out of memory.
What's a good workaround such that I can bound B between, say, 0 and 1 regardless of nut and e?
I've tried to use if-then statements but unfortunately c++ is new to me and I haven't eben able to get good results.
Foam has a built in quantity called SMALL that can be added to the denominator that is very near machine zero, but still strictly non-zero. This won't prevent huge values but will keep you from getting NAN errors, and help you track down errors.
That was helpful, thanks!
It's running now but I'm still looking for a way to bound the values.
|All times are GMT -4. The time now is 22:31.|