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-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::noiseModels::surfaceNoise
28 
29 Description
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  // Surface reader
64  reader ensight;
65 
66  // Surface writer
67  writer ensight;
68 
69  // Collate times for ensight output - ensures geometry is only written once
70  writeOptions
71  {
72  ensight
73  {
74  collateTimes true;
75  }
76 
77  // Write Prmsf; default = yes
78  writePrmsf no;
79 
80  // Write SPL; default = yes
81  writeSPL yes;
82 
83  // Write PSD; default = yes
84  writePSD yes;
85 
86  // Write PSDf; default = yes
87  writePSDf no;
88 
89  // Write writeOctaves; default = yes
90  writeOctaves yes;
91  }
92 
93  \endverbatim
94 
95 SourceFiles
96  surfaceNoise.C
97 
98 SeeAlso
99  noiseModel.H
100 
101 
102 \*---------------------------------------------------------------------------*/
103 
104 #ifndef noiseModels_surfaceNoise_H
105 #define noiseModels_surfaceNoise_H
106 
107 #include "noiseModel.H"
108 #include "labelList.H"
109 #include "scalarField.H"
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 namespace Foam
114 {
115 
116 // Forward declarations
117 class surfaceReader;
118 class surfaceWriter;
119 
120 namespace noiseModels
121 {
122 
123 /*---------------------------------------------------------------------------*\
124  Class surfaceNoise Declaration
125 \*---------------------------------------------------------------------------*/
126 
127 class surfaceNoise
128 :
129  public noiseModel
130 {
131 
132 protected:
133 
134  // Protected Data
135 
136  //- Input file names
138 
139  //- Name of pressure field
140  word pName_;
141 
142  //- Index of pressure field in reader field list
143  label pIndex_;
144 
145  //- Sample times
147 
148  //- Time step (constant)
149  scalar deltaT_;
150 
151  //- Start time index
152  label startTimeIndex_;
153 
154  //- Number of surface faces
155  label nFace_;
156 
157  //- Frequency data output interval, default = 1
158  // nSamples/2 data points are returned from the FFT, which can
159  // result in a very large number of output files (1 per frequency)
160  label fftWriteInterval_;
161 
162  //- Reader type
164 
165  //- Pointer to the surface reader
167 
168  //- Pointer to the surface writer
170 
171 
172  // Protected Member Functions
173 
174  //- Initialise
175  void initialise(const fileName& fName);
176 
177  //- Read surface data
178  void readSurfaceData
179  (
180  const labelList& procFaceOffset,
181  List<scalarField>& pData
182  );
183 
184  //- Write surface data to file
185  // Returns the area average value
186  scalar writeSurfaceData
187  (
188  const fileName& outDirBase,
189  const word& fName,
190  const word& title,
191  const scalar freq,
192  const scalarField& data,
193  const labelList& procFaceOffset,
194  const bool writeSurface
195  ) const;
196 
197  //- Calculate the area average value
198  scalar surfaceAverage
199  (
200  const scalarField& data,
201  const labelList& procFaceOffset
202  ) const;
203 
204 
205 public:
206 
207  //- Runtime type information
208  TypeName("surfaceNoise");
209 
210  //- Constructor
211  surfaceNoise(const dictionary& dict, const bool readFields = true);
212 
213  //- Destructor
214  virtual ~surfaceNoise() = default;
215 
216 
217  // Public Member Functions
218 
219  //- Read from dictionary
220  virtual bool read(const dictionary& dict);
221 
222  //- Calculate
223  virtual void calculate();
224 };
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace noiseModels
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
Foam::noiseModels::surfaceNoise::nFace_
label nFace_
Number of surface faces.
Definition: surfaceNoise.H:154
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::noiseModel
Base class for noise models.
Definition: noiseModel.H:169
scalarField.H
Foam::noiseModels::surfaceNoise::times_
scalarList times_
Sample times.
Definition: surfaceNoise.H:145
Foam::noiseModels::surfaceNoise::pIndex_
label pIndex_
Index of pressure field in reader field list.
Definition: surfaceNoise.H:142
Foam::noiseModels::surfaceNoise::calculate
virtual void calculate()
Calculate.
Definition: surfaceNoise.C:475
Foam::noiseModels::surfaceNoise::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: surfaceNoise.C:442
Foam::noiseModels::surfaceNoise::pName_
word pName_
Name of pressure field.
Definition: surfaceNoise.H:139
noiseModel.H
Foam::noiseModels::surfaceNoise::surfaceNoise
surfaceNoise(const dictionary &dict, const bool readFields=true)
Constructor.
Definition: surfaceNoise.C:418
Foam::noiseModels::surfaceNoise::deltaT_
scalar deltaT_
Time step (constant)
Definition: surfaceNoise.H:148
labelList.H
Foam::Field< scalar >
Foam::noiseModels::surfaceNoise::~surfaceNoise
virtual ~surfaceNoise()=default
Destructor.
Foam::noiseModels::surfaceNoise::startTimeIndex_
label startTimeIndex_
Start time index.
Definition: surfaceNoise.H:151
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::noiseModels::surfaceNoise::writeSurfaceData
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:241
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::noiseModels::surfaceNoise::fftWriteInterval_
label fftWriteInterval_
Frequency data output interval, default = 1.
Definition: surfaceNoise.H:159
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::noiseModels::surfaceNoise::readerPtr_
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
Definition: surfaceNoise.H:165
Foam::noiseModels::surfaceNoise::readerType_
word readerType_
Reader type.
Definition: surfaceNoise.H:162
Foam::List< fileName >
Foam::noiseModels::surfaceNoise
Perform noise analysis on surface-based pressure data.
Definition: surfaceNoise.H:126
Foam::noiseModels::surfaceNoise::readSurfaceData
void readSurfaceData(const labelList &procFaceOffset, List< scalarField > &pData)
Read surface data.
Definition: surfaceNoise.C:118
Foam::noiseModels::surfaceNoise::initialise
void initialise(const fileName &fName)
Initialise.
Definition: surfaceNoise.C:49
Foam::noiseModels::surfaceNoise::inputFileNames_
List< fileName > inputFileNames_
Input file names.
Definition: surfaceNoise.H:136
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
Foam::noiseModels::surfaceNoise::surfaceAverage
scalar surfaceAverage(const scalarField &data, const labelList &procFaceOffset) const
Calculate the area average value.
Definition: surfaceNoise.C:353
Foam::noiseModels::surfaceNoise::writerPtr_
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.
Definition: surfaceNoise.H:168
Foam::noiseModels::surfaceNoise::TypeName
TypeName("surfaceNoise")
Runtime type information.