Loading...
Searching...
No Matches
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-2022 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; // none
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
99 Communication Options
100 \table
101 Property | Description | Type | Req'd | Dflt
102 commsType | Communication type for send/receive field | word | no | scheduled
103 broadcast | (Experimental) broadcast all fields | bool | no | false
104 \endtable
105
106SourceFiles
107 surfaceNoise.C
108
109SeeAlso
110 noiseModel.H
111
112\*---------------------------------------------------------------------------*/
113
114#ifndef Foam_noiseModels_surfaceNoise_H
115#define Foam_noiseModels_surfaceNoise_H
116
117#include "noiseModel.H"
118#include "scalarField.H"
119#include "UPstream.H"
120
121// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122
123namespace Foam
124{
125
126// Forward Declarations
127class globalIndex;
128class surfaceReader;
129class surfaceWriter;
130
131namespace noiseModels
132{
133
134/*---------------------------------------------------------------------------*\
135 Class surfaceNoise Declaration
136\*---------------------------------------------------------------------------*/
137
138class surfaceNoise
139:
140 public noiseModel
141{
142protected:
143
144 // Protected Data
145
146 //- Input file names
147 List<fileName> inputFileNames_;
148
149 //- Name of pressure field
150 word pName_;
152 //- Index of pressure field in reader field list
153 label pIndex_;
154
155 //- Sample times
157
158 //- Time step (constant)
159 scalar deltaT_;
160
161 //- Start time index
163
164 //- Global number of surface faces
165 label nFaces_;
166
167 //- Frequency data output interval, default = 1
168 // nSamples/2 data points are returned from the FFT, which can
169 // result in a very large number of output files (1 per frequency)
170 label fftWriteInterval_;
171
172 //- Apply area average; default = no (ensemble average) for backwards
173 //- compatibility
174 bool areaAverage_;
175
176 //- Use broadcast to send entire field to sub-ranks
178
179 //- Communication type (for sending/receiving fields)
181
182 //- Reader type
184
185 //- Pointer to the surface reader
188 //- Pointer to the surface writer
190
191
192 // Protected Member Functions
193
194 //- Initialise
195 void initialise(const fileName& fName);
196
197 //- Read surface data
198 void readSurfaceData
199 (
200 const globalIndex& procFaceAddr,
201 List<scalarField>& pData
202 );
203
204 //- Calculate the area average value
205 scalar surfaceAverage
207 const scalarField& data,
208 const globalIndex& procFaceAddr
209 ) const;
210
211 //- Write surface data to file
212 // Returns the area average value
213 scalar writeSurfaceData
214 (
215 const fileName& outDirBase,
216 const word& fName,
217 const word& title,
218 const scalar freq,
219 const scalarField& data,
220 const globalIndex& procFaceAddr,
221 const bool writeSurface
222 ) const;
223
224
225public:
227 //- Runtime type information
228 TypeName("surfaceNoise");
229
230
231 //- Constructor
233 (
234 const dictionary& dict,
235 const objectRegistry& obr,
236 const word& name = typeName,
237 const bool readFields = true
238 );
239
240 //- Destructor
241 virtual ~surfaceNoise() = default;
242
243
244 // Public Member Functions
245
246 //- Read from dictionary
247 virtual bool read(const dictionary& dict);
248
249 //- Calculate
250 virtual void calculate();
251};
252
253
254// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255
256} // End namespace noiseModels
257} // End namespace Foam
258
259// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260
261#endif
262
263// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
commsTypes
Communications types.
Definition UPstream.H:81
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Definition globalIndex.H:77
noiseModel(const noiseModel &)=delete
No copy construct.
Perform noise analysis on surface-based pressure data.
scalarList times_
Sample times.
word pName_
Name of pressure field.
void initialise(const fileName &fName)
Initialise.
label nFaces_
Global number of surface faces.
TypeName("surfaceNoise")
Runtime type information.
surfaceNoise(const dictionary &dict, const objectRegistry &obr, const word &name=typeName, const bool readFields=true)
Constructor.
scalar surfaceAverage(const scalarField &data, const globalIndex &procFaceAddr) const
Calculate the area average value.
virtual ~surfaceNoise()=default
Destructor.
scalar deltaT_
Time step (constant).
virtual bool read(const dictionary &dict)
Read from dictionary.
List< fileName > inputFileNames_
Input file names.
UPstream::commsTypes commType_
Communication type (for sending/receiving fields).
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.
bool useBroadcast_
Use broadcast to send entire field to sub-ranks.
label startTimeIndex_
Start time index.
label fftWriteInterval_
Frequency data output interval, default = 1.
void readSurfaceData(const globalIndex &procFaceAddr, List< scalarField > &pData)
Read surface data.
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
bool areaAverage_
Apply area average; default = no (ensemble average) for backwards compatibility.
label pIndex_
Index of pressure field in reader field list.
scalar writeSurfaceData(const fileName &outDirBase, const word &fName, const word &title, const scalar freq, const scalarField &data, const globalIndex &procFaceAddr, const bool writeSurface) const
Write surface data to file.
virtual void calculate()
Calculate.
Registry of regIOobjects.
Abstract base class for surface readers with fields.
Base class for surface writers.
A class for handling words, derived from Foam::string.
Definition word.H:66
Namespace for OpenFOAM.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68