diff --git a/applications/solvers/combustion/fireFoam/UEqn.H b/applications/solvers/combustion/fireFoam/UEqn.H index 4a2d03490d..a77c262831 100644 --- a/applications/solvers/combustion/fireFoam/UEqn.H +++ b/applications/solvers/combustion/fireFoam/UEqn.H @@ -13,7 +13,9 @@ solve == fvc::reconstruct ( - fvc::interpolate(rho)*(g & mesh.Sf()) - - fvc::snGrad(p)*mesh.magSf() + ( + - ghf*fvc::snGrad(rho) + - fvc::snGrad(p_rgh) + )*mesh.magSf() ) ); diff --git a/applications/solvers/combustion/fireFoam/combustionModels/Make/files b/applications/solvers/combustion/fireFoam/combustionModels/Make/files index 86696b0709..5b1262b70d 100644 --- a/applications/solvers/combustion/fireFoam/combustionModels/Make/files +++ b/applications/solvers/combustion/fireFoam/combustionModels/Make/files @@ -1,5 +1,5 @@ combustionModel/combustionModel.C -combustionModel/combustionModelNew.C +combustionModel/newCombustionModel.C infinitelyFastChemistry/infinitelyFastChemistry.C diff --git a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModelNew.C b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C similarity index 77% rename from applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModelNew.C rename to applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C index e23386589c..62781b0fdb 100644 --- a/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/combustionModelNew.C +++ b/applications/solvers/combustion/fireFoam/combustionModels/combustionModel/newCombustionModel.C @@ -29,19 +29,22 @@ License Foam::autoPtr Foam::combustionModel::New ( - const dictionary& propDict, + const dictionary& combustionProperties, const hsCombustionThermo& thermo, const compressible::turbulenceModel& turbulence, const surfaceScalarField& phi, const volScalarField& rho ) { - const word modelType(propDict.lookup("combustionModel")); + word combustionModelTypeName = combustionProperties.lookup + ( + "combustionModel" + ); - Info<< "Selecting combustion model " << modelType << endl; + Info<< "Selecting combustion model " << combustionModelTypeName << endl; dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(modelType); + dictionaryConstructorTablePtr_->find(combustionModelTypeName); if (cstrIter == dictionaryConstructorTablePtr_->end()) { @@ -49,14 +52,14 @@ Foam::autoPtr Foam::combustionModel::New ( "combustionModel::New" ) << "Unknown combustionModel type " - << modelType << nl << nl - << "Valid combustionModels are : " << endl - << dictionaryConstructorTablePtr_->toc() + << combustionModelTypeName << endl << endl + << "Valid combustionModels are : " << endl + << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } return autoPtr - (cstrIter()(propDict, thermo, turbulence, phi, rho)); + (cstrIter()(combustionProperties, thermo, turbulence, phi, rho)); } diff --git a/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H index 851f119feb..53832f21b9 100644 --- a/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H +++ b/applications/solvers/combustion/fireFoam/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H @@ -88,8 +88,9 @@ public: ); - //- Destructor - virtual ~infinitelyFastChemistry(); + // Destructor + + virtual ~infinitelyFastChemistry(); // Member Functions diff --git a/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H index 9e15f0d300..b3f8bb225e 100644 --- a/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H +++ b/applications/solvers/combustion/fireFoam/combustionModels/noCombustion/noCombustion.H @@ -83,8 +83,9 @@ public: ); - //- Destructor - virtual ~noCombustion(); + // Destructor + + virtual ~noCombustion(); // Member Functions diff --git a/applications/solvers/combustion/fireFoam/createFields.H b/applications/solvers/combustion/fireFoam/createFields.H index 9a6274bb1a..6a1a40b777 100644 --- a/applications/solvers/combustion/fireFoam/createFields.H +++ b/applications/solvers/combustion/fireFoam/createFields.H @@ -35,6 +35,7 @@ const volScalarField& psi = thermo.psi(); volScalarField& ft = composition.Y("ft"); volScalarField& fu = composition.Y("fu"); + Info<< "Reading field U\n" << endl; volVectorField U @@ -73,7 +74,7 @@ IOdictionary combustionProperties Info<< "Creating combustion model\n" << endl; autoPtr combustion ( - combustionModel::New + combustionModel::combustionModel::New ( combustionProperties, thermo, @@ -83,6 +84,29 @@ autoPtr combustion ) ); + +Info<< "Calculating field g.h\n" << endl; +volScalarField gh("gh", g & mesh.C()); +surfaceScalarField ghf("gh", g & mesh.Cf()); + +Info<< "Reading field p_rgh\n" << endl; +volScalarField p_rgh +( + IOobject + ( + "p_rgh", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +// Force p_rgh to be consistent with p +p_rgh = p - rho*gh; + + volScalarField dQ ( IOobject @@ -103,15 +127,6 @@ volScalarField DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); -Info<< "Calculating field g.h\n" << endl; -volScalarField gh("gh", g & mesh.C()); - -surfaceScalarField ghf("gh", g & mesh.Cf()); - -p += rho*gh; - -thermo.correct(); - dimensionedScalar initialMass = fvc::domainIntegrate(rho); diff --git a/applications/solvers/combustion/fireFoam/pEqn.H b/applications/solvers/combustion/fireFoam/pEqn.H index 8d1ed0d9f8..b31a7c6636 100644 --- a/applications/solvers/combustion/fireFoam/pEqn.H +++ b/applications/solvers/combustion/fireFoam/pEqn.H @@ -1,5 +1,3 @@ -bool closedVolume = false; - rho = thermo.rho(); volScalarField rUA = 1.0/UEqn.A(); @@ -15,43 +13,41 @@ surfaceScalarField phiU ) ); -phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); +phi = phiU - rhorUAf*ghf*fvc::snGrad(rho)*mesh.magSf(); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA); + surfaceScalarField rhorUAf = fvc::interpolate(rho*rUA); - fvScalarMatrix pEqn + fvScalarMatrix p_rghEqn + ( + fvm::ddt(psi, p_rgh) + fvc::ddt(psi, rho)*gh + + fvc::div(phi) + - fvm::laplacian(rhorUAf, p_rgh) + ); + + p_rghEqn.solve + ( + mesh.solver ( - fvm::ddt(psi,p) - + fvc::div(phi) - - fvm::laplacian(rhorUAf, p) - ); - - closedVolume = p.needReference(); - - pEqn.solve - ( - mesh.solver + p_rgh.select ( - p.select ( - ( - finalIter - && corr == nCorr-1 - && nonOrth == nNonOrthCorr - ) + finalIter + && corr == nCorr-1 + && nonOrth == nNonOrthCorr ) ) - ); + ) + ); - if (nonOrth == nNonOrthCorr) - { - phi += pEqn.flux(); - } + if (nonOrth == nNonOrthCorr) + { + phi += p_rghEqn.flux(); + } } -DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +p = p_rgh + rho*gh; #include "rhoEqn.H" #include "compressibleContinuityErrs.H" @@ -59,12 +55,4 @@ DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf); U.correctBoundaryConditions(); -// For closed-volume cases adjust the pressure and density levels -// to obey overall mass continuity -if (closedVolume) -{ - p += - (initialMass - fvc::domainIntegrate(thermo.psi()*p)) - /fvc::domainIntegrate(thermo.psi()); - rho = thermo.rho(); -} +DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); diff --git a/applications/solvers/multiphase/interFoam/alphaCourantNo.H b/applications/solvers/multiphase/interFoam/alphaCourantNo.H index b970d4ce23..12d1b933d4 100644 --- a/applications/solvers/multiphase/interFoam/alphaCourantNo.H +++ b/applications/solvers/multiphase/interFoam/alphaCourantNo.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Global - CourantNo + alphaCourantNo Description Calculates and outputs the mean and maximum Courant Numbers. @@ -39,17 +39,14 @@ scalar meanAlphaCoNum = 0.0; if (mesh.nInternalFaces()) { - surfaceScalarField alphaf = fvc::interpolate(alpha1); + scalarField sumPhi = + pos(alpha1 - 0.01)*pos(0.99 - alpha1) + *fvc::surfaceSum(mag(phi))().internalField(); - surfaceScalarField SfUfbyDelta = - pos(alphaf - 0.01)*pos(0.99 - alphaf) - *mesh.surfaceInterpolation::deltaCoeffs()*mag(phi); + alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaT().value(); - alphaCoNum = max(SfUfbyDelta/mesh.magSf()) - .value()*runTime.deltaT().value(); - - meanAlphaCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) - .value()*runTime.deltaT().value(); + meanAlphaCoNum = + 0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaT().value(); } Info<< "Interface Courant Number mean: " << meanAlphaCoNum diff --git a/applications/test/Polynomial/Make/options b/applications/test/Polynomial/Make/options index 1b98398577..4c3dd783cb 100644 --- a/applications/test/Polynomial/Make/options +++ b/applications/test/Polynomial/Make/options @@ -1,3 +1,3 @@ -EXE_INC = \ +EXE_INC = -EXE_LIBS = \ +EXE_LIBS = diff --git a/applications/test/Polynomial/PolynomialTest.C b/applications/test/Polynomial/PolynomialTest.C index 4b7db7ef6f..fbfbcc2000 100644 --- a/applications/test/Polynomial/PolynomialTest.C +++ b/applications/test/Polynomial/PolynomialTest.C @@ -29,24 +29,30 @@ Description \*---------------------------------------------------------------------------*/ -#include "IFstream.H" +#include "IStringStream.H" #include "Polynomial.H" #include "Random.H" +#include "cpuTime.H" using namespace Foam; +const int PolySize = 8; +const scalar coeff[] = { 0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78 }; +const char* polyDef = "testPoly (0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)"; + + scalar polyValue(const scalar x) { // Hard-coded polynomial 8 coeff (7th order) return - 0.11 - + 0.45*x - - 0.94*sqr(x) - + 1.58*pow3(x) - - 2.58*pow4(x) - + 0.08*pow5(x) - + 3.15*pow6(x) - - 4.78*x*pow6(x); + coeff[0] + + coeff[1]*x + + coeff[2]*sqr(x) + + coeff[3]*pow3(x) + + coeff[4]*pow4(x) + + coeff[5]*pow5(x) + + coeff[6]*pow6(x) + + coeff[7]*x*pow6(x); } @@ -54,14 +60,44 @@ scalar intPolyValue(const scalar x) { // Hard-coded integrated form of above polynomial return - 0.11*x - + 0.45/2.0*sqr(x) - - 0.94/3.0*pow3(x) - + 1.58/4.0*pow4(x) - - 2.58/5.0*pow5(x) - + 0.08/6.0*pow6(x) - + 3.15/7.0*x*pow6(x) - - 4.78/8.0*x*x*pow6(x); + coeff[0]*x + + coeff[1]/2.0*sqr(x) + + coeff[2]/3.0*pow3(x) + + coeff[3]/4.0*pow4(x) + + coeff[4]/5.0*pow5(x) + + coeff[5]/6.0*pow6(x) + + coeff[6]/7.0*x*pow6(x) + + coeff[7]/8.0*x*x*pow6(x); +} + + +scalar polyValue1(const scalar x) +{ + // "normal" evaluation using pow() + scalar value = coeff[0]; + + for (int i=1; i < PolySize; ++i) + { + value += coeff[i]*pow(x, i); + } + + return value; +} + + +scalar polyValue2(const scalar x) +{ + // calculation avoiding pow() + scalar value = coeff[0]; + + scalar powX = x; + for (int i=1; i < PolySize; ++i) + { + value += coeff[i] * powX; + powX *= x; + } + + return value; } @@ -69,9 +105,14 @@ scalar intPolyValue(const scalar x) int main(int argc, char *argv[]) { - IFstream is("polyTestInput"); + const label n = 10000; + const label nIters = 1000; + scalar sum = 0.0; - Polynomial<8> poly("testPoly", is); + Info<< "null poly = " << (Polynomial<8>()) << nl << endl; + + // Polynomial<8> poly("testPoly", IStringStream(polyDef)()); + Polynomial<8> poly(coeff); Polynomial<9> intPoly(poly.integrate(0.0)); Info<< "poly = " << poly << endl; @@ -118,6 +159,62 @@ int main(int argc, char *argv[]) Info<< endl; } + + // + // test speed of Polynomial: + // + Info<< "start timing loops" << nl + << "~~~~~~~~~~~~~~~~~~" << endl; + + cpuTime timer; + + for (int loop = 0; loop < n; ++loop) + { + sum = 0.0; + for (label iter = 0; iter < nIters; ++iter) + { + sum += poly.evaluate(loop+iter); + } + } + Info<< "evaluate: " << sum + << " in " << timer.cpuTimeIncrement() << " s\n"; + + + for (int loop = 0; loop < n; ++loop) + { + sum = 0.0; + for (label iter = 0; iter < nIters; ++iter) + { + sum += polyValue(loop+iter); + } + } + Info<< "hard-coded 0: " << sum + << " in " << timer.cpuTimeIncrement() << " s\n"; + + + for (int loop = 0; loop < n; ++loop) + { + sum = 0.0; + for (label iter = 0; iter < nIters; ++iter) + { + sum += polyValue1(loop+iter); + } + } + Info<< "hard-coded 1: " << sum + << " in " << timer.cpuTimeIncrement() << " s\n"; + + for (int loop = 0; loop < n; ++loop) + { + sum = 0.0; + for (label iter = 0; iter < nIters; ++iter) + { + sum += polyValue2(loop+iter); + } + } + Info<< "hard-coded 2: " << sum + << " in " << timer.cpuTimeIncrement() << " s\n"; + + Info<< nl << "Done." << endl; return 0; diff --git a/applications/test/Polynomial/polyTestInput b/applications/test/Polynomial/polyTestInput deleted file mode 100644 index 4ba8f65e51..0000000000 --- a/applications/test/Polynomial/polyTestInput +++ /dev/null @@ -1,11 +0,0 @@ - testPoly - ( - 0.11 - 0.45 - -0.94 - 1.58 - -2.58 - 0.08 - 3.15 - -4.78 - ) diff --git a/applications/utilities/postProcessing/velocityField/Co/Co.C b/applications/utilities/postProcessing/velocityField/Co/Co.C index c64ca9e2b1..73653e3726 100644 --- a/applications/utilities/postProcessing/velocityField/Co/Co.C +++ b/applications/utilities/postProcessing/velocityField/Co/Co.C @@ -25,7 +25,7 @@ Application Co Description - Calculates and writes the Co number as a surfaceScalarField obtained + Calculates and writes the Co number as a volScalarField obtained from field phi. The -noWrite option just outputs the max values without writing the @@ -38,52 +38,6 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - tmp Co(const surfaceScalarField& Cof) - { - const fvMesh& mesh = Cof.mesh(); - - tmp tCo - ( - new volScalarField - ( - IOobject - ( - "Co", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar("0", Cof.dimensions(), 0) - ) - ); - - volScalarField& Co = tCo(); - - // Set local references to mesh data - const unallocLabelList& owner = mesh.owner(); - const unallocLabelList& neighbour = mesh.neighbour(); - - forAll(owner, facei) - { - label own = owner[facei]; - label nei = neighbour[facei]; - - Co[own] = max(Co[own], Cof[facei]); - Co[nei] = max(Co[nei], Cof[facei]); - } - - forAll(Co.boundaryField(), patchi) - { - Co.boundaryField()[patchi] = Cof.boundaryField()[patchi]; - } - - return tCo; - } -} - - void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); @@ -98,15 +52,28 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) if (phiHeader.headerOk()) { - autoPtr CoPtr; + volScalarField Co + ( + IOobject + ( + "Co", + runTime.timeName(), + mesh, + IOobject::NO_READ + ), + mesh, + dimensionedScalar("0", dimless, 0), + zeroGradientFvPatchScalarField::typeName + ); Info<< " Reading phi" << endl; surfaceScalarField phi(phiHeader, mesh); - Info<< " Calculating Co" << endl; if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) { - // compressible + Info<< " Calculating compressible Co" << endl; + + Info<< " Reading rho" << endl; volScalarField rho ( IOobject @@ -119,60 +86,34 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) mesh ); - CoPtr.set - ( - new surfaceScalarField - ( - IOobject - ( - "Cof", - runTime.timeName(), - mesh, - IOobject::NO_READ - ), - ( - mesh.surfaceInterpolation::deltaCoeffs() - * (mag(phi)/(fvc::interpolate(rho)*mesh.magSf())) - * runTime.deltaT() - ) - ) - ); + Co.dimensionedInternalField() = + (0.5*runTime.deltaT()) + *fvc::surfaceSum(mag(phi))().dimensionedInternalField() + /(rho*mesh.V()); + Co.correctBoundaryConditions(); } else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) { - // incompressible - CoPtr.set - ( - new surfaceScalarField - ( - IOobject - ( - "Cof", - runTime.timeName(), - mesh, - IOobject::NO_READ - ), - ( - mesh.surfaceInterpolation::deltaCoeffs() - * (mag(phi)/mesh.magSf()) - * runTime.deltaT() - ) - ) - ); + Info<< " Calculating incompressible Co" << endl; + + Co.dimensionedInternalField() = + (0.5*runTime.deltaT()) + *fvc::surfaceSum(mag(phi))().dimensionedInternalField() + /mesh.V(); + Co.correctBoundaryConditions(); } else { FatalErrorIn(args.executable()) << "Incorrect dimensions of phi: " << phi.dimensions() - << abort(FatalError); + << abort(FatalError); } - Info<< "Co max : " << max(CoPtr()).value() << endl; + Info<< "Co max : " << max(Co).value() << endl; if (writeResults) { - CoPtr().write(); - Co(CoPtr())().write(); + Co.write(); } } else @@ -183,4 +124,5 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) Info<< "\nEnd\n" << endl; } + // ************************************************************************* // diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 94bc86f2ef..97513b339d 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -85,6 +85,7 @@ $(primitiveLists)/vectorListIOList.C $(primitiveLists)/sphericalTensorList.C $(primitiveLists)/symmTensorList.C $(primitiveLists)/tensorList.C +$(primitiveLists)/hashedWordList.C Streams = db/IOstreams $(Streams)/token/tokenIO.C diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index 61c3da9bb9..a0b52f63d1 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -686,8 +686,14 @@ public: // Useful derived info - //- Is the point in the cell bounding box - bool pointInCellBB(const point& p, label celli) const; + //- Is the point in the cell bounding box, option relative + // tolerance to increase the effective size of the boundBox + bool pointInCellBB + ( + const point& p, + label celli, + scalar tol = 0 + ) const; //- Is the point in the cell bool pointInCell(const point& p, label celli) const; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C index fecbc3c6fb..228097654c 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C @@ -30,16 +30,33 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Is the point in the cell bounding box -bool Foam::primitiveMesh::pointInCellBB(const point& p, label celli) const +bool Foam::primitiveMesh::pointInCellBB +( + const point& p, + label celli, + scalar tol +) const { - return boundBox + boundBox bb ( cells()[celli].points ( faces(), points() - ) - ).contains(p); + ), + false + ); + + if (tol > SMALL) + { + bb = boundBox + ( + bb.min() - tol*bb.span(), + bb.max() + tol*bb.span() + ); + } + + return bb.contains(p); } diff --git a/src/OpenFOAM/primitives/Lists/hashedWordList.C b/src/OpenFOAM/primitives/Lists/hashedWordList.C new file mode 100644 index 0000000000..e9206bda8e --- /dev/null +++ b/src/OpenFOAM/primitives/Lists/hashedWordList.C @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 "hashedWordList.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::hashedWordList::rehash() +{ + indices_.clear(); + forAll(*this, i) + { + indices_.insert(List::operator[](i), i); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::hashedWordList::hashedWordList() +: + List() +{} + + +Foam::hashedWordList::hashedWordList(const UList& names) +: + List(names) +{ + rehash(); +} + + +Foam::hashedWordList::hashedWordList(const hashedWordList& names) +: + List(static_cast&>(names)) +{ + rehash(); +} + + +Foam::hashedWordList::hashedWordList(const Xfer< List >& names) +: + List(names) +{ + rehash(); +} + + +Foam::hashedWordList::hashedWordList +( + const label nNames, + const char** names +) +: + List(nNames) +{ + forAll(*this, i) + { + List::operator[](i) = names[i]; + } + + rehash(); +} + + +Foam::hashedWordList::hashedWordList +( + const char** names +) +{ + // count names + label nNames = 0; + for (unsigned i = 0; names[i] && *(names[i]); ++i) + { + ++nNames; + } + + List::setSize(nNames); + forAll(*this, i) + { + List::operator[](i) = names[i]; + } + + rehash(); +} + + +Foam::hashedWordList::hashedWordList(Istream& is) +{ + is >> *this; +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::hashedWordList::clear() +{ + List::clear(); + indices_.clear(); +} + + +void Foam::hashedWordList::append(const word& name) +{ + const label idx = size(); + List::append(name); + indices_.insert(name, idx); +} + + +void Foam::hashedWordList::transfer(List& lst) +{ + List::transfer(lst); + rehash(); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, hashedWordList& lst) +{ + is >> static_cast&>(lst); + lst.rehash(); + + return is; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const hashedWordList& lst) +{ + os << static_cast&>(lst); + return os; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Lists/hashedWordList.H b/src/OpenFOAM/primitives/Lists/hashedWordList.H new file mode 100644 index 0000000000..93a23d8db3 --- /dev/null +++ b/src/OpenFOAM/primitives/Lists/hashedWordList.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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::hashedWordList + +Description + A wordList with hashed indices for faster lookup by name. + +SourceFiles + hashedWordListI.H + hashedWordList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef hashedWordList_H +#define hashedWordList_H + +#include "wordList.H" +#include "HashTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class hashedWordList; + +// Forward declaration of friend functions and operators +Istream& operator>>(Istream&, hashedWordList&); +Ostream& operator<<(Ostream&, const hashedWordList&); + + +/*---------------------------------------------------------------------------*\ + Class hashedWordList Declaration +\*---------------------------------------------------------------------------*/ + +class hashedWordList +: + public List +{ + // Private data + + HashTable indices_; + + + // Private Member Functions + + //- rebuild the hash of indices + void rehash(); + +public: + + // Constructors + + //- Construct null + hashedWordList(); + + //- Copy constructor. + hashedWordList(const hashedWordList&); + + //- Construct from list of names + hashedWordList(const UList& names); + + //- Construct by transferring the parameter contents + hashedWordList(const Xfer< List >& names); + + //- Construct from number and list of names + hashedWordList(const label nNames, const char** names); + + //- Construct from a NULL-terminated list of names + hashedWordList(const char** names); + + //- Construct from Istream + hashedWordList(Istream&); + + + // Member Functions + + //- Clear the list, i.e. set size to zero. + void clear(); + + //- Append an element at the end of the list + void append(const word&); + + //- Does the list contain the specified name + inline bool contains(const word&) const; + + //- Transfer the contents of the argument List into this list + // and annul the argument list. + void transfer(List&); + + + // Member Operators + + //- Assignment operator from list of names + inline void operator=(const UList& names); + + //- Assignment operator. + inline void operator=(const hashedWordList&); + + //- Allow readonly access to list of words + inline operator const Foam::UList&() const; + + //- Return name corresponding to specified index + inline const word& operator[](const label index) const; + + //- Return index corresponding to specified name + inline label operator[](const word&) const; + + + // Istream operators + + friend Istream& operator>>(Istream&, hashedWordList&); + friend Ostream& operator<<(Ostream&, const hashedWordList&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "hashedWordListI.H" + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/speciesTable/speciesTableI.H b/src/OpenFOAM/primitives/Lists/hashedWordListI.H similarity index 66% rename from src/thermophysicalModels/specie/speciesTable/speciesTableI.H rename to src/OpenFOAM/primitives/Lists/hashedWordListI.H index 8a8c85694a..1e736aa6c5 100644 --- a/src/thermophysicalModels/specie/speciesTable/speciesTableI.H +++ b/src/OpenFOAM/primitives/Lists/hashedWordListI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,32 +21,44 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline bool Foam::speciesTable::contains(const word& specieName) const +inline bool Foam::hashedWordList::contains(const word& name) const { - return specieIndices_.found(specieName); + return indices_.found(name); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline const Foam::word& Foam::speciesTable::operator[] -( - const label specieIndex -) const +inline void Foam::hashedWordList::operator=(const UList& lst) { - return wordList::operator[](specieIndex); + List::operator=(lst); + rehash(); } -inline Foam::label Foam::speciesTable::operator[](const word& specieName) const +inline void Foam::hashedWordList::operator=(const hashedWordList& lst) { - return specieIndices_[specieName]; + operator=(static_cast&>(lst)); +} + + +inline const Foam::word& Foam::hashedWordList::operator[] +( + const label index +) const +{ + return List::operator[](index); +} + + +// could return -1 instead of bombing out +inline Foam::label Foam::hashedWordList::operator[](const word& name) const +{ + return indices_[name]; } diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C index 1e7b7aa618..cff3744644 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C @@ -33,7 +33,50 @@ Foam::Polynomial::Polynomial() VectorSpace, scalar, PolySize>(), logActive_(false), logCoeff_(0.0) -{} +{ + for (int i = 0; i < PolySize; ++i) + { + this->v_[i] = 0.0; + } +} + + +template +Foam::Polynomial::Polynomial(const scalar coeffs[PolySize]) +: + VectorSpace, scalar, PolySize>(), + logActive_(false), + logCoeff_(0.0) +{ + for (int i=0; iv_[i] = coeffs[i]; + } +} + + +template +Foam::Polynomial::Polynomial(const UList& coeffs) +: + VectorSpace, scalar, PolySize>(), + logActive_(false), + logCoeff_(0.0) +{ + if (coeffs.size() != PolySize) + { + FatalErrorIn + ( + "Polynomial::Polynomial(const UList&)" + ) << "Size mismatch: Needed " << PolySize + << " but got " << coeffs.size() + << nl << exit(FatalError); + } + + for (int i = 0; i < PolySize; ++i) + { + this->v_[i] = coeffs[i]; + } +} template @@ -101,9 +144,12 @@ Foam::scalar Foam::Polynomial::evaluate(const scalar x) const { scalar y = this->v_[0]; - for (label i=1; iv_[i]*pow(x, i); + y += this->v_[i]*powX; + powX *= x; } if (logActive_) @@ -170,13 +216,9 @@ Foam::Polynomial::integrateMinus1(const scalar intConstant) } newCoeffs[0] = intConstant; - - if (PolySize > 0) + for (label i=1; iv_[i]/i; - } + newCoeffs[i] = this->v_[i]/i; } return newCoeffs; diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H index cbfe045803..f2449d1835 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H @@ -29,7 +29,7 @@ Description poly = logCoeff*log(x) + sum(coeff_[i]*x^i) - where 0 <= i <= n + where 0 \<= i \<= n - integer powers, starting at zero - evaluate(x) to evaluate the poly for a given value @@ -51,6 +51,7 @@ SourceFiles #include "scalar.H" #include "Ostream.H" #include "VectorSpace.H" +#include "StaticAssert.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -79,6 +80,9 @@ class Polynomial : public VectorSpace, scalar, PolySize> { + //- Size must be positive (non-zero) + StaticAssert(PolySize > 0); + // Private data //- Include the log term? - only activated using integrateMinus1() @@ -97,9 +101,15 @@ public: // Constructors - //- Construct null + //- Construct null, with all coefficients = 0.0 Polynomial(); + //- Construct from C-array of coefficients + explicit Polynomial(const scalar coeffs[PolySize]); + + //- Construct from a list of coefficients + explicit Polynomial(const UList& coeffs); + //- Construct from name and Istream Polynomial(const word& name, Istream& is); diff --git a/src/finiteVolume/cfdTools/compressible/compressibleCourantNo.H b/src/finiteVolume/cfdTools/compressible/compressibleCourantNo.H index b618efbd0d..73da862406 100644 --- a/src/finiteVolume/cfdTools/compressible/compressibleCourantNo.H +++ b/src/finiteVolume/cfdTools/compressible/compressibleCourantNo.H @@ -34,14 +34,14 @@ scalar meanCoNum = 0.0; if (mesh.nInternalFaces()) { - surfaceScalarField SfUfbyDelta = - mesh.surfaceInterpolation::deltaCoeffs()*mag(phi)/fvc::interpolate(rho); + scalarField sumPhi = + fvc::surfaceSum(mag(phi))().internalField() + /rho.internalField(); - CoNum = max(SfUfbyDelta/mesh.magSf()) - .value()*runTime.deltaTValue(); + CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaT().value(); - meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) - .value()*runTime.deltaTValue(); + meanCoNum = + 0.5*(gSum(sumPhi)/sum(mesh.V().field()))*runTime.deltaT().value(); } Info<< "Courant Number mean: " << meanCoNum diff --git a/src/finiteVolume/cfdTools/incompressible/CourantNo.H b/src/finiteVolume/cfdTools/incompressible/CourantNo.H index 83bc8765ac..caef48a396 100644 --- a/src/finiteVolume/cfdTools/incompressible/CourantNo.H +++ b/src/finiteVolume/cfdTools/incompressible/CourantNo.H @@ -34,14 +34,13 @@ scalar meanCoNum = 0.0; if (mesh.nInternalFaces()) { - surfaceScalarField SfUfbyDelta = - mesh.surfaceInterpolation::deltaCoeffs()*mag(phi); + scalarField sumPhi = + fvc::surfaceSum(mag(phi))().internalField(); - CoNum = max(SfUfbyDelta/mesh.magSf()) - .value()*runTime.deltaTValue(); + CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaT().value(); - meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) - .value()*runTime.deltaTValue(); + meanCoNum = + 0.5*(gSum(sumPhi)/sum(mesh.V().field()))*runTime.deltaT().value(); } Info<< "Courant Number mean: " << meanCoNum diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C index 2593c7ad1a..92309507c1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C @@ -249,7 +249,7 @@ void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs() min ( openFraction_ - + max + + min ( this->db().time().deltaTValue()/openingTime_, maxOpenFractionDelta_ diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index 87b23e4538..c18174baec 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -121,9 +121,9 @@ void Foam::Cloud::initCloud(const bool checkClass) } else { - Pout<< "Cannot read particle positions file " << nl + Pout<< "Cannot read particle positions file:" << nl << " " << ioP.path() << nl - << " assuming the initial cloud contains 0 particles." << endl; + << "Assuming the initial cloud contains 0 particles." << endl; } // Ask for the tetBasePtIs to trigger all processors to build diff --git a/src/lagrangian/basic/Particle/ParticleI.H b/src/lagrangian/basic/Particle/ParticleI.H index 35d658d115..50c727fe4a 100644 --- a/src/lagrangian/basic/Particle/ParticleI.H +++ b/src/lagrangian/basic/Particle/ParticleI.H @@ -970,11 +970,12 @@ inline void Foam::Particle::initCellFacePt() // number, but hasn't been able to find a cell to // occupy. - if(!cloud_.polyMesh_.pointInCellBB(position_, oldCellI)) + if(!cloud_.polyMesh_.pointInCellBB(position_, oldCellI, 0.1)) { - // If the position is not inside the bound-box of - // the cell that it thought it should be in, then - // this is considered an error. + // If the position is not inside the (slightly + // extended) bound-box of the cell that it thought + // it should be in, then this is considered an + // error. FatalErrorIn ( @@ -985,18 +986,20 @@ inline void Foam::Particle::initCellFacePt() ")" ) << "cell, tetFace and tetPt search failure at position " << position_ << nl + << "for requested cell " << oldCellI << nl << abort(FatalError); } - // The position is in the bound-box of the cell. This - // situation may arise because the face decomposition - // of the cell is not the same as when the particle - // acquired the cell index. For example, it has been - // read into a mesh that has made a different face - // base-point decision for a boundary face and now - // this particle is in a position that is not in the - // mesh. Gradually move the particle towards the - // centre of the cell that it thought that it was in. + // The position is in the (slightly extended) + // bound-box of the cell. This situation may arise + // because the face decomposition of the cell is not + // the same as when the particle acquired the cell + // index. For example, it has been read into a mesh + // that has made a different face base-point decision + // for a boundary face and now this particle is in a + // position that is not in the mesh. Gradually move + // the particle towards the centre of the cell that it + // thought that it was in. cellI_ = oldCellI; diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C index ef50886ebf..da5f1ce1dd 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C @@ -1108,7 +1108,7 @@ Foam::moleculeCloud::moleculeCloud mesh_(mesh), pot_(pot), cellOccupancy_(mesh_.nCells()), - il_(mesh_, pot_.pairPotentials().rCutMax(), true), + il_(mesh_, pot_.pairPotentials().rCutMax(), false), constPropList_(), rndGen_(clock::getTime()) { diff --git a/src/thermophysicalModels/liquidMixture/Make/options b/src/thermophysicalModels/liquidMixture/Make/options index 506b8ac9a2..bfa6b569ba 100644 --- a/src/thermophysicalModels/liquidMixture/Make/options +++ b/src/thermophysicalModels/liquidMixture/Make/options @@ -5,3 +5,7 @@ EXE_INC = \ -I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude +LIB_LIBS = \ + -lliquids \ + -lthermophysicalFunctions + diff --git a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C index 4941eab537..d46e3e110a 100644 --- a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C +++ b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C @@ -31,6 +31,7 @@ License const Foam::scalar Foam::liquidMixture::TrMax = 0.999; + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::liquidMixture::liquidMixture @@ -41,32 +42,26 @@ Foam::liquidMixture::liquidMixture components_(thermophysicalProperties.lookup("liquidComponents")), properties_(components_.size()) { - // use sub-dictionary "liquidProperties" if possible to avoid + // can use sub-dictionary "liquidProperties" to avoid // collisions with identically named gas-phase entries // (eg, H2O liquid vs. gas) + const dictionary* subDictPtr = thermophysicalProperties.subDictPtr + ( + "liquidProperties" + ); + + const dictionary& props = + ( + subDictPtr ? *subDictPtr : thermophysicalProperties + ); + forAll(components_, i) { - const dictionary* subDictPtr = thermophysicalProperties.subDictPtr + properties_.set ( - "liquidProperties" + i, + liquid::New(props.lookup(components_[i])) ); - - if (subDictPtr) - { - properties_.set - ( - i, - liquid::New(subDictPtr->lookup(components_[i])) - ); - } - else - { - properties_.set - ( - i, - liquid::New(thermophysicalProperties.lookup(components_[i])) - ); - } } } diff --git a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H index a5ae1c3fbb..8810256475 100644 --- a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H +++ b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H @@ -103,7 +103,7 @@ class liquidMixture { // Private data - // maximum reduced temperature + //- Maximum reduced temperature static const scalar TrMax; //- The names of the liquids @@ -130,6 +130,7 @@ public: // Member Functions + //- Return the liquid names inline const List& components() const { return components_; @@ -141,6 +142,13 @@ public: return properties_; } + //- Return the number of liquids in the mixture + inline label size() const + { + return components_.size(); + } + + //- Calculate the critical temperature of mixture scalar Tc(const scalarField& x) const; diff --git a/src/thermophysicalModels/liquids/Make/options b/src/thermophysicalModels/liquids/Make/options index 8a129fda6c..b964b61294 100644 --- a/src/thermophysicalModels/liquids/Make/options +++ b/src/thermophysicalModels/liquids/Make/options @@ -1 +1,5 @@ -EXE_INC = -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude +EXE_INC = \ + -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude + +LIB_LIBS = \ + -lthermophysicalFunctions diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H index deec87298d..0ac653c9c0 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H @@ -44,38 +44,38 @@ Description The look-up table ("speciesTable") file should be in constant i.e. dictionary + @verbatim + LookUpTableFileName "speciesTable"; - LookUpTableFileName "speciesTable"; + EhrrCoeff 0.0; - EhrrCoeff 0.0; + CO2 + { + Tcommon 300.; // Common Temp + invTemp true; // Is the polynomial using inverse temperature? + Tlow 300.; // Low Temp + Thigh 2500.; // High Temp - CO2 - { - Tcommon 300.; // Common Temp - invTemp true; // Is the polynomial using inverse temperature? - Tlow 300.; // Low Temp - Thigh 2500.; // High Temp - - loTcoeffs // coeffs for T < Tcommon - ( - 0 // a0 + - 0 // a1*T + - 0 // a2*T^(+/-)2 + - 0 // a3*T^(+/-)3 + - 0 // a4*T^(+/-)4 + - 0 // a5*T^(+/-)5 + - ); - hiTcoeffs // coeffs for T > Tcommon - ( - 18.741 - -121.31e3 - 273.5e6 - -194.05e9 - 56.31e12 - -5.8169e15 - ); - - } + loTcoeffs // coeffs for T < Tcommon + ( + 0 // a0 + + 0 // a1*T + + 0 // a2*T^(+/-)2 + + 0 // a3*T^(+/-)3 + + 0 // a4*T^(+/-)4 + + 0 // a5*T^(+/-)5 + + ); + hiTcoeffs // coeffs for T > Tcommon + ( + 18.741 + -121.31e3 + 273.5e6 + -194.05e9 + 56.31e12 + -5.8169e15 + ); + } + @endverbatim SourceFiles greyMeanAbsorptionEmission.C diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.H index f1194b3f0c..4b93da89de 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.H @@ -46,53 +46,52 @@ Description The look Up table file should be in the constant directory. band dictionary: - - band0 - { - bandLimits (1.0e-6 2.63e-6); - EhrrCoeff 0.0; - species + @verbatim + band0 { - CH4 + bandLimits (1.0e-6 2.63e-6); + EhrrCoeff 0.0; + species { - Tcommon 300.; - Tlow 300.; - Thigh 2500.; - invTemp false; - loTcoeffs (0 0 0 0 0 0) ; - hiTcoeffs (.1 0 0 0 0 0); - } - CO2 - { - Tcommon 300.; - Tlow 300.; - Thigh 2500.; - invTemp false; - loTcoeffs (0 0 0 0 0 0) ; - hiTcoeffs (.1 0 0 0 0 0); - } - - H2O - { - Tcommon 300.; - Tlow 300.; - Thigh 2500.; - invTemp false; - loTcoeffs (0 0 0 0 0 0) ; - hiTcoeffs (.1 0 0 0 0 0); - } - - Ysoot - { - Tcommon 300.; - Tlow 300.; - Thigh 2500.; - invTemp false; - loTcoeffs (0 0 0 0 0 0) ; - hiTcoeffs (.1 0 0 0 0 0); + CH4 + { + Tcommon 300.; + Tlow 300.; + Thigh 2500.; + invTemp false; + loTcoeffs (0 0 0 0 0 0) ; + hiTcoeffs (.1 0 0 0 0 0); + } + CO2 + { + Tcommon 300.; + Tlow 300.; + Thigh 2500.; + invTemp false; + loTcoeffs (0 0 0 0 0 0) ; + hiTcoeffs (.1 0 0 0 0 0); + } + H2O + { + Tcommon 300.; + Tlow 300.; + Thigh 2500.; + invTemp false; + loTcoeffs (0 0 0 0 0 0) ; + hiTcoeffs (.1 0 0 0 0 0); + } + Ysoot + { + Tcommon 300.; + Tlow 300.; + Thigh 2500.; + invTemp false; + loTcoeffs (0 0 0 0 0 0) ; + hiTcoeffs (.1 0 0 0 0 0); + } } } - } + @endverbatim SourceFiles diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C index 80418cbc83..b474c59451 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C @@ -859,7 +859,7 @@ Foam::chemkinReader::chemkinReader : lineNo_(1), specieNames_(10), - speciesTable_(static_cast(wordList())) + speciesTable_() { read(CHEMKINFileName, thermoFileName); } @@ -870,7 +870,7 @@ Foam::chemkinReader::chemkinReader(const dictionary& thermoDict) : lineNo_(1), specieNames_(10), - speciesTable_(static_cast(wordList())) + speciesTable_() { fileName chemkinFile ( diff --git a/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.C b/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.C index 55ccd4057f..6cf5163397 100644 --- a/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.C +++ b/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.C @@ -35,13 +35,24 @@ Foam::solidMixture::solidMixture components_(thermophysicalProperties.lookup("solidComponents")), properties_(components_.size()) { + // can use sub-dictionary "solidProperties" to avoid + // collisions with identically named gas-phase entries + const dictionary* subDictPtr = thermophysicalProperties.subDictPtr + ( + "solidProperties" + ); + + const dictionary& props = + ( + subDictPtr ? *subDictPtr : thermophysicalProperties + ); forAll(components_, i) { properties_.set ( i, - solid::New(thermophysicalProperties.lookup(components_[i])) + solid::New(props.lookup(components_[i])) ); } } @@ -82,12 +93,12 @@ Foam::scalar Foam::solidMixture::rho const scalarField& X ) const { - scalar tmp = 0.0; + scalar val = 0.0; forAll(properties_, i) { - tmp += properties_[i].rho()*X[i]; + val += properties_[i].rho()*X[i]; } - return tmp; + return val; } @@ -96,12 +107,12 @@ Foam::scalar Foam::solidMixture::cp const scalarField& Y ) const { - scalar tmp = 0.0; + scalar val = 0.0; forAll(properties_, i) { - tmp += properties_[i].cp()*Y[i]; + val += properties_[i].cp()*Y[i]; } - return tmp; + return val; } diff --git a/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H b/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H index 50f8b54a6c..ba1d582ee5 100644 --- a/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H +++ b/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H @@ -25,7 +25,18 @@ Class Foam::solidMixture Description - Foam::solidMixture + A mixture of solids. + +Note + The dictionary constructor searches for the entry @c solidComponents, + which is a wordList. The solid properties of each component can either + be contained within a @c solidProperties sub-dictionary or (for legacy + purposes) can be found directly in the dictionary. + The @c solidProperties sub-dictionary entry should be used when possible + to avoid conflicts with identically named gas-phase entries. + +SeeAlso + Foam::liquidMixture \*---------------------------------------------------------------------------*/ @@ -74,7 +85,7 @@ public: // Member Functions - //- Return the sold names + //- Return the solid names inline const List& components() const { return components_; @@ -86,6 +97,13 @@ public: return properties_; } + //- Return the number of solids in the mixture + inline label size() const + { + return components_.size(); + } + + //- Returns the mass fractions, given mole fractions scalarField Y(const scalarField& X) const; diff --git a/src/thermophysicalModels/specie/Make/files b/src/thermophysicalModels/specie/Make/files index 428f6d8fc7..0e0eacae89 100644 --- a/src/thermophysicalModels/specie/Make/files +++ b/src/thermophysicalModels/specie/Make/files @@ -1,12 +1,10 @@ atomicWeights = atomicWeights specie = specie -speciesTable = speciesTable equationOfState = equationOfState reactions = reaction/reactions $(atomicWeights)/atomicWeights.C $(specie)/specie.C -$(speciesTable)/speciesTable.C $(equationOfState)/perfectGas/perfectGas.C $(reactions)/makeChemkinReactions.C $(reactions)/makeReactionThermoReactions.C diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H b/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H index 8e8096fa71..dd6008f09e 100644 --- a/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H +++ b/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H @@ -42,7 +42,7 @@ inline Foam::thirdBodyEfficiencies::thirdBodyEfficiencies "thirdBodyEfficiencies::thirdBodyEfficiencies" "(const speciesTable& species, const scalarList& efficiencies)" ) << "number of efficiencies = " << size() - << " is not equat to the number of species " << species_.size() + << " is not equal to the number of species " << species_.size() << exit(FatalError); } } @@ -105,7 +105,7 @@ inline Foam::thirdBodyEfficiencies::thirdBodyEfficiencies "(const speciesTable& species, Istream& is)", is ) << "number of efficiencies = " << size() - << " is not equat to the number of species " << species_.size() + << " is not equal to the number of species " << species_.size() << exit(FatalIOError); } } diff --git a/src/thermophysicalModels/specie/speciesTable/speciesTable.C b/src/thermophysicalModels/specie/speciesTable/speciesTable.C deleted file mode 100644 index 3c5b0cb176..0000000000 --- a/src/thermophysicalModels/specie/speciesTable/speciesTable.C +++ /dev/null @@ -1,83 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. - \\/ 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 "speciesTable.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::speciesTable::setIndices() -{ - forAll(*this, i) - { - specieIndices_.insert(wordList::operator[](i), i); - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from list of specie names -Foam::speciesTable::speciesTable(const wordList& specieNames) -: - wordList(specieNames) -{ - setIndices(); -} - - -// Construct from number of species and list of specie names -Foam::speciesTable::speciesTable(const label nSpecies, const char** specieNames) -: - wordList(nSpecies) -{ - forAll(*this, i) - { - wordList::operator[](i) = specieNames[i]; - } - - setIndices(); -} - - -// Construct from Istream -Foam::speciesTable::speciesTable(Istream& is) -: - wordList(is) -{ - setIndices(); -} - - -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -Foam::Istream& Foam::operator>>(Istream& is, speciesTable& st) -{ - is >> static_cast(st); - st.setIndices(); - - return is; -} - -// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/speciesTable/speciesTable.H b/src/thermophysicalModels/specie/speciesTable/speciesTable.H index 4e7013d015..72533ad0a6 100644 --- a/src/thermophysicalModels/specie/speciesTable/speciesTable.H +++ b/src/thermophysicalModels/specie/speciesTable/speciesTable.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,89 +21,25 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Class +Typedef Foam::speciesTable Description - A table of species - -SourceFiles - speciesTableI.H - speciesTable.C + A table of species as a hashedWordList \*---------------------------------------------------------------------------*/ #ifndef speciesTable_H #define speciesTable_H -#include "wordList.H" -#include "HashTable.H" +#include "hashedWordList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -/*---------------------------------------------------------------------------*\ - Class speciesTable Declaration -\*---------------------------------------------------------------------------*/ - -class speciesTable -: - public wordList -{ - // Private data - - HashTable