diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index 19f2eb74fc..0ff3988afb 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) IOdictionary dict(dictIO); - autoPtr model(noiseModel::New(dict)); + autoPtr model(noiseModel::New(dict, runTime)); model->calculate(); Info<< nl << "End\n" << endl; diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 54bde949ba..bbe328fa62 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -76,6 +76,15 @@ Foam::fileName Foam::functionObjects::writeFile::baseTimeDir() const } +Foam::fileName Foam::functionObjects::writeFile::filePath +( + const fileName& fName +) const +{ + return baseFileDir()/prefix_/fName; +} + + Foam::autoPtr Foam::functionObjects::writeFile::newFile ( const fileName& fName @@ -85,7 +94,7 @@ Foam::autoPtr Foam::functionObjects::writeFile::newFile if (Pstream::master() && writeToFile_) { - fileName outputDir(baseFileDir()/prefix_/fName.path()); + fileName outputDir(filePath(fName).path()); mkDir(outputDir); diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index b856e09898..3c776876a6 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -137,6 +137,9 @@ protected: //- Return the base directory for the current time value fileName baseTimeDir() const; + //- Return the full path for the supplied file name + fileName filePath(const fileName& fName) const; + //- Return autoPtr to a new file using file name // Note: no check for if the file already exists virtual autoPtr newFile(const fileName& fName) const; diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C index 15e3d090cf..05bc2e2814 100644 --- a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -243,16 +243,58 @@ Foam::fileName Foam::noiseModel::baseFileDir(const label dataseti) const { return ( - argList::envGlobalPath() - / functionObject::outputPrefix - / "noise" - / outputPrefix_ + outputPrefix_ / type() / ("input" + Foam::name(dataseti)) ); } +void Foam::noiseModel::writeFileHeader +( + Ostream& os, + const string& x, + const string& y, + const List>& headerValues +) const +{ + writeHeader(os, x + " vs " + y); + writeHeaderValue(os, "Lower frequency", fLower_); + writeHeaderValue(os, "Upper frequency", fUpper_); + writeHeaderValue(os, "Window model", windowModelPtr_->type()); + writeHeaderValue(os, "Window number", windowModelPtr_->nWindow()); + writeHeaderValue(os, "Window samples", windowModelPtr_->nSamples()); + writeHeaderValue(os, "Window overlap %", windowModelPtr_->overlapPercent()); + writeHeaderValue(os, "dBRef", dBRef_); + + for (const auto& hv : headerValues) + { + writeHeaderValue(os, hv.first(), hv.second()); + } + + writeCommented(os, x.substr(0, x.find(' '))); + writeTabbed(os, y.substr(0, y.find(' '))); + os << nl; +} + + +void Foam::noiseModel::writeFreqDataToFile +( + Ostream& os, + const scalarField& f, + const scalarField& fx +) const +{ + forAll(f, i) + { + if (f[i] >= fLower_ && f[i] <= fUpper_) + { + os << f[i] << tab << fx[i] << nl; + } + } +} + + Foam::tmp Foam::noiseModel::uniformFrequencies ( const scalar deltaT, @@ -563,8 +605,15 @@ Foam::scalar Foam::noiseModel::gainD(const scalar f) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields) +Foam::noiseModel::noiseModel +( + const dictionary& dict, + const objectRegistry& obr, + const word& name, + const bool readFields +) : + functionObjects::writeFile(obr, "noise"), dict_(dict), rhoRef_(1), nSamples_(65536), @@ -572,7 +621,6 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields) fUpper_(10000), startTime_(0), windowModelPtr_(), - graphFormat_("raw"), SPLweighting_(weightingType::none), dBRef_(2e-5), minPressure_(-0.5*VGREAT), @@ -603,12 +651,16 @@ Foam::noiseModel::noiseModel(const dictionary& dict, const bool readFields) bool Foam::noiseModel::read(const dictionary& dict) { + if (!functionObjects::writeFile::read(dict)) + { + return false; + } + dict.readIfPresent("rhoRef", rhoRef_); dict.readIfPresent("N", nSamples_); dict.readIfPresent("fl", fLower_); dict.readIfPresent("fu", fUpper_); dict.readIfPresent("startTime", startTime_); - dict.readIfPresent("graphFormat", graphFormat_); dict.readIfPresent("minPressure", minPressure_); dict.readIfPresent("maxPressure", maxPressure_); dict.readIfPresent("outputPrefix", outputPrefix_); diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H index 05d8518b5d..aa57a599da 100644 --- a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,7 +64,6 @@ Description outputPrefix | Prefix applied to output files| no | '' SPLweighting | Weighting: dBA, dBB, dBC, DBD | no | none dBRef | Reference for dB calculation | no | 2e-5 - graphFormat | Graph format | no | raw writePrmsf | Write Prmsf data | no | yes writeSPL | Write SPL data | no | yes writePSD | Write PSD data | no | yes @@ -80,13 +79,14 @@ SourceFiles #ifndef noiseModel_H #define noiseModel_H +#include "writeFile.H" #include "dictionary.H" #include "scalarList.H" #include "instantList.H" #include "windowModel.H" #include "Enum.H" +#include "Tuple2.H" #include "runTimeSelectionTables.H" -#include "graph.H" #include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -99,6 +99,8 @@ namespace Foam \*---------------------------------------------------------------------------*/ class noiseModel +: + public functionObjects::writeFile { public: @@ -173,9 +175,6 @@ protected: //- Window model autoPtr windowModelPtr_; - //- Graph format - word graphFormat_; - //- Weighting weightingType SPLweighting_; @@ -252,6 +251,23 @@ protected: //- Return the base output directory fileName baseFileDir(const label dataseti) const; + //- Write output file header + void writeFileHeader + ( + Ostream& os, + const string& x, + const string& y, + const List>& headerValues = {} + ) const; + + // Write frequency-based data to file + void writeFreqDataToFile + ( + Ostream& os, + const scalarField& f, + const scalarField& fx + ) const; + //- Create a field of equally spaced frequencies for the current set of //- data - assumes a constant time step tmp uniformFrequencies @@ -334,16 +350,27 @@ public: noiseModel, dictionary, ( - const dictionary& dict + const dictionary& dict, + const objectRegistry& obr ), - (dict) + (dict, obr) ); //- Selector - static autoPtr New(const dictionary& dict); + static autoPtr New + ( + const dictionary& dict, + const objectRegistry& obr + ); //- Constructor - noiseModel(const dictionary& dict, const bool readFields = true); + noiseModel + ( + const dictionary& dict, + const objectRegistry& obr, + const word& name, + const bool readFields = true + ); //- Destructor virtual ~noiseModel() = default; diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C index b5188b59a8..086af68f84 100644 --- a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModelNew.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,11 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::autoPtr Foam::noiseModel::New(const dictionary& dict) +Foam::autoPtr Foam::noiseModel::New +( + const dictionary& dict, + const objectRegistry& obr +) { const word modelType(dict.get("noiseModel")); @@ -48,7 +52,10 @@ Foam::autoPtr Foam::noiseModel::New(const dictionary& dict) ) << exit(FatalIOError); } - return autoPtr(ctorPtr(dict.subDict(modelType + "Coeffs"))); + return autoPtr + ( + ctorPtr(dict.subDict(modelType + "Coeffs"), obr) + ); } diff --git a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C index 9addd356ee..ca93813430 100644 --- a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C +++ b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -113,19 +113,13 @@ void pointNoise::processData // RMS pressure [Pa] if (writePrmsf_) { - graph g - ( - "Prms(f)", - "f [Hz]", - "Prms(f) [Pa]", - f, - RMSmeanPf(p) - ); + auto filePtr = newFile(outDir/"Prms_f"); + auto& os = filePtr(); - g.setXRange(fLower_, fUpper_); + Info<< " Writing " << os.name() << endl; - Info<< " Creating graph for " << g.title() << endl; - g.write(outDir, graph::wordify(g.title()), graphFormat_); + writeFileHeader(os, "f [Hz]", "Prms(f) [Pa]"); + writeFreqDataToFile(os, f, RMSmeanPf(p)); } // PSD [Pa^2/Hz] @@ -133,55 +127,42 @@ void pointNoise::processData if (writePSDf_) { - graph g - ( - "PSD(f)", - "f [Hz]", - "PSD(f) [PaPa_Hz]", - f, - PSDf - ); + auto filePtr = newFile(outDir/"PSD_f"); + auto& os = filePtr(); - g.setXRange(fLower_, fUpper_); + Info<< " Writing " << os.name() << endl; - Info<< " Creating graph for " << g.title() << endl; - g.write(outDir, graph::wordify(g.title()), graphFormat_); + writeFileHeader(os, "f [Hz]", "PSD(f) [PaPa_Hz]"); + writeFreqDataToFile(os, f, PSDf); } // PSD [dB/Hz] if (writePSD_) { - graph g - ( - "PSD_dB_Hz(f)", - "f [Hz]", - "PSD(f) [dB_Hz]", - f, - PSD(PSDf) - ); + auto filePtr = newFile(outDir/"PSD_dB_Hz_f"); + auto& os = filePtr(); - g.setXRange(fLower_, fUpper_); + Info<< " Writing " << os.name() << endl; - Info<< " Creating graph for " << g.title() << endl; - g.write(outDir, graph::wordify(g.title()), graphFormat_); + writeFileHeader(os, "f [Hz]", "PSD(f) [dB_Hz]"); + writeFreqDataToFile(os, f, PSD(PSDf)); } // SPL [dB] if (writeSPL_) { - graph g + auto filePtr = newFile(outDir/"SPL_dB_f"); + auto& os = filePtr(); + + Info<< " Writing " << os.name() << endl; + + writeFileHeader ( - "SPL_dB(f)", + os, "f [Hz]", - "SPL(f) [" + weightingTypeNames_[SPLweighting_] + "]", - f, - SPL(PSDf*deltaf, f) + "SPL(f) [" + weightingTypeNames_[SPLweighting_] + "]" ); - - g.setXRange(fLower_, fUpper_); - - Info<< " Creating graph for " << g.title() << endl; - g.write(outDir, graph::wordify(g.title()), graphFormat_); + writeFreqDataToFile(os, f, SPL(PSDf*deltaf, f)); } if (writeOctaves_) @@ -205,26 +186,38 @@ void pointNoise::processData // Integrated PSD = P(rms)^2 [Pa^2] scalarField Prms13f(octaves(PSDf, f, octave13BandIDs)); - graph g + auto filePtr = newFile(outDir/"SPL13_dB_fm"); + auto& os = filePtr(); + + Info<< " Writing " << os.name() << endl; + + writeFileHeader ( - "SPL13_dB(fm)", + os, "fm [Hz]", - "SPL(fm) [" + weightingTypeNames_[SPLweighting_] + "]", + "SPL(fm) [" + weightingTypeNames_[SPLweighting_] + "]" + ); + writeFreqDataToFile + ( + os, octave13FreqCentre, SPL(Prms13f, octave13FreqCentre) ); - - Info<< " Creating graph for " << g.title() << endl; - g.write(outDir, graph::wordify(g.title()), graphFormat_); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -pointNoise::pointNoise(const dictionary& dict, const bool readFields) +pointNoise::pointNoise +( + const dictionary& dict, + const objectRegistry& obr, + const word& name, + const bool readFields +) : - noiseModel(dict, false) + noiseModel(dict, obr, name, false) { if (readFields) { diff --git a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H index 99d2cf8629..a480391326 100644 --- a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H +++ b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2016 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,8 +62,6 @@ Description separator " "; mergeSeparators yes; - graphFormat raw; - \endverbatim SourceFiles @@ -129,7 +127,13 @@ public: TypeName("pointNoise"); //- Constructor - pointNoise(const dictionary& dict, const bool readFields = true); + pointNoise + ( + const dictionary& dict, + const objectRegistry& obr, + const word& name = typeName, + const bool readFields = true + ); //- Destructor virtual ~pointNoise() = default; diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C index 4c5826f3f7..4e82fac993 100644 --- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C @@ -29,7 +29,6 @@ License #include "surfaceReader.H" #include "surfaceWriter.H" #include "argList.H" -#include "graph.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -441,9 +440,15 @@ scalar surfaceNoise::surfaceAverage // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -surfaceNoise::surfaceNoise(const dictionary& dict, const bool readFields) +surfaceNoise::surfaceNoise +( + const dictionary& dict, + const objectRegistry& obr, + const word& name, + const bool readFields +) : - noiseModel(dict, false), + noiseModel(dict, obr, name, false), inputFileNames_(), pName_("p"), pIndex_(0), @@ -648,7 +653,7 @@ void surfaceNoise::calculate() const word fNameBase = fName.nameLessExt(); - // Output directory for graphs + // Output directory fileName outDirBase(baseFileDir(filei)/fNameBase); const scalar deltaf = 1.0/(deltaT_*win.nSamples()); @@ -663,8 +668,28 @@ void surfaceNoise::calculate() << endl; } + // Common output information + // Note: hard-coded to read mesh from first time index + scalar surfArea = 0; + label surfSize = 0; + if (Pstream::master()) + { + const meshedSurface& surf = readerPtr_->geometry(0); + surfArea = sum(surf.magSf()); + surfSize = surf.size(); + } + Pstream::broadcast(surfArea); + Pstream::broadcast(surfSize); + List> commonInfo = + { + {"Area average", token(word(Switch::name(areaAverage_)))}, + {"Area sum", token(surfArea)}, + {"Number of faces", token(surfSize)} + }; + { fileName outDir(outDirBase/"fft"); + fileName outSurfDir(filePath(outDir)); // Determine frequency range of interest // Note: frequencies have fixed interval, and are in the range @@ -693,7 +718,7 @@ void surfaceNoise::calculate() PrmsfAve[i] = writeSurfaceData ( - outDir, + outSurfDir, fNameBase, "Prmsf", freq1[freqI], @@ -704,7 +729,7 @@ void surfaceNoise::calculate() PSDfAve[i] = writeSurfaceData ( - outDir, + outSurfDir, fNameBase, "PSDf", freq1[freqI], @@ -714,7 +739,7 @@ void surfaceNoise::calculate() ); writeSurfaceData ( - outDir, + outSurfDir, fNameBase, "PSD", freq1[freqI], @@ -724,7 +749,7 @@ void surfaceNoise::calculate() ); writeSurfaceData ( - outDir, + outSurfDir, fNameBase, "SPL", freq1[freqI], @@ -737,65 +762,60 @@ void surfaceNoise::calculate() if (Pstream::master()) { - graph Prmsfg - ( - "Average Prms(f)", - "f [Hz]", - "P(f) [Pa]", - fOut, - PrmsfAve - ); - Prmsfg.write - ( - outDir, - graph::wordify(Prmsfg.title()), - graphFormat_ - ); + { + auto filePtr = newFile(outDir/"Average_Prms_f"); + auto& os = filePtr(); - graph PSDfg - ( - "Average PSD_f(f)", - "f [Hz]", - "PSD(f) [PaPa_Hz]", - fOut, - PSDfAve - ); - PSDfg.write - ( - outDir, - graph::wordify(PSDfg.title()), - graphFormat_ - ); + Info<< " Writing " << os.name() << endl; - graph PSDg - ( - "Average PSD_dB_Hz(f)", - "f [Hz]", - "PSD(f) [dB_Hz]", - fOut, - PSD(PSDfAve) - ); - PSDg.write - ( - outDir, - graph::wordify(PSDg.title()), - graphFormat_ - ); + writeFileHeader(os, "f [Hz]", "P(f) [Pa]", commonInfo); + writeFreqDataToFile(os, fOut, PrmsfAve); + } + { + auto filePtr = newFile(outDir/"Average_PSD_f_f"); + auto& os = filePtr(); - graph SPLg - ( - "Average SPL_dB(f)", - "f [Hz]", - "SPL(f) [dB]", - fOut, - SPL(PSDfAve*deltaf, fOut) - ); - SPLg.write - ( - outDir, - graph::wordify(SPLg.title()), - graphFormat_ - ); + Info<< " Writing " << os.name() << endl; + + writeFileHeader + ( + os, + "f [Hz]", + "PSD(f) [PaPa_Hz]", + commonInfo + ); + writeFreqDataToFile(os, fOut, PSDfAve); + } + { + auto filePtr = newFile(outDir/"Average_PSD_dB_Hz_f"); + auto& os = filePtr(); + + Info<< " Writing " << os.name() << endl; + + writeFileHeader + ( + os, + "f [Hz]", + "PSD(f) [dB_Hz]", + commonInfo + ); + writeFreqDataToFile(os, fOut, PSD(PSDfAve)); + } + { + auto filePtr = newFile(outDir/"Average_SPL_dB_f"); + auto& os = filePtr(); + + Info<< " Writing " << os.name() << endl; + + writeFileHeader + ( + os, + "f [Hz]", + "SPL(f) [dB]", + commonInfo + ); + writeFreqDataToFile(os, fOut, SPL(PSDfAve*deltaf, fOut)); + } } } @@ -803,6 +823,7 @@ void surfaceNoise::calculate() Info<< "Writing one-third octave surface data" << endl; { fileName outDir(outDirBase/"oneThirdOctave"); + fileName outSurfDir(filePath(outDir)); scalarField PSDfAve(surfPrms13f.size(), Zero); scalarField Prms13fAve(surfPrms13f.size(), Zero); @@ -811,7 +832,7 @@ void surfaceNoise::calculate() { writeSurfaceData ( - outDir, + outSurfDir, fNameBase, "SPL13", octave13FreqCentre[i], @@ -826,20 +847,24 @@ void surfaceNoise::calculate() if (Pstream::master()) { - graph SPL13g + auto filePtr = newFile(outDir/"Average_SPL13_dB_fm"); + auto& os = filePtr(); + + Info<< " Writing " << os.name() << endl; + + writeFileHeader ( - "Average SPL13_dB(fm)", + os, "fm [Hz]", "SPL(fm) [dB]", + commonInfo + ); + writeFreqDataToFile + ( + os, octave13FreqCentre, SPL(Prms13fAve, octave13FreqCentre) ); - SPL13g.write - ( - outDir, - graph::wordify(SPL13g.title()), - graphFormat_ - ); } } } diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.H b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.H index 98a8aaaaf3..4f8c8f3f8c 100644 --- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.H +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -216,7 +216,13 @@ public: //- Constructor - explicit surfaceNoise(const dictionary& dict, const bool readFields=true); + surfaceNoise + ( + const dictionary& dict, + const objectRegistry& obr, + const word& name = typeName, + const bool readFields = true + ); //- Destructor virtual ~surfaceNoise() = default; diff --git a/src/randomProcesses/windowModels/windowModel/windowModel.C b/src/randomProcesses/windowModels/windowModel/windowModel.C index 7febd9c701..440c8064ef 100644 --- a/src/randomProcesses/windowModels/windowModel/windowModel.C +++ b/src/randomProcesses/windowModels/windowModel/windowModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,14 +41,10 @@ namespace Foam Foam::windowModel::windowModel(const dictionary& dict, const label nSamples) : scalarField(nSamples), - nOverlapSamples_(0), + overlapPercent_(dict.get("overlapPercent")), + nOverlapSamples_(floor(overlapPercent_/scalar(100)*nSamples)), nWindow_(dict.getOrDefault("nWindow", -1)) -{ - nOverlapSamples_ = floor - ( - dict.get("overlapPercent")/scalar(100)*nSamples - ); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -59,6 +55,18 @@ Foam::label Foam::windowModel::nSamples() const } +Foam::scalar Foam::windowModel::overlapPercent() const +{ + return overlapPercent_; +} + + +Foam::label Foam::windowModel::nOverlapSamples() const +{ + return nOverlapSamples_; +} + + Foam::label Foam::windowModel::nWindow() const { return nWindow_; diff --git a/src/randomProcesses/windowModels/windowModel/windowModel.H b/src/randomProcesses/windowModels/windowModel/windowModel.H index 22bb440338..dd927185e9 100644 --- a/src/randomProcesses/windowModels/windowModel/windowModel.H +++ b/src/randomProcesses/windowModels/windowModel/windowModel.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,6 +59,9 @@ protected: // Protected Data + //- Overlap percent + scalar overlapPercent_; + //- Number of overlap samples per window label nOverlapSamples_; @@ -108,6 +111,12 @@ public: //- Return the number of samples in the window label nSamples() const; + //- Return the overlap percent + scalar overlapPercent() const; + + //- Return number of overlap samples per window + label nOverlapSamples() const; + //- Return the number of windows label nWindow() const;