CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Bugs (
-   -   Bugs in FFT (

luca January 27, 2009 13:31

Hi, maybe there is a little

maybe there is a little bug in fft.C file at line 52: the algorithm seems to check if the size of the field is a power of two.
The source is written as

if ((pow2 - int(pow2 + 0.5)) > SMALL)

but should be:

if (mag(pow2 - int(pow2 + 0.5)) > SMALL)


if (mag(pow2 - int(pow2)) > SMALL).

The first one does not work.

olesen January 27, 2009 14:03

Or maybe just check directly?
Or maybe just check directly?

// check for power of two
unsigned int dimCount = nn[idim];
if (!dimCount || (dimCount & (dimCount - 1)))

BTW: how often do people use ffts in OpenFOAM?
I have a Singleton FFT kicking about (ie, fft-olesen.tar.gz) that benchmarked quite well in the first FFTW roundup.

With radix-4 or radix-8 data it gives good speedup, but also handles arbitrary data without padding [I used it for image processing]. The only issue I remember is that the NR routine (ie, the one in OpenFOAM) handles the scaling a bit different.

Is there a bit enough call for FFTs, that it should be ported from the C version into usingthe OpenFOAM structures? Or would it be better (and easier) just to have FFTW as ThirdParty?

henry January 27, 2009 16:40

Yep checking directly is much
Yep checking directly is much more sensible, I will push this change to OpenFOAM-1.5.x.

I don't think the FFT in OpenFOAM is used much; we only use it for noise analysis and we don't need it to be particularly efficient but it would be useful if it were more flexible, i.e. allowed arbitrary number of data in arbitrary dimensions. If yours can do this then it would be interesting to integrate it into OpenFOAM somehow.


All times are GMT -4. The time now is 05:47.