CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Problems with fft

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Pascal_doran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2008, 09:57
Default Hi Foamers! I'm trying to imp
  #1
Senior Member
 
Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 210
Rep Power: 18
ivan_cozza is on a distinguished road
Send a message via MSN to ivan_cozza
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(x-x_mon/lRef)+sqr(y-y_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/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigSegv::sigSegvHandler(int) in "/opt/OpenFOAM/OpenFOAM-1.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/OpenFOAM-1.5/lib/linux64GccDPOpt/librandomProcesses.so"
#4 Foam::fft::forwardTransform(Foam::tmp<foam::field< foam::complex> > const&, Foam::List<int> const&) in "/opt/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/librandomProcesses.so"
#5 main in "/home/ivan/OpenFOAM/ivan-1.5/applications/bin/linux64GccDPOpt/monopolo"
#6 __libc_start_main in "/lib64/libc.so.6"
#7 Foam::regIOobject::readIfModified() in "/home/ivan/OpenFOAM/ivan-1.5/applications/bin/linux64GccDPOpt/monopolo"
Segmentation fault

I have a square bidimensional mesh.
What does it means this segmentation fault?
Thanks
ivan_cozza is offline   Reply With Quote

Old   November 16, 2008, 07:43
Default Segmentation fault means that
  #2
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Segmentation fault means that it accesses outside the allocated memory. See e.g. http://openfoamwiki.net/index.php/HowTo_debugging.
mattijs is offline   Reply With Quote

Old   November 16, 2008, 16:38
Default Ok, the correct question is:
  #3
Senior Member
 
Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 210
Rep Power: 18
ivan_cozza is on a distinguished road
Send a message via MSN to ivan_cozza
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 best-practise for the use of fft?
Thanks
ivan_cozza is offline   Reply With Quote

Old   November 15, 2010, 19:08
Default basic info with fft in OF
  #4
Member
 
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 17
Pascal_doran is on a distinguished road
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
Pascal_doran is offline   Reply With Quote

Old   May 11, 2011, 07:52
Default
  #5
Member
 
Elisabet Mas de les Valls
Join Date: Mar 2009
Location: Barcelona, Spain
Posts: 64
Rep Power: 17
elisabet is on a distinguished road
Hi all,

I've tried to implement a post-process 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"
#include "Kmesh.H"
#include "complexFields.H"
2. To calculate the FFT of the x velocity component (this can be discussed)
Kmesh K(mesh);
scalarField Ufft=mag(fft::forwardTransform(ReComplexField(U.co mponent(0)),K.nn()));
where Ufft is a scalarField of the same dimensions as the mesh.

I guess that Ufft is the y-axis of a typical FFT diagram but, what should be the x-axis?

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
elisabet is offline   Reply With Quote

Old   May 11, 2011, 12:10
Default Fftw 2.1.5
  #6
Member
 
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 17
Pascal_doran is on a distinguished road
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 post-process utility.

Regard,
Pascal
Pascal_doran is offline   Reply With Quote

Old   May 12, 2011, 08:07
Default
  #7
Member
 
Elisabet Mas de les Valls
Join Date: Mar 2009
Location: Barcelona, Spain
Posts: 64
Rep Power: 17
elisabet is on a distinguished road
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/Complex-One_...onal-DFTs.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
elisabet is offline   Reply With Quote

Old   May 12, 2011, 11:55
Default
  #8
Member
 
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 17
Pascal_doran is on a distinguished road
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;
            }
where inWx[nzi] is the nzi element of the array inWx created by FFTW. nz is the number of cell in the 'z' direction required for normalization. And champModeX is a new volVectorField. At the end I can observe the mode 0, 1, 2, etc. of the velocity field (called champModeX).

Entire code of this utility is attached to the post.

Hope this help.
Pascal
Attached Files
File Type: c modeFFTuw.C (9.3 KB, 83 views)
caduqued likes this.
Pascal_doran is offline   Reply With Quote

Old   May 12, 2011, 13:14
Default
  #9
Member
 
Elisabet Mas de les Valls
Join Date: Mar 2009
Location: Barcelona, Spain
Posts: 64
Rep Power: 17
elisabet is on a distinguished road
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
elisabet is offline   Reply With Quote

Old   May 12, 2011, 14:30
Default
  #10
Member
 
Pascal
Join Date: Jun 2009
Location: Montreal
Posts: 65
Rep Power: 17
Pascal_doran is on a distinguished road
Hi Elisabet,

I'm doing FFT along 'z' axis (1D) and I calculate the most interesting mode (n) from 0 to nz/2-1 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
Pascal_doran is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


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


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