Go to the documentation of this file.
51 Info<<
"Reading data file " << fName <<
endl;
53 label nAvailableTimes = 0;
67 <<
"Unable to find pressure field name " <<
pName_
68 <<
" in list of available fields: " <<
fieldNames
128 Info <<
"Reading pressure data" <<
endl;
142 const label nLocalFace =
143 procFaceOffset[myProcI + 1] - procFaceOffset[myProcI];
147 const label nTimes = times_.size();
160 label timeI = i + startTimeIndex_;
162 Info<<
" time: " << times_[i] <<
endl;
165 scalarField p(readerPtr_->field(timeI, pIndex_, scalar(0)));
173 label face0 = procFaceOffset[procI];
175 procFaceOffset[procI + 1] - procFaceOffset[procI];
178 toProc << SubList<scalar>(
p, nLocalFace, face0);
191 pData[faceI][i] = pSlice[faceI];
197 pData[faceI] -=
average(pData[faceI]);
202 const label nLocalFace = procFaceOffset[0];
207 pf.setSize(times_.size());
212 label timeI = i + startTimeIndex_;
214 Info<<
" time: " << times_[i] <<
endl;
215 scalarField p(readerPtr_->field(timeI, pIndex_, scalar(0)));
222 pData[faceI][i] =
p[faceI];
228 pData[faceI] -=
average(pData[faceI]);
234 <<
" pressure traces with "
236 <<
" time values" <<
nl <<
endl;
248 const bool writeSurface
251 Info<<
" processing " << title <<
" for frequency " << freq <<
endl;
269 scalar areaAverage = 0;
280 allData[faceI] =
data[faceI];
289 label faceI = procFaceOffset[procI] + i;
290 allData[faceI] = dataSlice[i];
297 writerPtr_->beginTime(freqInst);
303 (outDirBase / fName),
307 writerPtr_->nFields(1);
308 writerPtr_->write(title, allData);
310 writerPtr_->endTime();
320 areaAverage =
sum(allData)/(allData.size() + ROOTVSMALL);
335 writerPtr_->beginTime(freqInst);
341 (outDirBase / fName),
345 writerPtr_->nFields(1);
346 writerPtr_->write(title,
data);
348 writerPtr_->endTime();
384 scalar areaAverage = 0;
395 allData[faceI] =
data[faceI];
404 label faceI = procFaceOffset[procI] + i;
405 allData[faceI] = dataSlice[i];
411 areaAverage =
sum(allData)/allData.size();
440 fftWriteInterval_(1),
442 readerType_(
word::null),
475 Info<<
" Averaging: area weighted" <<
endl;
479 Info<<
" Averaging: ensemble" <<
endl;
489 dict.subOrEmptyDict(
"writeOptions").subOrEmptyDict(writerType)
526 const label nFacePerProc = floor(
nFace_/nProcs) + 1;
528 procFaceOffset.
setSize(nProcs + 1, 0);
529 for (label i = 1; i < procFaceOffset.size(); ++i)
531 procFaceOffset[i] =
min(i*nFacePerProc,
nFace_);
545 Info<<
"Creating noise FFTs" <<
endl;
554 const label nLocalFace = pData.size();
561 surfPrmsf[freqI].setSize(nLocalFace);
562 surfPSDf[freqI].
setSize(nLocalFace);
579 if (octave13BandIDs.empty())
582 <<
"Octave band calculation failed (zero sized). "
583 <<
"Please check your input data"
588 bandSize = octave13BandIDs.size() - 1;
592 forAll(surfPrms13f, freqI)
594 surfPrms13f[freqI].
setSize(nLocalFace);
612 surfPrmsf[i][faceI] = Prmsf[freqI];
613 surfPSDf[i][faceI] =
PSDf[freqI];
628 forAll(surfPrms13f, freqI)
630 surfPrms13f[freqI][faceI] = Prms13f[freqI];
641 Info<<
"Writing fft surface data";
660 label nFreq = f1 - f0;
669 <<
"No surface data available using a fftWriteInterval of "
677 fOut[i] = freq1[freqI];
707 PSD(surfPSDf[i + f0]),
717 SPL(surfPSDf[i + f0]*deltaf, freq1[freqI]),
758 "Average PSD_dB_Hz(f)",
777 SPL(PSDfAve*deltaf, fOut)
789 Info<<
"Writing one-third octave surface data" <<
endl;
791 fileName outDir(outDirBase/
"oneThirdOctave");
803 octave13FreqCentre[i],
804 SPL(surfPrms13f[i], octave13FreqCentre[i]),
817 "Average SPL13_dB(fm)",
821 SPL(Prms13fAve, octave13FreqCentre)
const string & title() const
scalar checkUniformTimeStep(const scalarList ×) const
Check and return uniform time step.
virtual bool read(const dictionary &dict)
Read from dictionary.
label nFace_
Number of surface faces.
Class to create, store and output qgraph files.
static std::string nameLessExt(const std::string &str)
Return basename, without extension.
A class for handling words, derived from Foam::string.
Output inter-processor communications stream operating on external buffer.
A class for handling file names.
Base class for noise models.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void resize(const label len)
Adjust allocated size of list.
static fileName envGlobalPath()
Global case (directory) from environment variable.
static word wordify(const string &sname)
Helper function to convert string name into appropriate word.
static constexpr const zero Zero
Global zero (0)
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName)
Return a reference to the selected surfaceReader.
scalar fUpper_
Upper frequency limit, default = 10kHz.
scalarList times_
Sample times.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label pIndex_
Index of pressure field in reader field list.
const List< Face > & surfFaces() const
Return const access to the faces.
tmp< scalarField > octaves(const scalarField &data, const scalarField &f, const labelUList &freqBandIDs) const
Generate octave data.
static bool master(const label communicator=worldComm)
Am I the master process.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
defineTypeNameAndDebug(pointNoise, 0)
virtual void calculate()
Calculate.
label findStartTimeIndex(const instantList &allTimes, const scalar startTime) const
Find and return start time index.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool read(const dictionary &dict)
Read from dictionary.
void clear()
Reset (clear) individual buffers and reset state.
scalar fLower_
Lower frequency limit, default = 25Hz.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
word pName_
Name of pressure field.
surfaceNoise(const dictionary &dict, const bool readFields=true)
Constructor.
#define forAll(list, i)
Loop across all elements in list.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
const scalarField & magSf() const
Face area magnitudes.
scalar deltaT_
Time step (constant)
messageStream Info
Information stream (stdout output on master, null elsewhere)
void setSize(const label n)
Alias for resize()
autoPtr< windowModel > windowModelPtr_
Window model.
bool writeOctaves_
Write writeOctaves; default = yes.
scalar startTime_
Start time, default = 0s.
static void setOctaveBands(const scalarField &f, const scalar fLower, const scalar fUpper, const scalar octave, labelList &fBandIDs, scalarField &fCentre)
bool writePSD_
Write PSD; default = yes.
label startTimeIndex_
Start time index.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void finishedSends(const bool block=true)
Mark all sends as having been done.
void write(Ostream &, const word &format) const
Write graph to stream in given format.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
Macros for easy insertion into run-time selection tables.
bool writePSDf_
Write PSDf; default = yes.
bool writePrmsf_
Write Prmsf; default = yes.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
tmp< scalarField > RMSmeanPf(const scalarField &p) const
label fftWriteInterval_
Frequency data output interval, default = 1.
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
tmp< scalarField > SPL(const scalarField &Prms2, const scalar f) const
SPL [dB].
word readerType_
Reader type.
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
static bool & parRun() noexcept
Test if this a parallel run.
fileName baseFileDir(const label dataseti) const
Return the base output directory.
string & expand(const bool allowEmpty=false)
void clear()
Clear the list, i.e. set size to zero.
tmp< scalarField > PSDf(const scalarField &p, const scalar deltaT) const
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
tmp< scalarField > uniformFrequencies(const scalar deltaT, const bool check) const
label nSamples() const
Return the number of samples in the window.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
An instant of time. Contains the time value and name.
void readSurfaceData(const labelList &procFaceOffset, List< scalarField > &pData)
Read surface data.
Input inter-processor communications stream operating on external buffer.
word graphFormat_
Graph format.
void initialise(const fileName &fName)
Initialise.
tmp< Foam::scalarField > PSD(const scalarField &PSDf) const
PSD [dB/Hz].
Base class for windowing models.
label size() const
The surface size is the number of faces.
List< fileName > inputFileNames_
Input file names.
addToRunTimeSelectionTable(noiseModel, pointNoise, dictionary)
#define WarningInFunction
Report a warning using Foam::Warning.
bool writeSPL_
Write SPL; default = yes.
Database for solution data, solver performance and other reduced data.
static bool isAbsolute(const std::string &str)
scalar surfaceAverage(const scalarField &data, const labelList &procFaceOffset) const
Calculate the area average value.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.