surfaceNoise.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::noiseModels::surfaceNoise
28
29Description
30 Perform noise analysis on surface-based pressure data.
31
32 Input data is read from a dictionary, e.g.
33
34 \verbatim
35 // Pressure reference
36 pRef 0;
37
38 // Number of samples in sampling window, default = 2^16 (=65536)
39 N 4096;
40
41 // Lower frequency bounds
42 fl 25;
43
44 // Upper frequency bounds
45 fu 25;
46
47 // Start time
48 startTime 0;
49
50 windowModel <modelType>
51 <modelType>Coeffs
52 {
53 ...
54 }
55
56 // Input file
57 file "postProcessing/faceSource1/surface/patch/patch.case";
58 //files ("postProcessing/faceSource1/surface/patch/patch.case");
59
60 // Write interval for FFT data, default = 1
61 fftWriteInterval 100;
62
63 // Area-weighted averaging switch, default = no (ensemble) for backwards
64 // compatibility
65 areaAverage yes;
66
67 // Surface reader
68 reader ensight;
69
70 // Surface writer
71 writer ensight;
72
73 // Collate times for ensight output - ensures geometry is only written once
74 writeOptions
75 {
76 ensight
77 {
78 collateTimes true;
79 }
80
81 // Write Prmsf; default = yes
82 writePrmsf no;
83
84 // Write SPL; default = yes
85 writeSPL yes;
86
87 // Write PSD; default = yes
88 writePSD yes;
89
90 // Write PSDf; default = yes
91 writePSDf no;
92
93 // Write writeOctaves; default = yes
94 writeOctaves yes;
95 }
96
97 \endverbatim
98
99SourceFiles
100 surfaceNoise.C
101
102SeeAlso
103 noiseModel.H
104
105
106\*---------------------------------------------------------------------------*/
107
108#ifndef noiseModels_surfaceNoise_H
109#define noiseModels_surfaceNoise_H
110
111#include "noiseModel.H"
112#include "labelList.H"
113#include "scalarField.H"
114
115// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116
117namespace Foam
118{
119
120// Forward declarations
121class surfaceReader;
122class surfaceWriter;
123
124namespace noiseModels
125{
126
127/*---------------------------------------------------------------------------*\
128 Class surfaceNoise Declaration
129\*---------------------------------------------------------------------------*/
131class surfaceNoise
132:
133 public noiseModel
134{
135
136protected:
137
138 // Protected Data
139
140 //- Input file names
142
143 //- Name of pressure field
144 word pName_;
145
146 //- Index of pressure field in reader field list
147 label pIndex_;
148
149 //- Sample times
151
152 //- Time step (constant)
153 scalar deltaT_;
154
155 //- Start time index
156 label startTimeIndex_;
157
158 //- Number of surface faces
159 label nFace_;
160
161 //- Frequency data output interval, default = 1
162 // nSamples/2 data points are returned from the FFT, which can
163 // result in a very large number of output files (1 per frequency)
164 label fftWriteInterval_;
165
166 //- Apply area average; default = no (ensemble average) for backwards
167 //- compatibility
168 bool areaAverage_;
169
170 //- Reader type
172
173 //- Pointer to the surface reader
175
176 //- Pointer to the surface writer
178
179
180 // Protected Member Functions
181
182 //- Initialise
183 void initialise(const fileName& fName);
184
185 //- Read surface data
186 void readSurfaceData
187 (
188 const labelList& procFaceOffset,
189 List<scalarField>& pData
190 );
191
192 //- Write surface data to file
193 // Returns the area average value
194 scalar writeSurfaceData
195 (
196 const fileName& outDirBase,
197 const word& fName,
198 const word& title,
199 const scalar freq,
200 const scalarField& data,
201 const labelList& procFaceOffset,
202 const bool writeSurface
203 ) const;
204
205 //- Calculate the area average value
206 scalar surfaceAverage
207 (
208 const scalarField& data,
209 const labelList& procFaceOffset
210 ) const;
211
212
213public:
214
215 //- Runtime type information
216 TypeName("surfaceNoise");
217
218 //- Constructor
219 surfaceNoise(const dictionary& dict, const bool readFields = true);
220
221 //- Destructor
222 virtual ~surfaceNoise() = default;
223
224
225 // Public Member Functions
226
227 //- Read from dictionary
228 virtual bool read(const dictionary& dict);
229
230 //- Calculate
231 virtual void calculate();
232};
233
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237} // End namespace noiseModels
238} // End namespace Foam
239
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242#endif
243
244// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Base class for noise models.
Definition: noiseModel.H:176
Perform noise analysis on surface-based pressure data.
Definition: surfaceNoise.H:133
scalarList times_
Sample times.
Definition: surfaceNoise.H:149
scalar surfaceAverage(const scalarField &data, const labelList &procFaceOffset) const
Calculate the area average value.
Definition: surfaceNoise.C:372
word pName_
Name of pressure field.
Definition: surfaceNoise.H:143
void initialise(const fileName &fName)
Initialise.
Definition: surfaceNoise.C:49
TypeName("surfaceNoise")
Runtime type information.
virtual ~surfaceNoise()=default
Destructor.
scalar deltaT_
Time step (constant)
Definition: surfaceNoise.H:152
label nFace_
Number of surface faces.
Definition: surfaceNoise.H:158
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: surfaceNoise.C:470
List< fileName > inputFileNames_
Input file names.
Definition: surfaceNoise.H:140
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.
Definition: surfaceNoise.H:176
label startTimeIndex_
Start time index.
Definition: surfaceNoise.H:155
label fftWriteInterval_
Frequency data output interval, default = 1.
Definition: surfaceNoise.H:163
scalar writeSurfaceData(const fileName &outDirBase, const word &fName, const word &title, const scalar freq, const scalarField &data, const labelList &procFaceOffset, const bool writeSurface) const
Write surface data to file.
Definition: surfaceNoise.C:248
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
Definition: surfaceNoise.H:173
label pIndex_
Index of pressure field in reader field list.
Definition: surfaceNoise.H:146
void readSurfaceData(const labelList &procFaceOffset, List< scalarField > &pData)
Read surface data.
Definition: surfaceNoise.C:126
virtual void calculate()
Calculate.
Definition: surfaceNoise.C:519
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73