From c681206a947ad8cbb3f41ef511414d9e74333392 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Tue, 5 Jun 2018 09:17:07 +0200 Subject: [PATCH] fixedHeatFluxTemperature boundary condition The boundary condition uses a specified heat flux and kappe effective to calculate the temperature gradient. It is a part of LES library in order to allow both RAS and LES models to use the BC. --- .../incompressible/LES/Make/files | 1 + ...xedHeatFluxTemperatureFvPatchScalarField.C | 234 ++++++++++++++++++ ...xedHeatFluxTemperatureFvPatchScalarField.H | 167 +++++++++++++ 3 files changed, 402 insertions(+) create mode 100644 src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.C create mode 100644 src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.H diff --git a/src/turbulenceModels/incompressible/LES/Make/files b/src/turbulenceModels/incompressible/LES/Make/files index ff17b596e..817f0520c 100644 --- a/src/turbulenceModels/incompressible/LES/Make/files +++ b/src/turbulenceModels/incompressible/LES/Make/files @@ -33,6 +33,7 @@ wallFunctions=derivedFvPatchFields/wallFunctions derivedFvPatchFields/decayingTurbulence/decayingVorton.C derivedFvPatchFields/decayingTurbulence/decayingTurbulenceFvPatchVectorField.C +derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.C nuSgsWallFunctions=$(wallFunctions)/nuSgsWallFunctions $(nuSgsWallFunctions)/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 000000000..80d820449 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "fixedHeatFluxTemperatureFvPatchScalarField.H" +#include "incompressible/RAS/RASModel/RASModel.H" +#include "incompressible/LES/LESModel/LESModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +fixedHeatFluxTemperatureFvPatchScalarField:: +fixedHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(p, iF), + heatFlux_(p.size(), 0.0), + Pr_(0.0), + Prt_(0.0) +{ + this->gradient() = 0.0; +} + + +fixedHeatFluxTemperatureFvPatchScalarField:: +fixedHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchScalarField(p, iF), + heatFlux_("heatFlux", dict, p.size()), + Pr_(0.0), // Initialized in constructor body + Prt_(0.0) // Initialized in constructor body +{ + // Set dummy gradient + this->gradient() = 0.0; + + // Read the value entry from the dictionary + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + FatalIOErrorIn + ( + "fixedHeatFluxTemperatureFvPatchScalarField::" + "fixedHeatFluxTemperatureFvPatchScalarField" + "(" + "const fvPatch& p," + "const DimensionedField& iF," + "const dictionary& dict," + "const bool valueRequired" + ")", + dict + ) << "Essential entry 'value' missing" + << exit(FatalIOError); + } + + // Get mesh + const fvMesh& mesh = this->dimensionedInternalField().mesh(); + + // Create transportProperties dictionary + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false // do not register in the database + ) + ); + + // Read in Prandtl numbers + Pr_ = dimensionedScalar(transportProperties.lookup("Pr")).value(); + Prt_ = dimensionedScalar(transportProperties.lookup("Prt")).value(); +} + + +fixedHeatFluxTemperatureFvPatchScalarField:: +fixedHeatFluxTemperatureFvPatchScalarField +( + const fixedHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), + heatFlux_(ptf.heatFlux_), + Pr_(ptf.Pr_), + Prt_(ptf.Prt_) +{} + + +fixedHeatFluxTemperatureFvPatchScalarField:: +fixedHeatFluxTemperatureFvPatchScalarField +( + const fixedHeatFluxTemperatureFvPatchScalarField& ptf +) +: + fixedGradientFvPatchScalarField(ptf), + heatFlux_(ptf.heatFlux_), + Pr_(ptf.Pr_), + Prt_(ptf.Prt_) +{} + + +fixedHeatFluxTemperatureFvPatchScalarField:: +fixedHeatFluxTemperatureFvPatchScalarField +( + const fixedHeatFluxTemperatureFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(ptf, iF), + heatFlux_(ptf.heatFlux_), + Pr_(ptf.Pr_), + Prt_(ptf.Prt_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void fixedHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + // Calculate the gradient depending on the turbulence model + const fvMesh& mesh = this->dimensionedInternalField().mesh(); + + // Get this patch index + const label patchID = this->patch().index(); + + if (mesh.foundObject("RASProperties")) + { + const incompressible::RASModel& ras = + mesh.lookupObject("RASProperties"); + + // Calculate effective kappa at the patch + const scalarField kappaEffp = + ras.nu().boundaryField()[patchID]/Pr_ + + ras.nut()().boundaryField()[patchID]/Prt_; + + this->gradient() = heatFlux_/kappaEffp; + } + else if (mesh.foundObject("LESProperties")) + { + const incompressible::LESModel& les = + mesh.lookupObject("LESProperties"); + + // Calculate effective kappa at the patch + const scalarField kappaEffp = + les.nu().boundaryField()[patchID]/Pr_ + + les.nut()().boundaryField()[patchID]/Prt_; + + this->gradient() = heatFlux_/kappaEffp; + } + else + { + FatalErrorIn + ( + "fixedHeatFluxTemperatureFvPatchScalarField::updateCoeffs()" + ) << " No valid model for effective kappa calculations." + << abort(FatalError); + } + + fixedGradientFvPatchScalarField::updateCoeffs(); +} + + +void fixedHeatFluxTemperatureFvPatchScalarField::write(Ostream& os) const +{ + fixedGradientFvPatchScalarField::write(os); + heatFlux_.writeEntry("heatFlux", os); + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + fixedHeatFluxTemperatureFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 000000000..6cefdf919 --- /dev/null +++ b/src/turbulenceModels/incompressible/LES/derivedFvPatchFields/fixedHeatFluxTemperature/fixedHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::fixedHeatFluxTemperatureFvPatchScalarField + +Description + + Fixed temperature flux boundary condition. Assumes incompressible turbulent + flow. The normal temperature gradient is calculated as: + + snGrad(T) = q/kappaEff + + where: + - q is the prescribed heat flux [W/m^2], + - kappaEff is the effective diffusivity field: nu/Pr + nu_t/Pr_t, + - Pr and Prt are laminar and turbulent Prandtl number read from + transportProperties dictionary + + Designed to be used alongside solvers with Boussinesq buoyancy + approximation (e.g. buoyantBoussinesqSimpleFoam). + +Author + Vuko Vukcevic, Wikki Ltd. All rights reserved + +SourceFiles + fixedHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedHeatFluxTemperatureFvPatchScalarField_H +#define fixedHeatFluxTemperatureFvPatchScalarField_H + +#include "fixedGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class fixedHeatFluxTemperatureFvPatchScalarField +: + public fixedGradientFvPatchScalarField +{ + // Private data + + //- Fixed heat flux + scalarField heatFlux_; + + //- Laminar Prandtl number + scalar Pr_; + + //- Turbulent Prandtl number + scalar Prt_; + + +public: + + //- Runtime type information + TypeName("fixedHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + fixedHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + fixedHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // fixedHeatFluxTemperatureFvPatchScalarField onto a new patch + fixedHeatFluxTemperatureFvPatchScalarField + ( + const fixedHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedHeatFluxTemperatureFvPatchScalarField + ( + const fixedHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new fixedHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + fixedHeatFluxTemperatureFvPatchScalarField + ( + const fixedHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new fixedHeatFluxTemperatureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //