noiseFFT.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::noiseFFT
26 
27 Description
28  FFT of the pressure field
29 
30 SourceFiles
31  noiseFFT.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef noiseFFT_H
36 #define noiseFFT_H
37 
38 #include "scalarField.H"
39 #include "graph.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class noiseFFT Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class noiseFFT
51 :
52  public scalarField
53 {
54  // Private data
55 
56  //- Time spacing of the raw data
57  scalar deltat_;
58 
59 
60 public:
61 
62  //- Reference pressure
63  static scalar p0;
64 
65 
66  // Constructors
67 
68  //- Construct from pressure field
69  noiseFFT
70  (
71  const scalar deltat,
72  const scalarField& pressure
73  );
74 
75  //- Construct from Istream
76  noiseFFT(Istream&);
77 
78  //- Construct from pressure field file name
79  noiseFFT(const fileName& pFileName, const label skip = 0);
80 
81 
82  // Member Functions
83 
84  //- Return the graph of p(t)
85  graph pt() const;
86 
87  //- Return the nth window
88  tmp<scalarField> window(const label N, const label n) const;
89 
90  //- Return the Hanning window function
91  tmp<scalarField> Hanning(const label N) const;
92 
93  //- Return the fft of the given pressure data
94  tmp<scalarField> Pf(const tmp<scalarField>& pn) const;
95 
96  //- Return the multi-window mean fft of the complete pressure data
97  graph meanPf(const label N, const label nw) const;
98 
99  //- Return the multi-window RMS mean fft of the complete pressure data
100  graph RMSmeanPf(const label N, const label nw) const;
101 
102  //- Return the narrow-band PFL (pressure-fluctuation level) spectrum
103  graph Lf(const graph& gPf) const;
104 
105  //- Return the one-third-octave-band PFL spectrum
106  // starting at octave with mean frequency f1
107  graph Ldelta(const graph& gLf, const scalar f1, const scalar fU) const;
108 
109  //- Return the one-third-octave-band pressure spectrum
110  // starting at octave with mean frequency f1
111  graph Pdelta(const graph& gLf, const scalar f1, const scalar fU) const;
112 
113  //- Return the total PFL as the sum of Lf over all frequencies
114  scalar Lsum(const graph& gLf) const;
115 
116  //- Convert the db into Pa
117  scalar dbToPa(const scalar db) const;
118 
119  //- Convert the db-field into Pa
120  tmp<scalarField> dbToPa(const tmp<scalarField>& db) const;
121 };
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
noiseFFT(const scalar deltat, const scalarField &pressure)
Construct from pressure field.
Definition: noiseFFT.C:41
tmp< scalarField > window(const label N, const label n) const
Return the nth window.
Definition: noiseFFT.C:128
scalar fU
Definition: createFields.H:31
graph RMSmeanPf(const label N, const label nw) const
Return the multi-window RMS mean fft of the complete pressure data.
Definition: noiseFFT.C:255
graph Ldelta(const graph &gLf, const scalar f1, const scalar fU) const
Return the one-third-octave-band PFL spectrum.
Definition: noiseFFT.C:314
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
scalar f1
Definition: createFields.H:28
tmp< scalarField > Hanning(const label N) const
Return the Hanning window function.
Definition: noiseFFT.C:159
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
FFT of the pressure field.
Definition: noiseFFT.H:49
static scalar p0
Reference pressure.
Definition: noiseFFT.H:62
Namespace for OpenFOAM.
label nw
Definition: createFields.H:25
label n
graph Lf(const graph &gPf) const
Return the narrow-band PFL (pressure-fluctuation level) spectrum.
Definition: noiseFFT.C:300
label N
Definition: createFields.H:22
scalar Lsum(const graph &gLf) const
Return the total PFL as the sum of Lf over all frequencies.
Definition: noiseFFT.C:425
Class to create, store and output qgraph files.
Definition: graph.H:58
A class for handling file names.
Definition: fileName.H:69
scalar dbToPa(const scalar db) const
Convert the db into Pa.
Definition: noiseFFT.C:442
graph pt() const
Return the graph of p(t)
Definition: noiseFFT.C:108
tmp< scalarField > Pf(const tmp< scalarField > &pn) const
Return the fft of the given pressure data.
Definition: noiseFFT.C:174
graph Pdelta(const graph &gLf, const scalar f1, const scalar fU) const
Return the one-third-octave-band pressure spectrum.
Definition: noiseFFT.C:370
graph meanPf(const label N, const label nw) const
Return the multi-window mean fft of the complete pressure data.
Definition: noiseFFT.C:209
A class for managing temporary objects.
Definition: PtrList.H:118