OpenFOAM FFT of Entire Transient Data
I was wondering if there was any utility or outside code that could perform an FFT analysis of an entire unsteady solution set.
By that, I mean if I run my analysis and determine the fundamental frequency of concern. In the past I've used tools that allow the researcher to cleverly define his time step and file write frequency to obtain 2^n result files. He can then perform FFT on the entire set of result files to obtain a solution set in "frequencydomain" allowing the individual to see amplitudes and phases of certain frequencies. Anything related to this around? 
FFT of a complete dataset? I am not sure what you have in mind by that. I know FFT of a time series, I know that you can apply a Fourier transform in more dimensions in space is possible for simple geometries, but which of these do you have in mind? Or just the FFT of a time series?

So, you're basically performing FFT at each data point using a reduced set of data (one temporal point for each saved time step). So, rather than doing FFT of a single probe location using 2,048 (2^n) data points, you're doing FFT at each grid point using something like 32 data points.
With a reduced set of points, you can typically only grab a few frequencies of interest, but consider the following: If you have something shedding at multiple frequencies, it may be of interest to "see" where the highest amplitudes are for the first fundamental frequency. . .the second, etc. 
Hi Minger,
As Bernhard, I am pretty unsure of what you would like to accomplish, however, analysis of timeseries using FFT has been implemented in the postprocessing part of waves2Foam (openfoamwiki.net/index.php/Contrib/waves2Foam), and you should be able to use is right out of the box for e.g. sampled forces and velocity probes. The implemented method is based on GSL's FFT, since I did not find the interface in the OF implementation that nice. You can defined the number of frequencies, the overlapping of windows and only use part of a sampled time series. All of it in native OF data format; except for the spectra, which are outputted in easily loadable ASCII format. Kind regards, Niels 
OK, I've tried to find a solution to no avail. Let me try and describe my problem once again.
I'm not looking for FFT analysis at a single point, rather all points in the domain. So, rather than having 30,000 data points at a single probe location, let's say that I had 256 data files. I would then like to do FFT at each node, and then basically output a data file for each frequency (amplitude, phase, real, img, etc). So, if you were looking at spectral data at a probe location and noticed an unexpected peak, you could pull the amplitude data for that frequency and "see" what that unsteadiness looks like. I used to have a routine somewhere that did this on 2^n plot3d formatted files. It is truly a terrific tool. If anyone can provide any more insight, I would appreciate it. Thanks! 
Hi Minger,
I do not understand, what it is you want to achieve. Is it either of the following: 1. A FFT of the spatial data, i.e. a 2dimensional FFT for a xyplane and a 3dimensional FFT for a xyz volume? This FFT is then computed for each time step. 2. An FFT in each probe location in your domain, where the FFT is based on a time series. In the spatial dimensions you then want to visualise various spectral properties related to the FFT as a function of, say, x and y. Kind regards Niels 
1 Attachment(s)
I apologize, I must be terrible at explaining things.
The end goal is to be able to plot the amplitude as a contour at each point for a given frequency. I have attached an incredibly crude illustration of what we're going for. The process is kind of like this:  Take 2^n results files and perform 1D FFT at each and every grid point.  The function will essentially read data as a 1D array in time for each grid point and perform the FFT analysis.  What I get is then 2^n / 2 data files. Let's assume that I get  p.0.amp > this file would contain the pressure amplitude for the mean flow  p.1.amp > this file would contain the pressure amplitude for the first frequency (which would be implicitly set by the number of files and the time between each file write)  p.1.phase > I would typically also get a phase  p.n.amp / p.n.phase  I would files for each FFT frequency computed. What I could then do is open up, e.g. p.1.amplitude and "plot" the pressure. I could then see where in my computational domain this frequency is dominant. (If I had a probe in the areas of high amplitude, it would show up on a traditional FFT plot  likewise if I had a probe in a low amplitude area here, it may not show up). 
Hi Minger,
Good, now it does make sense. To my knowledge nothing exactly as that exists in OF, but you might want to look into the POD utility (Prober Orthogonal Decomposition) in OF1.6ext, which decomposes the solution into eigenvalue space. Back to your problem at hand, then it will most probably require a bit of work from your hand, so let me try to sketch what is needed (at least for an efficient execution of the fullspace FFT decomposition): 1. One way or the other, you will need to store the transient data for every single computational cell in your computational domain. It could result in large amounts of data, though, it is definitely feasible. Two options exists: a. Utilise the function object to probe e.g. the velocities at a given rate. This merely requires you to create the probing dictionary, tedious but doable. A trick in this context would be to use Code:
writeCellCentres time 0 b. Write the data at a sufficiently high rate, such that you can walk through the data afterwards and recovering files with the transient information in one file per location. This will also ensure that the time series are equidistant in time for your FFT analysis. You should also be able to utilise the sampling utility for that (the parent utility for the probing). The reason that I want you to preprocess the data into files with (time, data) rather than (space,data) format is that the processing of the FFT will become much faster. 2. Now you have the data ready and you want to do the FFT. Therefore, you will need to read the probed data format and pass this to an FFT method. Here I can recommend that you uses the FFT decomposition already implemented in the waves2Foam framework as mentioned above. This method is not bound to a length of the data sets of 2^N, so it become somewhat more flexible, and know tricks as shifting windows, averaging of multiple spectra, etc, are already available there. It comes with a separate interface to the FFT, so you should be able to implemented something, which utilises the existing interface. 3. Now you have a function, which computes the FFT, but it does not store the data. This should be made as flexible as possible, so I recommend that you read the following thread on runTime allocation of multiple fields: http://www.cfdonline.com/Forums/ope...openfoam.html If you are interested in all 2^N/2 fields, then you will end up with a tremendous amount of data (too much?) in the memory, so if you are not performing some kind of flexible data management, where you move fields in and out of the memory, you will easily end up swapping. You are done and just about to begin:) Best of luck, Niels P.S. You should be aware that the probing/sampling methods output the data in the serial directory, i.e. not under the parallel processors. This means that you will have to do some additional thinking, if you what to execute the above described steps in parallel. 
Niels,
This may be just what I was looking for! I was originally looking to find a way to compare several configurations to see where the different "modes" were. I was initially thinking that frequency space was the way to go  but in hindsight, if the frequencies are slightly off, it could make the FFT process tedious. I plan on installing 1.6ext tonight (after having read through a couple posts regarding running multiple version of OF concurrently), however could use a reference for the POD process. I can't seem to find a tutorial or any files online actually describing the process. Do you have anything? Thanks a bunch! 
Hi Minger,
No, unfortunately not, I merely know that it is there. Kind regards Niels 
All times are GMT 4. The time now is 01:02. 