/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 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 "smoluchowskiJumpTFvPatchScalarField.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "basicThermo.H" #include "mathematicalConstants.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF ) : mixedFvPatchScalarField(p, iF), UName_("U"), rhoName_("rho"), psiName_("thermo:psi"), muName_("thermo:mu"), accommodationCoeff_(1.0), Twall_(p.size(), Zero), gamma_(1.4) { refValue() = 0.0; refGrad() = 0.0; valueFraction() = 0.0; } Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ( const smoluchowskiJumpTFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : mixedFvPatchScalarField(ptf, p, iF, mapper), UName_(ptf.UName_), rhoName_(ptf.rhoName_), psiName_(ptf.psiName_), muName_(ptf.muName_), accommodationCoeff_(ptf.accommodationCoeff_), Twall_(ptf.Twall_), gamma_(ptf.gamma_) {} Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : mixedFvPatchScalarField(p, iF), UName_(dict.getOrDefault("U", "U")), rhoName_(dict.getOrDefault("rho", "rho")), psiName_(dict.getOrDefault("psi", "thermo:psi")), muName_(dict.getOrDefault("mu", "thermo:mu")), accommodationCoeff_(dict.get("accommodationCoeff")), Twall_("Twall", dict, p.size()), gamma_(dict.getOrDefault("gamma", 1.4)) { if ( mag(accommodationCoeff_) < SMALL || mag(accommodationCoeff_) > 2.0 ) { FatalIOErrorInFunction(dict) << "unphysical accommodationCoeff specified" << "(0 < accommodationCoeff <= 1)" << endl << exit(FatalIOError); } if (dict.found("value")) { fvPatchField::operator= ( scalarField("value", dict, p.size()) ); } else { fvPatchField::operator=(patchInternalField()); } refValue() = *this; refGrad() = 0.0; valueFraction() = 0.0; } Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ( const smoluchowskiJumpTFvPatchScalarField& ptpsf, const DimensionedField& iF ) : mixedFvPatchScalarField(ptpsf, iF), accommodationCoeff_(ptpsf.accommodationCoeff_), Twall_(ptpsf.Twall_), gamma_(ptpsf.gamma_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Map from self void Foam::smoluchowskiJumpTFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) { mixedFvPatchScalarField::autoMap(m); } // Reverse-map the given fvPatchField onto this fvPatchField void Foam::smoluchowskiJumpTFvPatchScalarField::rmap ( const fvPatchField& ptf, const labelList& addr ) { mixedFvPatchField::rmap(ptf, addr); } // Update the coefficients associated with the patch field void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const fvPatchScalarField& pmu = patch().lookupPatchField(muName_); const fvPatchScalarField& prho = patch().lookupPatchField(rhoName_); const fvPatchField& ppsi = patch().lookupPatchField(psiName_); const fvPatchVectorField& pU = patch().lookupPatchField(UName_); // Prandtl number reading consistent with rhoCentralFoam const dictionary& thermophysicalProperties = db().lookupObject(basicThermo::dictName); dimensionedScalar Pr ( "Pr", dimless, thermophysicalProperties.subDict("mixture").subDict("transport") ); Field C2 ( pmu/prho *sqrt(ppsi*constant::mathematical::piByTwo) *2.0*gamma_/Pr.value()/(gamma_ + 1.0) *(2.0 - accommodationCoeff_)/accommodationCoeff_ ); Field aCoeff(prho.snGrad() - prho/C2); Field KEbyRho(0.5*magSqr(pU)); valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C2)); refValue() = Twall_; refGrad() = 0.0; mixedFvPatchScalarField::updateCoeffs(); } // Write void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); os.writeEntryIfDifferent("U", "U", UName_); os.writeEntryIfDifferent("rho", "rho", rhoName_); os.writeEntryIfDifferent("psi", "thermo:psi", psiName_); os.writeEntryIfDifferent("mu", "thermo:mu", muName_); os.writeEntry("accommodationCoeff", accommodationCoeff_); Twall_.writeEntry("Twall", os); os.writeEntry("gamma", gamma_); writeEntry("value", os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { makePatchTypeField ( fvPatchScalarField, smoluchowskiJumpTFvPatchScalarField ); } // ************************************************************************* //