From e3a26cfe3d5c2c85dbd1a765ac3d8ba5e6f1b601 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 25 Jan 2013 15:34:16 +0000 Subject: [PATCH 001/253] ENH: Film model updates for surface quantities --- .../kinematicSingleLayer/kinematicSingleLayer.C | 12 ++++++------ .../thermoSingleLayer/thermoSingleLayer.C | 16 +++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 21d86aa6fa..824ee22e7e 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -299,8 +299,6 @@ tmp kinematicSingleLayer::solveMomentum Info<< "kinematicSingleLayer::solveMomentum()" << endl; } - updateSurfaceVelocities(); - // Momentum tmp tUEqn ( @@ -861,8 +859,13 @@ void kinematicSingleLayer::evolveRegion() Info<< "kinematicSingleLayer::evolveRegion()" << endl; } + // Update film coverage indicator correctAlpha(); + // Update film wall and surface velocities + updateSurfaceVelocities(); + + // Update sub-models to provide updated source contributions updateSubmodels(); // Solve continuity for deltaRho_ @@ -890,9 +893,6 @@ void kinematicSingleLayer::evolveRegion() // Update deltaRho_ with new delta_ deltaRho_ == delta_*rho_; - // Update film wall and surface velocities - updateSurfaceVelocities(); - // Reset source terms for next time integration resetPrimaryRegionSourceTerms(); } diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C index 5bf0534819..42d459ce01 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -637,8 +637,16 @@ void thermoSingleLayer::evolveRegion() Info<< "thermoSingleLayer::evolveRegion()" << endl; } + // Update film coverage indicator correctAlpha(); + // Update film wall and surface velocities + updateSurfaceVelocities(); + + // Update film wall and surface temperatures + updateSurfaceTemperatures(); + + // Update sub-models to provide updated source contributions updateSubmodels(); // Solve continuity for deltaRho_ @@ -672,12 +680,6 @@ void thermoSingleLayer::evolveRegion() // Update temperature using latest hs_ T_ == T(hs_); - // Update film wall and surface velocities - updateSurfaceVelocities(); - - // Update film wall and surface temperatures - updateSurfaceTemperatures(); - // Reset source terms for next time integration resetPrimaryRegionSourceTerms(); } From f84900fbffb0168d00525dafdf9b1dfe4f4ffd76 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 28 Jan 2013 16:42:18 +0000 Subject: [PATCH 002/253] ENH: Apply quadratic approximation to film surface velocity --- .../kinematicSingleLayer/kinematicSingleLayer.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 824ee22e7e..fecefcd2e3 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -282,8 +282,8 @@ void kinematicSingleLayer::updateSurfaceVelocities() Uw_ -= nHat()*(Uw_ & nHat()); Uw_.correctBoundaryConditions(); - // apply quadratic profile to surface velocity - Us_ = 2.0*U_; + // apply quadratic profile to surface velocity (scale by sqrt(2)) + Us_ = 1.414*U_; Us_.correctBoundaryConditions(); } From 12e55d7d97420ff246e5529326235e74d32e8a92 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 28 Jan 2013 16:43:17 +0000 Subject: [PATCH 003/253] ENH: Added helper function to create appropriate graph name from string --- src/OpenFOAM/graph/graph.C | 21 ++++++++++++++++++--- src/OpenFOAM/graph/graph.H | 5 ++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/graph/graph.C b/src/OpenFOAM/graph/graph.C index 7c59cfc2f6..0ec122dcc3 100644 --- a/src/OpenFOAM/graph/graph.C +++ b/src/OpenFOAM/graph/graph.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,6 +41,17 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +Foam::word Foam::graph::wordify(const Foam::string& sname) +{ + string wname = sname; + wname.replace(' ', '_'); + wname.replace('(', '_'); + wname.replace(')', ""); + + return word(wname); +} + + void Foam::graph::readCurves(Istream& is) { List xyData(is); @@ -54,7 +65,11 @@ void Foam::graph::readCurves(Istream& is) y[i] = xyData[i].y_; } - insert(yName_, new curve(yName_, curve::curveStyle::CONTINUOUS, y)); + insert + ( + wordify(yName_), + new curve(wordify(yName_), curve::curveStyle::CONTINUOUS, y) + ); } @@ -89,7 +104,7 @@ Foam::graph::graph yName_(yName), x_(x) { - insert(yName, new curve(yName, curve::curveStyle::CONTINUOUS, y)); + insert(wordify(yName), new curve(yName, curve::curveStyle::CONTINUOUS, y)); } diff --git a/src/OpenFOAM/graph/graph.H b/src/OpenFOAM/graph/graph.H index 2a41498061..b3ff00c37d 100644 --- a/src/OpenFOAM/graph/graph.H +++ b/src/OpenFOAM/graph/graph.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -263,6 +263,9 @@ public: const word& format ) const; + //- Helper function to convert string name into appropriate word + static word wordify(const string& sname); + // Friend operators From 6c6a91c425beebd4cfa709b11591d3f97849ec6e Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 28 Jan 2013 16:45:11 +0000 Subject: [PATCH 004/253] ENH: Added helper function to return CSV data as fields --- .../functions/DataEntry/Table/TableBase.C | 32 ++++++++++++++++++- .../functions/DataEntry/Table/TableBase.H | 8 ++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C index 08dde8e758..054d87575e 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -414,6 +414,36 @@ Foam::dimensioned Foam::TableBase::dimIntegrate } +template +Foam::tmp Foam::TableBase::x() const +{ + tmp tfld(new scalarField(table_.size(), 0.0)); + scalarField& fld = tfld(); + + forAll(table_, i) + { + fld[i] = table_[i].first(); + } + + return tfld; +} + + +template +Foam::tmp > Foam::TableBase::y() const +{ + tmp > tfld(new Field(table_.size(), pTraits::zero)); + Field& fld = tfld(); + + forAll(table_, i) + { + fld[i] = table_[i].second(); + } + + return tfld; +} + + // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // #include "TableBaseIO.C" diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H index da670e2db5..793716803a 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -172,6 +172,12 @@ public: const scalar x2 ) const; + //- Return the reference values + virtual tmp x() const; + + //- Return the dependent values + virtual tmp > y() const; + // I/O From 0c6a9870f0a7edc6f30d892348f09464577ac48b Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 28 Jan 2013 16:45:28 +0000 Subject: [PATCH 005/253] ENH: Documentation update --- .../fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H index 3540c9254c..8e1b21691f 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ Description \table Property | Description | Required | Default value - value | values | yes | + value | Patch face values | yes | \endtable Example of the boundary condition specification: From 3753faf14731f13e094f576dd601c565ea2131d0 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 28 Jan 2013 16:46:59 +0000 Subject: [PATCH 006/253] ENH: Updated CSV DataEntry --- .../primitives/functions/DataEntry/CSV/CSV.C | 99 +++++++++++++++---- .../primitives/functions/DataEntry/CSV/CSV.H | 29 ++++-- .../functions/DataEntry/CSV/CSVIO.C | 9 +- 3 files changed, 109 insertions(+), 28 deletions(-) diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C index 4719be1145..f896fa2fdb 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,36 +87,83 @@ void Foam::CSV::read() DynamicList > values; // skip header - if (headerLine_) + for (label i = 0; i < nHeaderLine_; i++) { string line; is.getLine(line); } + label nEntries = max(componentColumns_); + // read data while (is.good()) { string line; is.getLine(line); + + label n = 0; + std::size_t pos = 0; DynamicList splitted; - std::size_t pos = 0; - while (pos != std::string::npos) + if (mergeSeparators_) { - std::size_t nPos = line.find(separator_, pos); + std::size_t nPos = 0; - if (nPos == std::string::npos) + while ((pos != std::string::npos) && (n <= nEntries)) { - splitted.append(line.substr(pos)); - pos = nPos; - } - else - { - splitted.append(line.substr(pos, nPos - pos)); - pos = nPos + 1; + bool found = false; + while (!found) + { + nPos = line.find(separator_, pos); + + if ((nPos != std::string::npos) && (nPos - pos == 0)) + { + pos = nPos + 1; + } + else + { + found = true; + } + } + + nPos = line.find(separator_, pos); + + if (nPos == std::string::npos) + { + splitted.append(line.substr(pos)); + pos = nPos; + n++; + } + else + { + splitted.append(line.substr(pos, nPos - pos)); + pos = nPos + 1; + n++; + } } } + else + { + while ((pos != std::string::npos) && (n <= nEntries)) + { + std::size_t nPos = line.find(separator_, pos); + + if (nPos == std::string::npos) + { + splitted.append(line.substr(pos)); + pos = nPos; + n++; + } + else + { + splitted.append(line.substr(pos, nPos - pos)); + pos = nPos + 1; + n++; + } + } + } + if (splitted.size() <= 1) { @@ -136,15 +183,21 @@ void Foam::CSV::read() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::CSV::CSV(const word& entryName, const dictionary& dict) +Foam::CSV::CSV +( + const word& entryName, + const dictionary& dict, + const word& ext +) : DataEntry(entryName), - TableBase(entryName, dict.subDict(type() + "Coeffs")), - coeffs_(dict.subDict(type() + "Coeffs")), - headerLine_(readBool(coeffs_.lookup("hasHeaderLine"))), + TableBase(entryName, dict.subDict(type() + ext)), + coeffs_(dict.subDict(type() + ext)), + nHeaderLine_(readLabel(coeffs_.lookup("nHeaderLine"))), refColumn_(readLabel(coeffs_.lookup("refColumn"))), componentColumns_(coeffs_.lookup("componentColumns")), separator_(coeffs_.lookupOrDefault("separator", string(","))[0]), + mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))), fName_(coeffs_.lookup("fileName")) { if (componentColumns_.size() != pTraits::nComponents) @@ -166,10 +219,11 @@ Foam::CSV::CSV(const CSV& tbl) : DataEntry(tbl), TableBase(tbl), - headerLine_(tbl.headerLine_), + nHeaderLine_(tbl.nHeaderLine_), refColumn_(tbl.refColumn_), componentColumns_(tbl.componentColumns_), separator_(tbl.separator_), + mergeSeparators_(tbl.mergeSeparators_), fName_(tbl.fName_) {} @@ -181,6 +235,15 @@ Foam::CSV::~CSV() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +const Foam::fileName& Foam::CSV::fName() const +{ + return fName_; +} + + // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // #include "CSVIO.C" diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H index bcc3aee956..e5d0d23055 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,10 +32,11 @@ Description csvFile; csvFileCoeffs { - hasHeaderLine true; + nHeaderLines 4; refColumn 0; // reference column index componentColumns (1 2 3); // component column indices separator ","; // optional (defaults to ",") + mergeSeparators no; // merge multiple separators fileName "fileXYZ"; // name of csv data file outOfBounds clamp; // optional out-of-bounds handling interpolationScheme linear; // optional interpolation scheme @@ -86,8 +87,8 @@ class CSV //- Coefficients dictionary (for convenience on reading) dictionary coeffs_; - //- Does the file have a header line? - bool headerLine_; + //- Number header lines + label nHeaderLine_; //- Column of the time label refColumn_; @@ -98,7 +99,10 @@ class CSV //- Separator character char separator_; - //- File name for csv table (optional) + //- Merge separators flag, e.g. ',,,' becomes ',' + bool mergeSeparators_; + + //- File name for csv table fileName fName_; @@ -122,8 +126,13 @@ public: // Constructors - //- Construct from entry name and Istream - CSV(const word& entryName, const dictionary& dict); + //- Construct from entry name and dictionary + CSV + ( + const word& entryName, + const dictionary& dict, + const word& ext = "Ceoffs" + ); //- Copy constructor CSV(const CSV& tbl); @@ -150,6 +159,12 @@ public: } + // Access + + //- Return const access to the file name + virtual const fileName& fName() const; + + // Evaluation //- Return Table value diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C index b5bfad8b3a..683b2edf1e 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,10 +37,11 @@ Foam::Ostream& Foam::operator<< if (os.format() == IOstream::ASCII) { os << static_cast& >(tbl) - << token::SPACE << tbl.headerLine_ + << token::SPACE << tbl.nHeaderLine_ << token::SPACE << tbl.timeColumn_ << token::SPACE << tbl.componentColumns_ << token::SPACE << tbl.separator_ + << token::SPACE << tbl.mergeSeparators_ << token::SPACE << tbl.fileName_; } else @@ -70,13 +71,15 @@ void Foam::CSV::writeData(Ostream& os) const // the values themselves TableBase::writeEntries(os); - os.writeKeyword("hasHeaderLine") << headerLine_ << token::END_STATEMENT + os.writeKeyword("nHeaderLine") << nHeaderLine_ << token::END_STATEMENT << nl; os.writeKeyword("refColumn") << refColumn_ << token::END_STATEMENT << nl; os.writeKeyword("componentColumns") << componentColumns_ << token::END_STATEMENT << nl; os.writeKeyword("separator") << string(separator_) << token::END_STATEMENT << nl; + os.writeKeyword("mergeSeparators") << string(mergeSeparators_) + << token::END_STATEMENT << nl; os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl; os << decrIndent << indent << token::END_BLOCK << endl; } From c7d6a731d170259a7d64ce11b090f0f562b1d7ef Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 28 Jan 2013 16:55:07 +0000 Subject: [PATCH 007/253] ENH: Added new noise utility to generate FFT metrics from pressure data --- .../utilities/postProcessing/noise/Make/files | 3 + .../postProcessing/noise/Make/options | 7 + .../postProcessing/noise/createFields.H | 34 ++++ .../utilities/postProcessing/noise/noise.C | 177 ++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 applications/utilities/postProcessing/noise/Make/files create mode 100644 applications/utilities/postProcessing/noise/Make/options create mode 100644 applications/utilities/postProcessing/noise/createFields.H create mode 100644 applications/utilities/postProcessing/noise/noise.C diff --git a/applications/utilities/postProcessing/noise/Make/files b/applications/utilities/postProcessing/noise/Make/files new file mode 100644 index 0000000000..f39ca7345d --- /dev/null +++ b/applications/utilities/postProcessing/noise/Make/files @@ -0,0 +1,3 @@ +noise.C + +EXE = $(FOAM_APPBIN)/noise diff --git a/applications/utilities/postProcessing/noise/Make/options b/applications/utilities/postProcessing/noise/Make/options new file mode 100644 index 0000000000..b29b939580 --- /dev/null +++ b/applications/utilities/postProcessing/noise/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/randomProcesses/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +EXE_LIBS = \ + -lrandomProcesses \ + -lsampling diff --git a/applications/utilities/postProcessing/noise/createFields.H b/applications/utilities/postProcessing/noise/createFields.H new file mode 100644 index 0000000000..53598de047 --- /dev/null +++ b/applications/utilities/postProcessing/noise/createFields.H @@ -0,0 +1,34 @@ + word dictName("noiseDict"); + if (args.optionFound("dict")) + { + dictName = args["dict"]; + } + + IOdictionary dict + ( + IOobject + ( + dictName, + runTime.system(), + runTime, + IOobject::MUST_READ + ) + ); + + // reference pressure + scalar pRef = dict.lookupOrDefault("pRef", 0.0); + + // number of samples in sampling window + label N = dict.lookupOrDefault("N", 65536); + + // number of sampling windows + label nw = dict.lookupOrDefault("nw", 100); + + // lower frequency of frequency band + scalar f1 = dict.lookupOrDefault("f1", 25.0); + + // upper frequency of frequency band + scalar fU = dict.lookupOrDefault("fU", 10000.0); + + // graph format + word graphFormat = dict.lookupOrDefault("graphFormat", "raw"); diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C new file mode 100644 index 0000000000..9c19aadb99 --- /dev/null +++ b/applications/utilities/postProcessing/noise/noise.C @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + noise + +Description + Utility to perform noise analysis of pressure data using the noiseFFT + library. + + Control settings are read from the $FOAM_CASE/system/noiseDict dictionary, + or user-specified dictionary using the -dict option. Pressure data is + read using a CSV reader: + + \heading Usage + + \verbatim + pRef 101325; + N 65536; + nw 100; + f1 25; + fU 10000; + graphFormat raw; + + csvFileData + { + fileName "pressureData" + nHeaderLine 1; + refColumn 0; + componentColumns (1); + separator " "; + } + \endverbatim + + where + \table + Property | Description | Required | Default value + pRef | Reference pressure | no | 0 + N | Number of samples in sampling window | no | 65536 + nw | Number of sampling windows | no | 100 + fl | Lower frequency band | no | 25 + fU | Upper frequency band | no | 10000 + graphFormat | Output grapch format | no | raw + \endtable + + +SeeAlso + CSV.H + +\*---------------------------------------------------------------------------*/ + + +#include "noiseFFT.H" +#include "argList.H" +#include "Time.H" +#include "functionObjectFile.H" +#include "CSV.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::scalar checkUniformTimeStep(const scalarField& t) +{ + // check that a uniform time step has been applied + scalar deltaT = -1.0; + if (t.size() > 1) + { + for (label i = 1; i < t.size(); i++) + { + scalar dT = t[i] - t[i-1]; + if (deltaT < 0) + { + deltaT = dT; + } + + if (mag(deltaT - dT) > SMALL) + { + FatalErrorIn("checkUniformTimeStep(const scalarField&)") + << "Unable to process data with a variable time step" + << exit(FatalError); + } + } + } + else + { + FatalErrorIn("checkUniformTimeStep(const scalarField&)") + << "Unable to create FFT with a single value" + << exit(FatalError); + } + + return deltaT; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + #include "addDictOption.H" + #include "setRootCase.H" + #include "createTime.H" + #include "createFields.H" + + Info<< "Reading data file" << endl; + CSV pData("pressure", dict, "Data"); + + // time history data + const scalarField t(pData.x()); + + // pressure data + const scalarField p(pData.y()); + + if (t.size() < N) + { + FatalErrorIn(args.executable()) + << "Block size N = " << N + << " is larger than number of data = " << t.size() + << exit(FatalError); + } + + Info<< " read " << t.size() << " values" << nl << endl; + + + Info<< "Creating noise FFT" << endl; + noiseFFT nfft(checkUniformTimeStep(t), p); + + nfft -= pRef; + + fileName baseFileName(pData.fName().lessExt()); + + graph Pf(nfft.RMSmeanPf(N, min(nfft.size()/N, nw))); + Info<< " Creating graph for " << Pf.title() << endl; + Pf.write(baseFileName + graph::wordify(Pf.title()), graphFormat); + + graph Lf(nfft.Lf(Pf)); + Info<< " Creating graph for " << Lf.title() << endl; + Lf.write(baseFileName + graph::wordify(Lf.title()), graphFormat); + + graph Ldelta(nfft.Ldelta(Lf, f1, fU)); + Info<< " Creating graph for " << Ldelta.title() << endl; + Ldelta.write(baseFileName + graph::wordify(Ldelta.title()), graphFormat); + + graph Pdelta(nfft.Pdelta(Pf, f1, fU)); + Info<< " Creating graph for " << Pdelta.title() << endl; + Pdelta.write(baseFileName + graph::wordify(Pdelta.title()), graphFormat); + + Info<< nl << "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // From ed5304a6b346b91b91a28a6af767103dc179b30b Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 28 Jan 2013 17:05:27 +0000 Subject: [PATCH 008/253] ENH: Test-PointEdgeWave: patch wildcards --- .../test/PointEdgeWave/Test-PointEdgeWave.C | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/applications/test/PointEdgeWave/Test-PointEdgeWave.C b/applications/test/PointEdgeWave/Test-PointEdgeWave.C index 229268d518..c49c8662c1 100644 --- a/applications/test/PointEdgeWave/Test-PointEdgeWave.C +++ b/applications/test/PointEdgeWave/Test-PointEdgeWave.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,50 +41,50 @@ using namespace Foam; int main(int argc, char *argv[]) { - argList::validArgs.append("patch"); + argList::validArgs.append("(patches)"); # include "setRootCase.H" # include "createTime.H" # include "createPolyMesh.H" - const polyBoundaryMesh& patches = mesh.boundaryMesh(); + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); - // Get name of patch - const word patchName = args[1]; + labelList patchIDs + ( + pbm.patchSet(wordReList(IStringStream(args[1])())).sortedToc() + ); - // Find the label in patches by name. - label patchI = patches.findPatchID(patchName); + Info<< "Starting walk from patches " + << UIndirectList(pbm.names(), patchIDs) + << nl + << endl; + label nPoints = 0; + forAll(patchIDs, i) { - // Test whether any processor has patch - label maxPatchI = patchI; - - reduce(maxPatchI, maxOp