
[Sponsors] 
November 14, 2008, 09:57 
Hi Foamers!
I'm trying to imp

#1 
Senior Member

Hi Foamers!
I'm trying to implement some analytical solutions of the Linearized Euler Equations and I need to evaluate a spatioal convolution product: p(x,y,t) = f(x,y)@dG(x,y,t)/dt where G is the free space green function. To solve this convolution I apply this property: FourierTransform(a(x,y)@b(x,y))=FourierTransform(a (x,y)) FourierTransform(b(x,y)) then I come back to physical space with the inverse fft. My code is: .... Kmesh K(mesh); volScalarField f = eps*exp(Foam::log(2.0)/2*(sqr(xx_mon/lRef)+sqr(yy_mon/lRef))); Info << "\nEvaluating FFT" << endl; complexField fFour = fft::forwardTransform(ReComplexField(f), K.nn()); etc etc.... but when I execute it I have: Create time Create mesh for time = 0 Reading parameters Reading field U (1.99 1.99 0.2) 3(200 200 1) 442.056 Evaluating FFT #0 Foam::error::printStack(Foam:stream&) in "/opt/OpenFOAM/OpenFOAM1.5/lib/linux64GccDPOpt/libOpenFOAM.so" #1 Foam::sigSegv::sigSegvHandler(int) in "/opt/OpenFOAM/OpenFOAM1.5/lib/linux64GccDPOpt/libOpenFOAM.so" #2 ?? in "/lib64/libc.so.6" #3 Foam::fft::transform(Foam::Field<foam::complex>&, Foam::List<int> const&, Foam::fft::transformDirection) in "/opt/OpenFOAM/OpenFOAM1.5/lib/linux64GccDPOpt/librandomProcesses.so" #4 Foam::fft::forwardTransform(Foam::tmp<foam::field< foam::complex> > const&, Foam::List<int> const&) in "/opt/OpenFOAM/OpenFOAM1.5/lib/linux64GccDPOpt/librandomProcesses.so" #5 main in "/home/ivan/OpenFOAM/ivan1.5/applications/bin/linux64GccDPOpt/monopolo" #6 __libc_start_main in "/lib64/libc.so.6" #7 Foam::regIOobject::readIfModified() in "/home/ivan/OpenFOAM/ivan1.5/applications/bin/linux64GccDPOpt/monopolo" Segmentation fault I have a square bidimensional mesh. What does it means this segmentation fault? Thanks 

November 16, 2008, 07:43 
Segmentation fault means that

#2 
Super Moderator
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 18 
Segmentation fault means that it accesses outside the allocated memory. See e.g. http://openfoamwiki.net/index.php/HowTo_debugging.


November 16, 2008, 16:38 
Ok, the correct question is:

#3 
Senior Member

Ok, the correct question is:
I'm doing something wrong in my setup, something like the use of fft::forwardTransform is incorrect or it works only with 3D meshes, or there are any bestpractise for the use of fft? Thanks 

November 15, 2010, 19:08 
basic info with fft in OF

#4 
Member
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 10 
Hi Yvan,
Did you find a solution? I'm trying to implement 1D fft with the velocities in my solver and I'm not able to compile the solver... kMesh, fft and complexField have not been declared the error message said. How can I use the kMesh and fft class in OF 1.6.x. Would it be easier if create a utility for the fft? Any advice would be great! Thank you, Pascal 

May 11, 2011, 06:52 

#5 
Member
Elisabet Mas de les Valls
Join Date: Mar 2009
Location: Barcelona, Spain
Posts: 64
Rep Power: 10 
Hi all,
I've tried to implement a postprocess in order to evaluate the FFT in a 3D mesh. What I've done is: 1. To include the required header files (and modify accordingly the 'options' file): #include "fft.H"2. To calculate the FFT of the x velocity component (this can be discussed) Kmesh K(mesh);where Ufft is a scalarField of the same dimensions as the mesh. I guess that Ufft is the yaxis of a typical FFT diagram but, what should be the xaxis? Sorry if this is a very basic question, I'm familiar with FFT in time but I've never dealt with FFT in space. Thanks!! elisabet 

May 11, 2011, 11:10 
Fftw 2.1.5

#6 
Member
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 10 
Hi Elisabet,
The simplest solution I found was to link the public code FFTW 2.1.5 with OpenFOAM 1.6.x. All you need to do is modify your solver: option file and add a few line of code in order to calculate your FFT. You will have great flexibility using FFTW. Note: Also, you can all do that as an postprocess utility. Regard, Pascal 

May 12, 2011, 07:07 

#7 
Member
Elisabet Mas de les Valls
Join Date: Mar 2009
Location: Barcelona, Spain
Posts: 64
Rep Power: 10 
Thanks Pascal for the answer.
First of all, now I know what the final output should be (correct me if I'm wrong): a volScalarField in order to the see the peaks on my mesh (with paraview for example) I've been looking to use FFTW properly. I've found the place: http://www.fftw.org/doc/ComplexOne_...onalDFTs.html but, as fas as I understand, my 'in' (of fft_complex type) would be a ReComplexField of size K.sizeOfBox(), as well as my 'out' variable. Afterwords, I would convert the 'out' to a scalarField. However, I still have the same question: how to convert a scalarField to a volScalarField in order to visualize the resulting FFT in the physical space? Any suggestion? Or other ways to handle it? Elisabet 

May 12, 2011, 10:55 

#8 
Member
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 10 
Hi Elisabet,
When I use FFTW I need 1D array (standard C++) and volVectorField (I'm using 1D FFT on velocity vector): Code:
for (int nzi = 0; nzi < nz; nzi++) // Écriture du nouveau champ vectoriel { champModeX[nxy + nzi*nLim].component(0) = inWx[nzi]/nz; champModeX[nxy + nzi*nLim].component(1) = inWy[nzi]/nz; champModeX[nxy + nzi*nLim].component(2) = inWz[nzi]/nz; } Entire code of this utility is attached to the post. Hope this help. Pascal 

May 12, 2011, 12:14 

#9 
Member
Elisabet Mas de les Valls
Join Date: Mar 2009
Location: Barcelona, Spain
Posts: 64
Rep Power: 10 
Thank you very much Pascal! it was very useful!
If I understand it well, you call 'mode' a given xy plane (defined by z). Is it correct? Thus, it's reasonable to just look the FFT at a given xy plane, but I don't see the reason why you are interested in looking all xy planes except one. elisabet 

May 12, 2011, 13:30 

#10 
Member
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 10 
Hi Elisabet,
I'm doing FFT along 'z' axis (1D) and I calculate the most interesting mode (n) from 0 to nz/21 or wavenumber (k = 2*pi*n/Lz). I have also the possibility to observe all the modes except one. For example, I could be interested by all the modes except mode 0 (which is the base flow or 2D field) Doing that it will allow me to visualize the perturbed field which is very interesting depending what you are looking for. The calculation is applied to the entire domain of simulation. Regards, Pascal 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF problems  Winnie  FLUENT  21  March 15, 2011 10:26 
Problems with Fluent on simple 1D problems  agg  FLUENT  3  November 21, 2008 12:55 
problems  Rogerio Fernandes Brito  CFX  1  May 5, 2008 21:08 
MPI PROBLEMS  gtg627e  OpenFOAM Running, Solving & CFD  20  October 5, 2007 04:02 
UDF problems  Paolo Lampitella  FLUENT  5  September 8, 2005 20:43 