CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   How to extract sound file from pressure-time OpenFoam data? (

Bertrand April 10, 2010 10:15

How to extract sound file from pressure-time OpenFoam data?

I am very new to OpenFoam fantastic world, disovering stunning things everyday I try it. I already 'played' for a while with different functionalities. I got stuck at some point, though, and I hope you foamer experts could give a hand on that.
I would like to extract a sound file from the pressure-time data caculated after running any Foam solver on a pipe case, for instance, i.e. I ran the case, already, I have the pressure in the time directories, but I would like to transform it into a sound file, so I could assess the reliability of my results.

I had read (and tried) about probeToAudio, which was available in previous versions of OpenFoam (I have the lastest OpenFOAM-1.6-x) but although I implemented it and check it on pitzDaily tutorial case, with the probes as indicated in, I got the same error result :

probeToAudio $FOAM_CASE/probes/0/p -column 1 -timeStretchRatio 10 -startTime 1e-4
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6.x |
| \\ / A nd | Web: |
| \\/ M anipulation | |
Build : 1.6.x-3c7e63aa590d
Exec : probeToAudio /probes/0/p -column 1 -timeStretchRatio 10 -startTime 1e-4
Date : Apr 10 2010
Time : 16:12:43
Host : bertrand-laptop
PID : 3279
Case : /home/bertrand/OpenFOAM/bertrand-1.6.x/run/tutorials/incompressible/pisoFoam/les/pitzDaily
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Create time

#0 Foam::error::printStack(Foam::Ostream&) in "/home/bertrand/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/"
#1 Foam::sigSegv::sigSegvHandler(int) in "/home/bertrand/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/"
#2 ?? in "/lib/"
#3 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) in "/home/bertrand/OpenFOAM/ThirdParty-1.6.x/gcc-4.3.3/platforms/linux64/lib64/"
#4 main in "/home/bertrand/OpenFOAM/bertrand-1.6.x/applications/bin/linux64GccDPOpt/probeToAudio"
#5 __libc_start_main in "/lib/"
#6 _start at /build/buildd/eglibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:116
Segmentation fault

I am still not really familiar with implementing a new lib or application into an existing openFoam set, so I might have done something wrong.

I hope I was clear enough so that some of you can take a bit of their time to answer me.

Thank you!


7islands April 10, 2010 21:31

Hi Bertrand,
I'm the one who wrote the utility and finally got a first feedback since the public release of more than two years ago! :) Shall take a look and let you know when fixed.


Bertrand April 11, 2010 03:39

Hello Takuya,

Thank you for your very quick answer!

Actually, after writing my post, I tried again, and eventually could get it to work after installing setFunkyFields (which needs bison to be installed as well). The only thing is it didn't work with '/probes/0/p' but with 'probes/0/p' :). I am pretty new to Linux, so I gotta get to know about syntaxes, installing packages and so on.

Although, I have 2 questions :

1. When I try to run potentialWaveFoam on the example case you gave, i.e. reverberationRoom, here is the error message that comes :

| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6.x |
| \\ / A nd | Web: |
| \\/ M anipulation | |
Build : 1.6.x-3c7e63aa590d
Exec : potentialWaveFoam
Date : Apr 11 2010
Time : 09:23:42
Host : bertrand-laptop
PID : 4181
Case : /home/bertrand/OpenFOAM/bertrand-1.6.x/run/potentialWaveFoam/reverberationRoom
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

// using new solver syntax:
solver diagonal;

Reading transportProperties

Reading speed of sound c0

Reading density of medium rho

Reading field phi

size 53910 is not equal to the given value of 55500

file: /home/bertrand/OpenFOAM/bertrand-1.6.x/run/potentialWaveFoam/reverberationRoom/0/phi_0 from line 18 to line 53971.

From function Field<Type>::Field(const word& keyword, const dictionary&, const label)
in file /home/bertrand/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Field.C at line 237.

FOAM exiting

2. About the probeToAudio utility :

I tried on my 'special cavities' with initial conditions such as sinus or 1st half of a sinus and then clamped for the 2nd half. I could get the fundamental frequency I gave as an input. So it roughly gave me the tune I was looking for, which is a good start!!

A. How shall I use the sample rate now, if I want to have the exact fundamental frequency (and not an octave higher, lower), if I have, let's say, I have a pitch of F0 = 500 Hz, but I would like to catch more details about the overtones produced by this frequency?

B. How to represent data's from the probe file into a spectrum-plot? Is there a possibility for paraView?

Again, thanks a lot if you have time to answer one of these questions, I know I asked some... ;)



7islands April 11, 2010 09:46


1. Can you try removing the whole potentialWaveFoam and its subdirectories, and start over from checking out the subversion repository?

2.A. I am not sure if I am getting your question right. The utility simply sets the sampling rate from the deltaT entry in controlDict and does no more complex processing. If you want to extract overtones you have to use a high-pass filter of some audio processing software or write your own somehow.

2.B. In theory yes you can use "FFT Of Selection Over Time" in ParaView, but I don't think it's a realistic option because you have to save/load the field data at every time step. I'd suggest you start by trying any one of audio processing softwares, for example Audacity, which is available from Synaptic if you are using Ubuntu. If that's not enough for you, you may have to write your own with e.g. SciPy.


m2montazari December 10, 2010 17:00


about the third answer(2B), I'm not so sure if using fft over time really needs to write all timesteps! I think we can write just SOME timesteps and have a good estimate of the result by for example 200 or 300 timesteps saved. although this might be inefficient for large cases, but could be used in some simpler cases.
help me if I'm wrong!!
Thank you,

Mohammad H.

7islands December 11, 2010 00:59

Note that I said "I don't think it's a realistic option", of course only from my point of view. If you think different, just feel free to go ahead (and hopefully share your experience).


All times are GMT -4. The time now is 13:07.