CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   OpenFOAM FFT of Entire Transient Data (https://www.cfd-online.com/Forums/openfoam-post-processing/122431-openfoam-fft-entire-transient-data.html)

minger August 19, 2013 22:03

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 "frequency-domain" allowing the individual to see amplitudes and phases of certain frequencies.

Anything related to this around?

Bernhard August 20, 2013 01:33

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?

minger August 20, 2013 15:24

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.

ngj August 20, 2013 15:50

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 post-processing 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 over-lapping 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

minger September 6, 2013 22:39

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!

ngj September 8, 2013 16:03

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 2-dimensional FFT for a xy-plane and a 3-dimensional 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

minger September 9, 2013 13:05

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).

ngj September 9, 2013 14:49

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 OF-1.6-ext, 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 full-space 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
which gives you the cell centres for every computational cell, i.e. the point locations needed by the probing dictionary. Combining this with the functionObject outputs the data in a run-time manner.
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 pre-process 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.cfd-online.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.

minger September 10, 2013 08:45

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.6-ext 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!

ngj September 10, 2013 12:37

Hi Minger,

No, unfortunately not, I merely know that it is there.

Kind regards

Niels


All times are GMT -4. The time now is 14:09.