Perform noise analysis on surface-based pressure data. More...
#include <surfaceNoise.H>


Public Member Functions | |
| TypeName ("surfaceNoise") | |
| Runtime type information. | |
| surfaceNoise (const dictionary &dict, const objectRegistry &obr, const word &name=typeName, const bool readFields=true) | |
| Constructor. | |
| virtual | ~surfaceNoise ()=default |
| Destructor. | |
| virtual bool | read (const dictionary &dict) |
| Read from dictionary. | |
| virtual void | calculate () |
| Calculate. | |
| Public Member Functions inherited from noiseModel | |
| TypeName ("noiseModel") | |
| Runtime type information. | |
| declareRunTimeSelectionTable (autoPtr, noiseModel, dictionary,(const dictionary &dict, const objectRegistry &obr),(dict, obr)) | |
| Run time selection table. | |
| noiseModel (const noiseModel &)=delete | |
| No copy construct. | |
| void | operator= (const noiseModel &)=delete |
| No copy assignment. | |
| noiseModel (const dictionary &dict, const objectRegistry &obr, const word &name, const bool readFields=true) | |
| Constructor. | |
| virtual | ~noiseModel ()=default |
| Destructor. | |
| tmp< Foam::scalarField > | PSD (const scalarField &PSDf) const |
| PSD [dB/Hz]. | |
| tmp< scalarField > | SPL (const scalarField &Prms2, const scalar f) const |
| SPL [dB]. | |
| tmp< scalarField > | SPL (const scalarField &Prms2, const scalarField &f) const |
| SPL [dB]. | |
| void | cleanFFTW () |
| Clean up the FFTW. | |
| void | writeWeightings () const |
| Helper function to check weightings. | |
| Public Member Functions inherited from writeFile | |
| writeFile (const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat") | |
| Construct from objectRegistry, prefix, fileName. | |
| writeFile (const objectRegistry &obr, const fileName &prefix, const word &name, const dictionary &dict, const bool writeToFile=true, const string &ext=".dat") | |
| Construct from objectRegistry, prefix, fileName and read options from dictionary. | |
| writeFile (const writeFile &wf) | |
| Construct copy. | |
| virtual | ~writeFile ()=default |
| Destructor. | |
| virtual const string & | setExt (const string &ext) |
| Set extension. | |
| virtual OFstream & | file () |
| Return access to the file (if only 1). | |
| virtual bool | writeToFile () const |
| Flag to allow writing to file. | |
| virtual bool | canWriteToFile () const |
| Flag to allow writing to the file. | |
| virtual bool | canResetFile () const |
| Flag to allow resetting the file. | |
| virtual bool | canWriteHeader () const |
| Flag to allow writing the header. | |
| virtual label | charWidth () const |
| Return width of character stream output. | |
| virtual void | writeCommented (Ostream &os, const string &str) const |
| Write a commented string to stream. | |
| virtual void | writeTabbed (Ostream &os, const string &str) const |
| Write a tabbed string to stream. | |
| virtual void | writeHeader (Ostream &os, const string &str) const |
| Write a commented header to stream. | |
| virtual void | writeCurrentTime (Ostream &os) const |
| Write the current time to stream. | |
| virtual void | writeBreak (Ostream &os) const |
| Write a break marker to the stream. | |
| template<class Type> | |
| void | writeHeaderValue (Ostream &os, const string &property, const Type &value) const |
| Write a (commented) header property and value pair. | |
| template<class Type> | |
| void | writeValue (Ostream &os, const Type &val) const |
| Write a given value to stream with the space delimiter. | |
Protected Member Functions | |
| void | initialise (const fileName &fName) |
| Initialise. | |
| void | readSurfaceData (const globalIndex &procFaceAddr, List< scalarField > &pData) |
| Read surface data. | |
| scalar | surfaceAverage (const scalarField &data, const globalIndex &procFaceAddr) const |
| Calculate the area average value. | |
| 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. | |
| Protected Member Functions inherited from noiseModel | |
| scalar | checkUniformTimeStep (const scalarList ×) const |
| Check and return uniform time step. | |
| bool | validateBounds (const scalarList &p) const |
| Return true if all pressure data is within min/max bounds. | |
| fileName | baseFileDir (const label dataseti) const |
| Return the base output directory. | |
| void | writeFileHeader (Ostream &os, const string &x, const string &y, const UList< Tuple2< string, token > > &headerValues=UList< Tuple2< string, token > >::null()) const |
| Write output file header. | |
| void | writeFreqDataToFile (Ostream &os, const scalarField &f, const scalarField &fx) const |
| tmp< scalarField > | uniformFrequencies (const scalar deltaT, const bool check) const |
| Create a field of equally spaced frequencies for the current set of data - assumes a constant time step. | |
| tmp< scalarField > | octaves (const scalarField &data, const scalarField &f, const labelUList &freqBandIDs) const |
| Generate octave data. | |
| tmp< scalarField > | Pf (const scalarField &p) const |
| Return the fft of the given pressure data. | |
| tmp< scalarField > | meanPf (const scalarField &p) const |
| Return the multi-window mean fft of the complete pressure data [Pa]. | |
| tmp< scalarField > | RMSmeanPf (const scalarField &p) const |
| Return the multi-window RMS mean fft of the complete pressure data [Pa]. | |
| tmp< scalarField > | PSDf (const scalarField &p, const scalar deltaT) const |
| Return the multi-window Power Spectral Density (PSD) of the complete pressure data [Pa^2/Hz]. | |
| scalar | RAf (const scalar f) const |
| A weighting function. | |
| scalar | gainA (const scalar f) const |
| A weighting as gain in dB. | |
| scalar | RBf (const scalar f) const |
| B weighting function. | |
| scalar | gainB (const scalar f) const |
| B weighting as gain in dB. | |
| scalar | RCf (const scalar f) const |
| C weighting function. | |
| scalar | gainC (const scalar f) const |
| C weighting as gain in dB. | |
| scalar | RDf (const scalar f) const |
| D weighting function. | |
| scalar | gainD (const scalar f) const |
| D weighting as gain in dB. | |
| Protected Member Functions inherited from writeFile | |
| void | initStream (Ostream &os) const |
| Initialise the output stream for writing. | |
| fileName | baseFileDir () const |
| Return the base directory for output. | |
| fileName | baseTimeDir () const |
| Return the base directory for the current time value. | |
| fileName | filePath (const fileName &fName) const |
| Return the full path for the supplied file name. | |
| virtual autoPtr< OFstream > | newFile (const fileName &fName) const |
| Return autoPtr to a new file using file name. | |
| virtual autoPtr< OFstream > | newFileAtTime (const word &name, scalar timeValue) const |
| Return autoPtr to a new file for a given time. | |
| virtual autoPtr< OFstream > | newFileAtStartTime (const word &name) const |
| Return autoPtr to a new file using the simulation start time. | |
| virtual void | resetFile (const word &name) |
| Reset internal file pointer to new file with new name. | |
| Omanip< int > | valueWidth (const label offset=0) const |
| Return the value width when writing to stream with optional offset. | |
| void | operator= (const writeFile &)=delete |
| No copy assignment. | |
| virtual autoPtr< OFstream > | createFile (const word &name, scalar timeValue) const |
| Deprecated(2022-09) Return autoPtr to a new file for a given time. | |
| virtual autoPtr< OFstream > | createFile (const word &name) const |
| Deprecated(2022-09) Return autoPtr to a new file using the simulation start time. | |
Protected Attributes | |
| List< fileName > | inputFileNames_ |
| Input file names. | |
| word | pName_ |
| Name of pressure field. | |
| label | pIndex_ |
| Index of pressure field in reader field list. | |
| scalarList | times_ |
| Sample times. | |
| scalar | deltaT_ |
| Time step (constant). | |
| label | startTimeIndex_ |
| Start time index. | |
| label | nFaces_ |
| Global number of surface faces. | |
| label | fftWriteInterval_ |
| Frequency data output interval, default = 1. | |
| bool | areaAverage_ |
| Apply area average; default = no (ensemble average) for backwards compatibility. | |
| bool | useBroadcast_ |
| Use broadcast to send entire field to sub-ranks. | |
| UPstream::commsTypes | commType_ |
| Communication type (for sending/receiving fields). | |
| word | readerType_ |
| Reader type. | |
| autoPtr< surfaceReader > | readerPtr_ |
| Pointer to the surface reader. | |
| autoPtr< surfaceWriter > | writerPtr_ |
| Pointer to the surface writer. | |
| Protected Attributes inherited from noiseModel | |
| const dictionary | dict_ |
| Copy of dictionary used for construction. | |
| scalar | rhoRef_ |
| Reference density (to convert from kinematic to static pressure). | |
| label | nSamples_ |
| Number of samples in sampling window, default = 2^16. | |
| scalar | fLower_ |
| Lower frequency limit, default = 25Hz. | |
| scalar | fUpper_ |
| Upper frequency limit, default = 10kHz. | |
| scalar | sampleFreq_ |
| Prescribed sample frequency. | |
| scalar | startTime_ |
| Start time, default = 0s. | |
| autoPtr< windowModel > | windowModelPtr_ |
| Window model. | |
| weightingType | SPLweighting_ |
| Weighting. | |
| scalar | dBRef_ |
| Reference for dB calculation, default = 2e-5. | |
| scalar | minPressure_ |
| Min pressure value. | |
| scalar | maxPressure_ |
| Min pressure value. | |
| fileName | outputPrefix_ |
| Output file prefix, default = ''. | |
| bool | writePrmsf_ |
| Write Prmsf; default = yes. | |
| bool | writeSPL_ |
| Write SPL; default = yes. | |
| bool | writePSD_ |
| Write PSD; default = yes. | |
| bool | writePSDf_ |
| Write PSDf; default = yes. | |
| bool | writeOctaves_ |
| Write writeOctaves; default = yes. | |
| planInfo | planInfo_ |
| Plan information for FFTW. | |
| Protected Attributes inherited from writeFile | |
| const objectRegistry & | fileObr_ |
| Reference to the region objectRegistry. | |
| const fileName | prefix_ |
| Prefix. | |
| word | fileName_ |
| Name of file. | |
| autoPtr< OFstream > | filePtr_ |
| File pointer. | |
| label | writePrecision_ |
| Write precision. | |
| bool | writeToFile_ |
| Flag to enable/disable writing to file. | |
| bool | updateHeader_ |
| Flag to update the header, e.g. on mesh changes. Default is true. | |
| bool | writtenHeader_ |
| Flag to identify whether the header has been written. | |
| bool | useUserTime_ |
| Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true. | |
| scalar | startTime_ |
| Start time value. | |
| string | ext_ |
| File extension; default = .dat. | |
Additional Inherited Members | |
| Public Types inherited from noiseModel | |
| enum class | weightingType { none , dBA , dBB , dBC , dBD } |
| Static Public Member Functions inherited from noiseModel | |
| static autoPtr< noiseModel > | New (const dictionary &dict, const objectRegistry &obr) |
| Selector. | |
| Static Public Attributes inherited from noiseModel | |
| static const Enum< weightingType > | weightingTypeNames_ |
| Static Public Attributes inherited from writeFile | |
| static label | addChars = 8 |
| Additional characters for writing. | |
| Static Protected Member Functions inherited from noiseModel | |
| static label | findStartTimeIndex (const instantList &allTimes, const scalar startTime) |
| Find and return start time index. | |
| static void | setOctaveBands (const scalarField &f, const scalar fLower, const scalar fUpper, const scalar octave, labelList &fBandIDs, scalarField &fCentre) |
| Return a list of the frequency indices wrt f field that correspond to the bands limits for a given octave. | |
Perform noise analysis on surface-based pressure data.
Input data is read from a dictionary, e.g.
// Pressure reference
pRef 0;
// Number of samples in sampling window, default = 2^16 (=65536)
N 4096;
// Lower frequency bounds
fl 25;
// Upper frequency bounds
fu 25;
// Start time
startTime 0;
windowModel <modelType>
<modelType>Coeffs
{
...
}
// Input file
file "postProcessing/faceSource1/surface/patch/patch.case";
//files ("postProcessing/faceSource1/surface/patch/patch.case");
// Write interval for FFT data, default = 1
fftWriteInterval 100;
// Area-weighted averaging switch, default = no (ensemble) for backwards
// compatibility
areaAverage yes;
// Surface reader
reader ensight;
// Surface writer
writer ensight; // none
// Collate times for ensight output - ensures geometry is only written once
writeOptions
{
ensight
{
collateTimes true;
}
// Write Prmsf; default = yes
writePrmsf no;
// Write SPL; default = yes
writeSPL yes;
// Write PSD; default = yes
writePSD yes;
// Write PSDf; default = yes
writePSDf no;
// Write writeOctaves; default = yes
writeOctaves yes;
}
Communication Options
| Property | Description | Type | Req'd | Dflt |
|---|---|---|---|---|
commsType | Communication type for send/receive field | word | no | scheduled |
broadcast | (Experimental) broadcast all fields | bool | no | false |
Definition at line 151 of file surfaceNoise.H.
| surfaceNoise | ( | const dictionary & | dict, |
| const objectRegistry & | obr, | ||
| const word & | name = typeName, | ||
| const bool | readFields = true ) |
Constructor.
Definition at line 421 of file surfaceNoise.C.
References areaAverage_, commType_, deltaT_, dict, fftWriteInterval_, inputFileNames_, Foam::name(), nFaces_, noiseModel::noiseModel(), pIndex_, pName_, read(), readerPtr_, readerType_, Foam::readFields(), startTimeIndex_, times_, useBroadcast_, and writerPtr_.

|
virtualdefault |
Destructor.
References dict.
|
protected |
Initialise.
Definition at line 42 of file surfaceNoise.C.
References Pstream::broadcasts(), noiseModel::checkUniformTimeStep(), deltaT_, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, writeFile::fileObr_, UList< T >::find(), instant::findStart(), forAll, Foam::Info, UPstream::master(), surfaceReader::New(), PrimitivePatch< FaceList, PointField >::nFaces(), nFaces_, pIndex_, pName_, readerPtr_, readerType_, noiseModel::sampleFreq_, UList< T >::size(), noiseModel::startTime_, startTimeIndex_, times_, noiseModel::windowModelPtr_, and UPstream::worldComm.
Referenced by calculate().


|
protected |
Read surface data.
Definition at line 125 of file surfaceNoise.C.
References Foam::average(), UPstream::broadcast, commType_, Foam::endl(), forAll, Foam::Info, globalIndex::localSize(), UPstream::master(), UPstream::msgType(), Foam::nl, UPstream::parRun(), pIndex_, globalIndex::range(), readerPtr_, List< T >::resize(), List< T >::resize_nocopy(), Foam::returnReduce(), noiseModel::rhoRef_, globalIndex::scatter(), UList< T >::size(), Field< Type >::slice(), startTimeIndex_, times_, useBroadcast_, and UPstream::worldComm.
Referenced by calculate().


|
protected |
Calculate the area average value.
Definition at line 251 of file surfaceNoise.C.
References areaAverage_, UPstream::broadcast, commType_, globalIndex::gather(), MeshedSurface< Face >::magSf(), UPstream::master(), UPstream::msgType(), nFaces_, UPstream::parRun(), readerPtr_, Foam::reduce(), Foam::sum(), and UPstream::worldComm.
Referenced by calculate(), and writeSurfaceData().


|
protected |
Write surface data to file.
Returns the area average value
Definition at line 311 of file surfaceNoise.C.
References areaAverage_, UPstream::broadcast, commType_, Foam::endl(), globalIndex::gather(), Foam::Info, MeshedSurface< Face >::magSf(), UPstream::master(), UPstream::msgType(), Foam::name(), UPstream::parRun(), PrimitivePatch< FaceList, PointField >::points(), readerPtr_, UList< T >::size(), Foam::sum(), surfaceAverage(), MeshedSurface< Face >::surfFaces(), UPstream::worldComm, and writerPtr_.
Referenced by calculate().


| TypeName | ( | "surfaceNoise" | ) |
Runtime type information.
References dict, Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, Foam::name(), and Foam::readFields().

|
virtual |
Read from dictionary.
Reimplemented from noiseModel.
Definition at line 454 of file surfaceNoise.C.
References areaAverage_, UPstream::commsTypeNames, commType_, dict, Foam::endl(), fftWriteInterval_, surfaceWriter::formatOptions(), Foam::Info, inputFileNames_, surfaceWriter::New(), Foam::nl, UPstream::parRun(), pName_, noiseModel::read(), readerType_, Foam::type(), useBroadcast_, and writerPtr_.
Referenced by surfaceNoise().


|
virtual |
Calculate.
Implements noiseModel.
Definition at line 522 of file surfaceNoise.C.
References areaAverage_, writeFile::baseFileDir(), Pstream::broadcasts(), deltaT_, UList< T >::empty(), Foam::endl(), argList::envGlobalPath(), string::expand(), fftWriteInterval_, writeFile::filePath(), filePtr, noiseModel::fLower_, forAll, noiseModel::fUpper_, Foam::Info, initialise(), inputFileNames_, fileName::isAbsolute(), MeshedSurface< Face >::magSf(), UPstream::master(), Foam::max(), Foam::min(), Switch::name(), writeFile::newFile(), nFaces_, UPstream::nProcs(), windowModel::nSamples(), noiseModel::octaves(), globalIndex::offsets(), os(), p, UPstream::parRun(), noiseModel::PSD(), noiseModel::PSDf(), readerPtr_, readSurfaceData(), globalIndex::reset(), noiseModel::RMSmeanPf(), noiseModel::setOctaveBands(), List< T >::setSize(), MeshedSurface< Face >::size(), UList< T >::size(), noiseModel::SPL(), fileName::stem(), Foam::sum(), surfaceAverage(), noiseModel::uniformFrequencies(), WarningInFunction, noiseModel::windowModelPtr_, UPstream::worldComm, noiseModel::writeFileHeader(), noiseModel::writeFreqDataToFile(), noiseModel::writeOctaves_, noiseModel::writePrmsf_, noiseModel::writePSD_, noiseModel::writePSDf_, noiseModel::writeSPL_, writeSurfaceData(), and Foam::Zero.

Input file names.
Definition at line 162 of file surfaceNoise.H.
Referenced by calculate(), read(), and surfaceNoise().
|
protected |
Name of pressure field.
Definition at line 167 of file surfaceNoise.H.
Referenced by initialise(), read(), and surfaceNoise().
|
protected |
Index of pressure field in reader field list.
Definition at line 172 of file surfaceNoise.H.
Referenced by initialise(), readSurfaceData(), and surfaceNoise().
|
protected |
Sample times.
Definition at line 177 of file surfaceNoise.H.
Referenced by initialise(), readSurfaceData(), and surfaceNoise().
|
protected |
Time step (constant).
Definition at line 182 of file surfaceNoise.H.
Referenced by calculate(), initialise(), and surfaceNoise().
|
protected |
Start time index.
Definition at line 187 of file surfaceNoise.H.
Referenced by initialise(), readSurfaceData(), and surfaceNoise().
|
protected |
Global number of surface faces.
Definition at line 192 of file surfaceNoise.H.
Referenced by calculate(), initialise(), surfaceAverage(), and surfaceNoise().
|
protected |
Frequency data output interval, default = 1.
nSamples/2 data points are returned from the FFT, which can result in a very large number of output files (1 per frequency)
Definition at line 200 of file surfaceNoise.H.
Referenced by calculate(), read(), and surfaceNoise().
|
protected |
Apply area average; default = no (ensemble average) for backwards compatibility.
Definition at line 206 of file surfaceNoise.H.
Referenced by calculate(), read(), surfaceAverage(), surfaceNoise(), and writeSurfaceData().
|
protected |
Use broadcast to send entire field to sub-ranks.
Definition at line 211 of file surfaceNoise.H.
Referenced by read(), readSurfaceData(), and surfaceNoise().
|
protected |
Communication type (for sending/receiving fields).
Definition at line 216 of file surfaceNoise.H.
Referenced by read(), readSurfaceData(), surfaceAverage(), surfaceNoise(), and writeSurfaceData().
|
protected |
Reader type.
Definition at line 221 of file surfaceNoise.H.
Referenced by initialise(), read(), and surfaceNoise().
|
mutableprotected |
Pointer to the surface reader.
Definition at line 226 of file surfaceNoise.H.
Referenced by calculate(), initialise(), readSurfaceData(), surfaceAverage(), surfaceNoise(), and writeSurfaceData().
|
mutableprotected |
Pointer to the surface writer.
Definition at line 231 of file surfaceNoise.H.
Referenced by read(), surfaceNoise(), and writeSurfaceData().