diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C new file mode 100644 index 000000000..0ed904120 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "Uniform.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::Function1Types::Uniform::Uniform +( + const word& entryName, + const dictionary& dict +) +: + Constant(entryName, dict) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H new file mode 100644 index 000000000..cd949ae0d --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::Function1Types::Uniform + +Description + Templated function that returns a constant value. + + Provides backward-compatibility for cases where a field is spatially + "uniform" and may be treated as a constant value. + + Usage - for entry \ returning the value : + \verbatim + uniform + \endverbatim + +SourceFiles + Uniform.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Uniform_H +#define Uniform_H + +#include "Function1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace Function1Types +{ + +/*---------------------------------------------------------------------------*\ + Class Uniform Declaration +\*---------------------------------------------------------------------------*/ + +template +class Uniform +: + public Constant +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const Uniform&); + + +public: + + // Runtime type information + TypeName("uniform"); + + + // Constructors + + //- Construct from entry name and dictionary + Uniform(const word& entryName, const dictionary& dict); + + //- Construct and return a clone + virtual tmp> clone() const + { + return tmp>(new Uniform(*this)); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Function1Types +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "Uniform.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C b/src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C index b7c93ca1b..f64b55fd1 100644 --- a/src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C +++ b/src/OpenFOAM/primitives/functions/Function1/makeDataEntries.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Constant.H" +#include "Uniform.H" #include "ZeroConstant.H" #include "OneConstant.H" #include "PolynomialEntry.H" @@ -41,6 +42,7 @@ License #define makeFunction1s(Type) \ makeFunction1(Type); \ makeFunction1Type(Constant, Type); \ + makeFunction1Type(Uniform, Type); \ makeFunction1Type(ZeroConstant, Type); \ makeFunction1Type(OneConstant, Type); \ makeFunction1Type(Polynomial, Type); \ diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C index fb9c06417..617860d36 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -69,6 +69,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), mode_(fixedHeatFlux), Q_(0), + Ta_(), relaxation_(1), emissivity_(0), qrRelaxation_(1), @@ -94,6 +95,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField temperatureCoupledBase(patch(), dict), mode_(operationModeNames.read(dict.lookup("mode"))), Q_(0), + Ta_(Function1::New("Ta", dict)), relaxation_(dict.lookupOrDefault("relaxation", 1)), emissivity_(dict.lookupOrDefault("emissivity", 0)), qrRelaxation_(dict.lookupOrDefault("qrRelaxation", 1)), @@ -118,7 +120,6 @@ externalWallHeatFluxTemperatureFvPatchScalarField case fixedHeatTransferCoeff: { h_ = scalarField("h", dict, p.size()); - Ta_ = scalarField("Ta", dict, p.size()); if (dict.found("thicknessLayers")) { @@ -174,6 +175,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField temperatureCoupledBase(patch(), ptf), mode_(ptf.mode_), Q_(ptf.Q_), + Ta_(ptf.Ta_, false), relaxation_(ptf.relaxation_), emissivity_(ptf.emissivity_), qrRelaxation_(ptf.qrRelaxation_), @@ -196,7 +198,6 @@ externalWallHeatFluxTemperatureFvPatchScalarField case fixedHeatTransferCoeff: { h_.map(ptf.h_, mapper); - Ta_.map(ptf.Ta_, mapper); break; } @@ -221,7 +222,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField Q_(tppsf.Q_), q_(tppsf.q_), h_(tppsf.h_), - Ta_(tppsf.Ta_), + Ta_(tppsf.Ta_, false), relaxation_(tppsf.relaxation_), emissivity_(tppsf.emissivity_), qrPrevious_(tppsf.qrPrevious_), @@ -245,7 +246,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField Q_(tppsf.Q_), q_(tppsf.q_), h_(tppsf.h_), - Ta_(tppsf.Ta_), + Ta_(tppsf.Ta_, false), relaxation_(tppsf.relaxation_), emissivity_(tppsf.emissivity_), qrPrevious_(tppsf.qrPrevious_), @@ -280,7 +281,6 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap case fixedHeatTransferCoeff: { h_.autoMap(m); - Ta_.autoMap(m); break; } @@ -319,7 +319,6 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::rmap case fixedHeatTransferCoeff: { h_.rmap(tiptf.h_, addr); - Ta_.rmap(tiptf.Ta_, addr); break; } @@ -386,7 +385,8 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() } scalarField hp(1/(1/h_ + totalSolidRes)); - scalarField hpTa(hp*Ta_); + const scalar Ta = Ta_->value(this->db().time().timeOutputValue()); + scalarField hpTa(hp*Ta); if (emissivity_ > 0) { @@ -397,18 +397,18 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() // ... including the effect of the solid wall thermal // resistance scalarField TpLambda(h_/(h_ + 1/totalSolidRes)); - scalarField Ts(TpLambda*Tp + (1 - TpLambda)*Ta_); - scalarField lambdaTa4(pow4((1 - TpLambda)*Ta_)); + scalarField Ts(TpLambda*Tp + (1 - TpLambda)*Ta); + scalarField lambdaTa4(pow4((1 - TpLambda)*Ta)); hp += emissivity_*sigma.value()*(pow4(Ts) - lambdaTa4)/Tp; - hpTa += sigma.value()*(emissivity_*lambdaTa4 + pow4(Ta_)); + hpTa += sigma.value()*(emissivity_*lambdaTa4 + pow4(Ta)); } else { // ... if there is no solid wall thermal resistance use // the current wall temperature hp += emissivity_*sigma.value()*pow3(Tp); - hpTa += sigma.value()*pow4(Ta_); + hpTa += sigma.value()*pow4(Ta); } } @@ -490,7 +490,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write case fixedHeatTransferCoeff: { h_.writeEntry("h", os); - Ta_.writeEntry("Ta", os); + Ta_->writeData(os); if (relaxation_ < 1) { diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H index 411dfe9ef..50a8ee2d2 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H @@ -100,6 +100,7 @@ SourceFiles #include "mixedFvPatchFields.H" #include "temperatureCoupledBase.H" +#include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -147,7 +148,7 @@ private: scalarField h_; //- Ambient temperature [K] - scalarField Ta_; + autoPtr> Ta_; //- Relaxation for the wall temperature (thermal inertia) scalar relaxation_;