noiseModel.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-2018 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::noiseModel
28 
29 Description
30  Base class for noise models.
31 
32  Data is read from a dictionary, e.g.
33 
34  \verbatim
35  rhoRef 0;
36  N 4096;
37  fl 25;
38  fu 25;
39  startTime 0;
40 
41  outputPrefix "test1";
42 
43  // Optional write options dictionary
44  writeOptions
45  {
46  writePrmsf no;
47  writeSPL yes;
48  writePSD yes;
49  writePSDf no;
50  writeOctaves yes;
51  }
52  \endverbatim
53 
54  where
55  \table
56  Property | Description | Required | Default value
57  rhoRef | Reference density | no | 1
58  N | Number of samples in sampling window | no | 65536 (2^16)
59  fl | Lower frequency bounds | no | 25
60  fu | Upper frequency bounds | no | 10000
61  startTime | Start time | no | 0
62  outputPrefix | Prefix applied to output files| no | ''
63  graphFormat | Graph format | no | raw
64  writePrmsf | Write Prmsf data | no | yes
65  writeSPL | Write SPL data | no | yes
66  writePSD | Write PSD data | no | yes
67  writePSDf | Write PSDf data | no | yes
68  writeOctaves | Write octaves data | no | yes
69  \endtable
70 
71 SourceFiles
72  noiseModel.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef noiseModel_H
77 #define noiseModel_H
78 
79 #include "dictionary.H"
80 #include "scalarList.H"
81 #include "instantList.H"
82 #include "windowModel.H"
83 #include "runTimeSelectionTables.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 
90 /*---------------------------------------------------------------------------*\
91  Class noiseModel Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 class noiseModel
95 {
96 protected:
97 
98  // Protected Data
99 
100  //- Copy of dictionary used for construction
101  const dictionary dict_;
102 
103  //- Reference density (to convert from kinematic to static pressure)
104  scalar rhoRef_;
105 
106  //- Number of samples in sampling window, default = 2^16
107  label nSamples_;
108 
109  //- Lower frequency limit, default = 25Hz
110  scalar fLower_;
111 
112  //- Upper frequency limit, default = 10kHz
113  scalar fUpper_;
114 
115  //- Flag to indicate that custom frequency bounds are being used
116  bool customBounds_;
117 
118  //- Start time, default = 0s
119  scalar startTime_;
120 
121  //- Window model
122  autoPtr<windowModel> windowModelPtr_;
123 
124  //- Graph format
125  word graphFormat_;
126 
127 
128  // Data validation
129 
130  //- Min pressure value
131  scalar minPressure_;
132 
133  //- Min pressure value
134  scalar maxPressure_;
135 
136 
137  // Write options
138 
139  //- Output file prefix, default = ''
140  fileName outputPrefix_;
141 
142  //- Write Prmsf; default = yes
143  bool writePrmsf_;
144 
145  //- Write SPL; default = yes
146  bool writeSPL_;
147 
148  //- Write PSD; default = yes
149  bool writePSD_;
150 
151  //- Write PSDf; default = yes
152  bool writePSDf_;
153 
154  //- Write writeOctaves; default = yes
155  bool writeOctaves_;
156 
157 
158  // Protected Member Functions
159 
160  //- Helper function to read write options and provide info feedback
161  void readWriteOption
162  (
163  const dictionary& dict,
164  const word& lookup,
165  bool& option
166  ) const;
167 
168  //- Check and return uniform time step
169  scalar checkUniformTimeStep
170  (
171  const scalarList& times
172  ) const;
173 
174  //- Return true if all pressure data is within min/max bounds
175  bool validateBounds(const scalarList& p) const;
176 
177  //- Find and return start time index
178  label findStartTimeIndex
179  (
180  const instantList& allTimes,
181  const scalar startTime
182  ) const;
183 
184  //- Return the base output directory
185  fileName baseFileDir(const label dataseti) const;
186 
187 
188  //- No copy construct
189  noiseModel(const noiseModel&) = delete;
190 
191  //- No copy assignment
192  void operator=(const noiseModel&) = delete;
193 
194 
195 public:
196 
197  //- Runtime type information
198  TypeName("noiseModel");
199 
200  //- Run time selection table
202  (
203  autoPtr,
205  dictionary,
206  (
208  ),
209  (dict)
210  );
211 
212  //- Selector
214 
215  //- Constructor
216  noiseModel(const dictionary& dict, const bool readFields = true);
217 
218  //- Destructor
219  virtual ~noiseModel() = default;
220 
221 
222  // Public Member Functions
223 
224  //- Read from dictionary
225  virtual bool read(const dictionary& dict);
226 
227  //- Abstract call to calculate
228  virtual void calculate() = 0;
229 };
230 
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
Foam::noiseModel::~noiseModel
virtual ~noiseModel()=default
Destructor.
instantList.H
Foam::noiseModel::checkUniformTimeStep
scalar checkUniformTimeStep(const scalarList &times) const
Check and return uniform time step.
Definition: noiseModel.C:66
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::noiseModel::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: noiseModel.C:189
Foam::noiseModel::readWriteOption
void readWriteOption(const dictionary &dict, const word &lookup, bool &option) const
Helper function to read write options and provide info feedback.
Definition: noiseModel.C:43
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:158
Foam::noiseModel::calculate
virtual void calculate()=0
Abstract call to calculate.
Foam::noiseModel::fUpper_
scalar fUpper_
Upper frequency limit, default = 10kHz.
Definition: noiseModel.H:177
Foam::noiseModel::noiseModel
noiseModel(const noiseModel &)=delete
No copy construct.
windowModel.H
Foam::noiseModel::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, noiseModel, dictionary,(const dictionary &dict),(dict))
Run time selection table.
Foam::noiseModel::findStartTimeIndex
label findStartTimeIndex(const instantList &allTimes, const scalar startTime) const
Find and return start time index.
Definition: noiseModel.C:125
Foam::noiseModel::fLower_
scalar fLower_
Lower frequency limit, default = 25Hz.
Definition: noiseModel.H:174
scalarList.H
Foam::noiseModel::minPressure_
scalar minPressure_
Min pressure value.
Definition: noiseModel.H:195
Foam::noiseModel::dict_
const dictionary dict_
Copy of dictionary used for construction.
Definition: noiseModel.H:165
Foam::noiseModel::customBounds_
bool customBounds_
Flag to indicate that custom frequency bounds are being used.
Definition: noiseModel.H:180
Foam::noiseModel::rhoRef_
scalar rhoRef_
Reference density (to convert from kinematic to static pressure)
Definition: noiseModel.H:168
Foam::noiseModel::New
static autoPtr< noiseModel > New(const dictionary &dict)
Selector.
Definition: noiseModelNew.C:32
Foam::noiseModel::windowModelPtr_
autoPtr< windowModel > windowModelPtr_
Window model.
Definition: noiseModel.H:186
Foam::noiseModel::writeOctaves_
bool writeOctaves_
Write writeOctaves; default = yes.
Definition: noiseModel.H:219
Foam::noiseModel::operator=
void operator=(const noiseModel &)=delete
No copy assignment.
Foam::noiseModel::startTime_
scalar startTime_
Start time, default = 0s.
Definition: noiseModel.H:183
Foam::noiseModel::writePSD_
bool writePSD_
Write PSD; default = yes.
Definition: noiseModel.H:213
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:63
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::noiseModel::validateBounds
bool validateBounds(const scalarList &p) const
Return true if all pressure data is within min/max bounds.
Definition: noiseModel.C:102
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::noiseModel::maxPressure_
scalar maxPressure_
Min pressure value.
Definition: noiseModel.H:198
Foam::noiseModel::writePSDf_
bool writePSDf_
Write PSDf; default = yes.
Definition: noiseModel.H:216
Foam::noiseModel::writePrmsf_
bool writePrmsf_
Write Prmsf; default = yes.
Definition: noiseModel.H:207
Foam::noiseModel::outputPrefix_
fileName outputPrefix_
Output file prefix, default = ''.
Definition: noiseModel.H:204
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::noiseModel::TypeName
TypeName("noiseModel")
Runtime type information.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::List< scalar >
Foam::noiseModel::baseFileDir
fileName baseFileDir(const label dataseti) const
Return the base output directory.
Definition: noiseModel.C:144
dictionary.H
startTime
Foam::label startTime
Definition: checkTimeOptions.H:1
Foam::noiseModel::graphFormat_
word graphFormat_
Graph format.
Definition: noiseModel.H:189
Foam::noiseModel::writeSPL_
bool writeSPL_
Write SPL; default = yes.
Definition: noiseModel.H:210
Foam::noiseModel::nSamples_
label nSamples_
Number of samples in sampling window, default = 2^16.
Definition: noiseModel.H:171