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;
298 areaAverage =
sum(data*surf.magSf())/
sum(surf.magSf());
308 areaAverage =
sum(data);
309 reduce(areaAverage, sumOp<scalar>());
311 areaAverage /= (scalar(
nFaces_) + ROOTVSMALL);
326 const bool writeSurface
329 Info<<
" processing " << title <<
" for frequency " << freq <<
endl;
338 scalar areaAverage = 0;
358 areaAverage =
sum(allData*surf.magSf())/
sum(surf.magSf());
362 areaAverage =
sum(allData)/(allData.size() + ROOTVSMALL);
374 (outDirBase / fName),
393 areaAverage =
sum(data*surf.magSf())/
sum(surf.magSf());
397 areaAverage =
sum(data)/(data.
size() + ROOTVSMALL);
409 (outDirBase / fName),
444 fftWriteInterval_(1),
446 useBroadcast_(false),
447 commType_(
UPstream::commsTypes::scheduled),
475 <<
" Pressure field name: " <<
pName_ <<
nl
482 Info<<
" Averaging: area weighted" <<
endl;
486 Info<<
" Averaging: ensemble" <<
endl;
495 Info<<
" Distribute fields: "
500 Info<<
" (broadcast all)";
509 const word writerType =
dict.get<word>(
"writer");
544 globalIndex procFaceAddr;
552 procFaceOffsets[0] = 0;
553 for (label proci = 1; proci < procFaceOffsets.size(); ++proci)
555 procFaceOffsets[proci] =
min(proci*nFacePerProc,
nFaces_);
558 procFaceAddr.offsets() = std::move(procFaceOffsets);
565 procFaceAddr.reset(globalIndex::gatherNone{},
nFaces_);
569 List<scalarField> pData;
577 Info<<
"Creating noise FFTs" <<
endl;
581 const scalar maxFreq1 =
max(freq1);
588 const label nLocalFace = pData.size();
591 List<scalarField> surfPrmsf(nFFT);
592 List<scalarField> surfPSDf(nFFT);
595 surfPrmsf[freqI].setSize(nLocalFace);
596 surfPSDf[freqI].setSize(nLocalFace);
613 if (octave13BandIDs.empty())
616 <<
"Octave band calculation failed (zero sized). "
617 <<
"Please check your input data"
622 bandSize = octave13BandIDs.size() - 1;
625 List<scalarField> surfPrms13f(bandSize);
626 forAll(surfPrms13f, freqI)
628 surfPrms13f[freqI].setSize(nLocalFace);
646 surfPrmsf[i][faceI] = Prmsf[freqI];
647 surfPSDf[i][faceI] =
PSDf[freqI];
662 forAll(surfPrms13f, freqI)
664 surfPrms13f[freqI][faceI] = Prms13f[freqI];
669 const word fNameBase = fName.
stem();
674 const scalar deltaf = 1.0/(
deltaT_*win.nSamples());
675 Info<<
"Writing fft surface data";
693 surfArea =
sum(surf.magSf());
694 surfSize = surf.size();
703 List<Tuple2<string, token>> commonInfo
706 {
"Area sum", token(surfArea)},
707 {
"Number of faces", token(surfSize)}
711 fileName outDir(outDirBase/
"fft");
712 fileName outSurfDir(
filePath(outDir));
719 label nFreq = f1 - f0;
728 <<
"No surface data available using a fftWriteInterval of "
736 fOut[i] = freq1[freqI];
766 PSD(surfPSDf[i + f0]),
776 SPL(surfPSDf[i + f0]*deltaf, freq1[freqI]),
789 Info<<
" Writing " <<
os.relativeName() <<
endl;
798 Info<<
" Writing " <<
os.relativeName() <<
endl;
813 Info<<
" Writing " <<
os.relativeName() <<
endl;
828 Info<<
" Writing " <<
os.relativeName() <<
endl;
843 Info<<
"Writing one-third octave surface data" <<
endl;
845 fileName outDir(outDirBase/
"oneThirdOctave");
846 fileName outSurfDir(
filePath(outDir));
858 octave13FreqCentre[i],
859 SPL(surfPrms13f[i], octave13FreqCentre[i]),
873 Info<<
" Writing " <<
os.relativeName() <<
endl;
886 SPL(Prms13fAve, octave13FreqCentre)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
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.
SubField< scalar > subField
SubField< Type > slice(const label pos, label len=-1)
Return SubField slice (non-const access) - no range checking.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void setSize(label n)
Alias for resize().
void resize(const label len)
Adjust allocated size of list.
const scalarField & magSf() const
Face area magnitudes.
label size() const
The surface size is the number of faces.
const List< Face > & surfFaces() const
Return const access to the faces.
label nFaces() const noexcept
Number of faces in the patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel.
static const char * name(bool b) noexcept
A string representation of bool as "false" / "true".
T & first()
Access first element of the list, position [0].
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
Inter-processor communications stream.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static int & msgType() noexcept
Message tag of standard messages.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
@ broadcast
broadcast [MPI]
static bool & parRun() noexcept
Test if this a parallel run.
static fileName envGlobalPath()
Global case (directory) from environment variable.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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...
A class for handling file names.
static std::string stem(const std::string &str)
Return the basename, without extension.
static bool isAbsolute(const std::string &str)
Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.
fileName baseFileDir() const
Return the base directory for output.
virtual autoPtr< OFstream > newFile(const fileName &fName) const
Return autoPtr to a new file using file name.
fileName filePath(const fileName &fName) const
Return the full path for the supplied file name.
const objectRegistry & fileObr_
Reference to the region objectRegistry.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, UList< Type > &allFld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
labelRange range(label proci) const noexcept
Return start/size range of proci data.
static void scatter(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &allFld, UList< Type > &fld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Distribute data in processor order.
void reset(label localSize, const label comm=UPstream::worldComm, const bool parallel=UPstream::parRun())
Reset from local size, using gather/broadcast with default/specified communicator if parallel.
label localSize(const label proci) const
Size of proci data.
const labelList & offsets() const noexcept
Const-access to the offsets.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
static label findStart(const UList< instant > ×, const scalar timeVal)
Find and return index of given start time (linear search).
Base class for noise models.
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 rhoRef_
Reference density (to convert from kinematic to static pressure).
tmp< scalarField > octaves(const scalarField &data, const scalarField &f, const labelUList &freqBandIDs) const
Generate octave data.
tmp< scalarField > RMSmeanPf(const scalarField &p) const
Return the multi-window RMS mean fft of the complete pressure data [Pa].
scalar fUpper_
Upper frequency limit, default = 10kHz.
tmp< Foam::scalarField > PSD(const scalarField &PSDf) const
PSD [dB/Hz].
bool writePSD_
Write PSD; default = yes.
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...
virtual bool read(const dictionary &dict)
Read from dictionary.
bool writeOctaves_
Write writeOctaves; default = yes.
noiseModel(const noiseModel &)=delete
No copy construct.
tmp< scalarField > SPL(const scalarField &Prms2, const scalar f) const
SPL [dB].
autoPtr< windowModel > windowModelPtr_
Window model.
bool writeSPL_
Write SPL; default = yes.
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.
bool writePrmsf_
Write Prmsf; default = yes.
scalar checkUniformTimeStep(const scalarList ×) const
Check and return uniform time step.
bool writePSDf_
Write PSDf; default = yes.
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 startTime_
Start time, default = 0s.
scalar sampleFreq_
Prescribed sample frequency.
void writeFreqDataToFile(Ostream &os, const scalarField &f, const scalarField &fx) const
scalar fLower_
Lower frequency limit, default = 25Hz.
Perform noise analysis on surface-based pressure data.
scalarList times_
Sample times.
word pName_
Name of pressure field.
void initialise(const fileName &fName)
Initialise.
label nFaces_
Global number of surface faces.
surfaceNoise(const dictionary &dict, const objectRegistry &obr, const word &name=typeName, const bool readFields=true)
Constructor.
scalar surfaceAverage(const scalarField &data, const globalIndex &procFaceAddr) const
Calculate the area average value.
scalar deltaT_
Time step (constant).
virtual bool read(const dictionary &dict)
Read from dictionary.
List< fileName > inputFileNames_
Input file names.
UPstream::commsTypes commType_
Communication type (for sending/receiving fields).
autoPtr< surfaceWriter > writerPtr_
Pointer to the surface writer.
word readerType_
Reader type.
bool useBroadcast_
Use broadcast to send entire field to sub-ranks.
label startTimeIndex_
Start time index.
label fftWriteInterval_
Frequency data output interval, default = 1.
void readSurfaceData(const globalIndex &procFaceAddr, List< scalarField > &pData)
Read surface data.
autoPtr< surfaceReader > readerPtr_
Pointer to the surface reader.
bool areaAverage_
Apply area average; default = no (ensemble average) for backwards compatibility.
label pIndex_
Index of pressure field in reader field list.
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 void calculate()
Calculate.
Registry of regIOobjects.
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
static autoPtr< surfaceReader > New(const word &readType, const fileName &fName, const dictionary &options=dictionary())
Return a reference to the selected surfaceReader.
static autoPtr< surfaceWriter > New(const word &writeType)
Select construct a surfaceWriter.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
A token holds an item read from Istream.
Base class for windowing models.
label nSamples() const
Return the number of samples in the window.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Dispatch tag: Construct with a single (local size) entry, no communication.
autoPtr< OFstream > filePtr