/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2020-2025 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 "fixedMeanOutletInletFvPatchField.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::fixedMeanOutletInletFvPatchField::fixedMeanOutletInletFvPatchField
(
const fvPatch& p,
const DimensionedField& iF
)
:
outletInletFvPatchField(p, iF),
meanValue_()
{}
template
Foam::fixedMeanOutletInletFvPatchField::fixedMeanOutletInletFvPatchField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
outletInletFvPatchField(p, iF),
meanValue_(Function1::New("meanValue", dict, &this->db()))
{
this->phiName_ = dict.getOrDefault("phi", "phi");
this->readValueEntry(dict, IOobjectOption::MUST_READ);
this->refValue() = *this;
this->refGrad() = Zero;
this->valueFraction() = 0.0;
}
template
Foam::fixedMeanOutletInletFvPatchField::fixedMeanOutletInletFvPatchField
(
const fixedMeanOutletInletFvPatchField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fvPatchFieldMapper& mapper
)
:
outletInletFvPatchField(ptf, p, iF, mapper),
meanValue_(ptf.meanValue_.clone())
{}
template
Foam::fixedMeanOutletInletFvPatchField::fixedMeanOutletInletFvPatchField
(
const fixedMeanOutletInletFvPatchField& ptf
)
:
outletInletFvPatchField(ptf),
meanValue_(ptf.meanValue_.clone())
{}
template
Foam::fixedMeanOutletInletFvPatchField::fixedMeanOutletInletFvPatchField
(
const fixedMeanOutletInletFvPatchField& ptf,
const DimensionedField& iF
)
:
outletInletFvPatchField(ptf, iF),
meanValue_(ptf.meanValue_.clone())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
void Foam::fixedMeanOutletInletFvPatchField::updateCoeffs()
{
if (this->updated())
{
return;
}
const scalar t = this->db().time().timeOutputValue();
Type meanValue = meanValue_->value(t);
Field newValues(this->patchInternalField());
Type meanValuePsi = gWeightedAverage(this->patch().magSf(), newValues);
if (mag(meanValue) > SMALL && mag(meanValuePsi) > 0.5*mag(meanValue))
{
newValues *= mag(meanValue)/mag(meanValuePsi);
}
else
{
newValues += (meanValue - meanValuePsi);
}
this->refValue() = newValues;
outletInletFvPatchField::updateCoeffs();
}
template
void Foam::fixedMeanOutletInletFvPatchField::write(Ostream& os) const
{
fvPatchField::write(os);
meanValue_->writeData(os);
fvPatchField::writeValueEntry(os);
}
// ************************************************************************* //