diff --git a/applications/utilities/postProcessing/noise/Make/files b/applications/utilities/postProcessing/noise/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..f39ca7345d41ec49f42c97b0689aa1d2320d2269 --- /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 0000000000000000000000000000000000000000..b29b939580748d59669a36947c8687210c2b4bc5 --- /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 0000000000000000000000000000000000000000..53598de047b8b65eb068794ac01794a6959c1425 --- /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<word>("graphFormat", "raw"); diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C new file mode 100644 index 0000000000000000000000000000000000000000..9c19aadb99ad4a53cc59125b318972c05f4010f9 --- /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 <http://www.gnu.org/licenses/>. + +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<scalar> 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; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/graph/graph.C b/src/OpenFOAM/graph/graph.C index 7c59cfc2f692ce68dccd07bab5b4cfd75f51c827..0ec122dcc320c76966d7a0de5cec406ad9655231 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<xy> 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 2a414980618710a4722f4b1683c4416b044fc5d7..b3ff00c37d5938a826bc3cc889d88622fc78ba8f 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 diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C index 4719be11452ff760d4808066876f249dd9157f76..f896fa2fdb5e6ab2806adcaa4434b3946db0035d 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,37 +87,84 @@ void Foam::CSV<Type>::read() DynamicList<Tuple2<scalar, Type> > 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); - DynamicList<string> splitted; + label n = 0; std::size_t pos = 0; - while (pos != std::string::npos) + DynamicList<string> splitted; + + 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; + 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 + } + else + { + while ((pos != std::string::npos) && (n <= nEntries)) { - splitted.append(line.substr(pos, nPos - pos)); - pos = nPos + 1; + 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) { break; @@ -136,15 +183,21 @@ void Foam::CSV<Type>::read() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Type> -Foam::CSV<Type>::CSV(const word& entryName, const dictionary& dict) +Foam::CSV<Type>::CSV +( + const word& entryName, + const dictionary& dict, + const word& ext +) : DataEntry<Type>(entryName), - TableBase<Type>(entryName, dict.subDict(type() + "Coeffs")), - coeffs_(dict.subDict(type() + "Coeffs")), - headerLine_(readBool(coeffs_.lookup("hasHeaderLine"))), + TableBase<Type>(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<string>("separator", string(","))[0]), + mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))), fName_(coeffs_.lookup("fileName")) { if (componentColumns_.size() != pTraits<Type>::nComponents) @@ -166,10 +219,11 @@ Foam::CSV<Type>::CSV(const CSV<Type>& tbl) : DataEntry<Type>(tbl), TableBase<Type>(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<Type>::~CSV() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +const Foam::fileName& Foam::CSV<Type>::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 bcc3aee956b34f1e3dba5dbe9632f31f11714e74..e5d0d23055bbb9da55e80e514aac5439c490f702 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 <entryName> 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<Type>& 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 b5bfad8b3af813f7bc72cbcd52cf3dbecb289586..683b2edf1e13f24ce3e3cd1418f64aa19286c0b0 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<const DataEntry<Type>& >(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<Type>::writeData(Ostream& os) const // the values themselves TableBase<Type>::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; } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C index 08dde8e7583ba8efb189e77ebf2df6742cc43d8d..054d87575e233f582dca293d42a4b8f05205ae87 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<Type> Foam::TableBase<Type>::dimIntegrate } +template<class Type> +Foam::tmp<Foam::scalarField> Foam::TableBase<Type>::x() const +{ + tmp<scalarField> tfld(new scalarField(table_.size(), 0.0)); + scalarField& fld = tfld(); + + forAll(table_, i) + { + fld[i] = table_[i].first(); + } + + return tfld; +} + + +template<class Type> +Foam::tmp<Foam::Field<Type> > Foam::TableBase<Type>::y() const +{ + tmp<Field<Type> > tfld(new Field<Type>(table_.size(), pTraits<Type>::zero)); + Field<Type>& 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 da670e2db56a80ec8eecc6e781963219464e79ce..793716803aeb6388f1029a85b19c13f125c88094 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<scalarField> x() const; + + //- Return the dependent values + virtual tmp<Field<Type> > y() const; + // I/O diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 47bdb976b3f4d6800b47156a3ec7cc2a5348a2ea..3bf9c8747d6ba37b46ca7e71634897d868d79eb1 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -124,6 +124,7 @@ $(derivedFvPatchFields)/buoyantPressure/buoyantPressureFvPatchScalarField.C $(derivedFvPatchFields)/codedFixedValue/codedFixedValueFvPatchFields.C $(derivedFvPatchFields)/codedMixed/codedMixedFvPatchFields.C $(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/externalCoupledMixed/externalCoupledMixedFvPatchFields.C $(derivedFvPatchFields)/fan/fanFvPatchFields.C $(derivedFvPatchFields)/fanPressure/fanPressureFvPatchScalarField.C $(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.H index 3540c9254ca7198422e26d4af1d8d5a0627821cc..8e1b21691f72ffd3aec03f8abd481f3ac9a6c29f 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: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..d207981fca2f4c4fb604390fad6137fd4bf2a183 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C @@ -0,0 +1,451 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "externalCoupledMixedFvPatchField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "IFstream.H" +#include "OFstream.H" +#include "globalIndex.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<class Type> +Foam::word Foam::externalCoupledMixedFvPatchField<Type>::lockName = "OpenFOAM"; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class Type> +Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::baseDir() const +{ + word regionName(this->dimensionedInternalField().mesh().name()); + if (regionName == polyMesh::defaultRegion) + { + regionName = "."; + } + + return fileName(commsDir_/regionName/this->patch().name()); +} + + +template<class Type> +void Foam::externalCoupledMixedFvPatchField<Type>::createLockFile() const +{ + if (!Pstream::master()) + { + return; + } + + if (log_) + { + Info<< type() << ": creating lock file" << endl; + } + + OFstream os(baseDir()/(lockName + ".lock")); + os << "waiting"; + os.flush(); +} + + +template<class Type> +void Foam::externalCoupledMixedFvPatchField<Type>::removeLockFile() const +{ + if (!Pstream::master()) + { + return; + } + + if (log_) + { + Info<< type() << ": removing lock file" << endl; + } + + rm(baseDir()/(lockName + ".lock")); +} + + +template<class Type> +void Foam::externalCoupledMixedFvPatchField<Type>::writeAndWait +( + const fileName& transferFile +) const +{ + if (log_) + { + Info<< type() << ": writing data to " << transferFile << endl; + } + + if (Pstream::parRun()) + { + int tag = Pstream::msgType() + 1; + + List<Field<Type> > values(Pstream::nProcs()); + values[Pstream::myProcNo()].setSize(this->refValue().size()); + values[Pstream::myProcNo()] = this->refValue(); + Pstream::gatherList(values, tag); + + List<Field<Type> > grads(Pstream::nProcs()); + grads[Pstream::myProcNo()].setSize(this->refGrad().size()); + grads[Pstream::myProcNo()] = this->refGrad(); + Pstream::gatherList(grads, tag); + + List<scalarField> fracs(Pstream::nProcs()); + fracs[Pstream::myProcNo()].setSize(this->valueFraction().size()); + fracs[Pstream::myProcNo()] = this->valueFraction(); + Pstream::gatherList(fracs, tag); + + if (Pstream::master()) + { + OFstream os(transferFile); + + forAll(values, procI) + { + const Field<Type>& v = values[procI]; + const Field<Type>& g = grads[procI]; + const scalarField& f = fracs[procI]; + + forAll(v, faceI) + { + os << v[faceI] << token::SPACE + << g[faceI] << token::SPACE + << f[faceI] << nl; + } + } + + os.flush(); + } + } + else + { + OFstream os(transferFile); + + forAll(this->patch(), faceI) + { + os << this->refValue()[faceI] << token::SPACE + << this->refGrad()[faceI] << token::SPACE + << this->valueFraction()[faceI] << nl; + } + + os.flush(); + } + + const fileName lockFile(baseDir()/(lockName + ".lock")); + + // remove lock file, signalling external source to execute + removeLockFile(); + + + if (log_) + { + Info<< type() << ": beginning wait for lock file " << lockFile + << endl; + } + + bool found = false; + label totalTime = 0; + + while (!found) + { + sleep(waitInterval_); + totalTime += waitInterval_; + + if (log_) + { + Info<< type() << ": wait time = " << totalTime << endl; + } + + if (totalTime > timeOut_) + { + FatalErrorIn + ( + "void Foam::externalCoupledMixedFvPatchField<Type>::" + "writeAndWait(const fileName&) const" + ) + << "Wait time exceeded time out time of " << timeOut_ + << " s" << abort(FatalError); + } + + IFstream is(lockFile); + + if (is.good()) + { + if (log_) + { + Info<< type() << ": found lock file " << lockFile << endl; + } + + found = true; + } + } + + + if (Pstream::master()) + { + // remove old data file from OpenFOAM + rm(transferFile); + } +} + + +template<class Type> +void Foam::externalCoupledMixedFvPatchField<Type>::initialiseRead +( + IFstream& is +) const +{ + if (!is.good()) + { + FatalErrorIn + ( + "void Foam::externalCoupledMixedFvPatchField<Type>::" + "initialiseRead()" + ) + << "Unable to open data transfer file " << is.name() + << " for patch " << this->patch().name() + << exit(FatalError); + } + + if (Pstream::parRun()) + { + // fast-forward to relevant point in file + globalIndex gi(this->patch().size()); + + if (this->patch().size()) + { + string line; + const label offset = gi.offset(Pstream::myProcNo()); + for (label i = 0; i < offset; i++) + { + if (is.good()) + { + is.getLine(line); + } + else + { + FatalErrorIn + ( + "void Foam::externalCoupledMixedFvPatchField<Type>::" + "initialiseRead()" + ) + << "Unable to distribute parallel data for file " + << is.name() << " for patch " << this->patch().name() + << exit(FatalError); + } + } + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::externalCoupledMixedFvPatchField<Type>::externalCoupledMixedFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF +) +: + mixedFvPatchField<Type>(p, iF), + commsDir_("unknown-commsDir"), + waitInterval_(0), + timeOut_(0), + calcFrequency_(0), + log_(false) +{ + this->refValue() = pTraits<Type>::zero; + this->refGrad() = pTraits<Type>::zero; + this->valueFraction() = 0.0; +} + + +template<class Type> +Foam::externalCoupledMixedFvPatchField<Type>::externalCoupledMixedFvPatchField +( + const externalCoupledMixedFvPatchField& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField<Type>(ptf, p, iF, mapper), + commsDir_(ptf.commsDir_), + fName_(ptf.fName_), + waitInterval_(ptf.waitInterval_), + timeOut_(ptf.timeOut_), + calcFrequency_(ptf.calcFrequency_), + log_(ptf.log_) +{} + + +template<class Type> +Foam::externalCoupledMixedFvPatchField<Type>::externalCoupledMixedFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchField<Type>(p, iF), + commsDir_(dict.lookup("commsDir")), + fName_(dict.lookup("fileName")), + waitInterval_(dict.lookupOrDefault("waitInterval", 1)), + timeOut_(dict.lookupOrDefault("timeOut", 100*waitInterval_)), + calcFrequency_(dict.lookupOrDefault("calcFrequency", 1)), + log_(dict.lookupOrDefault("log", false)) +{ + if (dict.found("value")) + { + fvPatchField<Type>::operator= + ( + Field<Type>("value", dict, p.size()) + ); + } + else + { + fvPatchField<Type>::operator=(this->patchInternalField()); + } + + if (Pstream::master()) + { + commsDir_.expand(); + mkDir(baseDir()); + createLockFile(); + } + + // initialise as a fixed value + this->refValue() = *this; + this->refGrad() = pTraits<Type>::zero; + this->valueFraction() = 1.0; +} + + +template<class Type> +Foam::externalCoupledMixedFvPatchField<Type>::externalCoupledMixedFvPatchField +( + const externalCoupledMixedFvPatchField& ecmpf +) +: + mixedFvPatchField<Type>(ecmpf), + commsDir_(ecmpf.commsDir_), + fName_(ecmpf.fName_), + waitInterval_(ecmpf.waitInterval_), + timeOut_(ecmpf.timeOut_), + calcFrequency_(ecmpf.calcFrequency_), + log_(ecmpf.log_) +{} + + +template<class Type> +Foam::externalCoupledMixedFvPatchField<Type>::externalCoupledMixedFvPatchField +( + const externalCoupledMixedFvPatchField& ecmpf, + const DimensionedField<Type, volMesh>& iF +) +: + mixedFvPatchField<Type>(ecmpf, iF), + commsDir_(ecmpf.commsDir_), + fName_(ecmpf.fName_), + waitInterval_(ecmpf.waitInterval_), + timeOut_(ecmpf.timeOut_), + calcFrequency_(ecmpf.calcFrequency_), + log_(ecmpf.log_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +void Foam::externalCoupledMixedFvPatchField<Type>::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + if (this->db().time().timeIndex() % calcFrequency_ == 0) + { + fileName transferFile(baseDir()/fName_); + + // write data for external source and wait for response + writeAndWait(transferFile + ".out"); + + // read data passed back from external source + IFstream is(transferFile + ".in"); + + // pre-process the input transfer file + initialiseRead(is); + + // read data from file + forAll(this->patch(), faceI) + { + if (is.good()) + { + is >> this->refValue()[faceI] + >> this->refGrad()[faceI] + >> this->valueFraction()[faceI]; + } + else + { + FatalErrorIn + ( + "void Foam::externalCoupledMixedFvPatchField<Type>::" + "updateCoeffs()" + ) + << "Insufficient data for patch " << this->patch().name() + << " in file " << is.name() << exit(FatalError); + } + } + + // create lock file for external source + createLockFile(); + } + + mixedFvPatchField<Type>::updateCoeffs(); +} + + +template<class Type> +void Foam::externalCoupledMixedFvPatchField<Type>::write(Ostream& os) const +{ + mixedFvPatchField<Type>::write(os); + + os.writeKeyword("commsDir") << commsDir_ << token::END_STATEMENT << nl; + os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl; + os.writeKeyword("waitInterval") << waitInterval_ << token::END_STATEMENT + << nl; + os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT + << nl; + os.writeKeyword("calcFrequency") << calcFrequency_ << token::END_STATEMENT + << nl; + os.writeKeyword("log") << log_ << token::END_STATEMENT << nl; + + this->writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..229d9bad6c33ebc16ae98faaff17b84eb3f27681 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H @@ -0,0 +1,251 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>. + +Class + Foam::externalCoupledMixedFvPatchField + +Group + grpGenericBoundaryConditions grpCoupledBoundaryConditions + +Description + This boundary condition provides an interface to an external application. + Values are transferred as plain text files, comprising of the constituent + pieces of the `mixed' condition, i.e. + + <value1> <gradient1> <valueFracion1> + <value2> <gradient2> <valueFracion2> + <value3> <gradient3> <valueFracion3> + ... + <valueN> <gradientN> <valueFracionN> + + At start-up, the boundary creates a lock file, e.g. + + $FOAM_CASE/comms/patchName/OpenFOAM.lock + + ... to signal the external source to wait. During the boundary condition + update, boundary values are written to file, e.g. + + $FOAM_CASE/comms/patchName/data.out + + The lock file is then removed, instructing the exterbal source to take + control of the program execution. When ready, the external program + should create the return values, e.g. to file + + $FOAM_CASE/comms/patchName/data.in + + ... and then re-instate the lock file. The boundary condition will then + read the return values, and pass program execution back to OpenFOAM. + + + \heading Patch usage + + \table + Property | Description | Required | Default value + commsDir | communications folder | yes | + fileName | data transfer file name | yes | + waitInterval | interval [s] between file checks | no | 1 + timeOut | time after which error invoked | no | 100*waitInterval + calcFrequency | calculation frequency | no | 1 + log | log program control | no | no + \endtable + + Example of the boundary condition specification: + \verbatim + myPatch + { + type externalCoupled; + commsDir "$FOAM_CASE/comms"; + fileName data; + } + \endverbatim + +SeeAlso + mixedFvPatchField + +SourceFiles + externalCoupledMixedFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef externalCoupledMixedFvPatchField_H +#define externalCoupledMixedFvPatchField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class IFstream; + +/*---------------------------------------------------------------------------*\ + Class externalCoupledMixedFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class externalCoupledMixedFvPatchField +: + public mixedFvPatchField<Type> +{ + +protected: + + // Private data + + //- Path to communications folder + fileName commsDir_; + + //- Name of data file + word fName_; + + //- Interval time between checking for return data [s] + label waitInterval_; + + //- Time out time [s] + label timeOut_; + + //- Calculation frequency + label calcFrequency_; + + //- Log flag + bool log_; + + + // Private Member Functions + + //- Return the file path to the base communications folder + fileName baseDir() const; + + //- Create lock file + void createLockFile() const; + + //- Remove lock file + void removeLockFile() const; + + //- Wait and remove lock file + void writeAndWait(const fileName& transferFile) const; + + //- Initialise input stream for reading + void initialiseRead(IFstream& is) const; + + +public: + + //- Runtime type information + TypeName("externalCoupled"); + + //- Name of lock file + static word lockName; + + + // Constructors + + //- Construct from patch and internal field + externalCoupledMixedFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + externalCoupledMixedFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given externalCoupledMixedFvPatchField + // onto a new patch + externalCoupledMixedFvPatchField + ( + const externalCoupledMixedFvPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + externalCoupledMixedFvPatchField + ( + const externalCoupledMixedFvPatchField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<Type> > clone() const + { + return tmp<fvPatchField<Type> > + ( + new externalCoupledMixedFvPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + externalCoupledMixedFvPatchField + ( + const externalCoupledMixedFvPatchField&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<Type> > clone + ( + const DimensionedField<Type, volMesh>& iF + ) const + { + return tmp<fvPatchField<Type> > + ( + new externalCoupledMixedFvPatchField<Type>(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "externalCoupledMixedFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..42ab10636d5cf304bfadc234540066b8e5d62a85 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFields.C @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "externalCoupledMixedFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(externalCoupledMixed); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..36d457004b0a9992f7fa24ba7048fcef6327a3e8 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef externalCoupledMixedFvPatchFields_H +#define externalCoupledMixedFvPatchFields_H + +#include "externalCoupledMixedFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(externalCoupledMixed); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFieldsFwd.H new file mode 100644 index 0000000000000000000000000000000000000000..7aae5c7b502ea25242f635c936398f08d5873d9f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef externalCoupledMixedFvPatchFieldsFwd_H +#define externalCoupledMixedFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class externalCoupledMixedFvPatchField; + +makePatchTypeFieldTypedefs(externalCoupledMixed); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 21d86aa6fa8c2f2c64ef1aac41c607a5317b4d47..fecefcd2e367be8dd1a5ffb064cd8239b0c2d533 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 @@ -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(); } @@ -299,8 +299,6 @@ tmp<Foam::fvVectorMatrix> kinematicSingleLayer::solveMomentum Info<< "kinematicSingleLayer::solveMomentum()" << endl; } - updateSurfaceVelocities(); - // Momentum tmp<fvVectorMatrix> 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 5bf0534819f0404869ee2193d28c5c4725c2d9fd..42d459ce01254a404dbff9ef2863dcf4fbd47cdf 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(); }