/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "inletOutletTotalTemperatureFvPatchScalarField.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF ) : inletOutletFvPatchScalarField(p, iF), UName_("U"), psiName_("psi"), gamma_(0.0), T0_(p.size(), Zero) { this->refValue() = Zero; this->refGrad() = Zero; this->valueFraction() = 0.0; } Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const inletOutletTotalTemperatureFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : inletOutletFvPatchScalarField(ptf, p, iF, mapper), UName_(ptf.UName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), T0_(ptf.T0_, mapper) {} Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : inletOutletFvPatchScalarField(p, iF), UName_(dict.getOrDefault("U", "U")), psiName_(dict.getOrDefault("psi", "thermo:psi")), gamma_(dict.get("gamma")), T0_("T0", dict, p.size()) { fvPatchFieldBase::readDict(dict); this->phiName_ = dict.getOrDefault("phi", "phi"); this->refValue() = Zero; if (!this->readValueEntry(dict)) { fvPatchField::operator=(T0_); } this->refGrad() = Zero; this->valueFraction() = 0.0; } Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const inletOutletTotalTemperatureFvPatchScalarField& tppsf ) : inletOutletFvPatchScalarField(tppsf), UName_(tppsf.UName_), psiName_(tppsf.psiName_), gamma_(tppsf.gamma_), T0_(tppsf.T0_) {} Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const inletOutletTotalTemperatureFvPatchScalarField& tppsf, const DimensionedField& iF ) : inletOutletFvPatchScalarField(tppsf, iF), UName_(tppsf.UName_), psiName_(tppsf.psiName_), gamma_(tppsf.gamma_), T0_(tppsf.T0_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) { inletOutletFvPatchScalarField::autoMap(m); T0_.autoMap(m); } void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap ( const fvPatchScalarField& ptf, const labelList& addr ) { inletOutletFvPatchScalarField::rmap(ptf, addr); const inletOutletTotalTemperatureFvPatchScalarField& tiptf = refCast(ptf); T0_.rmap(tiptf.T0_, addr); } void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const auto& Up = patch().lookupPatchField(UName_); const auto& phip = patch().lookupPatchField(this->phiName_); const auto& psip = patch().lookupPatchField(psiName_); scalar gM1ByG = (gamma_ - 1.0)/gamma_; this->refValue() = T0_/(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up)); this->valueFraction() = neg(phip); inletOutletFvPatchScalarField::updateCoeffs(); } void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); os.writeEntryIfDifferent("U", "U", UName_); os.writeEntryIfDifferent("phi", "phi", this->phiName_); os.writeEntryIfDifferent("psi", "psi", psiName_); os.writeEntry("gamma", gamma_); T0_.writeEntry("T0", os); fvPatchField::writeValueEntry(os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { makePatchTypeField ( fvPatchScalarField, inletOutletTotalTemperatureFvPatchScalarField ); } // ************************************************************************* //