diff --git a/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H index 743b1d68ff..d9ca1b09e0 100644 --- a/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H +++ b/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H @@ -31,7 +31,7 @@ if (solveSpecies) == parcels.SYi(i, Yi) + combustion->R(Yi) - + sources(Yi) + + sources(rho, Yi) ); sources.constrain(YEqn); diff --git a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H index 9ef9d6a1a0..3e4a041f90 100644 --- a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H @@ -47,17 +47,10 @@ #include "createPhi.H" - Info<< "Creating turbulence model\n" << endl; - singlePhaseTransportModel laminarTransport(U, phi); const volScalarField nu(laminarTransport.nu()); - autoPtr turbulence - ( - incompressible::turbulenceModel::New(U, phi, laminarTransport) - ); - volScalarField mu ( IOobject diff --git a/applications/test/volPointInterpolation/Test-volPointInterpolation.C b/applications/test/volPointInterpolation/Test-volPointInterpolation.C index 1bbcd6da5e..96ffeeac37 100644 --- a/applications/test/volPointInterpolation/Test-volPointInterpolation.C +++ b/applications/test/volPointInterpolation/Test-volPointInterpolation.C @@ -33,11 +33,10 @@ Application int main(int argc, char *argv[]) { + #include "setRootCase.H" -# include "setRootCase.H" - -# include "createTime.H" -# include "createMesh.H" + #include "createTime.H" + #include "createMesh.H" Info<< "Reading field p\n" << endl; volScalarField p @@ -67,9 +66,29 @@ int main(int argc, char *argv[]) mesh ); + const pointMesh& pMesh = pointMesh::New(mesh); + const pointBoundaryMesh& pbm = pMesh.boundary(); + + Info<< "pointMesh boundary" << nl; + forAll(pbm, patchI) + { + Info<< "patch=" << pbm[patchI].name() + << ", type=" << pbm[patchI].type() + << ", coupled=" << pbm[patchI].coupled() + << endl; + } + const volPointInterpolation& pInterp = volPointInterpolation::New(mesh); + pointScalarField pp(pInterp.interpolate(p)); + Info<< pp.name() << " boundary" << endl; + forAll(pp.boundaryField(), patchI) + { + Info<< pbm[patchI].name() << " coupled=" + << pp.boundaryField()[patchI].coupled()<< endl; + } + pp.write(); pointVectorField pU(pInterp.interpolate(U)); diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/Make/files b/applications/utilities/parallelProcessing/redistributeMeshPar/Make/files deleted file mode 100644 index c96d0406ba..0000000000 --- a/applications/utilities/parallelProcessing/redistributeMeshPar/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -redistributeMeshPar.C - -EXE = $(FOAM_APPBIN)/redistributeMeshPar diff --git a/applications/utilities/parallelProcessing/redistributePar/Make/files b/applications/utilities/parallelProcessing/redistributePar/Make/files new file mode 100644 index 0000000000..ce0b6760d4 --- /dev/null +++ b/applications/utilities/parallelProcessing/redistributePar/Make/files @@ -0,0 +1,3 @@ +redistributePar.C + +EXE = $(FOAM_APPBIN)/redistributePar diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/Make/options b/applications/utilities/parallelProcessing/redistributePar/Make/options similarity index 100% rename from applications/utilities/parallelProcessing/redistributeMeshPar/Make/options rename to applications/utilities/parallelProcessing/redistributePar/Make/options diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C similarity index 99% rename from applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C rename to applications/utilities/parallelProcessing/redistributePar/redistributePar.C index e8522fa18b..5eaff912ef 100644 --- a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Application - redistributeMeshPar + redistributePar Description Redistributes existing decomposed mesh and fields according to the current @@ -42,7 +42,7 @@ Description cp -r constant processor0 # Distribute - mpirun -np ddd redistributeMeshPar -parallel + mpirun -np ddd redistributePar -parallel \endverbatim \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C new file mode 100644 index 0000000000..3fe17d24a0 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "CSV.H" +#include "DynamicList.H" +#include "IFstream.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +namespace Foam +{ + // doesn't recognize specialization otherwise + template<> + scalar CSV::readValue(const List& splitted) + { + if (componentColumns_[0] >= splitted.size()) + { + FatalErrorIn("CSV::readValue(const List&)") + << "No column " << componentColumns_[0] << " in " + << splitted << endl + << exit(FatalError); + } + + return readScalar(IStringStream(splitted[componentColumns_[0]])()); + } + + + template + Type CSV::readValue(const List& splitted) + { + Type result; + + for (label i = 0; i < pTraits::nComponents; i++) + { + if (componentColumns_[i] >= splitted.size()) + { + FatalErrorIn("CSV::readValue(const List&)") + << "No column " << componentColumns_[i] << " in " + << splitted << endl + << exit(FatalError); + } + + result[i] = + readScalar(IStringStream(splitted[componentColumns_[i]])()); + } + + return result; + } +} + + +template +void Foam::CSV::read() +{ + IFstream is(fName_.expand()); + + DynamicList > values; + + // skip header + if (headerLine_) + { + string line; + is.getLine(line); + } + + // read data + while (is.good()) + { + string line; + is.getLine(line); + + DynamicList splitted; + + std::size_t pos = 0; + while (pos != std::string::npos) + { + std::size_t nPos = line.find(separator_, pos); + + if (nPos == std::string::npos) + { + splitted.append(line.substr(pos)); + pos = nPos; + } + else + { + splitted.append(line.substr(pos, nPos - pos)); + pos = nPos + 1; + } + } + + if (splitted.size() <= 1) + { + break; + } + + scalar x = readScalar(IStringStream(splitted[refColumn_])()); + Type value = readValue(splitted); + + values.append(Tuple2(x, value)); + } + + this->table_.transfer(values); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CSV::CSV(const word& entryName, const dictionary& dict) +: + DataEntry(entryName), + TableBase(entryName, dict.subDict(type() + "Coeffs")), + coeffs_(dict.subDict(type() + "Coeffs")), + headerLine_(readBool(coeffs_.lookup("hasHeaderLine"))), + refColumn_(readLabel(coeffs_.lookup("refColumn"))), + componentColumns_(coeffs_.lookup("componentColumns")), + separator_(coeffs_.lookupOrDefault("separator", string(","))[0]), + fName_(coeffs_.lookup("fileName")) +{ + if (componentColumns_.size() != pTraits::nComponents) + { + FatalErrorIn("Foam::CSV::CSV(const word&, Istream&)") + << componentColumns_ << " does not have the expected length of " + << pTraits::nComponents << endl + << exit(FatalError); + } + + read(); + + TableBase::check(); +} + + +template +Foam::CSV::CSV(const CSV& tbl) +: + DataEntry(tbl), + TableBase(tbl), + headerLine_(tbl.headerLine_), + refColumn_(tbl.refColumn_), + componentColumns_(tbl.componentColumns_), + separator_(tbl.separator_), + fName_(tbl.fName_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::CSV::~CSV() +{} + + +// * * * * * * * * * * * * * * 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 new file mode 100644 index 0000000000..c95406350b --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +Class + Foam::CSV + +Description + Templated CSV container data entry. Reference column is always a scalar, + e.g. time + + \verbatim + csvFile + { + hasHeaderLine true; + refColumn 0; // reference column index + componentColumns (0 1 2); // component column indices + separator ","; // optional (defaults to ",") + fileName fileXYZ; // name of csv data file + outOfBounds clamp; // optional out-of-bounds handling + } + \endverbatim + +SourceFiles + CSV.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CSV_H +#define CSV_H + +#include "DataEntry.H" +#include "TableBase.H" +#include "Tuple2.H" +#include "labelList.H" +#include "ISstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template +class CSV; + +template +Ostream& operator<< +( + Ostream&, + const CSV& +); + +/*---------------------------------------------------------------------------*\ + Class CSV Declaration +\*---------------------------------------------------------------------------*/ + +template +class CSV +: + public DataEntry, + public TableBase +{ + // Private data + + //- Coefficients dictionary (for convenience on reading) + dictionary coeffs_; + + //- Does the file have a header line? + bool headerLine_; + + //- Column of the time + label refColumn_; + + //- Labels of the components + labelList componentColumns_; + + //- Separator character + char separator_; + + //- File name for csv table (optional) + fileName fName_; + + + // Private Member Functions + + //- Read csv data table + void read(); + + //- Read the next value from the splitted string + Type readValue(const List&); + + //- Disallow default bitwise assignment + void operator=(const CSV&); + + +public: + + //- Runtime type information + TypeName("csvFile"); + + + // Constructors + + //- Construct from entry name and Istream + CSV(const word& entryName, const dictionary& dict); + + //- Copy constructor + CSV(const CSV& tbl); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp >(new CSV(*this)); + } + + + //- Destructor + virtual ~CSV(); + + + // Member Functions + + //- Return Table value + virtual Type value(const scalar x) const + { + return TableBase::value(x); + } + + //- Integrate between two (scalar) values + virtual Type integrate(const scalar x1, const scalar x2) const + { + return TableBase::integrate(x1, x2); + } + + + // I/O + + //- Ostream Operator + friend Ostream& operator<< + ( + Ostream& os, + const CSV& cnst + ); + + //- Write in dictionary format + virtual void writeData(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "CSV.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C new file mode 100644 index 0000000000..d16ca23ab8 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "DataEntry.H" + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const CSV& tbl +) +{ + if (os.format() == IOstream::ASCII) + { + os << static_cast& >(tbl) + << token::SPACE << tbl.headerLine_ + << token::SPACE << tbl.timeColumn_ + << token::SPACE << tbl.componentColumns_ + << token::SPACE << tbl.separator_ + << token::SPACE << tbl.fileName_; + } + else + { + os << static_cast& >(tbl); + } + + // Check state of Ostream + os.check + ( + "Ostream& operator<<(Ostream&, const CSV&)" + ); + + return os; +} + + +template +void Foam::CSV::writeData(Ostream& os) const +{ + DataEntry::writeData(os); + + os << token::END_STATEMENT << nl; + os << indent << word(type() + "Coeffs") << nl; + os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.writeKeyword("headerLine") << headerLine_ << 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("fileName") << fName_ << token::END_STATEMENT << nl; + os << decrIndent << indent << token::END_BLOCK << endl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C index 2fe5238d8d..410052f560 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C @@ -28,11 +28,14 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::Constant::Constant(const word& entryName, Istream& is) +Foam::Constant::Constant(const word& entryName, const dictionary& dict) : DataEntry(entryName), value_(pTraits::zero) { + Istream& is(dict.lookup(entryName)); + word entryType(is); + is >> value_; } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H index 658a667240..c42e07e054 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H @@ -83,7 +83,7 @@ public: // Constructors //- Construct from entry name and Istream - Constant(const word& entryName, Istream& is); + Constant(const word& entryName, const dictionary& dict); //- Copy constructor Constant(const Constant& cnst); diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H index 03d1da361a..5b3e783101 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H @@ -92,9 +92,9 @@ public: dictionary, ( const word& entryName, - Istream& is + const dictionary& dict ), - (entryName, is) + (entryName, dict) ); diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C index a62ce1054f..57cf79c419 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C @@ -35,7 +35,6 @@ Foam::autoPtr > Foam::DataEntry::New ) { Istream& is(dict.lookup(entryName)); - word DataEntryType(is); typename dictionaryConstructorTable::iterator cstrIter = @@ -54,7 +53,7 @@ Foam::autoPtr > Foam::DataEntry::New << exit(FatalError); } - return autoPtr >(cstrIter()(entryName, is)); + return autoPtr >(cstrIter()(entryName, dict)); } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C index 91e501f5be..dd60ac90fb 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C @@ -28,17 +28,17 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::Table::Table(const word& entryName, Istream& is) +Foam::Table::Table(const word& entryName, const dictionary& dict) : DataEntry(entryName), - table_(is) + TableBase(entryName, dictionary::null) { - if (!table_.size()) - { - FatalErrorIn("Foam::Table::Table(const Istream&)") - << "Table for entry " << this->name_ << " is invalid (empty)" - << nl << exit(FatalError); - } + Istream& is(dict.lookup(entryName)); + word entryType(is); + + is >> this->table_; + + TableBase::check(); } @@ -46,7 +46,7 @@ template Foam::Table::Table(const Table& tbl) : DataEntry(tbl), - table_(tbl.table_) + TableBase(tbl) {} @@ -57,98 +57,6 @@ Foam::Table::~Table() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Type Foam::Table::value(const scalar x) const -{ - // Return zero if out of bounds - if (x < table_[0].first() || x > table_.last().first()) - { - return pTraits::zero; - } - - // Find i such that x(i) < x < x(i+1) - label i = 0; - while ((table_[i+1].first() < x) && (i+1 < table_.size())) - { - i++; - } - - // Linear interpolation to find value. Note constructor needed for - // Table