/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-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 "fixedMeanFvPatchField.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::fixedMeanFvPatchField::fixedMeanFvPatchField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
fixedValueFvPatchField
(
p,
iF,
dict,
!p.time().completeCase()
),
meanValue_
(
Function1::New
(
"meanValue",
time().userUnits(),
iF.dimensions(),
dict
)
)
{
if (p.time().completeCase())
{
this->evaluate();
}
}
template
Foam::fixedMeanFvPatchField::fixedMeanFvPatchField
(
const fixedMeanFvPatchField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fieldMapper& mapper
)
:
fixedValueFvPatchField(ptf, p, iF, mapper),
meanValue_(ptf.meanValue_, false)
{}
template
Foam::fixedMeanFvPatchField::fixedMeanFvPatchField
(
const fixedMeanFvPatchField& ptf,
const DimensionedField& iF
)
:
fixedValueFvPatchField(ptf, iF),
meanValue_(ptf.meanValue_, false)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
void Foam::fixedMeanFvPatchField::updateCoeffs()
{
if (this->updated())
{
return;
}
Type meanValue = meanValue_->value(time().value());
Field newValues(patchInternalField());
Type meanValuePsi =
gSum(patch().magSf()*newValues)
/gSum(patch().magSf());
if (mag(meanValue) > small && mag(meanValuePsi)/mag(meanValue) > 0.5)
{
newValues *= mag(meanValue)/mag(meanValuePsi);
}
else
{
newValues += (meanValue - meanValuePsi);
}
this->operator==(newValues);
fixedValueFvPatchField::updateCoeffs();
}
template
void Foam::fixedMeanFvPatchField::write(Ostream& os) const
{
fvPatchField::write(os);
writeEntry
(
os,
time().userUnits(),
internalField().dimensions(),
meanValue_()
);
writeEntry(os, "value", *this);
}
// ************************************************************************* //