From b202ea483864359e358db3f8b5cfef445790d9fa Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 18 Oct 2013 08:27:48 +0100 Subject: [PATCH 01/37] STYLE: Minor code formatting --- src/OpenFOAM/db/Time/TimeIO.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 8aa894def7..84f334f18b 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -579,8 +579,8 @@ void Foam::Time::readModifiedObjects() if (controlDict_.readIfModified()) { - readDict(); - functionObjects_.read(); + readDict(); + functionObjects_.read(); } bool registryModified = objectRegistry::modified(); From cc052498133ad24ae5a493f842ea42c5abcc468a Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 18 Oct 2013 08:28:35 +0100 Subject: [PATCH 02/37] ENH: Surface filme - updated thixotropicViscosity model documentation --- .../thixotropicViscosity/thixotropicViscosity.H | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.H b/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.H index 3cdd3235e6..609b7940e6 100644 --- a/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.H +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/filmViscosityModel/thixotropicViscosity/thixotropicViscosity.H @@ -35,13 +35,13 @@ Description The viscosity is then calculated using the expression \f[ - \mu = \frac{\mu_{inf}}{{1 - K \lambda}^2} + \mu = \frac{\mu_{\infty}}{{1 - K \lambda}^2} \f] Where the parameter K is given by: \f[ - K = 1 - \frac{\mu_{\inf}}{\mu_{0}}^0.5 + K = 1 - \sqrt{\frac{\mu_{\infty}}{\mu_{0}}} \f] Here: @@ -53,7 +53,7 @@ Description d | model coefficient \dot{\gamma} | stress rate [1/s] \mu_{0} | limiting viscosity when \f$ \lambda = 1 \f$ - \mu_{\inf} | limiting viscosity when \f$ \lambda = 0 \f$ + \mu_{\infty} | limiting viscosity when \f$ \lambda = 0 \f$ \endvartable From f5e747a553c545893e58207af5144484bc6c040c Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 18 Oct 2013 08:29:14 +0100 Subject: [PATCH 03/37] STYLE: Minor code formatting --- .../polyTopoChanger/polyTopoChanger.C | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C index 7efbf7cce2..2c7a064b29 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,7 +51,7 @@ void Foam::polyTopoChanger::readModifiers() { WarningIn("polyTopoChanger::readModifiers()") << "Specified IOobject::MUST_READ_IF_MODIFIED but class" - << " does not support automatic rereading." + << " does not support automatic re-reading." << endl; } @@ -80,18 +80,13 @@ void Foam::polyTopoChanger::readModifiers() } // Check state of IOstream - is.check - ( - "polyTopoChanger::polyTopoChanger" - "(const IOobject&, const polyMesh&)" - ); + is.check("polyTopoChanger::readModifiers()"); close(); } } -// Read constructor given IOobject and a polyMesh reference Foam::polyTopoChanger::polyTopoChanger ( const IOobject& io, @@ -106,7 +101,6 @@ Foam::polyTopoChanger::polyTopoChanger } -// Read constructor given IOobject and a polyMesh reference Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) : PtrList(), @@ -133,7 +127,6 @@ Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) } -// Return a list of modifier types Foam::wordList Foam::polyTopoChanger::types() const { const PtrList& modifiers = *this; @@ -149,7 +142,6 @@ Foam::wordList Foam::polyTopoChanger::types() const } -// Return a list of modifier names Foam::wordList Foam::polyTopoChanger::names() const { const PtrList& modifiers = *this; @@ -165,7 +157,6 @@ Foam::wordList Foam::polyTopoChanger::names() const } -// Is topology change required bool Foam::polyTopoChanger::changeTopology() const { // Go through all mesh modifiers and accumulate the morphing information @@ -211,7 +202,6 @@ bool Foam::polyTopoChanger::changeTopology() const } -// Return topology change request Foam::autoPtr Foam::polyTopoChanger::topoChangeRequest() const { @@ -233,7 +223,6 @@ Foam::polyTopoChanger::topoChangeRequest() const } -// Correct polyTopoChanger after moving points void Foam::polyTopoChanger::modifyMotionPoints(pointField& p) const { const PtrList& topoChanges = *this; @@ -248,7 +237,6 @@ void Foam::polyTopoChanger::modifyMotionPoints(pointField& p) const } -// Force recalculation of locally stored data on topological change void Foam::polyTopoChanger::update(const mapPolyMesh& m) { // Go through all mesh modifiers and accumulate the morphing information @@ -299,7 +287,6 @@ Foam::autoPtr Foam::polyTopoChanger::changeMesh } -// Add mesh modifiers to the morph engine void Foam::polyTopoChanger::addTopologyModifiers ( const List& tm @@ -314,8 +301,10 @@ void Foam::polyTopoChanger::addTopologyModifiers { FatalErrorIn ( - "void polyTopoChanger::addTopologyModifiers(" - "const List& tm)" + "void polyTopoChanger::addTopologyModifiers" + "(" + "const List&" + ")" ) << "Mesh modifier created with different mesh reference." << abort(FatalError); } @@ -344,8 +333,7 @@ Foam::label Foam::polyTopoChanger::findModifierID // Modifier not found if (debug) { - Info<< "label polyTopoChanger::::findModifierID(const word& " - << "modName) const" + WarningIn("label polyTopoChanger::findModifierID(const word&) const") << "Modifier named " << modName << " not found. " << "List of available modifier names: " << names() << endl; } @@ -355,7 +343,6 @@ Foam::label Foam::polyTopoChanger::findModifierID } -// writeData member function required by regIOobject bool Foam::polyTopoChanger::writeData(Ostream& os) const { os << *this; From 84775cfd79992e392703f957e9c41709e8d80b63 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 4 Nov 2013 18:00:44 +0000 Subject: [PATCH 04/37] ENH: regionModels - updated to allow registration of multiple models --- .../pyrolysisModels/noPyrolysis/noPyrolysis.C | 19 +++- .../pyrolysisModels/noPyrolysis/noPyrolysis.H | 10 +- .../pyrolysisModel/pyrolysisModel.C | 20 ++-- .../pyrolysisModel/pyrolysisModel.H | 65 ++++++------- .../pyrolysisModel/pyrolysisModelCollection.C | 54 ++++++++--- .../pyrolysisModel/pyrolysisModelCollection.H | 39 ++++---- .../pyrolysisModel/pyrolysisModelNew.C | 38 ++++++-- .../reactingOneDim/reactingOneDim.C | 14 ++- .../reactingOneDim/reactingOneDim.H | 10 +- ...sRadiativeCoupledMixedFvPatchScalarField.C | 91 +++++++++++++++---- ...sRadiativeCoupledMixedFvPatchScalarField.H | 6 ++ ...ysisTemperatureCoupledFvPatchScalarField.C | 41 +++++++-- ...ysisTemperatureCoupledFvPatchScalarField.H | 8 +- ...rolysisVelocityCoupledFvPatchVectorField.C | 41 +++++++-- ...rolysisVelocityCoupledFvPatchVectorField.H | 8 +- .../regionModel/regionModel/regionModel.C | 46 ++++++++-- .../regionModel/regionModel/regionModel.H | 7 +- .../regionModel/regionModel1D/regionModel1D.C | 8 +- .../regionModel/regionModel1D/regionModel1D.H | 8 +- .../singleLayerRegion/singleLayerRegion.C | 10 +- .../singleLayerRegion/singleLayerRegion.H | 4 +- .../kinematicSingleLayer.C | 3 +- .../kinematicSingleLayer.H | 1 + .../surfaceFilmModels/noFilm/noFilm.C | 7 +- .../surfaceFilmModels/noFilm/noFilm.H | 5 +- .../surfaceFilmModel/surfaceFilmModel.C | 5 +- .../surfaceFilmModel/surfaceFilmModel.H | 13 ++- .../surfaceFilmModel/surfaceFilmModelNew.C | 18 +++- .../thermoSingleLayer/thermoSingleLayer.C | 3 +- .../thermoSingleLayer/thermoSingleLayer.H | 1 + .../thermalBaffleModel/thermalBaffleModel.C | 2 +- 31 files changed, 439 insertions(+), 166 deletions(-) diff --git a/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C index 0c2066f686..62916c61a6 100644 --- a/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C +++ b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C @@ -56,6 +56,7 @@ void noPyrolysis::constructThermoChemistry() radiation_.reset(radiation::radiationModel::New(solidThermo_->T()).ptr()); } + bool noPyrolysis::read() { if (pyrolysisModel::read()) @@ -86,9 +87,14 @@ bool noPyrolysis::read(const dictionary& dict) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -noPyrolysis::noPyrolysis(const word& modelType, const fvMesh& mesh) +noPyrolysis::noPyrolysis +( + const word& modelType, + const fvMesh& mesh, + const word& regionType +) : - pyrolysisModel(mesh), + pyrolysisModel(mesh, regionType), solidChemistry_(NULL), solidThermo_(NULL), radiation_(NULL) @@ -104,9 +110,11 @@ noPyrolysis::noPyrolysis ( const word& modelType, const fvMesh& mesh, - const dictionary& dict -): - pyrolysisModel(mesh), + const dictionary& dict, + const word& regionType +) +: + pyrolysisModel(mesh, regionType), solidChemistry_(NULL), solidThermo_(NULL), radiation_(NULL) @@ -117,6 +125,7 @@ noPyrolysis::noPyrolysis } } + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // noPyrolysis::~noPyrolysis() diff --git a/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H index dbbf3e4fa1..9107456be2 100644 --- a/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H +++ b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H @@ -100,14 +100,20 @@ public: // Constructors //- Construct from type name and mesh - noPyrolysis(const word& modelType, const fvMesh& mesh); + noPyrolysis + ( + const word& modelType, + const fvMesh& mesh, + const word& regionType + ); //- Construct from type name and mesh and dict noPyrolysis ( const word& modelType, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ); diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C index cfa52c3e80..74d56ea273 100644 --- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.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 @@ -80,15 +80,20 @@ bool pyrolysisModel::read(const dictionary& dict) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -pyrolysisModel::pyrolysisModel(const fvMesh& mesh) +pyrolysisModel::pyrolysisModel(const fvMesh& mesh, const word& regionType) : - regionModel1D(mesh) + regionModel1D(mesh, regionType) {} -pyrolysisModel::pyrolysisModel(const word& modelType, const fvMesh& mesh) +pyrolysisModel::pyrolysisModel +( + const word& modelType, + const fvMesh& mesh, + const word& regionType +) : - regionModel1D(mesh, "pyrolysis", modelType) + regionModel1D(mesh, regionType, modelType) { if (active_) { @@ -101,10 +106,11 @@ pyrolysisModel::pyrolysisModel ( const word& modelType, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ) : - regionModel1D(mesh, "pyrolysis", modelType, dict) + regionModel1D(mesh, regionType, modelType, dict) { if (active_) { diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H index 98da338d9a..7b577189d5 100644 --- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.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 @@ -22,9 +22,10 @@ License along with OpenFOAM. If not, see . Class - Foam::pyrolysisModel + Foam::regionModels::pyrolysisModels::pyrolysisModel Description + Base class for pyrolysis models SourceFiles pyrolysisModelI.H @@ -104,9 +105,10 @@ public: mesh, ( const word& modelType, - const fvMesh& mesh + const fvMesh& mesh, + const word& regionType ), - (modelType, mesh) + (modelType, mesh, regionType) ); declareRunTimeSelectionTable @@ -117,26 +119,37 @@ public: ( const word& modelType, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ), - (modelType, mesh, dict) + (modelType, mesh, dict, regionType) ); // Constructors //- Construct null from mesh - pyrolysisModel(const fvMesh& mesh); + pyrolysisModel + ( + const fvMesh& mesh, + const word& regionType + ); //- Construct from type name and mesh - pyrolysisModel(const word& modelType, const fvMesh& mesh); + pyrolysisModel + ( + const word& modelType, + const fvMesh& mesh, + const word& regionType + ); //- Construct from type name and mesh and dictionary pyrolysisModel ( const word& modelType, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ); //- Return clone @@ -150,39 +163,20 @@ public: // Selectors //- Return a reference to the selected pyrolysis model - static autoPtr New(const fvMesh& mesh); + static autoPtr New + ( + const fvMesh& mesh, + const word& regionType = "pyrolysis" + ); //- Return a reference to a named selected pyrolysis model static autoPtr New ( const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType = "pyrolysis" ); - //- Return pointer to new pyrolysis created on freestore from Istream - class iNew - { - const fvMesh& mesh_; - - public: - - iNew(const fvMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr operator()(Istream& is) const - { - keyType key(is); - dictionary dict(is); - - return autoPtr - ( - pyrolysisModel::New(mesh_, dict) - ); - } - }; - //- Destructor virtual ~pyrolysisModel(); @@ -212,6 +206,7 @@ public: //- Return the total gas mass flux to primary region [kg/m2/s] virtual const surfaceScalarField& phiGas() const = 0; + // Sources //- External hook to add mass to the primary region diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C index c9c097fc94..ca241f55ee 100644 --- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,11 +30,13 @@ License namespace Foam { - defineTemplateTypeNameAndDebug - ( - IOPtrList, - 0 - ); + namespace regionModels + { + namespace pyrolysisModels + { + defineTypeNameAndDebug(pyrolysisModelCollection, 0); + } + } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,12 +50,12 @@ namespace pyrolysisModels // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -pyrolysisModelCollection::pyrolysisModelCollection -( - const fvMesh& mesh -) +pyrolysisModelCollection::pyrolysisModelCollection(const fvMesh& mesh) : - IOPtrList + PtrList() + +{ + IOdictionary pyrolysisZonesDict ( IOobject ( @@ -62,10 +64,32 @@ pyrolysisModelCollection::pyrolysisModelCollection mesh, IOobject::MUST_READ, IOobject::NO_WRITE - ), - pyrolysisModel::iNew(mesh) - ), - mesh_(mesh) + ) + ); + + const wordList regions(pyrolysisZonesDict.toc()); + + setSize(regions.size()); + + for (label i = 0; i < regions.size(); i++) + { + set + ( + i, + pyrolysisModel::New + ( + mesh, + pyrolysisZonesDict.subDict(regions[i]), + regions[i] + ) + ); + } +} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +pyrolysisModelCollection::~pyrolysisModelCollection() {} diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.H b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.H index 84e28ef473..da2da6d9f8 100644 --- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.H +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelCollection.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 @@ -38,16 +38,15 @@ SourceFiles #ifndef pyrolysisModelCollection_H #define pyrolysisModelCollection_H -#include "IOPtrList.H" +#include "PtrList.H" #include "pyrolysisModel.H" -#include "fvc.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration of friend functions and operators +// Forward class declarations class fvMesh; namespace regionModels @@ -56,19 +55,13 @@ namespace pyrolysisModels { /*---------------------------------------------------------------------------*\ - Class pyrolysisModelCollection Declaration + Class pyrolysisModelCollection Declaration \*---------------------------------------------------------------------------*/ class pyrolysisModelCollection : - public IOPtrList + public PtrList { - // Private data - - //- Reference to the finite volume mesh this zone is part of - const fvMesh& mesh_; - - // Private Member Functions //- Disallow default bitwise copy construct @@ -80,6 +73,9 @@ class pyrolysisModelCollection public: + // Runtime type information + TypeName("pyrolysisModelCollection"); + // Constructors @@ -87,26 +83,29 @@ public: pyrolysisModelCollection(const fvMesh&); + //- Destructor + virtual ~pyrolysisModelCollection(); + + // Member Functions //- Pre-evolve regions - void preEvolveRegion(); + virtual void preEvolveRegion(); - //- Evolve the pyrolysis equation regions - void evolveRegion(); + //- Evolve the pyrolysis equation regions + virtual void evolveRegion(); //- Evolve regions - void evolve(); + virtual void evolve(); //- Provide some feedback from pyrolysis regions - void info() const; + virtual void info() const; //- Return max diffusivity allowed in the solid - scalar maxDiff() const; + virtual scalar maxDiff() const; //- Mean diffusion number of the solid regions - scalar solidRegionDiffNo() const; - + virtual scalar solidRegionDiffNo() const; }; diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C index 98861a0f5d..958dafdef1 100644 --- a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,7 +38,11 @@ namespace pyrolysisModels // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // -autoPtr pyrolysisModel::New(const fvMesh& mesh) +autoPtr pyrolysisModel::New +( + const fvMesh& mesh, + const word& regionType +) { // get model name, but do not register the dictionary const word modelType @@ -47,7 +51,7 @@ autoPtr pyrolysisModel::New(const fvMesh& mesh) ( IOobject ( - "pyrolysisProperties", + regionType + "Properties", mesh.time().constant(), mesh, IOobject::MUST_READ, @@ -64,21 +68,22 @@ autoPtr pyrolysisModel::New(const fvMesh& mesh) if (cstrIter == meshConstructorTablePtr_->end()) { - FatalErrorIn("pyrolysisModel::New(const fvMesh&)") + FatalErrorIn("pyrolysisModel::New(const fvMesh&, const word&)") << "Unknown pyrolysisModel type " << modelType << nl << nl << "Valid pyrolisisModel types are:" << nl << meshConstructorTablePtr_->sortedToc() << exit(FatalError); } - return autoPtr(cstrIter()(modelType, mesh)); + return autoPtr(cstrIter()(modelType, mesh, regionType)); } autoPtr pyrolysisModel::New ( const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ) { @@ -91,14 +96,31 @@ autoPtr pyrolysisModel::New if (cstrIter == dictionaryConstructorTablePtr_->end()) { - FatalErrorIn("pyrolysisModel::New(const fvMesh&, const dictionary&)") + FatalErrorIn + ( + "pyrolysisModel::New" + "(" + "const fvMesh&, " + "const dictionary&, " + "const word&" + ")" + ) << "Unknown pyrolysisModel type " << modelType << nl << nl << "Valid pyrolisisModel types are:" << nl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } - return autoPtr(cstrIter()(modelType, mesh, dict)); + return autoPtr + ( + cstrIter() + ( + modelType, + mesh, + dict, + regionType + ) + ); } diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C index b98417e52a..127a561342 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C @@ -382,9 +382,14 @@ void reactingOneDim::calculateMassTransfer() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh) +reactingOneDim::reactingOneDim +( + const word& modelType, + const fvMesh& mesh, + const word& regionType +) : - pyrolysisModel(modelType, mesh), + pyrolysisModel(modelType, mesh, regionType), solidChemistry_(basicSolidChemistryModel::New(regionMesh())), solidThermo_(solidChemistry_->solidThermo()), radiation_(radiation::radiationModel::New(solidThermo_.T())), @@ -482,10 +487,11 @@ reactingOneDim::reactingOneDim ( const word& modelType, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ) : - pyrolysisModel(modelType, mesh, dict), + pyrolysisModel(modelType, mesh, dict, regionType), solidChemistry_(basicSolidChemistryModel::New(regionMesh())), solidThermo_(solidChemistry_->solidThermo()), radiation_(radiation::radiationModel::New(solidThermo_.T())), diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H index a5950a9804..40cd93e149 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H @@ -203,14 +203,20 @@ public: // Constructors //- Construct from type name and mesh - reactingOneDim(const word& modelType, const fvMesh& mesh); + reactingOneDim + ( + const word& modelType, + const fvMesh& mesh, + const word& regionType + ); //- Construct from type name, mesh and dictionary reactingOneDim ( const word& modelType, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& regionType ); diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C index ed3d509d60..a658513bed 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C @@ -38,13 +38,29 @@ const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::filmModelType& filmPyrolysisRadiativeCoupledMixedFvPatchScalarField:: filmModel() const { - const regionModels::regionModel& model = - db().time().lookupObject - ( - "surfaceFilmProperties" - ); + HashTable models + = db().time().lookupClass(); - return dynamic_cast(model); + forAllConstIter(HashTable, models, iter) + { + if (iter()->regionMesh().name() == filmRegionName_) + { + return *iter(); + } + } + + + FatalErrorIn + ( + "const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::" + "filmModelType& " + "filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::" + "filmModel() const" + ) + << "Unable to locate film region " << filmRegionName_ + << abort(FatalError); + + return **models.begin(); } @@ -53,13 +69,28 @@ pyrolysisModelType& filmPyrolysisRadiativeCoupledMixedFvPatchScalarField:: pyrModel() const { - const regionModels::regionModel& model = - db().time().lookupObject - ( - "pyrolysisProperties" - ); + HashTable models = + db().time().lookupClass(); - return dynamic_cast(model); + forAllConstIter(HashTable, models, iter) + { + if (iter()->regionMesh().name() == pyrolysisRegionName_) + { + return *iter(); + } + } + + FatalErrorIn + ( + "const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::" + "pyrolysisModelType& " + "filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::" + "pyrModel() const" + ) + << "Unable to locate pyrolysis region " << pyrolysisRegionName_ + << abort(FatalError); + + return **models.begin(); } @@ -74,6 +105,8 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), "undefined", "undefined-K"), + filmRegionName_("surfaceFilmProperties"), + pyrolysisRegionName_("pyrolysisProperties"), TnbrName_("undefined-Tnbr"), QrNbrName_("undefined-QrNbr"), QrName_("undefined-Qr"), @@ -98,6 +131,8 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField : mixedFvPatchScalarField(psf, p, iF, mapper), temperatureCoupledBase(patch(), psf.KMethod(), psf.kappaName()), + filmRegionName_(psf.filmRegionName_), + pyrolysisRegionName_(psf.pyrolysisRegionName_), TnbrName_(psf.TnbrName_), QrNbrName_(psf.QrNbrName_), QrName_(psf.QrName_), @@ -117,6 +152,14 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), dict), + filmRegionName_ + ( + dict.lookupOrDefault("filmRegion", "surfaceFilmProperties") + ), + pyrolysisRegionName_ + ( + dict.lookupOrDefault("pyrolysisRegion", "pyrolysisProperties") + ), TnbrName_(dict.lookup("Tnbr")), QrNbrName_(dict.lookup("QrNbr")), QrName_(dict.lookup("Qr")), @@ -171,6 +214,8 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField : mixedFvPatchScalarField(psf, iF), temperatureCoupledBase(patch(), psf.KMethod(), psf.kappaName()), + filmRegionName_(psf.filmRegionName_), + pyrolysisRegionName_(psf.pyrolysisRegionName_), TnbrName_(psf.TnbrName_), QrNbrName_(psf.QrNbrName_), QrName_(psf.QrName_), @@ -196,7 +241,6 @@ updateCoeffs() const label patchI = patch().index(); const label nbrPatchI = mpp.samplePolyPatch().index(); - const polyMesh& mesh = patch().boundaryMesh().mesh(); const polyMesh& nbrMesh = mpp.sampleMesh(); const fvPatch& nbrPatch = @@ -240,13 +284,13 @@ updateCoeffs() // Obtain Rad heat (Qr) scalarField Qr(patch().size(), 0.0); - if (QrName_ != "none") //region0 + if (QrName_ != "none") // primary region (region0) { Qr = patch().lookupPatchField(QrName_); myPatchINrbPatchI = nbrPatch.index(); } - if (QrNbrName_ != "none") //pyrolysis + if (QrNbrName_ != "none") // pyrolysis region { Qr = nbrPatch.lookupPatchField(QrNbrName_); mpp.distribute(Qr); @@ -326,13 +370,12 @@ updateCoeffs() << " convective heat[W] : " << Qc << nl << " radiative heat [W] : " << Qr << nl << " total heat [W] : " << Qt << nl - << " walltemperature " + << " wall temperature " << " min:" << gMin(*this) << " max:" << gMax(*this) << " avg:" << gAverage(*this) << endl; } - } @@ -342,6 +385,20 @@ void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::write ) const { mixedFvPatchScalarField::write(os); + writeEntryIfDifferent + ( + os, + "filmRegion", + "surfaceFilmProperties", + filmRegionName_ + ); + writeEntryIfDifferent + ( + os, + "pyrolysisRegion", + "pyrolysisProperties", + pyrolysisRegionName_ + ); os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl; os.writeKeyword("QrNbr")<< QrNbrName_ << token::END_STATEMENT << nl; os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl; diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H index 734b19b364..e4161e1bfc 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H @@ -112,6 +112,12 @@ private: // Private data + //- Name of film region + const word filmRegionName_; + + //- Name of pyrolysis region + const word pyrolysisRegionName_; + //- Name of field on the neighbour region const word TnbrName_; diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C index 926773ba6c..db0c0cc5e6 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.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 @@ -39,6 +39,8 @@ filmPyrolysisTemperatureCoupledFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), + filmRegionName_("surfaceFilmProperties"), + pyrolysisRegionName_("pyrolysisProperties"), phiName_("phi"), rhoName_("rho") {} @@ -54,6 +56,8 @@ filmPyrolysisTemperatureCoupledFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), + filmRegionName_(ptf.filmRegionName_), + pyrolysisRegionName_(ptf.pyrolysisRegionName_), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_) {} @@ -68,6 +72,14 @@ filmPyrolysisTemperatureCoupledFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), + filmRegionName_ + ( + dict.lookupOrDefault("filmRegion", "surfaceFilmProperties") + ), + pyrolysisRegionName_ + ( + dict.lookupOrDefault("pyrolysisRegion", "pyrolysisProperties") + ), phiName_(dict.lookupOrDefault("phi", "phi")), rhoName_(dict.lookupOrDefault("rho", "rho")) { @@ -82,6 +94,8 @@ filmPyrolysisTemperatureCoupledFvPatchScalarField ) : fixedValueFvPatchScalarField(fptpsf), + filmRegionName_(fptpsf.filmRegionName_), + pyrolysisRegionName_(fptpsf.pyrolysisRegionName_), phiName_(fptpsf.phiName_), rhoName_(fptpsf.rhoName_) {} @@ -95,6 +109,8 @@ filmPyrolysisTemperatureCoupledFvPatchScalarField ) : fixedValueFvPatchScalarField(fptpsf, iF), + filmRegionName_(fptpsf.filmRegionName_), + pyrolysisRegionName_(fptpsf.pyrolysisRegionName_), phiName_(fptpsf.phiName_), rhoName_(fptpsf.rhoName_) {} @@ -117,11 +133,10 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() int oldTag = UPstream::msgType(); UPstream::msgType() = oldTag+1; - bool filmOk = - db().time().foundObject("surfaceFilmProperties"); + bool filmOk = db().time().foundObject(filmRegionName_); - bool pyrOk = db().time().foundObject("pyrolysisProperties"); + bool pyrOk = db().time().foundObject(pyrolysisRegionName_); if (!filmOk || !pyrOk) { @@ -135,7 +150,7 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() // Retrieve film model const filmModelType& filmModel = - db().time().lookupObject("surfaceFilmProperties"); + db().time().lookupObject(filmRegionName_); const label filmPatchI = filmModel.regionPatchID(patchI); @@ -147,7 +162,7 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() // Retrieve pyrolysis model const pyrModelType& pyrModel = - db().time().lookupObject("pyrolysisProperties"); + db().time().lookupObject(pyrolysisRegionName_); const label pyrPatchI = pyrModel.regionPatchID(patchI); @@ -171,6 +186,20 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::write ) const { fvPatchScalarField::write(os); + writeEntryIfDifferent + ( + os, + "filmRegion", + "surfaceFilmProperties", + filmRegionName_ + ); + writeEntryIfDifferent + ( + os, + "pyrolysisRegion", + "pyrolysisProperties", + pyrolysisRegionName_ + ); writeEntryIfDifferent(os, "phi", "phi", phiName_); writeEntryIfDifferent(os, "rho", "rho", rhoName_); writeEntry("value", os); diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.H b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.H index bc4ace8abd..bbcad6707c 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.H +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.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 @@ -70,6 +70,12 @@ class filmPyrolysisTemperatureCoupledFvPatchScalarField { // Private data + //- Name of film region + const word filmRegionName_; + + //- Name of pyrolysis region + const word pyrolysisRegionName_; + //- Name of flux field word phiName_; diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C index f5bdabd7dd..4b7bdef10b 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.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 @@ -39,6 +39,8 @@ filmPyrolysisVelocityCoupledFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), + filmRegionName_("surfaceFilmProperties"), + pyrolysisRegionName_("pyrolysisProperties"), phiName_("phi"), rhoName_("rho") {} @@ -54,6 +56,8 @@ filmPyrolysisVelocityCoupledFvPatchVectorField ) : fixedValueFvPatchVectorField(ptf, p, iF, mapper), + filmRegionName_(ptf.filmRegionName_), + pyrolysisRegionName_(ptf.pyrolysisRegionName_), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_) {} @@ -68,6 +72,14 @@ filmPyrolysisVelocityCoupledFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), + filmRegionName_ + ( + dict.lookupOrDefault("filmRegion", "surfaceFilmProperties") + ), + pyrolysisRegionName_ + ( + dict.lookupOrDefault("pyrolysisRegion", "pyrolysisProperties") + ), phiName_(dict.lookupOrDefault("phi", "phi")), rhoName_(dict.lookupOrDefault("rho", "rho")) { @@ -82,6 +94,8 @@ filmPyrolysisVelocityCoupledFvPatchVectorField ) : fixedValueFvPatchVectorField(fpvpvf), + filmRegionName_(fpvpvf.filmRegionName_), + pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_), phiName_(fpvpvf.phiName_), rhoName_(fpvpvf.rhoName_) {} @@ -95,6 +109,8 @@ filmPyrolysisVelocityCoupledFvPatchVectorField ) : fixedValueFvPatchVectorField(fpvpvf, iF), + filmRegionName_(fpvpvf.filmRegionName_), + pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_), phiName_(fpvpvf.phiName_), rhoName_(fpvpvf.rhoName_) {} @@ -117,11 +133,10 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() int oldTag = UPstream::msgType(); UPstream::msgType() = oldTag+1; - bool foundFilm = - db().time().foundObject("surfaceFilmProperties"); + bool foundFilm = db().time().foundObject(filmRegionName_); bool foundPyrolysis = - db().time().foundObject("pyrolysisProperties"); + db().time().foundObject(pyrolysisRegionName_); if (!foundFilm || !foundPyrolysis) { @@ -135,7 +150,7 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() // Retrieve film model const filmModelType& filmModel = - db().time().lookupObject("surfaceFilmProperties"); + db().time().lookupObject(filmRegionName_); const label filmPatchI = filmModel.regionPatchID(patchI); @@ -147,7 +162,7 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() // Retrieve pyrolysis model const pyrModelType& pyrModel = - db().time().lookupObject("pyrolysisProperties"); + db().time().lookupObject(pyrolysisRegionName_); const label pyrPatchI = pyrModel.regionPatchID(patchI); @@ -201,6 +216,20 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::write ) const { fvPatchVectorField::write(os); + writeEntryIfDifferent + ( + os, + "filmRegion", + "surfaceFilmProperties", + filmRegionName_ + ); + writeEntryIfDifferent + ( + os, + "pyrolysisRegion", + "pyrolysisProperties", + pyrolysisRegionName_ + ); writeEntryIfDifferent(os, "phi", "phi", phiName_); writeEntryIfDifferent(os, "rho", "rho", rhoName_); writeEntry("value", os); diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.H b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.H index b37157ddf0..916cf8a270 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.H +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.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 @@ -70,6 +70,12 @@ class filmPyrolysisVelocityCoupledFvPatchVectorField { // Private data + //- Name of film region + word filmRegionName_; + + //- Name of pyrolysis region + word pyrolysisRegionName_; + //- Name of flux field word phiName_; diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index 292dbe5e5a..388559c18b 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -288,11 +288,41 @@ Foam::label Foam::regionModels::regionModel::nbrCoupledPatchID // boundary mesh const polyBoundaryMesh& nbrPbm = nbrRegionMesh.boundaryMesh(); - const mappedPatchBase& mpb = - refCast + const polyBoundaryMesh& pbm = regionMesh().boundaryMesh(); + + if (regionPatchI > pbm.size() - 1) + { + FatalErrorIn ( - regionMesh().boundaryMesh()[regionPatchI] - ); + "Foam::label Foam::regionModels::regionModel::nbrCoupledPatchID" + "(" + "const regionModel&, " + "const label" + ") const" + ) + << "region patch index out of bounds: " + << "region patch index = " << regionPatchI + << ", maximum index = " << pbm.size() - 1 + << abort(FatalError); + } + + const polyPatch& pp = regionMesh().boundaryMesh()[regionPatchI]; + + if (!isA(pp)) + { + FatalErrorIn + ( + "Foam::label Foam::regionModels::regionModel::nbrCoupledPatchID" + "(" + "const regionModel&, " + "const label" + ") const" + ) + << "Expected a " << mappedPatchBase::typeName + << " patch, but found a " << pp.type() << abort(FatalError); + } + + const mappedPatchBase& mpb = refCast(pp); // sample patch name on the primary region const word& primaryPatchName = mpb.samplePatch(); @@ -335,13 +365,17 @@ Foam::label Foam::regionModels::regionModel::nbrCoupledPatchID // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::regionModels::regionModel::regionModel(const fvMesh& mesh) +Foam::regionModels::regionModel::regionModel +( + const fvMesh& mesh, + const word& regionType +) : IOdictionary ( IOobject ( - "regionModelProperties", + regionType + "Properties", mesh.time().constant(), mesh.time(), IOobject::NO_READ, diff --git a/src/regionModels/regionModel/regionModel/regionModel.H b/src/regionModels/regionModel/regionModel/regionModel.H index c0bd06e4df..1b8fecabab 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.H +++ b/src/regionModels/regionModel/regionModel/regionModel.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 @@ -140,7 +140,7 @@ protected: virtual bool read(const dictionary& dict); //- Create or return a new inter-region AMI object - virtual const Foam::AMIPatchToPatchInterpolation& interRegionAMI + virtual const AMIPatchToPatchInterpolation& interRegionAMI ( const regionModel& nbrRegion, const label regionPatchI, @@ -148,6 +148,7 @@ protected: const bool flip ); + public: //- Runtime type information @@ -157,7 +158,7 @@ public: // Constructors //- Construct null - regionModel(const fvMesh& mesh); + regionModel(const fvMesh& mesh, const word& regionType); //- Construct from mesh, region type and name regionModel diff --git a/src/regionModels/regionModel/regionModel1D/regionModel1D.C b/src/regionModels/regionModel/regionModel1D/regionModel1D.C index 86c640a3f2..d5e80beec8 100644 --- a/src/regionModels/regionModel/regionModel1D/regionModel1D.C +++ b/src/regionModels/regionModel/regionModel1D/regionModel1D.C @@ -277,9 +277,13 @@ Foam::tmp Foam::regionModels::regionModel1D::moveMesh // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::regionModels::regionModel1D::regionModel1D(const fvMesh& mesh) +Foam::regionModels::regionModel1D::regionModel1D +( + const fvMesh& mesh, + const word& regionType +) : - regionModel(mesh), + regionModel(mesh, regionType), boundaryFaceFaces_(), boundaryFaceCells_(), boundaryFaceOppositeFace_(), diff --git a/src/regionModels/regionModel/regionModel1D/regionModel1D.H b/src/regionModels/regionModel/regionModel1D/regionModel1D.H index 49e0eaec01..592e0af317 100644 --- a/src/regionModels/regionModel/regionModel1D/regionModel1D.H +++ b/src/regionModels/regionModel/regionModel1D/regionModel1D.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 @@ -126,7 +126,11 @@ public: // Constructors //- Construct null - regionModel1D(const fvMesh& mesh); + regionModel1D + ( + const fvMesh& mesh, + const word& regionType + ); //- Construct from mesh, region type and name regionModel1D diff --git a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C index 9a8d4db4e0..35dce8b879 100644 --- a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C +++ b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -157,9 +157,13 @@ bool Foam::regionModels::singleLayerRegion::read() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::regionModels::singleLayerRegion::singleLayerRegion(const fvMesh& mesh) +Foam::regionModels::singleLayerRegion::singleLayerRegion +( + const fvMesh& mesh, + const word& regionType +) : - regionModel(mesh), + regionModel(mesh, regionType), nHatPtr_(NULL), magSfPtr_(NULL), passivePatchIDs_() diff --git a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.H b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.H index 07d3decc80..ac0892c49f 100644 --- a/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.H +++ b/src/regionModels/regionModel/singleLayerRegion/singleLayerRegion.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 @@ -104,7 +104,7 @@ public: // Constructors //- Construct null - singleLayerRegion(const fvMesh& mesh); + singleLayerRegion(const fvMesh& mesh, const word& regionType); //- Construct from mesh, region type and name singleLayerRegion diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 4e2522a44c..26e2936f31 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -423,10 +423,11 @@ kinematicSingleLayer::kinematicSingleLayer const word& modelType, const fvMesh& mesh, const dimensionedVector& g, + const word& regionType, const bool readFields ) : - surfaceFilmModel(modelType, mesh, g), + surfaceFilmModel(modelType, mesh, g, regionType), momentumPredictor_(solution().subDict("PISO").lookup("momentumPredictor")), nOuterCorr_(solution().subDict("PISO").lookupOrDefault("nOuterCorr", 1)), diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H index 85deaa8b48..197895c844 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H @@ -300,6 +300,7 @@ public: const word& modelType, const fvMesh& mesh, const dimensionedVector& g, + const word& regionType, const bool readFields = true ); diff --git a/src/regionModels/surfaceFilmModels/noFilm/noFilm.C b/src/regionModels/surfaceFilmModels/noFilm/noFilm.C index 82f3d0afc9..b3d4827d70 100644 --- a/src/regionModels/surfaceFilmModels/noFilm/noFilm.C +++ b/src/regionModels/surfaceFilmModels/noFilm/noFilm.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 @@ -64,10 +64,11 @@ noFilm::noFilm ( const word& modelType, const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType ) : - surfaceFilmModel(modelType, mesh, g) + surfaceFilmModel(modelType, mesh, g, regionType) {} diff --git a/src/regionModels/surfaceFilmModels/noFilm/noFilm.H b/src/regionModels/surfaceFilmModels/noFilm/noFilm.H index 17915f7788..e8d22be6c4 100644 --- a/src/regionModels/surfaceFilmModels/noFilm/noFilm.H +++ b/src/regionModels/surfaceFilmModels/noFilm/noFilm.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 @@ -86,7 +86,8 @@ public: ( const word& modelType, const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType ); diff --git a/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.C b/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.C index f731152405..eb7f333b6d 100644 --- a/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.C +++ b/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.C @@ -61,10 +61,11 @@ surfaceFilmModel::surfaceFilmModel ( const word& modelType, const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType ) : - singleLayerRegion(mesh, "surfaceFilm", modelType), + singleLayerRegion(mesh, regionType, modelType), g_(g) { if (active_) diff --git a/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.H b/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.H index 4c43ffe9e3..2ab381f648 100644 --- a/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.H +++ b/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModel.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::surfaceFilmModel + Foam::regionModels::surfaceFilmModels::surfaceFilmModel Description Base class for surface film models @@ -106,9 +106,10 @@ public: ( const word& modelType, const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType ), - (modelType, mesh, g) + (modelType, mesh, g, regionType) ); // Constructors @@ -118,7 +119,8 @@ public: ( const word& modelType, const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType ); @@ -128,7 +130,8 @@ public: static autoPtr New ( const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType = "surfaceFilm" ); diff --git a/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModelNew.C b/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModelNew.C index 75c131e437..b199374864 100644 --- a/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModelNew.C +++ b/src/regionModels/surfaceFilmModels/surfaceFilmModel/surfaceFilmModelNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,7 +41,8 @@ namespace surfaceFilmModels autoPtr surfaceFilmModel::New ( const fvMesh& mesh, - const dimensionedVector& g + const dimensionedVector& g, + const word& regionType ) { word modelType; @@ -51,7 +52,7 @@ autoPtr surfaceFilmModel::New ( IOobject ( - "surfaceFilmProperties", + regionType + "Properties", mesh.time().constant(), mesh, IOobject::MUST_READ, @@ -79,7 +80,16 @@ autoPtr surfaceFilmModel::New << exit(FatalError); } - return autoPtr(cstrIter()(modelType, mesh, g)); + return autoPtr + ( + cstrIter() + ( + modelType, + mesh, + g, + regionType + ) + ); } diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C index ffa2036609..e88d7d2352 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C @@ -312,10 +312,11 @@ thermoSingleLayer::thermoSingleLayer const word& modelType, const fvMesh& mesh, const dimensionedVector& g, + const word& regionType, const bool readFields ) : - kinematicSingleLayer(modelType, mesh, g, false), + kinematicSingleLayer(modelType, mesh, g, regionType, false), thermo_(mesh.lookupObject("SLGThermo")), Cp_ ( diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.H b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.H index e7a11acac6..6995e34e3a 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.H +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.H @@ -245,6 +245,7 @@ public: const word& modelType, const fvMesh& mesh, const dimensionedVector& g, + const word& regionType, const bool readFields = true ); diff --git a/src/regionModels/thermalBaffleModels/thermalBaffleModel/thermalBaffleModel.C b/src/regionModels/thermalBaffleModels/thermalBaffleModel/thermalBaffleModel.C index 543ea6b974..5e9f2e620d 100644 --- a/src/regionModels/thermalBaffleModels/thermalBaffleModel/thermalBaffleModel.C +++ b/src/regionModels/thermalBaffleModels/thermalBaffleModel/thermalBaffleModel.C @@ -201,7 +201,7 @@ void thermalBaffleModel::init() thermalBaffleModel::thermalBaffleModel(const fvMesh& mesh) : - regionModel1D(mesh), + regionModel1D(mesh, "thermalBaffle"), thickness_(), delta_("delta", dimLength, 0.0), oneD_(false), From 6a1d1f9d717acfb5bbe515f47d306b43b14909c9 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 4 Nov 2013 18:01:16 +0000 Subject: [PATCH 05/37] ENH: MRFSource - re-intiliase zone on re-read --- src/fvOptions/sources/derived/MRFSource/MRFSource.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fvOptions/sources/derived/MRFSource/MRFSource.C b/src/fvOptions/sources/derived/MRFSource/MRFSource.C index 9f9fcca442..d9b4a2a9b9 100644 --- a/src/fvOptions/sources/derived/MRFSource/MRFSource.C +++ b/src/fvOptions/sources/derived/MRFSource/MRFSource.C @@ -175,6 +175,8 @@ bool Foam::fv::MRFSource::read(const dictionary& dict) coeffs_.readIfPresent("UName", UName_); coeffs_.readIfPresent("rhoName", rhoName_); + initialise(); + return true; } else From af72f2a512f02503b488b99d6d52660232f974a3 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 5 Nov 2013 10:20:00 +0000 Subject: [PATCH 06/37] BUG: Removed support for deprecated compilers - mantis #995 --- etc/bashrc | 2 +- etc/cshrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 4fb5d511df..8e6e630471 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -62,7 +62,7 @@ foamInstall=$HOME/$WM_PROJECT foamCompiler=system #- Compiler: -# WM_COMPILER = Gcc | Gcc43 | Gcc44 | Gcc45 | Gcc46 | Clang | Icc (Intel icc) +# WM_COMPILER = Gcc | Gcc45 | Gcc46 | Gcc47 | Clang | Icc (Intel icc) export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH diff --git a/etc/cshrc b/etc/cshrc index 2700735efd..af3a34d21b 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -61,7 +61,7 @@ if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall set foamCompiler=system #- Compiler: -# WM_COMPILER = Gcc | Gcc43 | Gcc44 | Gcc45 | Gcc46 | Clang | Icc (Intel icc) +# WM_COMPILER = Gcc | Gcc45 | Gcc46 | Gcc47 | Clang | Icc (Intel icc) setenv WM_COMPILER Gcc setenv WM_COMPILER_ARCH # defined but empty unsetenv WM_COMPILER_LIB_ARCH From 9a8e128e8d94a2e65ea18fe4c7c498115877ae93 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 5 Nov 2013 10:20:58 +0000 Subject: [PATCH 07/37] BUG: sprayFoam - updated pressure equation for relativeFlux - mantis #1045 --- applications/solvers/lagrangian/sprayFoam/pEqn.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/lagrangian/sprayFoam/pEqn.H b/applications/solvers/lagrangian/sprayFoam/pEqn.H index 26511b001d..b0c09f9e08 100644 --- a/applications/solvers/lagrangian/sprayFoam/pEqn.H +++ b/applications/solvers/lagrangian/sprayFoam/pEqn.H @@ -53,7 +53,7 @@ else ) ); - fvOptions.makeRelative(fvc::interpolate(psi), phiHbyA); + fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); while (pimple.correctNonOrthogonal()) { From adc056ca07dec4c4f41296b389a8c2cb171d530f Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 5 Nov 2013 11:13:04 +0000 Subject: [PATCH 08/37] ENH: Code refactoring --- .../primitives/Tensor/tensor/tensor.C | 139 ++++++++---------- 1 file changed, 61 insertions(+), 78 deletions(-) diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index a62eeff5e4..992c108ae2 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.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 @@ -26,69 +26,68 @@ License #include "tensor.H" #include "mathematicalConstants.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ +using namespace Foam::constant::mathematical; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -template<> -const char* const tensor::typeName = "tensor"; - -template<> -const char* tensor::componentNames[] = +namespace Foam { - "xx", "xy", "xz", - "yx", "yy", "yz", - "zx", "zy", "zz" -}; + template<> + const char* const tensor::typeName = "tensor"; -template<> -const tensor tensor::zero -( - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 -); + template<> + const char* tensor::componentNames[] = + { + "xx", "xy", "xz", + "yx", "yy", "yz", + "zx", "zy", "zz" + }; -template<> -const tensor tensor::one -( - 1, 1, 1, - 1, 1, 1, - 1, 1, 1 -); + template<> + const tensor tensor::zero + ( + 0, 0, 0, + 0, 0, 0, + 0, 0, 0 + ); -template<> -const tensor tensor::max -( - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, VGREAT -); + template<> + const tensor tensor::one + ( + 1, 1, 1, + 1, 1, 1, + 1, 1, 1 + ); -template<> -const tensor tensor::min -( - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, -VGREAT -); + template<> + const tensor tensor::max + ( + VGREAT, VGREAT, VGREAT, + VGREAT, VGREAT, VGREAT, + VGREAT, VGREAT, VGREAT + ); -template<> -const tensor tensor::I -( - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 -); + template<> + const tensor tensor::min + ( + -VGREAT, -VGREAT, -VGREAT, + -VGREAT, -VGREAT, -VGREAT, + -VGREAT, -VGREAT, -VGREAT + ); + + template<> + const tensor tensor::I + ( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + ); +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Return eigenvalues in ascending order of absolute values -vector eigenValues(const tensor& t) +Foam::vector Foam::eigenValues(const tensor& t) { scalar i = 0; scalar ii = 0; @@ -120,7 +119,7 @@ vector eigenValues(const tensor& t) + t.xy()*t.yx()*t.zz() + t.xx()*t.yz()*t.zy(); // If there is a zero root - if (mag(c) < 1.0e-100) + if (mag(c) < ROOTVSMALL) { scalar disc = sqr(a) - 4*b; @@ -157,14 +156,8 @@ vector eigenValues(const tensor& t) scalar aBy3 = a/3; i = m2SqrtQ*cos(theta/3) - aBy3; - ii = - m2SqrtQ - *cos((theta + constant::mathematical::twoPi)/3) - - aBy3; - iii = - m2SqrtQ - *cos((theta - constant::mathematical::twoPi)/3) - - aBy3; + ii = m2SqrtQ*cos((theta + twoPi)/3) - aBy3; + iii = m2SqrtQ*cos((theta - twoPi)/3) - aBy3; } else { @@ -210,7 +203,7 @@ vector eigenValues(const tensor& t) } -vector eigenVector(const tensor& t, const scalar lambda) +Foam::vector Foam::eigenVector(const tensor& t, const scalar lambda) { if (mag(lambda) < SMALL) { @@ -273,7 +266,7 @@ vector eigenVector(const tensor& t, const scalar lambda) } -tensor eigenVectors(const tensor& t) +Foam::tensor Foam::eigenVectors(const tensor& t) { vector evals(eigenValues(t)); @@ -289,7 +282,7 @@ tensor eigenVectors(const tensor& t) // Return eigenvalues in ascending order of absolute values -vector eigenValues(const symmTensor& t) +Foam::vector Foam::eigenValues(const symmTensor& t) { scalar i = 0; scalar ii = 0; @@ -321,7 +314,7 @@ vector eigenValues(const symmTensor& t) + t.xy()*t.xy()*t.zz() + t.xx()*t.yz()*t.yz(); // If there is a zero root - if (mag(c) < 1.0e-100) + if (mag(c) < ROOTVSMALL) { scalar disc = sqr(a) - 4*b; @@ -358,14 +351,8 @@ vector eigenValues(const symmTensor& t) scalar aBy3 = a/3; i = m2SqrtQ*cos(theta/3) - aBy3; - ii = - m2SqrtQ - *cos((theta + constant::mathematical::twoPi)/3) - - aBy3; - iii = - m2SqrtQ - *cos((theta - constant::mathematical::twoPi)/3) - - aBy3; + ii = m2SqrtQ*cos((theta + twoPi)/3) - aBy3; + iii = m2SqrtQ*cos((theta - twoPi)/3) - aBy3; } else { @@ -411,7 +398,7 @@ vector eigenValues(const symmTensor& t) } -vector eigenVector(const symmTensor& t, const scalar lambda) +Foam::vector Foam::eigenVector(const symmTensor& t, const scalar lambda) { if (mag(lambda) < SMALL) { @@ -474,7 +461,7 @@ vector eigenVector(const symmTensor& t, const scalar lambda) } -tensor eigenVectors(const symmTensor& t) +Foam::tensor Foam::eigenVectors(const symmTensor& t) { vector evals(eigenValues(t)); @@ -489,8 +476,4 @@ tensor eigenVectors(const symmTensor& t) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // From 8cb9d6f746464666ca05a9c33e942fd99a0f6e2a Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 5 Nov 2013 14:27:59 +0000 Subject: [PATCH 09/37] ENH: Added new demandDrivenEntry for dictionary --- .../demandDrivenEntry/demandDrivenEntry.C | 89 ++++++++++++ .../demandDrivenEntry/demandDrivenEntry.H | 136 ++++++++++++++++++ .../demandDrivenEntry/demandDrivenEntryI.H | 59 ++++++++ 3 files changed, 284 insertions(+) create mode 100644 src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C create mode 100644 src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H create mode 100644 src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H diff --git a/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C new file mode 100644 index 0000000000..bac4117c78 --- /dev/null +++ b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#include "demandDrivenEntry.H" + +// * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * // + +template +Foam::demandDrivenEntry::demandDrivenEntry +( + const dictionary& dict, + const Type& value +) +: + dict_(dict), + keyword_("unknown-keyword"), + value_(value), + stored_(true) +{} + + +template +Foam::demandDrivenEntry::demandDrivenEntry +( + const dictionary& dict, + const word& keyword +) +: + dict_(dict), + keyword_(keyword), + value_(pTraits::zero), + stored_(false) +{} + + +template +Foam::demandDrivenEntry::demandDrivenEntry +( + const dictionary& dict, + const word& keyword, + const Type& defaultValue, + const bool readIfPresent +) +: + dict_(dict), + keyword_(keyword), + value_(defaultValue), + stored_(true) +{ + if (readIfPresent) + { + dict_.readIfPresent(keyword, value_); + } +} + + +template +Foam::demandDrivenEntry::demandDrivenEntry(const demandDrivenEntry& dde) +: + dict_(dde.dict_), + keyword_(dde.keyword_), + value_(dde.value_), + stored_(dde.stored_) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H new file mode 100644 index 0000000000..e56934d92e --- /dev/null +++ b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntry.H @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::demandDrivenEntry + +Description + Class for demand-driven dictionary entries + + Holds a reference to a dictionary, which is then queried if the value + is requested and has not already been cached + +SourceFiles + demandDrivenEntry.C + demandDrivenEntryI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef demandDrivenEntry_H +#define demandDrivenEntry_H + +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class demandDrivenEntry Declaration +\*---------------------------------------------------------------------------*/ + +template +class demandDrivenEntry +{ +private: + + // Private data + + //- Reference to the dictionary + const dictionary& dict_; + + //- Keyword to look up + const word keyword_; + + //- Value + mutable Type value_; + + //- Flag to say that the value has been stored + mutable bool stored_; + + +public: + + //- Constructors + + //- Construct from dictionary and value - cannot be re-read + demandDrivenEntry + ( + const dictionary& dict, + const Type& value + ); + + + //- Construct from dictionary and keyword + demandDrivenEntry + ( + const dictionary& dict, + const word& keyword + ); + + + //- Construct from dictionary, keyword and default value + demandDrivenEntry + ( + const dictionary& dict, + const word& keyword, + const Type& defaultValue, + const bool readIfPresent = true + ); + + //- Copy constructor + demandDrivenEntry(const demandDrivenEntry& dde); + + + // Public Member Functions + + //- Return the value + inline const Type& value() const; + + //- Set the value + inline void setValue(const Type& value); + + //- Reset the demand-driven entry + inline void reset(); +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "demandDrivenEntryI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "demandDrivenEntry.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H new file mode 100644 index 0000000000..5a6a3e31b3 --- /dev/null +++ b/src/OpenFOAM/primitives/demandDrivenEntry/demandDrivenEntryI.H @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#include "demandDrivenEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +inline const Type& Foam::demandDrivenEntry::value() const +{ + if (!stored_) + { + dict_.lookup(keyword_) >> value_; + stored_ = true; + } + + return value_; +} + + +template +inline void Foam::demandDrivenEntry::setValue(const Type& value) +{ +// dict_.set(keyword_, value); + value_ = value; + stored_ = true; +} + + +template +inline void Foam::demandDrivenEntry::reset() +{ + stored_ = false; +} + + +// ************************************************************************* // From d41e15840dde13472a335b927566852126f7801f Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 5 Nov 2013 14:28:26 +0000 Subject: [PATCH 10/37] ENH: Lagrangian - constant properties now demend-driven --- .../KinematicParcel/KinematicParcel.H | 22 ++++-- .../KinematicParcel/KinematicParcelI.H | 71 +++++++----------- .../ReactingMultiphaseParcel.H | 11 ++- .../ReactingMultiphaseParcelI.H | 59 +++++++-------- .../Templates/ReactingParcel/ReactingParcel.H | 7 +- .../ReactingParcel/ReactingParcelI.H | 30 +++----- .../Templates/ThermoParcel/ThermoParcel.H | 17 +++-- .../Templates/ThermoParcel/ThermoParcelI.H | 73 +++++++------------ .../Templates/SprayParcel/SprayParcel.C | 2 +- .../Templates/SprayParcel/SprayParcel.H | 5 +- .../Templates/SprayParcel/SprayParcelI.H | 37 +++++++--- 11 files changed, 155 insertions(+), 179 deletions(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index 61ad57369e..858ef573e7 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -48,6 +48,7 @@ SourceFiles #include "IOstream.H" #include "autoPtr.H" #include "interpolation.H" +#include "demandDrivenEntry.H" // #include "ParticleForceList.H" // TODO @@ -82,29 +83,36 @@ public: //- Class to hold kinematic particle constant properties class constantProperties { - // Private data + protected: + + // Protected data //- Constant properties dictionary const dictionary dict_; + + private: + + // Private data + //- Parcel type id - used for post-processing to flag the type // of parcels issued by this cloud - label parcelTypeId_; + demandDrivenEntry