Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
surfaceNoise Class Reference

Perform noise analysis on surface-based pressure data. More...

Inheritance diagram for surfaceNoise:
Inheritance graph
[legend]
Collaboration diagram for surfaceNoise:
Collaboration graph
[legend]

Public Member Functions

 TypeName ("surfaceNoise")
 Runtime type information. More...
 
 surfaceNoise (const dictionary &dict, const objectRegistry &obr, const word &name=typeName, const bool readFields=true)
 Constructor. More...
 
virtual ~surfaceNoise ()=default
 Destructor. More...
 
virtual bool read (const dictionary &dict)
 Read from dictionary. More...
 
virtual void calculate ()
 Calculate. More...
 
- Public Member Functions inherited from noiseModel
 TypeName ("noiseModel")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, noiseModel, dictionary,(const dictionary &dict, const objectRegistry &obr),(dict, obr))
 Run time selection table. More...
 
 noiseModel (const noiseModel &)=delete
 No copy construct. More...
 
void operator= (const noiseModel &)=delete
 No copy assignment. More...
 
 noiseModel (const dictionary &dict, const objectRegistry &obr, const word &name, const bool readFields=true)
 Constructor. More...
 
virtual ~noiseModel ()=default
 Destructor. More...
 
tmp< Foam::scalarFieldPSD (const scalarField &PSDf) const
 PSD [dB/Hz]. More...
 
tmp< scalarFieldSPL (const scalarField &Prms2, const scalar f) const
 SPL [dB]. More...
 
tmp< scalarFieldSPL (const scalarField &Prms2, const scalarField &f) const
 SPL [dB]. More...
 
void cleanFFTW ()
 Clean up the FFTW. More...
 
void writeWeightings () const
 Helper function to check weightings. More...
 
- Public Member Functions inherited from writeFile
 writeFile (const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true)
 Construct from objectRegistry, prefix, fileName. More...
 
 writeFile (const objectRegistry &obr, const fileName &prefix, const word &name, const dictionary &dict, const bool writeToFile=true)
 Construct from objectRegistry, prefix, fileName and read options from dictionary. More...
 
 writeFile (const writeFile &wf)
 Construct copy. More...
 
virtual ~writeFile ()=default
 Destructor. More...
 
virtual OFstreamfile ()
 Return access to the file (if only 1) More...
 
virtual bool writeToFile () const
 Flag to allow writing to file. More...
 
virtual bool canWriteToFile () const
 Flag to allow writing to the file. More...
 
virtual bool canResetFile () const
 Flag to allow resetting the file. More...
 
virtual bool canWriteHeader () const
 Flag to allow writing the header. More...
 
virtual label charWidth () const
 Return width of character stream output. More...
 
virtual void writeCommented (Ostream &os, const string &str) const
 Write a commented string to stream. More...
 
virtual void writeTabbed (Ostream &os, const string &str) const
 Write a tabbed string to stream. More...
 
virtual void writeHeader (Ostream &os, const string &str) const
 Write a commented header to stream. More...
 
virtual void writeCurrentTime (Ostream &os) const
 Write the current time to stream. More...
 
virtual void writeBreak (Ostream &os) const
 Write a break marker to the stream. More...
 
template<class Type >
void writeHeaderValue (Ostream &os, const string &property, const Type &value) const
 Write a (commented) header property and value pair. More...
 
template<class Type >
void writeValue (Ostream &os, const Type &val) const
 Write a given value to stream with the space delimiter. More...
 

Protected Member Functions

void initialise (const fileName &fName)
 Initialise. More...
 
void readSurfaceData (const globalIndex &procFaceAddr, List< scalarField > &pData)
 Read surface data. More...
 
scalar surfaceAverage (const scalarField &data, const globalIndex &procFaceAddr) const
 Calculate the area average value. More...
 
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. More...
 
- Protected Member Functions inherited from noiseModel
scalar checkUniformTimeStep (const scalarList &times) const
 Check and return uniform time step. More...
 
bool validateBounds (const scalarList &p) const
 Return true if all pressure data is within min/max bounds. More...
 
fileName baseFileDir (const label dataseti) const
 Return the base output directory. More...
 
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. More...
 
void writeFreqDataToFile (Ostream &os, const scalarField &f, const scalarField &fx) const
 
tmp< scalarFielduniformFrequencies (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. More...
 
tmp< scalarFieldoctaves (const scalarField &data, const scalarField &f, const labelUList &freqBandIDs) const
 Generate octave data. More...
 
tmp< scalarFieldPf (const scalarField &p) const
 Return the fft of the given pressure data. More...
 
tmp< scalarFieldmeanPf (const scalarField &p) const
 Return the multi-window mean fft of the complete pressure data [Pa]. More...
 
tmp< scalarFieldRMSmeanPf (const scalarField &p) const
 Return the multi-window RMS mean fft of the complete pressure data [Pa]. More...
 
tmp< scalarFieldPSDf (const scalarField &p, const scalar deltaT) const
 Return the multi-window Power Spectral Density (PSD) of the complete pressure data [Pa^2/Hz]. More...
 
scalar RAf (const scalar f) const
 A weighting function. More...
 
scalar gainA (const scalar f) const
 A weighting as gain in dB. More...
 
scalar RBf (const scalar f) const
 B weighting function. More...
 
scalar gainB (const scalar f) const
 B weighting as gain in dB. More...
 
scalar RCf (const scalar f) const
 C weighting function. More...
 
scalar gainC (const scalar f) const
 C weighting as gain in dB. More...
 
scalar RDf (const scalar f) const
 D weighting function. More...
 
scalar gainD (const scalar f) const
 D weighting as gain in dB. More...
 
- Protected Member Functions inherited from writeFile
void initStream (Ostream &os) const
 Initialise the output stream for writing. More...
 
fileName baseFileDir () const
 Return the base directory for output. More...
 
fileName baseTimeDir () const
 Return the base directory for the current time value. More...
 
fileName filePath (const fileName &fName) const
 Return the full path for the supplied file name. More...
 
virtual autoPtr< OFstreamnewFile (const fileName &fName) const
 Return autoPtr to a new file using file name. More...
 
virtual autoPtr< OFstreamnewFileAtTime (const word &name, scalar timeValue) const
 Return autoPtr to a new file for a given time. More...
 
virtual autoPtr< OFstreamnewFileAtStartTime (const word &name) const
 Return autoPtr to a new file using the simulation start time. More...
 
virtual void resetFile (const word &name)
 Reset internal file pointer to new file with new name. More...
 
Omanip< int > valueWidth (const label offset=0) const
 Return the value width when writing to stream with optional offset. More...
 
void operator= (const writeFile &)=delete
 No copy assignment. More...
 
virtual autoPtr< OFstreamcreateFile (const word &name, scalar timeValue) const
 Deprecated(2022-09) Return autoPtr to a new file for a given time. More...
 
virtual autoPtr< OFstreamcreateFile (const word &name) const
 Deprecated(2022-09) Return autoPtr to a new file using the simulation start time. More...
 

Protected Attributes

List< fileNameinputFileNames_
 Input file names. More...
 
word pName_
 Name of pressure field. More...
 
label pIndex_
 Index of pressure field in reader field list. More...
 
scalarList times_
 Sample times. More...
 
scalar deltaT_
 Time step (constant) More...
 
label startTimeIndex_
 Start time index. More...
 
label nFaces_
 Global number of surface faces. More...
 
label fftWriteInterval_
 Frequency data output interval, default = 1. More...
 
bool areaAverage_
 Apply area average; default = no (ensemble average) for backwards compatibility. More...
 
bool useBroadcast_
 Use broadcast to send entire field to sub-ranks. More...
 
UPstream::commsTypes commType_
 Communication type (for sending/receiving fields) More...
 
word readerType_
 Reader type. More...
 
autoPtr< surfaceReaderreaderPtr_
 Pointer to the surface reader. More...
 
autoPtr< surfaceWriterwriterPtr_
 Pointer to the surface writer. More...
 
- Protected Attributes inherited from noiseModel
const dictionary dict_
 Copy of dictionary used for construction. More...
 
scalar rhoRef_
 Reference density (to convert from kinematic to static pressure) More...
 
label nSamples_
 Number of samples in sampling window, default = 2^16. More...
 
scalar fLower_
 Lower frequency limit, default = 25Hz. More...
 
scalar fUpper_
 Upper frequency limit, default = 10kHz. More...
 
scalar startTime_
 Start time, default = 0s. More...
 
autoPtr< windowModelwindowModelPtr_
 Window model. More...
 
weightingType SPLweighting_
 Weighting. More...
 
scalar dBRef_
 Reference for dB calculation, default = 2e-5. More...
 
scalar minPressure_
 Min pressure value. More...
 
scalar maxPressure_
 Min pressure value. More...
 
fileName outputPrefix_
 Output file prefix, default = ''. More...
 
bool writePrmsf_
 Write Prmsf; default = yes. More...
 
bool writeSPL_
 Write SPL; default = yes. More...
 
bool writePSD_
 Write PSD; default = yes. More...
 
bool writePSDf_
 Write PSDf; default = yes. More...
 
bool writeOctaves_
 Write writeOctaves; default = yes. More...
 
planInfo planInfo_
 Plan information for FFTW. More...
 
- Protected Attributes inherited from writeFile
const objectRegistryfileObr_
 Reference to the region objectRegistry. More...
 
const fileName prefix_
 Prefix. More...
 
word fileName_
 Name of file. More...
 
autoPtr< OFstreamfilePtr_
 File pointer. More...
 
label writePrecision_
 Write precision. More...
 
bool writeToFile_
 Flag to enable/disable writing to file. More...
 
bool updateHeader_
 Flag to update the header, e.g. on mesh changes. Default is true. More...
 
bool writtenHeader_
 Flag to identify whether the header has been written. More...
 
bool useUserTime_
 Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true. More...
 
scalar startTime_
 Start time value. More...
 

Additional Inherited Members

- Public Types inherited from noiseModel
enum  weightingType {
  none, dBA, dBB, dBC,
  dBD
}
 
- Static Public Member Functions inherited from noiseModel
static autoPtr< noiseModelNew (const dictionary &dict, const objectRegistry &obr)
 Selector. More...
 
- Static Public Attributes inherited from noiseModel
static const Enum< weightingTypeweightingTypeNames_
 
- Static Public Attributes inherited from writeFile
static label addChars = 8
 Additional characters for writing. More...
 
- Static Protected Member Functions inherited from noiseModel
static label findStartTimeIndex (const instantList &allTimes, const scalar startTime)
 Find and return start time index. More...
 
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. More...
 

Detailed Description

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
Source files
See also
noiseModel.H

Definition at line 151 of file surfaceNoise.H.

Constructor & Destructor Documentation

◆ surfaceNoise()

surfaceNoise ( const dictionary dict,
const objectRegistry obr,
const word name = typeName,
const bool  readFields = true 
)

Constructor.

Definition at line 422 of file surfaceNoise.C.

References dict, Foam::read(), and Foam::readFields().

Here is the call graph for this function:

◆ ~surfaceNoise()

virtual ~surfaceNoise ( )
virtualdefault

Destructor.

Member Function Documentation

◆ initialise()

void initialise ( const fileName fName)
protected

◆ readSurfaceData()

void readSurfaceData ( const globalIndex procFaceAddr,
List< scalarField > &  pData 
)
protected

◆ surfaceAverage()

scalar surfaceAverage ( const scalarField data,
const globalIndex procFaceAddr 
) const
protected

Calculate the area average value.

Definition at line 246 of file surfaceNoise.C.

References Pstream::broadcast(), globalIndex::gather(), MeshedSurface< Face >::magSf(), UPstream::master(), UPstream::msgType(), UPstream::parRun(), Foam::reduce(), Foam::sum(), and UPstream::worldComm.

Referenced by surfaceNoise::calculate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeSurfaceData()

scalar writeSurfaceData ( const fileName outDirBase,
const word fName,
const word title,
const scalar  freq,
const scalarField data,
const globalIndex procFaceAddr,
const bool  writeSurface 
) const
protected

Write surface data to file.

Returns the area average value

Definition at line 309 of file surfaceNoise.C.

References Pstream::broadcast(), Foam::endl(), globalIndex::gather(), Foam::Info, MeshedSurface< Face >::magSf(), UPstream::master(), UPstream::msgType(), Foam::name(), UPstream::parRun(), PrimitivePatch< FaceList, PointField >::points(), UList< T >::size(), Foam::sum(), MeshedSurface< Face >::surfFaces(), and UPstream::worldComm.

Referenced by surfaceNoise::calculate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TypeName()

TypeName ( "surfaceNoise"  )

Runtime type information.

◆ read()

bool read ( const dictionary dict)
virtual

◆ calculate()

void calculate ( )
virtual

Member Data Documentation

◆ inputFileNames_

List<fileName> inputFileNames_
protected

Input file names.

Definition at line 162 of file surfaceNoise.H.

Referenced by surfaceNoise::calculate(), and surfaceNoise::read().

◆ pName_

word pName_
protected

Name of pressure field.

Definition at line 167 of file surfaceNoise.H.

Referenced by surfaceNoise::initialise(), and surfaceNoise::read().

◆ pIndex_

label pIndex_
protected

Index of pressure field in reader field list.

Definition at line 172 of file surfaceNoise.H.

Referenced by surfaceNoise::initialise().

◆ times_

scalarList times_
protected

Sample times.

Definition at line 177 of file surfaceNoise.H.

Referenced by surfaceNoise::initialise().

◆ deltaT_

scalar deltaT_
protected

Time step (constant)

Definition at line 182 of file surfaceNoise.H.

Referenced by surfaceNoise::calculate(), and surfaceNoise::initialise().

◆ startTimeIndex_

label startTimeIndex_
protected

Start time index.

Definition at line 187 of file surfaceNoise.H.

Referenced by surfaceNoise::initialise().

◆ nFaces_

label nFaces_
protected

Global number of surface faces.

Definition at line 192 of file surfaceNoise.H.

Referenced by surfaceNoise::calculate(), and surfaceNoise::initialise().

◆ fftWriteInterval_

label fftWriteInterval_
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 surfaceNoise::calculate(), and surfaceNoise::read().

◆ areaAverage_

bool areaAverage_
protected

Apply area average; default = no (ensemble average) for backwards compatibility.

Definition at line 206 of file surfaceNoise.H.

Referenced by surfaceNoise::calculate(), and surfaceNoise::read().

◆ useBroadcast_

bool useBroadcast_
protected

Use broadcast to send entire field to sub-ranks.

Definition at line 211 of file surfaceNoise.H.

Referenced by surfaceNoise::read().

◆ commType_

UPstream::commsTypes commType_
protected

Communication type (for sending/receiving fields)

Definition at line 216 of file surfaceNoise.H.

Referenced by surfaceNoise::read().

◆ readerType_

word readerType_
protected

Reader type.

Definition at line 221 of file surfaceNoise.H.

Referenced by surfaceNoise::initialise(), and surfaceNoise::read().

◆ readerPtr_

autoPtr<surfaceReader> readerPtr_
mutableprotected

Pointer to the surface reader.

Definition at line 226 of file surfaceNoise.H.

Referenced by surfaceNoise::calculate(), and surfaceNoise::initialise().

◆ writerPtr_

autoPtr<surfaceWriter> writerPtr_
mutableprotected

Pointer to the surface writer.

Definition at line 231 of file surfaceNoise.H.

Referenced by surfaceNoise::read().


The documentation for this class was generated from the following files: