diff --git a/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C b/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C index c90594ff24..9fb3a646d6 100644 --- a/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C +++ b/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C @@ -39,24 +39,17 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - - Info<< "\nEstimating error in scalar transport equation\n" << endl; - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - Info<< "Reading transportProperties\n" << endl; + Info<< "\nEstimating error in scalar transport equation\n" + << "Reading transportProperties\n" << endl; IOdictionary transportProperties ( @@ -79,9 +72,9 @@ int main(int argc, char *argv[]) ); - for (label i=startTime; i - addArcEdgeIstreamConstructorToTable_; + addToRunTimeSelectionTable(curvedEdge, arcEdge, Istream); } diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C index c9d31ef6a1..6a2d41a83e 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C @@ -41,26 +41,7 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(curvedEdge, 0); - -// Define the constructor function hash tables -HashTable* - curvedEdge::IstreamConstructorTablePtr_; - - -// Hash table Constructor called from the table add functions. - -void curvedEdge::constructTables() -{ - static bool constructed = false; - - if (!constructed) - { - curvedEdge::IstreamConstructorTablePtr_ - = new HashTable; - - constructed = true; - } -} +defineRunTimeSelectionTable(curvedEdge, Istream); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -117,10 +98,11 @@ autoPtr curvedEdge::New(const pointField& points, Istream& is) word curvedEdgeType(is); - HashTable::iterator curvedEdgeConstructorIter = - IstreamConstructorTablePtr_->find(curvedEdgeType); + IstreamConstructorTable::iterator cstrIter = + IstreamConstructorTablePtr_ + ->find(curvedEdgeType); - if (curvedEdgeConstructorIter == IstreamConstructorTablePtr_->end()) + if (cstrIter == IstreamConstructorTablePtr_->end()) { FatalErrorIn("curvedEdge::New(const pointField&, Istream&)") << "Unknown curvedEdge type " << curvedEdgeType << endl << endl @@ -129,7 +111,7 @@ autoPtr curvedEdge::New(const pointField& points, Istream& is) << abort(FatalError); } - return autoPtr(curvedEdgeConstructorIter()(points, is)); + return autoPtr(cstrIter()(points, is)); } @@ -177,7 +159,6 @@ Ostream& operator<<(Ostream& os, const curvedEdge& p) } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H index c568180d73..5ecf489d38 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H @@ -63,51 +63,23 @@ protected: public: - // Constructor Hash tables - - //- Construct from Istream function pointer type - typedef autoPtr (*IstreamConstructorPtr_) - (const pointField&, Istream&); - - //- Construct from Istream function pointer table pointer - static HashTable* - IstreamConstructorTablePtr_; + //- Runtime type information + TypeName("curvedEdge"); - // Hash table constructor classes and functions + // Declare run-time constructor selection tables - //- Hash table Constructor. - // Must be called from the table add functions below. - static void constructTables(); - - - //- Class to add constructor from Istream to Hash table - template - class addIstreamConstructorToTable - { - public: - - static autoPtr New + declareRunTimeSelectionTable + ( + autoPtr, + curvedEdge, + Istream, ( const pointField& points, Istream& is - ) - { - return autoPtr(new curvedEdgeType(points, is)); - } - - addIstreamConstructorToTable() - { - curvedEdge::constructTables(); - - curvedEdge::IstreamConstructorTablePtr_ - ->insert(curvedEdgeType::typeName, New); - } - }; - - - //- Runtime type information - TypeName("curvedEdge"); + ), + (points, is) + ); // Constructors diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C index f4581ed338..7263f71843 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C @@ -26,6 +26,7 @@ License #include "polySplineEdge.H" #include "BSpline.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,8 +35,7 @@ namespace Foam defineTypeNameAndDebug(polySplineEdge, 0); // Add the curvedEdge constructor functions to the hash tables - curvedEdge::addIstreamConstructorToTable - addPolySplineEdgeIstreamConstructorToTable_; + addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream); } diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H index d71685782d..1f59d5bf8e 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H @@ -92,7 +92,7 @@ public: ); //- Construct from Istream setting pointsList - polySplineEdge(const pointField& points,Istream& is); + polySplineEdge(const pointField& points, Istream& is); // Destructor diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C index 8fe13aefe0..b45f0ea3c2 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C @@ -27,9 +27,8 @@ Description \*---------------------------------------------------------------------------*/ -#include "error.H" - #include "simpleSplineEdge.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,10 +38,8 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(simpleSplineEdge, 0); +addToRunTimeSelectionTable(curvedEdge, simpleSplineEdge, Istream); -// Add the curvedEdge constructor functions to the hash tables -curvedEdge::addIstreamConstructorToTable - addSimpleSplineEdgeIstreamConstructorToTable_; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 74ab53432a..d226008f5c 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -31,7 +31,9 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "Time.H" + #include "polyMesh.H" #include "globalMeshData.H" @@ -45,48 +47,34 @@ using namespace Foam; int main(int argc, char *argv[]) { + timeSelector::addOptions(false); // no constant # include "addRegionOption.H" - -# include "addTimeOptionsNoConstant.H" - argList::validOptions.insert("noTopology", ""); argList::validOptions.insert("allGeometry", ""); argList::validOptions.insert("allTopology", ""); # include "setRootCase.H" +# include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); +# include "createNamedPolyMesh.H" - const bool noTopology = args.options().found("noTopology"); + const bool noTopology = args.options().found("noTopology"); const bool allGeometry = args.options().found("allGeometry"); const bool allTopology = args.options().found("allTopology"); -# include "createTime.H" - - // Get times list - instantList Times = runTime.times(); - -# include "checkTimeOptionsNoConstant.H" - - runTime.setTime(Times[startTime], startTime); - -# include "createNamedPolyMesh.H" - - bool firstCheck = true; - - for (label i=startTime; iSetNumberOfOutputPorts(2); - vtkMultiBlockDataSet *lagrangian; - lagrangian = vtkMultiBlockDataSet::New(); + vtkMultiBlockDataSet *lagrangian = vtkMultiBlockDataSet::New(); lagrangian->ReleaseData(); this->GetExecutive()->SetOutputData(1, lagrangian); @@ -204,9 +203,9 @@ int vtkPV3FoamReader::RequestInformation ); } - double timeRange[2]; if (nTimeSteps) { + double timeRange[2]; timeRange[0] = timeSteps[0]; timeRange[1] = timeSteps[nTimeSteps-1]; @@ -273,19 +272,53 @@ int vtkPV3FoamReader::RequestData } } - // take port0 as the lead for other outputs - vtkInformation *outInfo = outputVector->GetInformationObject(0); + // Get the requested time step. + // We only support requests for a single time step + + int nRequestTime = 0; + double requestTime[nInfo]; + + // taking port0 as the lead for other outputs would be nice, but fails when + // a filter is added - we need to check everything + // but since PREVIOUS_UPDATE_TIME_STEPS() is protected, relay the logic + // to the vtkPV3Foam::setTime() method + for (int infoI = 0; infoI < nInfo; ++infoI) + { + vtkInformation *outInfo = outputVector->GetInformationObject(infoI); + + if + ( + outInfo->Has + ( + vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() + ) + && outInfo->Length + ( + vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() + ) >= 1 + ) + { + requestTime[nRequestTime++] = outInfo->Get + ( + vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() + )[0]; + } + } + + if (nRequestTime) + { + foamData_->setTime(nRequestTime, requestTime); + } vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast ( - outInfo->Get + outputVector->GetInformationObject(0)->Get ( vtkMultiBlockDataSet::DATA_OBJECT() ) ); - vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast ( outputVector->GetInformationObject(1)->Get @@ -294,24 +327,6 @@ int vtkPV3FoamReader::RequestData ) ); - if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) - { - // Get the requested time step. - // We only support requests for a single time step - int nRequestedTimeSteps = outInfo->Length - ( - vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() - ); - if (nRequestedTimeSteps >= 1) - { - double *requestedTimeSteps = outInfo->Get - ( - vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() - ); - - foamData_->setTime(requestedTimeSteps[0]); - } - } if (Foam::vtkPV3Foam::debug) { diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 4c4016c364..624358b4a0 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -90,12 +90,21 @@ void Foam::vtkPV3Foam::reduceMemory() -int Foam::vtkPV3Foam::setTime(const double& requestedTime) +int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[]) { if (debug) { - Info<< " Foam::vtkPV3Foam::setTime(" << requestedTime << ")" - << endl; + Info<< " Foam::vtkPV3Foam::setTime("; + for (int requestI = 0; requestI < nRequest; ++requestI) + { + if (requestI) + { + Info<< ", "; + } + + Info<< requestTimes[requestI]; + } + Info << ") - previousIndex = " << timeIndex_ << endl; } Time& runTime = dbPtr_(); @@ -103,12 +112,26 @@ int Foam::vtkPV3Foam::setTime(const double& requestedTime) // Get times list instantList Times = runTime.times(); - int nearestIndex = Time::findClosestTimeIndex(Times, requestedTime); + int nearestIndex = timeIndex_; + + for (int requestI = 0; requestI < nRequest; ++requestI) + { + int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]); + + if (index >= 0 && index != timeIndex_) + { + nearestIndex = index; + break; + } + } + + if (nearestIndex < 0) { nearestIndex = 0; } + // see what has changed if (timeIndex_ != nearestIndex) { @@ -138,10 +161,11 @@ int Foam::vtkPV3Foam::setTime(const double& requestedTime) if (debug) { - Info<< " Foam::vtkPV3Foam::setTime() - selected time " - << Times[nearestIndex].name() << " index=" << nearestIndex - << " meshChanged=" << meshChanged_ - << " fieldsChanged=" << fieldsChanged_ << endl; + Info<< " Foam::vtkPV3Foam::setTime() - selectedTime=" + << Times[nearestIndex].name() << " index=" << timeIndex_ + << "/" << Times.size() + << " meshChanged=" << Switch(meshChanged_) + << " fieldsChanged=" << Switch(fieldsChanged_) << endl; } return nearestIndex; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 59e7e86b59..c6dd65af9e 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -133,6 +133,7 @@ class vtkPV3Foam return block_; } + //- Assign block number, return previous value int block(int blockNo) { int prev = block_; @@ -718,9 +719,11 @@ public: //- Remove patch names from the display void removePatchNames(vtkRenderer* renderer); - //- set the runTime to the requested time, returns the timeIndex - // sets to "constant" on error and returns -1 - int setTime(const double& requestedTime); + //- set the runTime to the first plausible request time, + // returns the timeIndex + // sets to "constant" on error + int setTime(int count, const double requestTimes[]); + //- The current time index int timeIndex() const diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H index 8ef698872d..7e28460a46 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H @@ -40,7 +40,10 @@ void Foam::vtkPV3Foam::updateInfoFields { if (debug) { - Info<< " Foam::vtkPV3Foam::updateInfoFields" << endl; + Info<< " Foam::vtkPV3Foam::updateInfoFields <" + << meshType::Mesh::typeName + << "> [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" + << endl; } stringList enabledEntries; diff --git a/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C b/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C index bb41fb60d4..26d66de83e 100644 --- a/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C +++ b/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C @@ -36,25 +36,18 @@ Description int main(int argc, char *argv[]) { + timeSelector::addOptions(); -# include "addTimeOptions.H" # include "setRootCase.H" - # include "createTime.H" - // Get times list - instantList Times = runTime.times(); - - // set startTime and endTime depending on -time and -latestTime options -# include "checkTimeOptions.H" - - runTime.setTime(Times[startTime], startTime); + instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - for (label i=startTime; i tcurPoints ( - points0_ + pointDisplacement_.internalField() + points0() + pointDisplacement_.internalField() ); twoDCorrectPoints(tcurPoints()); @@ -208,63 +193,7 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh const mapPolyMesh& mpm ) { - fvMotionSolver::updateMesh(mpm); - - // Map points0_ - // Map points0_. Bit special since we somehow have to come up with - // a sensible points0 position for introduced points. - // Find out scaling between points0 and current points - - // Get the new points either from the map or the mesh - const pointField& points = - ( - mpm.hasMotionPoints() - ? mpm.preMotionPoints() - : fvMesh_.points() - ); - - // Note: boundBox does reduce - const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); - - vector scaleFactors(cmptDivide(span0, span)); - - pointField newPoints0(mpm.pointMap().size()); - - forAll(newPoints0, pointI) - { - label oldPointI = mpm.pointMap()[pointI]; - - if (oldPointI >= 0) - { - label masterPointI = mpm.reversePointMap()[oldPointI]; - - if (masterPointI == pointI) - { - newPoints0[pointI] = points0_[oldPointI]; - } - else - { - // New point. Assume motion is scaling. - newPoints0[pointI] = points0_[oldPointI] + cmptMultiply - ( - scaleFactors, - points[pointI]-points[masterPointI] - ); - } - } - else - { - FatalErrorIn - ( - "displacementSBRStressFvMotionSolver::updateMesh" - "(const mapPolyMesh& mpm)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " - << points[pointI] << exit(FatalError); - } - } - points0_.transfer(newPoints0); + displacementFvMotionSolver::updateMesh(mpm); // Update diffusivity. Note two stage to make sure old one is de-registered // before creating/registering new one. diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H index 740fed7e7b..766025cf86 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H @@ -37,7 +37,7 @@ SourceFiles #ifndef displacementSBRStressFvMotionSolver_H #define displacementSBRStressFvMotionSolver_H -#include "fvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,13 +53,10 @@ class motionDiffusivity; class displacementSBRStressFvMotionSolver : - public fvMotionSolver + public displacementFvMotionSolver { // Private data - //- Reference point field - pointField points0_; - //- Point motion field mutable pointVectorField pointDisplacement_; @@ -105,12 +102,6 @@ public: // Member Functions - //- Return reference to the reference field - const pointField& points0() const - { - return points0_; - } - //- Return reference to the point motion displacement field pointVectorField& pointDisplacement() { diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C new file mode 100644 index 0000000000..aee52c717c --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "displacementFvMotionSolver.H" +#include "addToRunTimeSelectionTable.H" +#include "mapPolyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +// defineTypeNameAndDebug(displacementFvMotionSolver, 0); +// +// addToRunTimeSelectionTable +// ( +// fvMotionSolver, +// displacementFvMotionSolver, +// dictionary +// ); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::displacementFvMotionSolver:: +displacementFvMotionSolver +( + const polyMesh& mesh, + Istream& +) +: + fvMotionSolver(mesh), + points0_ + ( + pointIOField + ( + IOobject + ( + "points", + mesh.time().constant(), + polyMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::displacementFvMotionSolver::~displacementFvMotionSolver() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::displacementFvMotionSolver::updateMesh(const mapPolyMesh& mpm) +{ + fvMotionSolver::updateMesh(mpm); + + // Map points0_. Bit special since we somehow have to come up with + // a sensible points0 position for introduced points. + // Find out scaling between points0 and current points + + // Get the new points either from the map or the mesh + const pointField& points = + ( + mpm.hasMotionPoints() + ? mpm.preMotionPoints() + : fvMesh_.points() + ); + + // Note: boundBox does reduce + const vector span0 = boundBox(points0_).span(); + const vector span = boundBox(points).span(); + + vector scaleFactors(cmptDivide(span0, span)); + + pointField newPoints0(mpm.pointMap().size()); + + forAll(newPoints0, pointI) + { + label oldPointI = mpm.pointMap()[pointI]; + + if (oldPointI >= 0) + { + label masterPointI = mpm.reversePointMap()[oldPointI]; + + if (masterPointI == pointI) + { + newPoints0[pointI] = points0_[oldPointI]; + } + else + { + // New point. Assume motion is scaling. + newPoints0[pointI] = points0_[oldPointI] + cmptMultiply + ( + scaleFactors, + points[pointI]-points[masterPointI] + ); + } + } + else + { + FatalErrorIn + ( + "displacementLaplacianFvMotionSolver::updateMesh" + "(const mapPolyMesh& mpm)" + ) << "Cannot work out coordinates of introduced vertices." + << " New vertex " << pointI << " at coordinate " + << points[pointI] << exit(FatalError); + } + } + points0_.transfer(newPoints0); +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.H new file mode 100644 index 0000000000..aedd15f704 --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::displacementFvMotionSolver.H + +Description + Base class for fvMotionSolvers which calculate displacement. + +SourceFiles + displacementFvMotionSolver.C + +\*---------------------------------------------------------------------------*/ + +#ifndef displacementFvMotionSolver_H +#define displacementFvMotionSolver_H + +#include "fvMotionSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class displacementFvMotionSolver Declaration +\*---------------------------------------------------------------------------*/ + +class displacementFvMotionSolver +: + public fvMotionSolver +{ + // Private data + + //- Reference point field + pointField points0_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + displacementFvMotionSolver + ( + const displacementFvMotionSolver& + ); + + //- Disallow default bitwise assignment + void operator=(const displacementFvMotionSolver&); + + +public: + + //- Runtime type information + TypeName("displacementInterpolation"); + + + // Constructors + + //- Construct from polyMesh and data stream + displacementFvMotionSolver + ( + const polyMesh&, + Istream& msDataUnused + ); + + + // Destructor + + ~displacementFvMotionSolver(); + + + // Member Functions + + //- Return reference to the reference field + const pointField& points0() const + { + return points0_; + } + + //- Update topology + virtual void updateMesh(const mapPolyMesh&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C index 178d1d1b2a..cdd5a999ec 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C @@ -58,26 +58,10 @@ Foam::displacementInterpolationFvMotionSolver:: displacementInterpolationFvMotionSolver ( const polyMesh& mesh, - Istream& + Istream& is ) : - fvMotionSolver(mesh), - points0_ - ( - pointIOField - ( - IOobject - ( - "points", - mesh.time().constant(), - polyMesh::meshSubDir, - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ) - ), + displacementFvMotionSolver(mesh, is), dynamicMeshCoeffs_ ( IOdictionary @@ -174,7 +158,7 @@ displacementInterpolationFvMotionSolver forAll(fz().meshPoints(), localI) { label pointI = fz().meshPoints()[localI]; - const scalar coord = points0_[pointI][dir]; + const scalar coord = points0()[pointI][dir]; minCoord = min(minCoord, coord); maxCoord = max(maxCoord, coord); } @@ -198,7 +182,7 @@ displacementInterpolationFvMotionSolver zoneCoordinates[zoneCoordinates.size()-1] += SMALL; // Check if we have static min and max mesh bounds - const scalarField meshCoords = points0_.component(dir); + const scalarField meshCoords = points0().component(dir); scalar minCoord = gMin(meshCoords); scalar maxCoord = gMax(meshCoords); @@ -288,7 +272,7 @@ displacementInterpolationFvMotionSolver "displacementInterpolationFvMotionSolver::" "displacementInterpolationFvMotionSolver" "(const polyMesh&, Istream&)" - ) << "Did not find point " << points0_[pointI] + ) << "Did not find point " << points0()[pointI] << " coordinate " << meshCoords[pointI] << " in ranges " << rangeToCoord << abort(FatalError); @@ -344,18 +328,18 @@ Foam::displacementInterpolationFvMotionSolver:: Foam::tmp Foam::displacementInterpolationFvMotionSolver::curPoints() const { - if (mesh().nPoints() != points0_.size()) + if (mesh().nPoints() != points0().size()) { FatalErrorIn ( "displacementInterpolationFvMotionSolver::curPoints() const" ) << "The number of points in the mesh seems to have changed." << endl - << "In constant/polyMesh there are " << points0_.size() + << "In constant/polyMesh there are " << points0().size() << " points; in the current mesh there are " << mesh().nPoints() << " points." << exit(FatalError); } - tmp tcurPoints(new pointField(points0_)); + tmp tcurPoints(new pointField(points0())); pointField& curPoints = tcurPoints(); // Interpolate the diplacement of the face zones. @@ -413,68 +397,4 @@ Foam::displacementInterpolationFvMotionSolver::curPoints() const } -void Foam::displacementInterpolationFvMotionSolver::updateMesh -( - const mapPolyMesh& mpm -) -{ - fvMotionSolver::updateMesh(mpm); - - // Map points0_. Bit special since we somehow have to come up with - // a sensible points0 position for introduced points. - // Find out scaling between points0 and current points - - // Get the new points either from the map or the mesh - const pointField& points = - ( - mpm.hasMotionPoints() - ? mpm.preMotionPoints() - : fvMesh_.points() - ); - - // Note: boundBox does reduce - const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); - - vector scaleFactors(cmptDivide(span0, span)); - - pointField newPoints0(mpm.pointMap().size()); - - forAll(newPoints0, pointI) - { - label oldPointI = mpm.pointMap()[pointI]; - - if (oldPointI >= 0) - { - label masterPointI = mpm.reversePointMap()[oldPointI]; - - if (masterPointI == pointI) - { - newPoints0[pointI] = points0_[oldPointI]; - } - else - { - // New point. Assume motion is scaling. - newPoints0[pointI] = points0_[oldPointI] + cmptMultiply - ( - scaleFactors, - points[pointI]-points[masterPointI] - ); - } - } - else - { - FatalErrorIn - ( - "displacementLaplacianFvMotionSolver::updateMesh" - "(const mapPolyMesh& mpm)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " - << points[pointI] << exit(FatalError); - } - } - points0_.transfer(newPoints0); -} - - // ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H index cd7438df06..d67886ac3c 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H @@ -48,7 +48,7 @@ SourceFiles #ifndef displacementInterpolationFvMotionSolver_H #define displacementInterpolationFvMotionSolver_H -#include "fvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,13 +61,10 @@ namespace Foam class displacementInterpolationFvMotionSolver : - public fvMotionSolver + public displacementFvMotionSolver { // Private data - //- Reference point field - pointField points0_; - //- Additional settings for motion solver dictionary dynamicMeshCoeffs_; @@ -130,21 +127,12 @@ public: // Member Functions - //- Return reference to the reference field - const pointField& points0() const - { - return points0_; - } - //- Return point location obtained from the current motion field virtual tmp curPoints() const; //- Solve for motion virtual void solve() {} - - //- Update topology - virtual void updateMesh(const mapPolyMesh&); }; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index a979feebb3..e57a17cce9 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -53,26 +53,10 @@ namespace Foam Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver ( const polyMesh& mesh, - Istream& + Istream& is ) : - fvMotionSolver(mesh), - points0_ - ( - pointIOField - ( - IOobject - ( - "points", - time().constant(), - polyMesh::meshSubDir, - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ) - ), + displacementFvMotionSolver(mesh, is), pointDisplacement_ ( IOobject @@ -186,7 +170,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const } pointLocation_().internalField() = - points0_ + points0() + pointDisplacement_.internalField(); pointLocation_().correctBoundaryConditions(); @@ -198,7 +182,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const forAll(pz, i) { - pointLocation_()[pz[i]] = points0_[pz[i]]; + pointLocation_()[pz[i]] = points0()[pz[i]]; } } @@ -210,7 +194,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const { tmp tcurPoints ( - points0_ + pointDisplacement_.internalField() + points0() + pointDisplacement_.internalField() ); // Implement frozen points @@ -220,7 +204,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const forAll(pz, i) { - tcurPoints()[pz[i]] = points0_[pz[i]]; + tcurPoints()[pz[i]] = points0()[pz[i]]; } } @@ -257,74 +241,7 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh const mapPolyMesh& mpm ) { - fvMotionSolver::updateMesh(mpm); - - // Map points0_. Bit special since we somehow have to come up with - // a sensible points0 position for introduced points. - // Find out scaling between points0 and current points - - // Get the new points either from the map or the mesh - const pointField& points = - ( - mpm.hasMotionPoints() - ? mpm.preMotionPoints() - : fvMesh_.points() - ); - - // Note: boundBox does reduce - const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); - - vector scaleFactors(cmptDivide(span0, span)); - - pointField newPoints0(mpm.pointMap().size()); - - forAll(newPoints0, pointI) - { - label oldPointI = mpm.pointMap()[pointI]; - - if (oldPointI >= 0) - { - label masterPointI = mpm.reversePointMap()[oldPointI]; - - if (masterPointI == pointI) - { - newPoints0[pointI] = points0_[oldPointI]; - } - else - { - // New point. Assume motion is scaling. - newPoints0[pointI] = points0_[oldPointI] + cmptMultiply - ( - scaleFactors, - points[pointI]-points[masterPointI] - ); - } - } - else - { - FatalErrorIn - ( - "displacementLaplacianFvMotionSolver::updateMesh" - "(const mapPolyMesh& mpm)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " - << points[pointI] << exit(FatalError); - } - } - points0_.transfer(newPoints0); - - if (debug & 2) - { - OFstream str(time().timePath()/"points0.obj"); - Pout<< "displacementLaplacianFvMotionSolver :" - << " Writing points0_ to " << str.name() << endl; - - forAll(points0_, pointI) - { - meshTools::writeOBJ(str, points0_[pointI]); - } - } + displacementFvMotionSolver::updateMesh(mpm); // Update diffusivity. Note two stage to make sure old one is de-registered // before creating/registering new one. diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H index 67ed89c40f..6ba0c01e32 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H @@ -37,7 +37,7 @@ SourceFiles #ifndef displacementLaplacianFvMotionSolver_H #define displacementLaplacianFvMotionSolver_H -#include "fvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,13 +53,10 @@ class motionDiffusivity; class displacementLaplacianFvMotionSolver : - public fvMotionSolver + public displacementFvMotionSolver { // Private data - //- Reference point field - pointField points0_; - //- Point motion field mutable pointVectorField pointDisplacement_; @@ -113,13 +110,6 @@ public: // Member Functions - - //- Return reference to the reference field - const pointField& points0() const - { - return points0_; - } - //- Return reference to the point motion displacement field pointVectorField& pointDisplacement() { diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index 9876dcb319..8c310481d7 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -29,7 +29,7 @@ License #include "Time.H" #include "transformField.H" #include "fvMesh.H" -#include "displacementLaplacianFvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,8 +95,8 @@ void surfaceSlipDisplacementPointPatchVectorField::calcProjection } // Get the starting locations from the motionSolver - const displacementLaplacianFvMotionSolver& motionSolver = - mesh.lookupObject + const displacementFvMotionSolver& motionSolver = + mesh.lookupObject ( "dynamicMeshDict" ); diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index 91c588c6d3..5a6686aad0 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -182,15 +182,24 @@ bool Foam::probes::checkFieldTypes() if (Pstream::master()) { fileName probeDir; + + fileName probeSubDir = name_; + + if (obr_.name() != polyMesh::defaultRegion) + { + probeSubDir = probeSubDir/obr_.name(); + } + probeSubDir = probeSubDir/obr_.time().timeName(); + if (Pstream::parRun()) { // Put in undecomposed case // (Note: gives problems for distributed data running) - probeDir = obr_.time().path()/".."/name_/obr_.time().timeName(); + probeDir = obr_.time().path()/".."/probeSubDir; } else { - probeDir = obr_.time().path()/name_/obr_.time().timeName(); + probeDir = obr_.time().path()/probeSubDir; } // Close the file if any fields have been removed. diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files index 9b385e8a56..4e7fb1b11c 100644 --- a/src/thermophysicalModels/radiation/Make/files +++ b/src/thermophysicalModels/radiation/Make/files @@ -1,13 +1,15 @@ /* Radiation constants */ radiationConstants/radiationConstants.C - /* Radiation model */ radiationModel/radiationModel/radiationModel.C radiationModel/radiationModel/newRadiationModel.C radiationModel/noRadiation/noRadiation.C radiationModel/P1/P1.C - +radiationModel/fvDOM/fvDOM/fvDOM.C +radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C +radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C /* Scatter model */ submodels/scatterModel/scatterModel/scatterModel.C @@ -21,11 +23,14 @@ submodels/absorptionEmissionModel/absorptionEmissionModel/newAbsorptionEmissionM submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.C submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.C +submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C /* Boundary conditions */ derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C - +derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C LIB = $(FOAM_LIBBIN)/libradiation diff --git a/src/thermophysicalModels/radiation/Make/options b/src/thermophysicalModels/radiation/Make/options index 31643f8150..98956f2b6d 100644 --- a/src/thermophysicalModels/radiation/Make/options +++ b/src/thermophysicalModels/radiation/Make/options @@ -1,6 +1,9 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \ + -I$(LIB_SRC)/OpenFOAM/lnInclude \ + -I radiationModel/fvDOM/interpolationLookUpTable LIB_LIBS = \ -lfiniteVolume diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C new file mode 100644 index 0000000000..e7daa58aaf --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -0,0 +1,273 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "greyDiffusiveRadiationMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +#include "fvDOM.H" +#include "radiationConstants.H" +#include "mathematicalConstants.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("undefinedT"), + emissivity_(0.0), + rayId_(0), + lambdaId_(0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 1.0; +} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const greyDiffusiveRadiationMixedFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_(dict.lookup("T")), + emissivity_(readScalar(dict.lookup("emissivity"))), + rayId_(-1), + lambdaId_(-1) +{ + const scalarField& Tp = + patch().lookupPatchField(TName_); + + refValue() = + emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) + /Foam::mathematicalConstant::pi; + + refGrad() = 0.0; + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(refValue()); + } +} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const greyDiffusiveRadiationMixedFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const greyDiffusiveRadiationMixedFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const scalarField& Tp = + patch().lookupPatchField(TName_); + + const fvDOM& dom = db().lookupObject("radiationProperties"); + + const label patchI = patch().index(); + + if (dom.nLambda() == 1) + { + if (rayId_ == -1) + { + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + for (label lambdaI=0; lambdaI < dom.nLambda(); lambdaI++) + { + const volScalarField& radiationField = + dom.IRayLambda(rayI, lambdaI); + if + ( + &(radiationField.internalField()) + == &dimensionedInternalField() + ) + { + rayId_ = rayI; + lambdaId_ = lambdaI; + break; + } + } + } + } + } + else + { + FatalErrorIn + ( + "Foam::radiation::" + "greyDiffusiveRadiationMixedFvPatchScalarField::" + "updateCoeffs" + ) << " a grey boundary condition is used with a non-grey" + << "absorption model" + << exit(FatalError); + } + + scalarField& Iw = *this; + vectorField n = patch().Sf()/patch().magSf(); + + radiativeIntensityRay& ray = + const_cast(dom.IRay(rayId_)); + + ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve()); + + forAll(Iw, faceI) + { + scalar Ir = 0.0; + + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + const vector& d = dom.IRay(rayI).d(); + + const scalarField& Iface = + dom.IRay(rayI).ILambda(lambdaId_).boundaryField()[patchI]; + + if ((-n[faceI] & d) < 0.0) // qin into the wall + { + const vector& dAve = dom.IRay(rayI).dAve(); + Ir += Iface[faceI]*mag(n[faceI] & dAve); + } + } + + const vector& d = dom.IRay(rayId_).d(); + + if ((-n[faceI] & d) > 0.) //direction out of the wall + { + refGrad()[faceI] = 0.0; + valueFraction()[faceI] = 1.0; + refValue()[faceI] = + ( + Ir*(1.0 - emissivity_) + + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI]) + ) + /mathematicalConstant::pi; + + } + else //direction into the wall + { + valueFraction()[faceI] = 0.0; + refGrad()[faceI] = 0.0; + refValue()[faceI] = 0.0; //not used + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl; + os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + makePatchTypeField + ( + fvPatchScalarField, + greyDiffusiveRadiationMixedFvPatchScalarField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H new file mode 100644 index 0000000000..f236f8be15 --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::greyDiffusiveRadiationMixedFvPatchScalarField + +Description + Radiation temperature specified + +SourceFiles + greyDiffusiveRadiationMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef greyDiffusiveRadiationMixedFvPatchScalarField_H +#define greyDiffusiveRadiationMixedFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class greyDiffusiveRadiationMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class greyDiffusiveRadiationMixedFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of temperature field + word TName_; + + //- Emissivity + scalar emissivity_; + + //- Ray index + label rayId_; + + //- Wavelength index + label lambdaId_; + + +public: + + //- Runtime type information + TypeName("greyDiffusiveRadiation"); + + + // Constructors + + //- Construct from patch and internal field + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given a + // greyDiffusiveRadiationMixedFvPatchScalarField onto a new patch + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const greyDiffusiveRadiationMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const greyDiffusiveRadiationMixedFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new greyDiffusiveRadiationMixedFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const greyDiffusiveRadiationMixedFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new greyDiffusiveRadiationMixedFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the temperature field name + const word& TName() const + { + return TName_; + } + + //- Return reference to the temperature field name to allow + // adjustment + word& TName() + { + return TName_; + } + + //- Return the emissivity + const scalar& emissivity() const + { + return emissivity_; + } + + //- Return reference to the emissivity to allow adjustment + scalar& emissivity() + { + return emissivity_; + } + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C new file mode 100644 index 0000000000..eb65337aca --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C @@ -0,0 +1,269 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "wideBandDiffusiveRadiationMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +#include "fvDOM.H" +#include "wideBandAbsorptionEmission.H" +#include "radiationConstants.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("undefinedT"), + emissivity_(0.0), + rayId_(0), + lambdaId_(0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 1.0; +} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_(dict.lookup("T")), + emissivity_(readScalar(dict.lookup("emissivity"))), + rayId_(0), + lambdaId_(0) +{ + const scalarField& Tp = + patch().lookupPatchField(TName_); + + refValue() = + emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) + /Foam::mathematicalConstant::pi; + refGrad() = 0.0; + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(refValue()); + } +} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const fvDOM& dom = db().lookupObject("radiationProperties"); + + const label patchI = patch().index(); + + if (dom.nLambda() > 1) + { + if (rayId_ == -1) + { + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + for (label lambdaI=0; lambdaI < dom.nLambda(); lambdaI++) + { + const volScalarField& radiationField = + dom.IRayLambda(rayI, lambdaI); + if + ( + &(radiationField.internalField()) + ==&dimensionedInternalField() + ) + { + rayId_ = rayI; + lambdaId_ = lambdaI; + break; + } + } + } + } + } + else + { + FatalErrorIn + ( + "Foam::radiation::" + "wideBandDiffusiveRadiationMixedFvPatchScalarField::" + "updateCoeffs" + ) << " a Non-grey boundary condition is used with a grey" + << "absorption model" << nl << exit(FatalError); + } + + scalarField& Iw = *this; + vectorField n = patch().Sf()/patch().magSf(); + + radiativeIntensityRay& ray = + const_cast(dom.IRay(rayId_)); + + ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve()); + + const scalarField Eb = + dom.blackBody().bLambda(lambdaId_).boundaryField()[patchI]; + + forAll(Iw, faceI) + { + scalar Ir = 0.0; + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + const vector& d = dom.IRay(rayI).d(); + + const scalarField& Iface = + dom.IRay(rayI).ILambda(lambdaId_).boundaryField()[patchI]; + + if ((-n[faceI] & d) < 0.0) // qin into the wall + { + const vector& dAve = dom.IRay(rayI).dAve(); + Ir = Ir + Iface[faceI]*mag(n[faceI] & dAve); + } + } + + const vector& d = dom.IRay(rayId_).d(); + + if ((-n[faceI] & d) > 0.0) //direction out of the wall + { + refGrad()[faceI] = 0.0; + valueFraction()[faceI] = 1.0; + refValue()[faceI] = + ( + Ir*(1.0 - emissivity_) + + emissivity_*Eb[faceI] + ) + /mathematicalConstant::pi; + } + else //direction into the wall + { + valueFraction()[faceI] = 0.0; + refGrad()[faceI] = 0.0; + refValue()[faceI] = 0.0; //not used + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl; + os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + makePatchTypeField + ( + fvPatchScalarField, + wideBandDiffusiveRadiationMixedFvPatchScalarField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H new file mode 100644 index 0000000000..3ff3990786 --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H @@ -0,0 +1,193 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::wideBandDiffusiveRadiationMixedFvPatchScalarField + +Description + Radiation temperature specified + +SourceFiles + wideBandDiffusiveRadiationMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef wideBandDiffusiveRadiationMixedFvPatchScalarField_H +#define wideBandDiffusiveRadiationMixedFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class wideBandDiffusiveRadiationMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class wideBandDiffusiveRadiationMixedFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of temperature field + word TName_; + + //- Emissivity + scalar emissivity_; + + //- Ray index + label rayId_; + + //- Wavelength index + label lambdaId_; + + //- Radiative heat flux on walls. + scalarField qr_; + + +public: + + //- Runtime type information + TypeName("wideBandDiffusiveRadiation"); + + + // Constructors + + //- Construct from patch and internal field + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given GreyDiffusiveRadiationMixedFvPatchField + // onto a new patch + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const wideBandDiffusiveRadiationMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new wideBandDiffusiveRadiationMixedFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const wideBandDiffusiveRadiationMixedFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new wideBandDiffusiveRadiationMixedFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the temperature field name + const word& TName() const + { + return TName_; + } + + //- Return reference to the temperature field name to allow + // adjustment + word& TName() + { + return TName_; + } + + //- Return the emissivity + const scalar& emissivity() const + { + return emissivity_; + } + + //- Return reference to the emissivity to allow adjustment + scalar& emissivity() + { + return emissivity_; + } + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C index 8679ac2861..dee9629292 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C @@ -50,9 +50,9 @@ namespace Foam } } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::radiation::P1::P1(const volScalarField& T) : radiationModel(typeName, T), @@ -133,12 +133,8 @@ bool Foam::radiation::P1::read() } -void Foam::radiation::P1::correct() +void Foam::radiation::P1::calculate() { - if (!radiation_) - { - return; - } a_ = absorptionEmission_->a(); e_ = absorptionEmission_->e(); E_ = absorptionEmission_->E(); diff --git a/src/thermophysicalModels/radiation/radiationModel/P1/P1.H b/src/thermophysicalModels/radiation/radiationModel/P1/P1.H index 7215664cf7..c0249e28db 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.H +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.H @@ -59,7 +59,6 @@ class P1 : public radiationModel { - // Private data //- Incident radiation / [W/m2] @@ -97,18 +96,17 @@ public: // Destructor - - ~P1(); + virtual ~P1(); // Member functions // Edit - //- Update radiationSource varible - void correct(); + //- Solve radiation equation(s) + void calculate(); - //- Read radiationProperties dictionary + //- Read radiation properties dictionary bool read(); diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C new file mode 100644 index 0000000000..3452797b3e --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "absorptionCoeffs.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::absorptionCoeffs::absorptionCoeffs(Istream& is) +: + Tcommon_(readScalar(is)), + Tlow_(readScalar(is)), + Thigh_(readScalar(is)), + invTemp_(readBool(is)) +{ + for (label coefLabel=0; absorptionCoeffs::nCoeffs_; coefLabel++) + { + is >> highACoeffs_[coefLabel]; + } + + for (label coefLabel=0; absorptionCoeffs::nCoeffs_; coefLabel++) + { + is >> lowACoeffs_[coefLabel]; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +Foam::radiation::absorptionCoeffs::~absorptionCoeffs() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::absorptionCoeffs::checkT(const scalar T) const +{ + if (T < Tlow_ || T > Thigh_) + { + FatalErrorIn + ( + "absorptionCoeffs::checkT(const scalar T) const" + ) << "attempt to use absCoeff out of temperature range:" << nl + << " " << Tlow_ << " -> " << Thigh_ << "; T = " << T + << nl << abort(FatalError); + } +} + + +const Foam::radiation::absorptionCoeffs::coeffArray& +Foam::radiation::absorptionCoeffs::coeffs +( + const scalar T +) const +{ + checkT(T); + + if (T < Tcommon_) + { + return lowACoeffs_; + } + else + { + return highACoeffs_; + } +} + + +void Foam::radiation::absorptionCoeffs::initialise(Istream&) +{ + absorptionCoeffs(Istream); +} + + +void Foam::radiation::absorptionCoeffs::initialise(const dictionary& dict) +{ + dict.lookup("Tcommon") >> Tcommon_; + dict.lookup("Tlow") >> Tlow_; + dict.lookup("Tlow") >> Thigh_; + dict.lookup("invTemp") >> invTemp_; + + dict.lookup("loTcoeffs") >> lowACoeffs_; + dict.lookup("hiTcoeffs") >> highACoeffs_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H new file mode 100644 index 0000000000..1a79e310b9 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::janafThermo + +Description + Absorption coefficients class used in greyMeanAbsorptionEmission and + wideBandAbsorptionEmission + +SourceFiles + absorptionCoeffs.C + +\*---------------------------------------------------------------------------*/ + +#ifndef absorptionCoeffs_H +#define absorptionCoeffs_H + +#include "List.H" +#include "IOstreams.H" +#include "IOdictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class absorptionCoeffs Declaration +\*---------------------------------------------------------------------------*/ + +class absorptionCoeffs +{ +public: + + // Public data members + + static const int nCoeffs_ = 6; + typedef FixedList coeffArray; + + +private: + + // Private data + + // Temperature limits of applicability for functions + + scalar Tcommon_; + + scalar Tlow_; + + scalar Thigh_; + + + // Polynomial using inverse temperatures + bool invTemp_; + + coeffArray highACoeffs_; + coeffArray lowACoeffs_; + + + // Private member functions + + //- Check given temperature is within the range of the fitted coeffs + void checkT(const scalar T) const; + + +public: + + // Constructors + + //- Construct from Istream + absorptionCoeffs(Istream&); + + // Null constructor + absorptionCoeffs() + {} + + + // Destructor + ~absorptionCoeffs(); + + + // Member functions + + //- Return the coefficients corresponding to the given temperature + const coeffArray& coeffs(const scalar T) const; + + // Initialise from a dictionary + void initialise(const dictionary&); + + // Initialise from an Istream + void initialise(Istream&); + + + // Access Functions + + inline bool invTemp() const; + + inline scalar Tcommon() const; + + inline scalar Tlow() const; + + inline scalar Thigh() const; + + inline const coeffArray& highACoeffs() const; + + inline const coeffArray& lowACoeffs() const; +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} // End namespace radiation + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "absorptionCoeffsI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffsI.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffsI.H new file mode 100644 index 0000000000..c7759db477 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffsI.H @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +inline bool Foam::radiation::absorptionCoeffs::invTemp() const +{ + return invTemp_; +} + + +inline Foam::scalar Foam::radiation::absorptionCoeffs::Tcommon() const +{ + return Tcommon_; +} + + +inline Foam::scalar Foam::radiation::absorptionCoeffs::Tlow() const +{ + return Tlow_; +} + + +inline Foam::scalar Foam::radiation::absorptionCoeffs::Thigh() const +{ + return Thigh_; +} + + +inline const Foam::radiation::absorptionCoeffs::coeffArray& +Foam::radiation::absorptionCoeffs::highACoeffs() const +{ + return highACoeffs_; +} + + +inline const Foam::radiation::absorptionCoeffs::coeffArray& +Foam::radiation::absorptionCoeffs::lowACoeffs() const +{ + return lowACoeffs_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C new file mode 100644 index 0000000000..39d02831bb --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "blackBodyEmission.H" +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::blackBodyEmission::blackBodyEmission +( + const fileName& name, + const word& instance, + const label nLambda, + const volScalarField& T +) +: + blackBodyEmissiveTable_(name, instance, T.mesh()), + C1_("C1",dimensionSet(1, 4, 3, 0, 0, 0, 0), 3.7419e-16), + C2_("C2",dimensionSet(0, 1, 0, 1, 0, 0, 0), 14.388e-6), + bLambda_(nLambda), + T_(T) +{ + forAll(bLambda_, lambdaI) + { + bLambda_.set + ( + lambdaI, + new volScalarField + ( + IOobject + ( + "bLambda_" + Foam::name(lambdaI) , + T.mesh().time().timeName(), + T.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + radiation::sigmaSB*pow4(T) + ) + ); + + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::radiation::blackBodyEmission::~blackBodyEmission() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::radiation::blackBodyEmission::fLambdaT +( + const scalar lambdaT +) const +{ + return blackBodyEmissiveTable_.lookUp(lambdaT*1.0e6)[1]; +} + + +Foam::tmp +Foam::radiation::blackBodyEmission::EbDeltaLambdaT +( + const volScalarField& T, + const Vector2D& band +) const +{ + tmp Eb + ( + new volScalarField + ( + IOobject + ( + "Eb", + T.mesh().time().timeName(), + T.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + radiation::sigmaSB*pow4(T) + ) + ); + + + if (band == Vector2D::one) + { + return Eb; + } + else + { + forAll(T, i) + { + scalar T1 = fLambdaT(band[1]*T[i]); + scalar T2 = fLambdaT(band[0]*T[i]); + dimensionedScalar fLambdaDelta + ( + "fLambdaDelta", + dimless, + T1 - T2 + ); + Eb()[i] = Eb()[i]*fLambdaDelta.value(); + } + return Eb; + } +} + + +void Foam::radiation::blackBodyEmission::correct +( + const label lambdaI, + const Vector2D& band +) +{ + bLambda_[lambdaI] = EbDeltaLambdaT(T_, band); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H new file mode 100644 index 0000000000..d21582938f --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::radiation::blackBodyEmission + +Description + Class black body emission + +SourceFiles + blackBodyEmission.C + +\*---------------------------------------------------------------------------*/ + +#ifndef blackModyEmission_H +#define blackModyEmission_H + +#include "volFields.H" +#include "dimensionedScalar.H" +#include "mathematicalConstants.H" +#include "radiationConstants.H" +#include "interpolationLookUpTable.H" +#include "Vector2D.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class blackBodyEmission Declaration +\*---------------------------------------------------------------------------*/ + +class blackBodyEmission +{ + // Private data + + mutable interpolationLookUpTable blackBodyEmissiveTable_; + + //- Constant C1 + const dimensionedScalar C1_; + + //- Constant C2 + const dimensionedScalar C2_; + + // Ptr List for black body emission energy field for each wavelength + PtrList bLambda_; + + // Reference to the temperature field + const volScalarField& T_; + + + // Private member functions + + scalar fLambdaT(const scalar lambdaT) const; + + +public: + + // Constructors + + //- Construct from components + blackBodyEmission + ( + const fileName& name, + const word& instance, + const label nLambda, + const volScalarField& T + ); + + + // Destructor + ~blackBodyEmission(); + + + // Member functions + + // Access + + //- Black body spectrum + inline const volScalarField& bLambda(const label lambdaI) const + { + return bLambda_[lambdaI]; + } + + //- Spectral emission for the black body at T and lambda + inline dimensionedScalar EblambdaT + ( + const dimensionedScalar& T, + const scalar lambda + ) const + { + return (C1_/(pow5(lambda)*(exp(C2_/(lambda*T)) - 1.0))); + } + + //- Integral energy at T from lambda1 to lambda2 + tmp EbDeltaLambdaT + ( + const volScalarField& T, + const Vector2D& band + ) const; + + + // Edit + + // Update black body emission + void correct(const label lambdaI, const Vector2D& band); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} // End namespace radiation + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower new file mode 100644 index 0000000000..c0151b436a --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower @@ -0,0 +1,174 @@ +171 +( +1000 0.00032 +1100 0.00091 +1200 0.00213 +1300 0.00432 +1400 0.00779 +1500 0.01285 +1600 0.01972 +1700 0.02853 +1800 0.03934 +1900 0.05210 +2000 0.06672 +2100 0.08305 +2200 0.10088 +2300 0.12002 +2400 0.14025 +2500 0.16135 +2600 0.18311 +2700 0.20535 +2800 0.22788 +2900 0.25055 +3000 0.27322 +3100 0.29576 +3200 0.31809 +3300 0.34009 +3400 0.36172 +3500 0.38290 +3600 0.40359 +3700 0.42375 +3800 0.44336 +3900 0.46240 +4000 0.48085 +4100 0.49872 +4200 0.51599 +4300 0.53267 +4400 0.54877 +4500 0.56429 +4600 0.57925 +4700 0.59366 +4800 0.60753 +4900 0.62088 +5000 0.63372 +5100 0.64606 +5200 0.65794 +5300 0.66935 +5400 0.68033 +5500 0.69087 +5600 0.70101 +5700 0.71076 +5800 0.72012 +5900 0.72913 +6000 0.73778 +6100 0.74610 +6200 0.75410 +6300 0.76180 +6400 0.76920 +6500 0.77631 +6600 0.78316 +6700 0.78975 +6800 0.79609 +6900 0.80219 +7000 0.80807 +7100 0.81373 +7200 0.81918 +7300 0.82443 +7400 0.82949 +7500 0.83436 +7600 0.83906 +7700 0.84359 +7800 0.84796 +7900 0.85218 +8000 0.85625 +8100 0.86017 +8200 0.86396 +8300 0.86762 +8400 0.87115 +8500 0.87456 +8600 0.87786 +8700 0.88105 +8800 0.88413 +8900 0.88711 +9000 0.88999 +9100 0.89277 +9200 0.89547 +9300 0.89807 +9400 0.90060 +9500 0.90304 +9600 0.90541 +9700 0.90770 +9800 0.90992 +9900 0.91207 +10000 0.91415 +10200 0.91813 +10400 0.92188 +10600 0.92540 +10800 0.92872 +11000 0.93184 +11200 0.93479 +11400 0.93758 +11600 0.94021 +11800 0.94270 +12000 0.94505 +12200 0.94728 +12400 0.94939 +12600 0.95139 +12800 0.95329 +13000 0.95509 +13200 0.95680 +13400 0.95843 +13600 0.95998 +13800 0.96145 +14000 0.96285 +14200 0.96418 +14400 0.96546 +14600 0.96667 +14800 0.96783 +15000 0.96893 +15200 0.96999 +15400 0.97100 +15600 0.97196 +15800 0.97288 +16000 0.97377 +16200 0.97461 +16400 0.97542 +16600 0.97620 +16800 0.97694 +17000 0.97765 +17200 0.97834 +17400 0.97899 +17600 0.97962 +17800 0.98023 +18000 0.98080 +18200 0.98137 +18400 0.98191 +18600 0.98243 +18900 0.98293 +19000 0.98340 +19200 0.98387 +19400 0.98431 +19600 0.98474 +19800 0.98515 +20000 0.98555 +21000 0.98735 +22000 0.98886 +23000 0.99014 +24000 0.99123 +25000 0.99217 +26000 0.99297 +27000 0.99367 +28000 0.99429 +29000 0.99482 +30000 0.99529 +31000 0.99571 +32000 0.99607 +33000 0.99640 +34000 0.99669 +35000 0.99695 +35000 0.99719 +36000 0.99740 +37000 0.99759 +38000 0.99776 +39000 0.99792 +40000 0.99806 +41000 0.99819 +42000 0.99831 +43000 0.99842 +44000 0.99851 +45000 0.99861 +46000 0.99869 +47000 0.99877 +48000 0.99884 +49000 0.99890 +) \ No newline at end of file diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C new file mode 100644 index 0000000000..af3b14ebb0 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -0,0 +1,372 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "fvDOM.H" +#include "addToRunTimeSelectionTable.H" +#include "fvm.H" + +#include "absorptionEmissionModel.H" +#include "scatterModel.H" +#include "mathematicalConstants.H" +#include "radiationConstants.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace radiation + { + defineTypeNameAndDebug(fvDOM, 0); + + addToRunTimeSelectionTable + ( + radiationModel, + fvDOM, + dictionary + ); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::fvDOM::fvDOM(const volScalarField& T) +: + radiationModel(typeName, T), + G_ + ( + IOobject + ( + "G", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("G", dimMass/pow3(dimTime), 0.0) + ), + Qr_ + ( + IOobject + ( + "Qr", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0) + ), + a_ + ( + IOobject + ( + "a", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("a", dimless/dimLength, 0.0) + ), + e_ + ( + IOobject + ( + "e", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("a", dimless/dimLength, 0.0) + ), + E_ + ( + IOobject + ( + "E", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0) + ), + nTheta_(readLabel(coeffs_.lookup("nTheta"))), + nPhi_(readLabel(coeffs_.lookup("nPhi"))), + nRay_(0), + nLambda_(absorptionEmission_->nBands()), + aLambda_(nLambda_), + blackBody_ + ( + fileName("blackBodyEmissivePower"), + mesh_.time().constant(), + nLambda_, + T + ), + IRay_(0), + convergence_(coeffs_.lookupOrDefault("convergence", 0.0)) +{ + if (mesh_.nSolutionD() == 3) //3D + { + IRay_.setSize(4*nPhi_*nTheta_); + nRay_ = 4*nPhi_*nTheta_; + scalar deltaPhi = mathematicalConstant::pi/(2.0*nPhi_); + scalar deltaTheta = mathematicalConstant::pi/nTheta_; + label i = 0; + for (label n = 1; n <= nTheta_; n++) + { + for (label m = 1; m <= 4*nPhi_; m++) + { + scalar thetai = (2.0*n - 1.0)*deltaTheta/2.0; + scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + IRay_.set + ( + i, + new radiativeIntensityRay + ( + *this, + mesh_, + phii, + thetai, + deltaPhi, + deltaTheta, + nLambda_, + absorptionEmission_, + blackBody_ + ) + ); + i++; + } + } + } + else + { + if (mesh_.nSolutionD() == 2) //2D (X & Y) + { + scalar thetai = mathematicalConstant::pi/2.0; + scalar deltaTheta = mathematicalConstant::pi; + IRay_.setSize(4*nPhi_); + nRay_ = 4*nPhi_; + scalar deltaPhi = mathematicalConstant::pi/(2.0*nPhi_); + label i = 0; + for (label m = 1; m <= 4*nPhi_; m++) + { + scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + IRay_.set + ( + i, + new radiativeIntensityRay + ( + *this, + mesh_, + phii, + thetai, + deltaPhi, + deltaTheta, + nLambda_, + absorptionEmission_, + blackBody_ + ) + ); + i++; + } + } + else //1D (X) + { + scalar thetai = mathematicalConstant::pi/2.0; + scalar deltaTheta = mathematicalConstant::pi; + IRay_.setSize(2); + nRay_ = 2; + scalar deltaPhi = mathematicalConstant::pi; + label i = 0; + for (label m = 1; m <= 2; m++) + { + scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + IRay_.set + ( + i, + new radiativeIntensityRay + ( + *this, + mesh_, + phii, + thetai, + deltaPhi, + deltaTheta, + nLambda_, + absorptionEmission_, + blackBody_ + ) + ); + i++; + } + + } + } + + + // Construct absorption field for each wavelength + forAll(aLambda_, lambdaI) + { + aLambda_.set + ( + lambdaI, + new volScalarField + ( + IOobject + ( + "aLambda_" + Foam::name(lambdaI) , + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + a_ + ) + ); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::radiation::fvDOM::~fvDOM() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::radiation::fvDOM::read() +{ + if (radiationModel::read()) + { + // nothing to read + +// coeffs_.lookup("nTheta") >> nTheta_; +// coeffs_.lookup("nPhi") >> nPhi_; + + return true; + } + else + { + return false; + } +} + + +void Foam::radiation::fvDOM::calculate() +{ + absorptionEmission_->correct(a_, aLambda_); + + updateBlackBodyEmission(); + + scalar maxResidual = 0.0; + label radIter = 0; + do + { + radIter++; + forAll(IRay_, rayI) + { + maxResidual = 0.0; + scalar maxBandResidual = IRay_[rayI].correct(); + maxResidual = max(maxBandResidual, maxResidual); + } + + Info << "Radiation solver iter: " << radIter << endl; + + } while(maxResidual > convergence_); + + updateG(); +} + + +Foam::tmp Foam::radiation::fvDOM::Rp() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + "Rp", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + 4.0*a_*radiation::sigmaSB //absorptionEmission_->a() + ) + ); +} + + +Foam::tmp > +Foam::radiation::fvDOM::Ru() const +{ + + const DimensionedField& G = + G_.dimensionedInternalField(); + const DimensionedField E = + absorptionEmission_->ECont()().dimensionedInternalField(); + const DimensionedField a = + a_.dimensionedInternalField(); //absorptionEmission_->aCont()() + + return a*G - 4.0*E; +} + + +void Foam::radiation::fvDOM::updateBlackBodyEmission() +{ + for (label j=0; j < nLambda_; j++) + { + blackBody_.correct(j, absorptionEmission_->bands(j)); + } +} + + +void Foam::radiation::fvDOM::updateG() +{ + G_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); + Qr_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); + + forAll(IRay_, rayI) + { + IRay_[rayI].addIntensity(); + G_ += IRay_[rayI].I()*IRay_[rayI].omega(); + Qr_ += IRay_[rayI].Qr(); + } +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H new file mode 100644 index 0000000000..3cbd921406 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H @@ -0,0 +1,227 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::radiation::fvDOM + +Description + + Finite Volume Discrete Ordinary Method. Solves the RTE equation for n + directions in a participating media, not including scatter. + + Available absorption models: + greyMeanAbsoprtionEmission + wideBandAbsorptionEmission + + i.e. dictionary + fvDOMCoeffs + { + Nphi 1; // azimuthal angles in PI/2 on X-Y.(from Y to X) + Ntheta 2; // polar angles in P1 (from Z to X-Y plane) + convergence 1e-4; // convergence criteria for radiation iteration + } + + nFlowIterPerRadIter 1; // Number of flow iterations per radiation + iteration + + The total number of solid angles is 4*Nphi*Ntheta. + + In 1D the direction of the rays is X (Nphi and Ntheta are ignored) + In 2D the direction of the rays is on X-Y plane (only Nphi is considered) + In 3D (Nphi and Ntheta are considered) + +SourceFiles + fvDOM.C + +\*---------------------------------------------------------------------------*/ + +#ifndef radiationModelfvDOM_H +#define radiationModelfvDOM_H + +#include "radiativeIntensityRay.H" +#include "radiationModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class fvDOM Declaration +\*---------------------------------------------------------------------------*/ + +class fvDOM +: + public radiationModel +{ + // Private data + + //- Incident radiation [W/m2] + volScalarField G_; + + //- Total radiative heat flux [W/m2] + volScalarField Qr_; + + //- Total absorption coefficient [1/m] + volScalarField a_; + + //- Total emission coefficient [1/m] + volScalarField e_; + + //- Emission contribution [Kg/m/s^3] + volScalarField E_; + + //- Number of solid angles in theta + label nTheta_; + + //- Number of solid angles in phi + label nPhi_ ; + + //- Total number of rays (1 per direction) + label nRay_; + + //- Number of wavelength bands + label nLambda_; + + //- Wavelength total absorption coefficient [1/m] + PtrList aLambda_; + + //- Black body + blackBodyEmission blackBody_; + + //- List of pointers to radiative intensity rays + PtrList IRay_; + + //- Convergence criterion + scalar convergence_; + + + // Private member functions + + //- Disallow default bitwise copy construct + fvDOM(const fvDOM&); + + //- Disallow default bitwise assignment + void operator=(const fvDOM&); + + //- Update Absorption Coefficients +// void updateAbsorptionCoeffs(void); + + //- Update nlack body emission + void updateBlackBodyEmission(); + + +public: + + //- Runtime type information + TypeName("fvDOM"); + + + // Constructors + + //- Construct from components + fvDOM(const volScalarField& T); + + + //- Destructor + virtual ~fvDOM(); + + + // Member functions + + // Edit + + //- Solve radiation equation(s) + void calculate(); + + //- Read radiation properties dictionary + bool read(); + + //- Update G and calculate total heat flux on boundary + void updateG(); + + //- Source term component (for power of T^4) + virtual tmp Rp() const; + + //- Source term component (constant) + virtual tmp > Ru() const; + + + // Access + + //- Ray intensity for rayI + inline const radiativeIntensityRay& IRay(const label rayI) const; + + //- Ray intensity for rayI and lambda bandwidth + inline const volScalarField& IRayLambda + ( + const label rayI, + const label lambdaI + ) const; + + //- Number of angles in theta + inline label nTheta() const; + + //- Number of angles in phi + inline label nPhi() const; + + //- Number of rays + inline label nRay() const; + + //- Number of wavelengths + inline label nLambda() const; + + // Const access to total absorption coefficient + inline const volScalarField& a() const; + + // Const access to wavelength total absorption coefficient + inline const volScalarField& aLambda(const label lambdaI) const; + + // Const access to incident radiation field + inline const volScalarField& G() const; + + // Const access to total radiative heat flux field + inline const volScalarField& Qr() const; + + // Const access to black body + inline const blackBodyEmission& blackBody() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "fvDOMI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace radiation +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H new file mode 100644 index 0000000000..594b5bee0a --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +inline const Foam::radiation::radiativeIntensityRay& +Foam::radiation::fvDOM::IRay(const label rayI) const +{ + return IRay_[rayI]; +} + + +inline const Foam::volScalarField& +Foam::radiation::fvDOM::IRayLambda +( + const label rayI, + const label lambdaI +) const +{ + return IRay_[rayI].ILambda(lambdaI); +} + + +inline Foam::label Foam::radiation::fvDOM::nTheta() const +{ + return nTheta_; +} + + +inline Foam::label Foam::radiation::fvDOM::nPhi() const +{ + return nPhi_; +} + + +inline Foam::label Foam::radiation::fvDOM::nRay() const +{ + return nRay_; +} + + +inline Foam::label Foam::radiation::fvDOM::nLambda() const +{ + return nLambda_; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::a() const +{ + return a_; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::aLambda +( + const label lambdaI +) const +{ + return aLambda_[lambdaI]; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::G() const +{ + return G_; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::Qr() const +{ + return Qr_; +} + + +inline const Foam::radiation::blackBodyEmission& +Foam::radiation::fvDOM::blackBody() const +{ + return blackBody_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C new file mode 100755 index 0000000000..e9e28658c4 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C @@ -0,0 +1,521 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "IFstream.H" + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +Foam::label Foam::interpolationLookUpTable ::index +( + const List& indices, + const bool lastDim +) const +{ + label totalindex = 0; + + for (int i = 0; i < dim_.size() - 1; i++) + { + label dim = 1; + for (int j = i + 1; j < dim_.size(); j++) + { + dim *=(dim_[j]+1); + } + + totalindex += + dim + *min + ( + max(label((indices[i] - min_[i])/delta_[i]), 0), + dim_[i] + ); + } + + if (lastDim) + { + label iLastdim = dim_.size() - 1; + totalindex += Foam::min + ( + max + ( + label((indices[iLastdim] - min_[iLastdim])/delta_[iLastdim]), + 0 + ), + dim_[iLastdim] + ); + } + + return totalindex; +} + + +template +Foam::label Foam::interpolationLookUpTable ::index +( + const scalar indice +) const +{ + label i = 0; + label totalIndex = + Foam::min + ( + Foam::max + ( + label((indice - min_[i])/delta_[i]), + 0 + ), + dim_[i] + ); + + return totalIndex; +} + + +template +bool Foam::interpolationLookUpTable::checkRange +( + const scalar lookUpValue, + const label interfield +) const +{ + if (lookUpValue >= min_[interfield] && lookUpValue <= max_[interfield]) + { + return true; + } + else + { + return false; + } +} + + +template +Foam::scalar Foam::interpolationLookUpTable::interpolate +( + const label lo, + const label hi, + const scalar lookUpValue, + const label ofield, + const label interfield +) const +{ + if + ( + List::operator[](interfield).operator[](hi) + != List::operator[](interfield).operator[](lo) + ) + { + scalar output + ( + List::operator[](ofield).operator[](lo) + + ( + List::operator[](ofield).operator[](hi) + - List::operator[](ofield).operator[](lo) + ) + *( + lookUpValue + - List::operator[](interfield).operator[](lo) + ) + /( + List::operator[](interfield).operator[](hi) + - List::operator[](interfield).operator[](lo) + ) + ); + return output; + } + else + { + return List::operator[](ofield).operator[](lo); + } +} + + +template +void Foam::interpolationLookUpTable::dimensionTable() +{ + min_.setSize(entries_.size()); + dim_.setSize(entries_.size()); + delta_.setSize(entries_.size()); + max_.setSize(entries_.size()); + entryIndices_.setSize(entries_.size()); + outputIndices_.setSize(output_.size()); + label index = 0; + label tableDim = 1; + + forAll(entries_,i) + { + dim_[i] = readLabel(entries_[i].lookup("N")); + max_[i] = readScalar(entries_[i].lookup("max")); + min_[i] = readScalar(entries_[i].lookup("min")); + delta_[i] = (max_[i] - min_[i])/dim_[i]; + tableDim *= (dim_[i] + 1); + fieldIndices_.insert(entries_[i].lookup("name"),index); + entryIndices_[i] = index; + index++; + } + + forAll(output_,i) + { + fieldIndices_.insert(output_[i].lookup("name"),index); + outputIndices_[i] = index; + index++; + } + + List& internal = *this; + + internal.setSize(entries_.size() + output_.size()); + + interpOutput_.setSize(entries_.size() + output_.size()); + + forAll(internal, i) + { + internal[i].setSize(tableDim); + } +} + + +template +void Foam::interpolationLookUpTable::readTable +( + const word& instance, + const fvMesh& mesh +) +{ + IOdictionary control + ( + IOobject + ( + fileName_, + instance, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + control.lookup("fields") >> entries_; + control.lookup("output") >> output_; + control.lookup("values") >> *this; + + dimensionTable(); + + check(); + + if (this->size() == 0) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::readTable()" + ) << "table is empty" << nl + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::interpolationLookUpTable::interpolationLookUpTable() +: + List(), + fileName_("fileNameIsUndefined") +{} + + +template +Foam::interpolationLookUpTable::interpolationLookUpTable +( + const fileName& fn, const word& instance, const fvMesh& mesh +) +: + List(), + fileName_(fn), + dim_(0), + min_(0), + delta_(0.0), + max_(0.0), + entries_(0), + output_(0), + entryIndices_(0), + outputIndices_(0), + interpOutput_(0) +{ + readTable(instance, mesh); +} + + +template +Foam::interpolationLookUpTable::interpolationLookUpTable +( + const interpolationLookUpTable& interpTable +) +: + List(interpTable), + fileName_(interpTable.fileName_), + entryIndices_(interpTable.entryIndices_), + outputIndices_(interpTable.outputIndices_), + dim_(interpTable.dim_), + min_(interpTable.min_), + delta_(interpTable.delta_), + max_(interpTable.max_), + entries_(0), + output_(0), + interpOutput_(interpTable.interpOutput_) +{} + + +template +Foam::interpolationLookUpTable::interpolationLookUpTable +( + const dictionary& dict +) +: + List(), + fileName_(fileName(dict.lookup("fileName")).expand()), + dim_(0), + min_(0.0), + delta_(0.0), + max_(0.0), + entries_(dict.lookup("fields")), + output_(dict.lookup("output")), + entryIndices_(0), + outputIndices_(0), + fieldIndices_(0), + interpOutput_(0) +{ + dimensionTable(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::interpolationLookUpTable::check() const +{ +// check order in the first dimension. + + scalar prevValue = List::operator[](0).operator[](0); + label dim = 1 ; + for (int j = 1; j < dim_.size(); j++) + { + dim *=(dim_[j]+1); + } + + for (label i = 1; i < dim_[0]; i++) + { + label index = i*dim; + const scalar currValue = + List::operator[](0).operator[](index); + + // avoid duplicate values (divide-by-zero error) + if (currValue <= prevValue) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::checkOrder() const" + ) << "out-of-order value: " + << currValue << " at index " << index << nl + << exit(FatalError); + } + prevValue = currValue; + } +} + + +template +void Foam::interpolationLookUpTable::write +( + Ostream& os, + const fileName& fn, + const word& instance, + const fvMesh& mesh +) const +{ + IOdictionary control + ( + IOobject + ( + fn, + instance, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ); + + control.writeHeader(os); + + os.writeKeyword("fields"); + os << entries_ << token::END_STATEMENT << nl; + + os.writeKeyword("output"); + os << output_ << token::END_STATEMENT << nl; + + if (this->size() == 0) + { + FatalErrorIn + ( + "Foam::interpolationTable::write()" + ) << "table is empty" << nl + << exit(FatalError); + } + os.writeKeyword("values"); + os << *this << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +Foam::scalarField& +Foam::interpolationLookUpTable::operator[](const label i) +{ + label ii = i; + label n = this->size(); + + if (n <= 1) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "table has (" << n << ") columns" << nl + << exit(FatalError); + } + else if (ii < 0) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") underflow" << nl + << exit(FatalError); + } + else if (ii > n) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") overflow" << nl + << exit(FatalError); + } + + return List::operator[](ii); +} + + +template +const Foam::scalarField& +Foam::interpolationLookUpTable::operator[](const label i) const +{ + label ii = i; + label n = this->size(); + + if (n <= 1) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "table has (" << n << ") columns" << nl + << exit(FatalError); + } + else if (ii < 0) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") underflow" << nl + << exit(FatalError); + } + + else if (ii > n) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") overflow" << nl + << exit(FatalError); + } + + return List::operator[](ii); +} + + +template +bool Foam::interpolationLookUpTable::found(const word& fieldName) const +{ + return fieldIndices_.found(fieldName); +} + + +template +const Foam::scalarList& +Foam::interpolationLookUpTable::lookUp(const scalar retvals) +{ + const label lo = index(retvals); + findHi(lo, retvals); + return interpOutput_; +} + + +template +void Foam::interpolationLookUpTable::findHi +( + const label lo, + const scalar retvals +) +{ + forAll(outputIndices_,j) + { + scalar tmp = 0; + label ofield = outputIndices_[j]; + scalar baseValue = List::operator[](ofield).operator[](lo); + + forAll(entryIndices_,i) + { + if (checkRange(retvals,entryIndices_[i])) + { + label dim = 1; + + label hi = Foam::min(lo + dim, (*this)[0].size() - 1); + + tmp += interpolate(lo, hi, retvals, ofield, entryIndices_[i]) + - baseValue; + } + interpOutput_[entryIndices_[i]] = retvals; + } + + tmp += baseValue; + interpOutput_[outputIndices_[j]] = tmp; + } +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H new file mode 100755 index 0000000000..d2518d4e02 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::interpolationLookUpTable + +Description + A list of lists. Interpolates based on the first dimension. + The values must be positive and monotonically increasing in each dimension + +Note + - Accessing an empty list results in an error. + - Accessing a list with a single element always returns the same value. + +SourceFiles + interpolationLookUpTable.C + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolationLookUpTable_H +#define interpolationLookUpTable_H + +#include "List.H" +#include "ListOps.H" +#include "scalarField.H" +#include "HashTable.H" +#include "IOdictionary.H" +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class interpolationLookUpTable Declaration +\*---------------------------------------------------------------------------*/ + +template +class interpolationLookUpTable +: + public List +{ +private: + + // Private data + + //- File name + fileName fileName_; + + //- Table dimensions + List