/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2026 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 "mixedFvPatchField.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::mixedFvPatchField::mixedFvPatchField ( const fvPatch& p, const DimensionedField& iF ) : fvPatchField(p, iF), refValue_(p.size()), refGrad_(p.size()), valueFraction_(p.size()) {} template Foam::mixedFvPatchField::mixedFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict, const bool valuesRequired ) : fvPatchField(p, iF, dict, false), refValue_(p.size()), refGrad_(p.size()), valueFraction_(p.size()) { if (valuesRequired) { if (dict.found("refValue")) { refValue_ = Field ( "refValue", iF.dimensions(), dict, p.size() ); } else { FatalIOErrorInFunction(dict) << "Essential entry 'refValue' missing" << exit(FatalIOError); } if (dict.found("refGradient")) { refGrad_ = Field ( "refGradient", iF.dimensions()/dimensions::length, dict, p.size() ); } else { FatalIOErrorInFunction(dict) << "Essential entry 'refGradient' missing" << exit(FatalIOError); } if (dict.found("valueFraction")) { valueFraction_ = Field("valueFraction", units::fraction, dict, p.size()); } else { FatalIOErrorInFunction(dict) << "Essential entry 'valueFraction' missing" << exit(FatalIOError); } evaluate(); } } template Foam::mixedFvPatchField::mixedFvPatchField ( const mixedFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fieldMapper& mapper, const bool mappingRequired ) : fvPatchField(ptf, p, iF, mapper, mappingRequired), refValue_(p.size()), refGrad_(p.size()), valueFraction_(p.size()) { if (mappingRequired) { mapper(refValue_, ptf.refValue_); mapper(refGrad_, ptf.refGrad_); mapper(valueFraction_, ptf.valueFraction_); } } template Foam::mixedFvPatchField::mixedFvPatchField ( const mixedFvPatchField& ptf, const DimensionedField& iF ) : fvPatchField(ptf, iF), refValue_(ptf.refValue_), refGrad_(ptf.refGrad_), valueFraction_(ptf.valueFraction_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::mixedFvPatchField::map ( const fvPatchField& ptf, const fieldMapper& mapper ) { fvPatchField::map(ptf, mapper); const mixedFvPatchField& mptf = refCast>(ptf); mapper(refValue_, mptf.refValue_); mapper(refGrad_, mptf.refGrad_); mapper(valueFraction_, mptf.valueFraction_); } template void Foam::mixedFvPatchField::reset(const fvPatchField& ptf) { fvPatchField::reset(ptf); const mixedFvPatchField& mptf = refCast>(ptf); refValue_.reset(mptf.refValue_); refGrad_.reset(mptf.refGrad_); valueFraction_.reset(mptf.valueFraction_); } template void Foam::mixedFvPatchField::evaluate(const Pstream::commsTypes) { if (!this->updated()) { this->updateCoeffs(); } Field::operator= ( valueFraction_*refValue_ + (1.0 - valueFraction_)* ( patchInternalField() + refGrad_/patch().deltaCoeffs() ) ); fvPatchField::evaluate(); } template Foam::tmp> Foam::mixedFvPatchField::snGrad() const { return valueFraction_ *(refValue_ - patchInternalField())*patch().deltaCoeffs() + (1.0 - valueFraction_)*refGrad_; } template Foam::tmp> Foam::mixedFvPatchField::valueInternalCoeffs ( const tmp& ) const { return Type(pTraits::one)*(1.0 - valueFraction_); } template Foam::tmp> Foam::mixedFvPatchField::valueBoundaryCoeffs ( const tmp& ) const { return valueFraction_*refValue_ + (1.0 - valueFraction_)*refGrad_/patch().deltaCoeffs(); } template Foam::tmp> Foam::mixedFvPatchField::gradientInternalCoeffs() const { return -Type(pTraits::one)*valueFraction_*patch().deltaCoeffs(); } template Foam::tmp> Foam::mixedFvPatchField::gradientBoundaryCoeffs() const { return valueFraction_*patch().deltaCoeffs()*refValue_ + (1.0 - valueFraction_)*refGrad_; } template void Foam::mixedFvPatchField::write(Ostream& os) const { fvPatchField::write(os); writeEntry(os, "refValue", refValue_); writeEntry(os, "refGradient", refGrad_); writeEntry(os, "valueFraction", valueFraction_); writeEntry(os, "value", *this); } // ************************************************************************* //