diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean index c583a8de0a..1a1d74eb61 100755 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x +wclean libso coupledDerivedFvPatch wclean wclean chtMultiRegionSimpleFoam diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake index f65ba1181b..fa679a5ab3 100755 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x +wmake libso coupledDerivedFvPatch wmake wmake chtMultiRegionSimpleFoam diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files index c62898c31f..9ae6090832 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -1,5 +1,3 @@ -derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C - fluid/compressibleCourantNo.C solid/solidRegionDiffNo.C diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options index 2fcfff4126..2265722b4a 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options @@ -19,4 +19,5 @@ EXE_LIBS = \ -lcompressibleLESModels \ -lmeshTools \ -lfiniteVolume \ - -lradiationModels + -lradiationModels \ + -lcoupledDerivedFvPatch diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files index 09754afdef..d604fafb22 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files @@ -1,6 +1,4 @@ chtMultiRegionSimpleFoam.C -../derivedFvPatchFields/turbulentTemperatureCoupledMixedST/turbulentTemperatureCoupledMixedSTFvPatchScalarField.C -../derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C EXE = $(FOAM_APPBIN)/chtMultiRegionSimpleFoam diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options index eeaf9cc437..af7f782123 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options @@ -1,7 +1,5 @@ EXE_INC = \ - /* -DFULLDEBUG -O0 -g */ \ -I.. \ - -I../derivedFvPatchFields \ -Ifluid \ -Isolid \ -I$(LIB_SRC)/finiteVolume/lnInclude \ @@ -22,4 +20,5 @@ EXE_LIBS = \ -lcompressibleTurbulenceModel \ -lcompressibleRASModels \ -lcompressibleLESModels \ - -lradiationModels + -lradiationModels \ + -lcoupledDerivedFvPatch diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H index a742e78cc8..2fde518a6c 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H @@ -10,12 +10,6 @@ + rad.Sh(thermo) ); -/* - fvScalarMatrix hEqn - ( - - fvm::laplacian(turb.alphaEff(), h) - ); -*/ hEqn.relax(); hEqn.solve(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/Make/files new file mode 100644 index 0000000000..93891d7c67 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/Make/files @@ -0,0 +1,4 @@ +turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C + +LIB = $(FOAM_LIBBIN)/libcoupledDerivedFvPatch diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/Make/options new file mode 100644 index 0000000000..a178c0d55d --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude + +EXE_LIBS = \ + -lmeshTools \ + -lbasicThermophysicalModels \ + -lfiniteVolume \ + -lradiationModels diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000..03d932975f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,271 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "externalWallHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "directMappedPatchBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template<> +const char* +NamedEnum +::names[]= +{ + "fixed_heat_flux", + "fixed_heat_transfer_coefficient", + "unknown" +}; + +const NamedEnum +< + externalWallHeatFluxTemperatureFvPatchScalarField::operationMode, 3 +> +externalWallHeatFluxTemperatureFvPatchScalarField::operationModeNames; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::externalWallHeatFluxTemperatureFvPatchScalarField:: +externalWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + temperatureCoupledBase(patch(), "undefined", "undefined-K"), + oldMode_(unknown), + q_(p.size(), 0.0), + h_(p.size(), 0.0), + Ta_(p.size(), 0.0) +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; +} + + +Foam::externalWallHeatFluxTemperatureFvPatchScalarField:: +externalWallHeatFluxTemperatureFvPatchScalarField +( + const externalWallHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + temperatureCoupledBase(patch(), ptf.KMethod(), ptf.KName()), + oldMode_(unknown), + q_(ptf.q_, mapper), + h_(ptf.h_, mapper), + Ta_(ptf.Ta_, mapper) +{} + + +Foam::externalWallHeatFluxTemperatureFvPatchScalarField:: +externalWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + temperatureCoupledBase(patch(), dict), + oldMode_(unknown), + q_(p.size(), 0.0), + h_(p.size(), 0.0), + Ta_(p.size(), 0.0) +{ + if (dict.found("q") && !dict.found("h") && !dict.found("Ta")) + { + oldMode_ = fixedHeatFlux; + q_ = scalarField("q", dict, p.size()); + } + else if(dict.found("h") && dict.found("Ta") && !dict.found("q")) + { + oldMode_ = fixedHeatTransferCoeff; + h_ = scalarField("h", dict, p.size()); + Ta_ = scalarField("Ta", dict, p.size()); + } + else + { + FatalErrorIn + ( + "externalWallHeatFluxTemperatureFvPatchScalarField::" + "externalWallHeatFluxTemperatureFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField& iF,\n" + " const dictionary& dict\n" + ")\n" + ) << "\n patch type '" << p.type() + << "' either q or h and Ta were not found '" + << "\n for patch " << p.name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + } +} + + +Foam::externalWallHeatFluxTemperatureFvPatchScalarField:: +externalWallHeatFluxTemperatureFvPatchScalarField +( + const externalWallHeatFluxTemperatureFvPatchScalarField& tppsf +) +: + mixedFvPatchScalarField(tppsf), + temperatureCoupledBase(tppsf), + oldMode_(unknown), + q_(tppsf.q_), + h_(tppsf.h_), + Ta_(tppsf.Ta_) +{} + + +Foam::externalWallHeatFluxTemperatureFvPatchScalarField:: +externalWallHeatFluxTemperatureFvPatchScalarField +( + const externalWallHeatFluxTemperatureFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(tppsf, iF), + temperatureCoupledBase(patch(), tppsf.KMethod(), tppsf.KName()), + oldMode_(tppsf.oldMode_), + q_(tppsf.q_), + h_(tppsf.h_), + Ta_(tppsf.Ta_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + if(oldMode_ == fixedHeatFlux) + { + this->refGrad() = q_/K(*this); + this->refValue() = 0.0; + this->valueFraction() = 0.0; + } + else if(oldMode_ == fixedHeatTransferCoeff) + { + this->refGrad() = (Ta_ - *this)*h_/K(*this); + this->refValue() = 0.0; + this->valueFraction() = 0.0; + } + else + { + FatalErrorIn + ( + "externalWallHeatFluxTemperatureFvPatchScalarField" + "::updateCoeffs()" + ) << "Illegal mode " << operationModeNames[oldMode_] + << exit(FatalError); + } + + mixedFvPatchScalarField::updateCoeffs(); + + if (debug) + { + scalar Q = gSum(K(*this)*patch().magSf()*snGrad()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " :" + << " heatFlux:" << Q + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } +} + + +void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + temperatureCoupledBase::write(os); + q_.writeEntry("q", os); + h_.writeEntry("h", os); + Ta_.writeEntry("Ta", os); + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + externalWallHeatFluxTemperatureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 0000000000..3ba68612dc --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,188 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + externalWallHeatFluxTemperatureFvPatchScalarField + +Description + Heat flux boundary condition for temperature on external wall. + + If h and Ta are specified then fixed_heat_transfer_coefficient mode is used + If q is specified then fixed_heat_flux is used. + + Example usage: + myWallPatch + { + type externalWallHeatFluxTemperature; + K solidThermo; // solidThermo or lookup + q uniform 1000; // Heat flux / [W/m2] + Ta uniform 300.0; // Tambient temperature /[K] + h uniform 10.0; // Heat transfer coeff /[W/Km2] + value uniform 300.0; // Initial temperature / [K] + KName none; + } + + +SourceFiles + externalWallHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidWallHeatFluxTemperatureFvPatchScalarField_H +#define solidWallHeatFluxTemperatureFvPatchScalarField_H + +//#include "fixedGradientFvPatchFields.H" + +#include "mixedFvPatchFields.H" +#include "temperatureCoupledBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class externalWallHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class externalWallHeatFluxTemperatureFvPatchScalarField +: + public mixedFvPatchScalarField, + public temperatureCoupledBase +{ + // Private data + + //- how to operate the BC + enum operationMode + { + fixedHeatFlux, + fixedHeatTransferCoeff, + unknown + }; + static const NamedEnum operationModeNames; + + //- Operation mode + operationMode oldMode_; + + //- Heat flux / [W/m2] + scalarField q_; + + //- Heat transfer coefficient / [W/m2K] + scalarField h_; + + //- Ambient temperature / [K] + scalarField Ta_; + + +public: + + //- Runtime type information + TypeName("externalWallHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + externalWallHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + externalWallHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // externalWallHeatFluxTemperatureFvPatchScalarField + // onto a new patch + externalWallHeatFluxTemperatureFvPatchScalarField + ( + const externalWallHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + externalWallHeatFluxTemperatureFvPatchScalarField + ( + const externalWallHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new externalWallHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + externalWallHeatFluxTemperatureFvPatchScalarField + ( + const externalWallHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new externalWallHeatFluxTemperatureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C new file mode 100644 index 0000000000..951216053f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -0,0 +1,258 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 "turbulentTemperatureRadCoupledMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "directMappedPatchBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentTemperatureRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureRadCoupledMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + temperatureCoupledBase(patch(), "undefined", "undefined-K"), + TnbrName_("undefined-Tnbr"), + QrNbrName_("undefined-QrNbr"), + QrName_("undefined-Qr") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; +} + + +turbulentTemperatureRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureRadCoupledMixedFvPatchScalarField +( + const turbulentTemperatureRadCoupledMixedFvPatchScalarField& psf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(psf, p, iF, mapper), + temperatureCoupledBase(patch(), psf.KMethod(), psf.KName()), + TnbrName_(psf.TnbrName_), + QrNbrName_(psf.QrNbrName_), + QrName_(psf.QrName_) +{} + + +turbulentTemperatureRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureRadCoupledMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + temperatureCoupledBase(patch(), dict), + TnbrName_(dict.lookup("Tnbr")), + QrNbrName_(dict.lookup("QrNbr")), + QrName_(dict.lookup("Qr")) +{ + if (!isA(this->patch().patch())) + { + FatalErrorIn + ( + "turbulentTemperatureRadCoupledMixedFvPatchScalarField::" + "turbulentTemperatureRadCoupledMixedFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField& iF,\n" + " const dictionary& dict\n" + ")\n" + ) << "\n patch type '" << p.type() + << "' not type '" << directMappedPatchBase::typeName << "'" + << "\n for patch " << p.name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + } +} + + +turbulentTemperatureRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureRadCoupledMixedFvPatchScalarField +( + const turbulentTemperatureRadCoupledMixedFvPatchScalarField& psf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(psf, iF), + temperatureCoupledBase(patch(), psf.KMethod(), psf.KName()), + TnbrName_(psf.TnbrName_), + QrNbrName_(psf.QrNbrName_), + QrName_(psf.QrName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Get the coupling information from the directMappedPatchBase + const directMappedPatchBase& mpp = + refCast(patch().patch()); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const label samplePatchI = mpp.samplePolyPatch().index(); + const fvPatch& nbrPatch = + refCast(nbrMesh).boundary()[samplePatchI]; + + // Force recalculation of mapping and schedule + //const mapDistribute& distMap = mpp.map(); + + scalarField Tc = patchInternalField(); + scalarField& Tp = *this; + + const turbulentTemperatureRadCoupledMixedFvPatchScalarField& + nbrField = refCast + + ( + nbrPatch.lookupPatchField(TnbrName_) + ); + + // Swap to obtain full local values of neighbour internal field + scalarField TcNbr = nbrField.patchInternalField(); + + mpp.map().distribute(TcNbr); + /* + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + TcNbr + ); + */ + + // Swap to obtain full local values of neighbour K*delta + scalarField KDeltaNbr = nbrField.K(TcNbr)*nbrPatch.deltaCoeffs(); + + mpp.map().distribute(KDeltaNbr); + /* + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + KDeltaNbr + ); + */ + scalarField KDelta = K(*this)*patch().deltaCoeffs(); + + scalarField Qr(Tp.size(), 0.0); + if (QrName_ != "none") + { + Qr = patch().lookupPatchField(QrName_); + } + + scalarField QrNbr(Tp.size(), 0.0); + if (QrNbrName_ != "none") + { + QrNbr = nbrPatch.lookupPatchField(QrNbrName_); + } + + scalarField alpha(KDeltaNbr - (Qr + QrNbr)/Tp); + + valueFraction() = alpha/(alpha + KDelta); + + refValue() = (KDeltaNbr*TcNbr)/alpha; + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl; + os.writeKeyword("QrNbr")<< QrNbrName_ << token::END_STATEMENT << nl; + os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl; + temperatureCoupledBase::write(os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentTemperatureRadCoupledMixedFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H new file mode 100644 index 0000000000..d899cc0f43 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatch/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam:: + compressible:: + turbulentTemperatureRadCoupledMixedFvPatchScalarField + +Description + Mixed boundary condition for temperature and radiation heat transfer + to be used for in multiregion cases + + Example usage: + myInterfacePatchName + { + type compressible::turbulentTemperatureRadCoupledMixed; + TNbr T; // name of T field on neighbour region + K lookup; + KName K; + QrNbr Qr; // or none. Name of Qr field on neighbour region + Qr Qr; // or none. Name of Qr field on local region + value uniform 300; + } + + Needs to be on underlying directMapped(Wall)FvPatch. + + Note: K : heat conduction at patch. Gets supplied how to lookup/calculate K: + - 'lookup' : lookup volScalarField (or volSymmTensorField) with name + - 'basicThermo' : use basicThermo and compressible::RASmodel to calculate K + - 'solidThermo' : use basicSolidThermo K() + - 'directionalSolidThermo' directionalK() + + Note: runs in parallel with arbitrary decomposition. Uses directMapped + functionality to calculate exchange. + +SourceFiles + turbulentTemperatureRadCoupledMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentTemperatureRadCoupledMixedFvPatchScalarField_H +#define turbulentTemperatureRadCoupledMixedFvPatchScalarField_H + +#include "mixedFvPatchFields.H" +#include "temperatureCoupledBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentTemperatureRadCoupledMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentTemperatureRadCoupledMixedFvPatchScalarField +: + public mixedFvPatchScalarField, + public temperatureCoupledBase +{ + // Private data + + //- Name of field on the neighbour region + const word TnbrName_; + + //- Name of the radiative heat flux in the neighbout region + const word QrNbrName_; + + //- Name of the radiative heat flux in local region + const word QrName_; + + +public: + + //- Runtime type information + TypeName("compressible::turbulentTemperatureRadCoupledMixed"); + + + // Constructors + + //- Construct from patch and internal field + turbulentTemperatureRadCoupledMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureRadCoupledMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a + // new patch + turbulentTemperatureRadCoupledMixedFvPatchScalarField + ( + const + turbulentTemperatureRadCoupledMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentTemperatureRadCoupledMixedFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureRadCoupledMixedFvPatchScalarField + ( + const turbulentTemperatureRadCoupledMixedFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentTemperatureRadCoupledMixedFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/Make/files b/src/thermophysicalModels/radiationModels/Make/files index 790e0a0271..33908248de 100644 --- a/src/thermophysicalModels/radiationModels/Make/files +++ b/src/thermophysicalModels/radiationModels/Make/files @@ -30,5 +30,6 @@ derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchSc derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C +derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C LIB = $(FOAM_LIBBIN)/libradiationModels diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C new file mode 100644 index 0000000000..4a062f3b90 --- /dev/null +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C @@ -0,0 +1,182 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "greyDiffusiveViewFactorFixedValueFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +greyDiffusiveViewFactorFixedValueFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + radiationCoupledBase(patch(), "undefined", scalarField::null()), + Qro_(p.size(), 0.0) +{} + + +Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +greyDiffusiveViewFactorFixedValueFvPatchScalarField +( + const greyDiffusiveViewFactorFixedValueFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + radiationCoupledBase + ( + patch(), + ptf.emissivityMethod(), + ptf.emissivity_ + ), + Qro_(ptf.Qro_) +{} + + +Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +greyDiffusiveViewFactorFixedValueFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF), + radiationCoupledBase(p, dict), + Qro_("Qro", dict, p.size()) +{ + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + + } + else + { + fvPatchScalarField::operator=(0.0); + } +} + + +Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +greyDiffusiveViewFactorFixedValueFvPatchScalarField +( + const greyDiffusiveViewFactorFixedValueFvPatchScalarField& ptf +) +: + fixedValueFvPatchScalarField(ptf), + radiationCoupledBase + ( + ptf.patch(), + ptf.emissivityMethod(), + ptf.emissivity_ + ), + Qro_(ptf.Qro_) +{} + + +Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +greyDiffusiveViewFactorFixedValueFvPatchScalarField +( + const greyDiffusiveViewFactorFixedValueFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(ptf, iF), + radiationCoupledBase + ( + ptf.patch(), + ptf.emissivityMethod(), + ptf.emissivity_ + ), + Qro_(ptf.Qro_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +void Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +updateCoeffs() +{ + //Do nothing + + if (debug) + { + scalar Q = gSum((*this)*patch().magSf()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " <- " + << " heat[W]:" << Q + << " wall radiative heat flux " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } + +} + + +void Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField:: +write +( + Ostream& os +) const +{ + fixedValueFvPatchScalarField::write(os); + radiationCoupledBase::write(os); + Qro_.writeEntry("Qro", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + makePatchTypeField + ( + fvPatchScalarField, + greyDiffusiveViewFactorFixedValueFvPatchScalarField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H new file mode 100644 index 0000000000..c1e4531873 --- /dev/null +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::greyDiffusiveViewFactorFixedValueFvPatchScalarField + +Description + Radiation temperature specified + +SourceFiles + greyDiffusiveViewFactorFixedValueFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef greyDiffusiveViewFactorFixedValueFvPatchScalarField_H +#define greyDiffusiveViewFactorFixedValueFvPatchScalarField_H + +#include "radiationCoupledBase.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class greyDiffusiveViewFactorFixedValueFvPatchScalarField declaration +\*---------------------------------------------------------------------------*/ + +class greyDiffusiveViewFactorFixedValueFvPatchScalarField +: + public fixedValueFvPatchScalarField, + public radiationCoupledBase +{ + // Private data + + //- External radiative heat flux + scalarField Qro_; + + +public: + + //- Runtime type information + TypeName("greyDiffusiveRadiationViewFactor"); + + + // Constructors + + //- Construct from patch and internal field + greyDiffusiveViewFactorFixedValueFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + greyDiffusiveViewFactorFixedValueFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given a + // greyDiffusiveViewFactorFixedValueFvPatchScalarField onto a new patch + greyDiffusiveViewFactorFixedValueFvPatchScalarField + ( + const greyDiffusiveViewFactorFixedValueFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + greyDiffusiveViewFactorFixedValueFvPatchScalarField + ( + const greyDiffusiveViewFactorFixedValueFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new greyDiffusiveViewFactorFixedValueFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + greyDiffusiveViewFactorFixedValueFvPatchScalarField + ( + const greyDiffusiveViewFactorFixedValueFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new greyDiffusiveViewFactorFixedValueFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return external radiative heat flux + const scalarList& Qro() + { + return Qro_; + } + + + // 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/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C index c5658b81a0..eab4624c29 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C @@ -56,12 +56,13 @@ const Foam::NamedEnum Foam::radiationCoupledBase::radiationCoupledBase ( const fvPatch& patch, - const word& calculationType + const word& calculationType, + const scalarField& emissivity ) : patch_(patch), method_(emissivityMethodTypeNames_[calculationType]), - emissivity_(patch.size(), 0.0) + emissivity_(emissivity) {} @@ -93,35 +94,7 @@ Foam::radiationCoupledBase::radiationCoupledBase << exit(FatalError); } - const directMappedPatchBase& mpp = refCast - < - const directMappedPatchBase - > - ( - patch_.patch() - ); - - const polyMesh& nbrMesh = mpp.sampleMesh(); - - if - ( - !nbrMesh.foundObject - ( - "solidThermophysicalProperties" - ) - ) - { - FatalErrorIn - ( - "radiationCoupledBase::radiationCoupledBase\n" - "(\n" - " const fvPatch& p,\n" - " const dictionary& dict\n" - ")\n" - ) << "\n solidThermophysicalProperties does not exist " - << "\n in mesh ' " << nbrMesh.name() << "'" - << exit(FatalError); - } + emissivity_ = scalarField(patch_.size(), 0.0); } break; @@ -136,9 +109,8 @@ Foam::radiationCoupledBase::radiationCoupledBase " const fvPatch& p,\n" " const dictionary& dict\n" ")\n" - ) << "\n emissivity key" - << "\n does not exist " - << "\n for patch " << patch_.name() + ) << "\n emissivity key does not exist for patch " + << patch_.name() << exit(FatalError); } else @@ -159,7 +131,6 @@ Foam::tmp Foam::radiationCoupledBase::emissivity() const { case SOLIDTHERMO: { - // Get the coupling information from the directMappedPatchBase const directMappedPatchBase& mpp = refCast @@ -168,25 +139,36 @@ Foam::tmp Foam::radiationCoupledBase::emissivity() const ); const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast ( nbrMesh ).boundary()[mpp.samplePolyPatch().index()]; - scalarField emissivity - ( - nbrPatch.lookupPatchField("emissivity") - ); + if (nbrMesh.foundObject("emissivity")) + { + tmp temissivity + ( + new scalarField + ( + nbrPatch.lookupPatchField + ( + "emissivity" + ) + ) + ); - // Force recalculation of mapping and schedule - const mapDistribute& distMap = mpp.map(); + scalarField& emissivity = temissivity(); - distMap.distribute(emissivity); + // Use direct map mapping to exchange data + mpp.map().distribute(emissivity); - return tmp - ( - new scalarField(emissivity) - ); + return temissivity; + } + else + { + return scalarField(0); + } } break; @@ -219,8 +201,7 @@ void Foam::radiationCoupledBase::write(Ostream& os) const { os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_] << token::END_STATEMENT << nl; - os.writeKeyword("emissivity") << emissivity_ - << token::END_STATEMENT << nl; + emissivity_.writeEntry("emissivity", os); } diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H index 7a7ce85b87..405d0f75a5 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H @@ -25,9 +25,8 @@ Class radiationCoupledBase Description - Common functions for use in temperature coupled boundaries when - radiation is used. For now only emissivity() : emissivity - gets supplied from lookup or calculate: + Common functions to emissivity. It gets supplied from lookup into a + dictionary or calculated by the solidThermo: - 'lookup' : lookup volScalarField with name - 'solidThermo' : use basicSolidThermo emissivity() @@ -73,11 +72,15 @@ private: //- Underlying patch const fvPatch& patch_; +protected: + + // Protected data + //- How to get emissivity const emissivityMethodType method_; //- Emissivity - // Cached locally when is read from dictionary + // Cached locally when is read from dictionary (lookup mode) scalarField emissivity_; @@ -85,11 +88,12 @@ public: // Constructors - //- Construct from patch and emissivity name + //- Construct from patch, emissivity mode and emissivity radiationCoupledBase ( const fvPatch& patch, - const word& calculationMethod + const word& calculationMethod, + const scalarField& emissivity ); //- Construct from patch and dictionary @@ -108,13 +112,7 @@ public: return emissivityMethodTypeNames_[method_]; } -/* - //- Name of thermal conductivity field - const word& emissivityName() const - { - return emissivityName_; - } -*/ + //- Calculate corresponding emissivity field tmp emissivity() const;