CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Preventing infinite fields? (http://www.cfd-online.com/Forums/openfoam-programming-development/119430-preventing-infinite-fields.html)

mosquera June 17, 2013 10:43

Preventing infinite fields?
 
Greetings all,

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.

Thanks,

Matt

mturcios777 June 17, 2013 12:58

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.

mosquera June 18, 2013 04:56

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 13:13.