/*---------------------------------------------------------------------------*\ ========= | \\ / 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 "fixedGradientFvPatchField.H" #include "dictionary.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::fixedGradientFvPatchField::fixedGradientFvPatchField ( const fvPatch& p, const DimensionedField& iF ) : fvPatchField(p, iF), gradient_(p.size()) {} template Foam::fixedGradientFvPatchField::fixedGradientFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict, const bool gradientRequired ) : fvPatchField(p, iF, dict, false), gradient_(p.size()) { if (gradientRequired) { if (dict.found("gradient")) { gradient_ = Field ( "gradient", iF.dimensions()/dimensions::length, dict, p.size() ); evaluate(); } else { FatalIOErrorInFunction(dict) << "Essential entry 'gradient' missing" << exit(FatalIOError); } } } template Foam::fixedGradientFvPatchField::fixedGradientFvPatchField ( const fixedGradientFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fieldMapper& mapper, const bool mappingRequired ) : fvPatchField(ptf, p, iF, mapper, mappingRequired), gradient_(p.size()) { if (mappingRequired) { mapper(gradient_, ptf.gradient_); } } template Foam::fixedGradientFvPatchField::fixedGradientFvPatchField ( const fixedGradientFvPatchField& ptf, const DimensionedField& iF ) : fvPatchField(ptf, iF), gradient_(ptf.gradient_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::fixedGradientFvPatchField::map ( const fvPatchField& ptf, const fieldMapper& mapper ) { fvPatchField::map(ptf, mapper); const fixedGradientFvPatchField& fgptf = refCast>(ptf); mapper(gradient_, fgptf.gradient_); } template void Foam::fixedGradientFvPatchField::reset ( const fvPatchField& ptf ) { fvPatchField::reset(ptf); const fixedGradientFvPatchField& fgptf = refCast>(ptf); gradient_.reset(fgptf.gradient_); } template void Foam::fixedGradientFvPatchField::evaluate(const Pstream::commsTypes) { if (!this->updated()) { this->updateCoeffs(); } Field::operator= ( patchInternalField() + gradient_/patch().deltaCoeffs() ); fvPatchField::evaluate(); } template Foam::tmp> Foam::fixedGradientFvPatchField::valueInternalCoeffs ( const tmp& ) const { return tmp>(new Field(this->size(), pTraits::one)); } template Foam::tmp> Foam::fixedGradientFvPatchField::valueBoundaryCoeffs ( const tmp& ) const { return gradient()/patch().deltaCoeffs(); } template Foam::tmp> Foam::fixedGradientFvPatchField::gradientInternalCoeffs() const { return tmp> ( new Field(this->size(), Zero) ); } template Foam::tmp> Foam::fixedGradientFvPatchField::gradientBoundaryCoeffs() const { return gradient(); } template void Foam::fixedGradientFvPatchField::write(Ostream& os) const { fvPatchField::write(os); writeEntry(os, "gradient", gradient_); } // ************************************************************************* //