CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ParaView

FFT Of Selection Over Time (Fourier Transform) in ParaView 3.14.1

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By babakflame
  • 1 Post By Mehrez

Reply
 
LinkBack Thread Tools Display Modes
Old   June 6, 2014, 08:27
Question FFT Of Selection Over Time (Fourier Transform) in ParaView 3.14.1
  #1
Member
 
Mehrez
Join Date: Nov 2012
Location: Bordeaux, France
Posts: 52
Rep Power: 4
Mehrez is on a distinguished road
Hello,
I'm running a transient simulation of flow around cylinder and storing the pressure and velocity fields in files corresponding to different times.
I apply then on the pressure the ParaView filter "FFT Of Selection Over Time".
I'm not sure what is this filter doing exactly !? I didn't find deep documentation on the Fourier transform with ParaView. Do you have an idea on how does this filter choose the point on which it applies the FFT ?
Any docs are welcome.

Thanks

Mehrez
Mehrez is offline   Reply With Quote

Old   December 16, 2014, 10:39
Default
  #2
Senior Member
 
Bobi
Join Date: Oct 2012
Posts: 286
Rep Power: 5
babakflame is on a distinguished road
Greetings Mehrez

I have been through this question as well. At first I thought maybe this filter plots energy spectrum along a specified line. I tried to search some links to find out what does this filter do exactly:

http://www.itk.org/Wiki/ParaView/Use...ters#Table_FFT
http://comments.gmane.org/gmane.comp...iew.user/22835

The above links are a bit vague. However some interesting points are mentioned. I would be very pleased if somebody describe this filter with an example. Since I have some doubts on the way of using this filter. For instance should we use it on a slice or line or why it does not accept velocity components ( I mean a separated component not a vector array) ?


Best,
Bobi
Mehrez likes this.
babakflame is offline   Reply With Quote

Old   December 16, 2014, 11:40
Default
  #3
Member
 
Mehrez
Join Date: Nov 2012
Location: Bordeaux, France
Posts: 52
Rep Power: 4
Mehrez is on a distinguished road
Quote:
Originally Posted by babakflame View Post
Greetings Mehrez

I have been through this question as well. At first I thought maybe this filter plots energy spectrum along a specified line. I tried to search some links to find out what does this filter do exactly:

http://www.itk.org/Wiki/ParaView/Use...ters#Table_FFT
http://comments.gmane.org/gmane.comp...iew.user/22835

The above links are a bit vague. However some interesting points are mentioned. I would be very pleased if somebody describe this filter with an example. Since I have some doubts on the way of using this filter. For instance should we use it on a slice or line or why it does not accept velocity components ( I mean a separated component not a vector array) ?


Best,
Bobi

Hi dear Bobi,
I have tried to undertand what is really done in the FFT filter but didn't get any convincing answer.
I have written my own python script that reads the OpenFoam files and plots the FFT.
Please tell me if you are interested, I can share it.
Best regards,
Mehrez
Mehrez is offline   Reply With Quote

Old   December 16, 2014, 11:52
Default
  #4
Senior Member
 
Bobi
Join Date: Oct 2012
Posts: 286
Rep Power: 5
babakflame is on a distinguished road
Greetings Mehrez

Thanks for your reply. In deed, I am interested in deriving Energy Spectrum (1D or 3D) from LES simulations in OpenFOAM. I hope that your python script do that. It would be my very pleasure if you share it with me.


Best,
Bobi
babakflame is offline   Reply With Quote

Old   December 16, 2014, 12:15
Default
  #5
Member
 
Mehrez
Join Date: Nov 2012
Location: Bordeaux, France
Posts: 52
Rep Power: 4
Mehrez is on a distinguished road
Here is the python script:



# -*- coding:Latin-1 -*-


from math import *
import numpy
import re
import pylab
import math
import os
import glob


# Script to read files of a given variable from an transient OpenFoam case
# It performs an fft on the selected variable from the different time fields (variable may be "p" or "U"...)
# WARNING ! time steps must be equidistant
# MUST BE GIVEN : path and a reference point through which the analysis will be done


path='/home/agnaou/Bureau/Square/porosity75%/Re27000/' # path of the OpenFoam case
ref_point=5000 # an integer comprised between 0 and the number of mesh cells - 1
variable="p" # variable on which the FFT will be performed


################################################## ################################################## ########################################
# Read the pressure fields
################################################## ################################################## ########################################


folders=[x[0] for x in os.walk(path)] # search the different folders contained in the path directory

files_number=0 # number of variable fields to be treated or number of time steps
min_t=1e+50 # minimum time of the simulation
max_t=0 # maximum time of the simulation
for i in range (len(folders)):
os.chdir(folders[i])
for file in glob.glob(variable):
files_number=files_number+1
t=float(folders[i][len(folders[0]):len(folders[i])])
if (t<min_t):
min_t=t
if (t>max_t):
max_t=t
time_step=(float(max_t-min_t))/(float(files_number-1)) # time step of the simulation

VARIABLE=numpy.empty((files_number),dtype='object' ) # fields of the selected variable stored and ordered as a function of time

for i in range (len(folders)):
os.chdir(folders[i])
for file in glob.glob(variable):

TakeValue=open(folders[i]+"/"+variable)
Lines=TakeValue.readlines()
mesh=int(Lines[20])
t=float(folders[i][len(folders[0]):len(folders[i])])
VARIABLE[int((t-min_t)/time_step)]=numpy.empty((mesh),dtype='object')

for j in range (mesh):
VARIABLE[int((t-min_t)/time_step)][j]=float(Lines[j+22])

point=numpy.empty((files_number),dtype='float64')
for i in range (files_number):
point[i]=VARIABLE[i][ref_point]


################################################## ################################################## ########################################
# perform the ffts
################################################## ################################################## ########################################


fft=numpy.fft.fft(point)
frequency= numpy.fft.fftfreq(files_number, d=time_step)

fftr=abs(fft.real)
ffti=abs(fft.imag)
fftb=numpy.sqrt(fft.imag**2+fft.real**2)
frequency= numpy.fft.fftfreq(files_number, d=time_step)


################################################## ################################################## ########################################
# Plot
################################################## ################################################## ########################################


pylab.subplot(221)
pylab.title("Original Data")
pylab.grid()
pylab.plot(numpy.arange(files_number)*time_step,po int,'r-',alpha=1)
pylab.xlabel("Time")
pylab.ylabel(variable)

pylab.subplot(222)
pylab.title("Real FFT")
pylab.xlabel("Frequency")
pylab.ylabel("Power")
pylab.grid()
#pylab.plot(frequency,fftr,'b-',alpha=1)
pylab.scatter(frequency,fftr, c='b')

pylab.subplot(223)
pylab.title("Imaginary FFT")
pylab.xlabel("Frequency")
pylab.ylabel("Power")
pylab.grid()
pylab.plot(frequency,ffti,'g-',alpha=1)

pylab.subplot(224)
pylab.title("Real+Imaginary FFT")
pylab.xlabel("Frequency")
pylab.ylabel("Power")
pylab.grid()
pylab.plot(frequency,fftb,'k-',alpha=1)

pylab.show()
babakflame likes this.
Mehrez is offline   Reply With Quote

Old   December 16, 2014, 12:25
Default
  #6
Senior Member
 
Bobi
Join Date: Oct 2012
Posts: 286
Rep Power: 5
babakflame is on a distinguished road
Greetings Mehrez

Many thanks for sharing your work. I will try it and may contact you in case of questions.

Best,
Bobi
babakflame is offline   Reply With Quote

Old   December 17, 2014, 03:44
Default
  #7
Senior Member
 
Bobi
Join Date: Oct 2012
Posts: 286
Rep Power: 5
babakflame is on a distinguished road
Greetings Mehrez

I have activated Programmable filter on my paraview 3.12.0. Then I copied your script in the empty script space. I modified the path and cell number in your script. However, after applying your Filter nothing happens. Actually, I am interested in energy spectrum along the axis of my case. Is it possible to hint me to efficiently use your Filter?

I can send you my case so that probably it would be easier to get help.


Best,
Bobi
Attached Images
File Type: jpg Screenshot at 2014-12-18 14:21:45.jpg (37.2 KB, 24 views)

Last edited by babakflame; December 18, 2014 at 06:56.
babakflame is offline   Reply With Quote

Old   December 19, 2014, 06:25
Arrow
  #8
Member
 
Mehrez
Join Date: Nov 2012
Location: Bordeaux, France
Posts: 52
Rep Power: 4
Mehrez is on a distinguished road
Hi dear Bobi,
You can use the script directly on a python shell without using Paraview.
You should have installed the loaded modules (matplotlib...) if it is not done yet.
You are right, you have to change the path, put a cell number and put a variable (replace 'p' in the original script by 'k' or 'eps' ...)
Please send me your case to take a look.
Best regards,
Mehrez.

Quote:
Originally Posted by babakflame View Post
Greetings Mehrez

I have activated Programmable filter on my paraview 3.12.0. Then I copied your script in the empty script space. I modified the path and cell number in your script. However, after applying your Filter nothing happens. Actually, I am interested in energy spectrum along the axis of my case. Is it possible to hint me to efficiently use your Filter?

I can send you my case so that probably it would be easier to get help.


Best,
Bobi
Mehrez is offline   Reply With Quote

Old   December 21, 2014, 12:12
Default
  #9
Senior Member
 
Bobi
Join Date: Oct 2012
Posts: 286
Rep Power: 5
babakflame is on a distinguished road
Greetings Mehrez

I have installed matplotlib via the instructions in the following link:
http://matplotlib.org/users/installing.html

However, I have still my problem with using it. Is it possible to give step by step hints to use matplotlib to draw power spectrum with your code?

PS: I sent you the case with file2send, For instance I need Power Spectrum for a point in the shear layer.

PS: How do you determine cell number in your script?

Best,
Bobi
babakflame is offline   Reply With Quote

Old   March 6, 2015, 12:01
Default
  #10
Member
 
Mehrez
Join Date: Nov 2012
Location: Bordeaux, France
Posts: 52
Rep Power: 4
Mehrez is on a distinguished road
Hi dear Bobi,
I'm sorry to respond so late. The link you sent me by email didn't work (may be because I opened it late :-/).
I you are still interested, please resend me your files.
Hope that my python script helped you.

Best regards,

Mehrez

Quote:
Originally Posted by babakflame View Post
Greetings Mehrez

I have installed matplotlib via the instructions in the following link:
http://matplotlib.org/users/installing.html

However, I have still my problem with using it. Is it possible to give step by step hints to use matplotlib to draw power spectrum with your code?

PS: I sent you the case with file2send, For instance I need Power Spectrum for a point in the shear layer.

PS: How do you determine cell number in your script?

Best,
Bobi
Mehrez is offline   Reply With Quote

Reply

Tags
fft, filters, fourier transform, paraview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fast Fourier Transform (FFT) in Tecplot 360 g.woyczynski Tecplot 3 October 23, 2014 18:57
FFT (Fast Fourier Transform) in fluent puneetnema FLUENT 0 March 3, 2014 15:41
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58
pimpleFoam: turbulence->correct(); is not executed when using residualControl hfs OpenFOAM Running, Solving & CFD 3 October 29, 2013 09:35
calculation diverge after continue to run zhajingjing OpenFOAM 0 April 28, 2010 04:35


All times are GMT -4. The time now is 06:54.