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_->write(title, allData);
309 writerPtr_->endTime();
315 areaAverage =
sum(allData)/(allData.size() + ROOTVSMALL);
329 writerPtr_->beginTime(freqInst);
335 (outDirBase / fName),
339 writerPtr_->write(title,
data);
341 writerPtr_->endTime();
372 scalar areaAverage = 0;
383 allData[faceI] =
data[faceI];
392 label faceI = procFaceOffset[procI] + i;
393 allData[faceI] = dataSlice[i];
399 areaAverage =
sum(allData)/allData.size();
428 fftWriteInterval_(1),
429 readerType_(
word::null),
462 dict.subOrEmptyDict(
"writeOptions").subOrEmptyDict(writerType)
497 const label nFacePerProc = floor(
nFace_/nProcs) + 1;
499 procFaceOffset.
setSize(nProcs + 1, 0);
500 for (label i = 1; i < procFaceOffset.size(); ++i)
502 procFaceOffset[i] =
min(i*nFacePerProc,
nFace_);
516 Info<<
"Creating noise FFTs" <<
endl;
525 const label nLocalFace = pData.size();
532 surfPrmsf[freqI].setSize(nLocalFace);
533 surfPSDf[freqI].
setSize(nLocalFace);
550 if (octave13BandIDs.empty())
553 <<
"Octave band calculation failed (zero sized). "
554 <<
"Please check your input data"
559 bandSize = octave13BandIDs.size() - 1;
563 forAll(surfPrms13f, freqI)
565 surfPrms13f[freqI].
setSize(nLocalFace);
583 surfPrmsf[i][faceI] = Prmsf[freqI];
584 surfPSDf[i][faceI] =
PSDf[freqI];
599 forAll(surfPrms13f, freqI)
601 surfPrms13f[freqI][faceI] = Prms13f[freqI];
612 Info<<
"Writing fft surface data";
631 label nFreq = f1 - f0;
640 <<
"No surface data available using a fftWriteInterval of "
648 fOut[i] = freq1[freqI];
678 PSD(surfPSDf[i + f0]),
688 SPL(surfPSDf[i + f0]*deltaf, freq1[freqI]),
729 "Average PSD_dB_Hz(f)",
748 SPL(PSDfAve*deltaf, fOut)
760 Info<<
"Writing one-third octave surface data" <<
endl;
762 fileName outDir(outDirBase/
"oneThirdOctave");
774 octave13FreqCentre[i],
775 SPL(surfPrms13f[i], octave13FreqCentre[i]),
788 "Average SPL13_dB(fm)",
792 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)
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.
static bool & parRun()
Test if this a parallel run, or allow modify access.
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()
Clear storage and reset.
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.
scalar deltaT_
Time step (constant)
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
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 resize(const label newSize)
Adjust allocated size of list.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
tmp< scalarField > uniformFrequencies(const scalar deltaT) const
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.
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.
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)
label nSamples() const
Return the number of samples in the window.
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.
void setSize(const label newSize)
Alias for resize(const label)
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)
Return true if string starts with a '/'.
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.