51 Info<<
"Reading data file: " 55 label nAvailableTimes = 0;
69 <<
"Unable to find pressure field name " <<
pName_ 70 <<
" in list of available fields: " << fieldNames
143 const label nLocalFace = procFaceAddr.
localSize();
150 pf.resize_nocopy(nTimes);
153 Info<<
"Reading pressure data" <<
endl;
171 scratch.
resize(nLocalFace);
207 : scratch.
slice(0, nLocalFace)
216 pData[facei][timei] = procData[facei];
231 auto& procData = allData;
239 pData[facei][timei] = procData[facei];
246 pData[facei] -=
average(pData[facei]);
252 <<
" pressure traces with " 254 <<
" time values" <<
nl <<
endl;
270 scalar areaAverage = 0;
301 areaAverage =
sum(data*surf.magSf())/
sum(surf.magSf());
311 areaAverage =
sum(data);
312 reduce(areaAverage, sumOp<scalar>());
314 areaAverage /= (scalar(
nFaces_) + ROOTVSMALL);
329 const bool writeSurface
332 Info<<
" processing " << title <<
" for frequency " << freq <<
endl;
341 scalar areaAverage = 0;
364 areaAverage =
sum(allData*surf.magSf())/
sum(surf.magSf());
368 areaAverage =
sum(allData)/(allData.size() + ROOTVSMALL);
380 (outDirBase / fName),
399 areaAverage =
sum(data*surf.magSf())/
sum(surf.magSf());
403 areaAverage =
sum(data)/(data.
size() + ROOTVSMALL);
415 (outDirBase / fName),
450 fftWriteInterval_(1),
452 useBroadcast_(false),
453 commType_(
UPstream::commsTypes::scheduled),
481 <<
" Pressure field name: " <<
pName_ <<
nl 488 Info<<
" Averaging: area weighted" <<
endl;
492 Info<<
" Averaging: ensemble" <<
endl;
501 Info<<
" Distribute fields: " 506 Info<<
" (broadcast all)";
515 const word writerType =
dict.get<word>(
"writer");
550 globalIndex procFaceAddr;
558 procFaceOffsets[0] = 0;
559 for (label proci = 1; proci < procFaceOffsets.size(); ++proci)
561 procFaceOffsets[proci] =
min(proci*nFacePerProc,
nFaces_);
564 procFaceAddr.offsets() = std::move(procFaceOffsets);
571 procFaceAddr.reset(globalIndex::gatherNone{},
nFaces_);
575 List<scalarField> pData;
583 Info<<
"Creating noise FFTs" <<
endl;
587 const scalar maxFreq1 =
max(freq1);
594 const label nLocalFace = pData.size();
597 List<scalarField> surfPrmsf(nFFT);
598 List<scalarField> surfPSDf(nFFT);
601 surfPrmsf[freqI].setSize(nLocalFace);
602 surfPSDf[freqI].setSize(nLocalFace);
619 if (octave13BandIDs.empty())
622 <<
"Octave band calculation failed (zero sized). " 623 <<
"Please check your input data" 628 bandSize = octave13BandIDs.size() - 1;
631 List<scalarField> surfPrms13f(bandSize);
632 forAll(surfPrms13f, freqI)
634 surfPrms13f[freqI].setSize(nLocalFace);
652 surfPrmsf[i][faceI] = Prmsf[freqI];
653 surfPSDf[i][faceI] =
PSDf[freqI];
668 forAll(surfPrms13f, freqI)
670 surfPrms13f[freqI][faceI] = Prms13f[freqI];
675 const word fNameBase = fName.
stem();
680 const scalar deltaf = 1.0/(
deltaT_*win.nSamples());
681 Info<<
"Writing fft surface data";
699 surfArea =
sum(surf.magSf());
700 surfSize = surf.size();
709 List<Tuple2<string, token>> commonInfo
712 {
"Area sum", token(surfArea)},
713 {
"Number of faces", token(surfSize)}
717 fileName outDir(outDirBase/
"fft");
718 fileName outSurfDir(
filePath(outDir));
725 label nFreq = f1 - f0;
734 <<
"No surface data available using a fftWriteInterval of " 742 fOut[i] = freq1[freqI];
772 PSD(surfPSDf[i + f0]),
782 SPL(surfPSDf[i + f0]*deltaf, freq1[freqI]),
795 Info<<
" Writing " <<
os.relativeName() <<
endl;
804 Info<<
" Writing " <<
os.relativeName() <<
endl;
819 Info<<
" Writing " <<
os.relativeName() <<
endl;
834 Info<<
" Writing " <<
os.relativeName() <<
endl;
849 Info<<
"Writing one-third octave surface data" <<
endl;
851 fileName outDir(outDirBase/
"oneThirdOctave");
852 fileName outSurfDir(
filePath(outDir));
864 octave13FreqCentre[i],
865 SPL(surfPrms13f[i], octave13FreqCentre[i]),
879 Info<<
" Writing " <<
os.relativeName() <<
endl;
892 SPL(Prms13fAve, octave13FreqCentre)
label nFaces_
Global number of surface faces.
virtual void calculate()
Calculate.
labelRange range(const label proci) const
Return start/size range of proci data.
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
A class for handling file names.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
autoPtr< windowModel > windowModelPtr_
Window model.
bool readIfPresent(const word &key, const dictionary &dict, EnumType &val, const bool warnOnly=false) const
Find an entry if present, and assign to T val.
bool writeOctaves_
Write writeOctaves; 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 initialise(const fileName &fName)
Initialise.
constexpr char nl
The newline '\n' character (0x0a)
scalar surfaceAverage(const scalarField &data, const globalIndex &procFaceAddr) const
Calculate the area average value.
surfaceNoise(const dictionary &dict, const objectRegistry &obr, const word &name=typeName, const bool readFields=true)
Constructor.
T & first()
Access first element of the list, position [0].
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.
fileName relativePath(const fileName &input, const bool caseTag=false) const
Return the input relative to the globalPath by stripping off a leading value of the globalPath...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
static int & msgType() noexcept
Message tag of standard messages.
static bool isAbsolute(const std::string &str)
Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.
virtual autoPtr< OFstream > newFile(const fileName &fName) const
Return autoPtr to a new file using file name.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
defineTypeNameAndDebug(pointNoise, 0)
static label findStart(const UList< instant > ×, const scalar timeVal)
Find and return index of given start time (linear search)
bool writePrmsf_
Write Prmsf; default = yes.
static std::string stem(const std::string &str)
Return the basename, without extension.
Macros for easy insertion into run-time selection tables.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
word pName_
Name of pressure field.
scalar startTime_
Start time, default = 0s.
scalar rhoRef_
Reference density (to convert from kinematic to static pressure)
#define forAll(list, i)
Loop across all elements in list.
scalar fUpper_
Upper frequency limit, default = 10kHz.
scalar checkUniformTimeStep(const scalarList ×) const
Check and return uniform time step.
autoPtr< OFstream > filePtr
fileName filePath(const fileName &fName) const
Return the full path for the supplied file name.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
scalarList times_
Sample times.
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 bool read(const dictionary &dict)
Read from dictionary.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
tmp< scalarField > octaves(const scalarField &data, const scalarField &f, const labelUList &freqBandIDs) const
Generate octave data.
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.
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.
word readerType_
Reader type.
A class for handling words, derived from Foam::string.
const scalarField & magSf() const
Face area magnitudes.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const Time & time() const noexcept
Return time registry.
MeshedSurface< face > meshedSurface
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]...
label localSize(const label proci) const
Size of proci data.
List< fileName > inputFileNames_
Input file names.
bool useBroadcast_
Use broadcast to send entire field to sub-ranks.
SubField< Type > slice(const label pos, label len=-1)
Return SubField slice (non-const access) - no range checking.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void writeFreqDataToFile(Ostream &os, const scalarField &f, const scalarField &fx) const
tmp< Foam::scalarField > PSD(const scalarField &PSDf) const
PSD [dB/Hz].
virtual bool read(const dictionary &dict)
Read from dictionary.
bool writeSPL_
Write SPL; default = yes.
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
OBJstream os(runTime.globalPath()/outputName)
bool areaAverage_
Apply area average; default = no (ensemble average) for backwards compatibility.
scalar deltaT_
Time step (constant)
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel. ...
UPstream::commsTypes commType_
Communication type (for sending/receiving fields)
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
fileName baseFileDir() const
Return the base directory for output.
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName, const dictionary &options=dictionary())
Return a reference to the selected surfaceReader.
static fileName envGlobalPath()
Global case (directory) from environment variable.
label fftWriteInterval_
Frequency data output interval, default = 1.
#define WarningInFunction
Report a warning using Foam::Warning.
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
Perform noise analysis on surface-based pressure data.
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 oc...
bool writePSDf_
Write PSDf; default = yes.
void readSurfaceData(const globalIndex &procFaceAddr, List< scalarField > &pData)
Read surface data.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
addToRunTimeSelectionTable(noiseModel, pointNoise, dictionary)
label pIndex_
Index of pressure field in reader field list.
const objectRegistry & fileObr_
Reference to the region objectRegistry.
tmp< scalarField > SPL(const scalarField &Prms2, const scalar f) const
SPL [dB].
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool writePSD_
Write PSD; default = yes.
SubField< scalar > subField
Declare type of subField.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
List< label > labelList
A List of labels.
Registry of regIOobjects.
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 st...
scalar sampleFreq_
Prescribed sample frequency.
Inter-processor communications stream.
static autoPtr< surfaceWriter > New(const word &writeType)
Select construct a surfaceWriter.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
tmp< scalarField > RMSmeanPf(const scalarField &p) const
Return the multi-window RMS mean fft of the complete pressure data [Pa].
scalar fLower_
Lower frequency limit, default = 25Hz.
static void scatter(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Distribute data in processor order.
static constexpr const zero Zero
Global zero (0)
Base class for noise models.