/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-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 "waveInletOutletFvPatchField.H"
#include "addToRunTimeSelectionTable.H"
#include "fieldMapper.H"
#include "levelSet.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "waveSuperposition.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::waveInletOutletFvPatchField::waveInletOutletFvPatchField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
mixedFvPatchField(p, iF, dict, false),
inletValueAbove_
(
Function1::New
(
"inletValueAbove",
this->time().userUnits(),
iF.dimensions(),
dict
)
),
inletValueBelow_
(
Function1::New
(
"inletValueBelow",
this->time().userUnits(),
iF.dimensions(),
dict
)
),
phiName_(dict.lookupOrDefault("phi", "phi"))
{
if (dict.found("value"))
{
fvPatchField::operator=
(
Field("value", iF.dimensions(), dict, p.size())
);
}
else
{
fvPatchField::operator=(this->patchInternalField());
}
this->refValue() = Zero;
this->refGrad() = Zero;
this->valueFraction() = Zero;
}
template
Foam::waveInletOutletFvPatchField::waveInletOutletFvPatchField
(
const waveInletOutletFvPatchField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fieldMapper& mapper
)
:
mixedFvPatchField(ptf, p, iF, mapper),
inletValueAbove_(ptf.inletValueAbove_, false),
inletValueBelow_(ptf.inletValueBelow_, false),
phiName_(ptf.phiName_)
{}
template
Foam::waveInletOutletFvPatchField::waveInletOutletFvPatchField
(
const waveInletOutletFvPatchField& ptf,
const DimensionedField& iF
)
:
mixedFvPatchField(ptf, iF),
inletValueAbove_(ptf.inletValueAbove_, false),
inletValueBelow_(ptf.inletValueBelow_, false),
phiName_(ptf.phiName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
void Foam::waveInletOutletFvPatchField::updateCoeffs()
{
if (this->updated())
{
return;
}
const Field& phip =
this->patch().template lookupPatchField
(
phiName_
);
const scalar t = this->time().value();
const waveSuperposition& waves = waveSuperposition::New(this->db());
const pointField& localPoints = this->patch().poly().localPoints();
this->refValue() =
levelSetAverage
(
this->patch(),
waves.height(t, this->patch().Cf()),
waves.height(t, localPoints),
Field(this->size(), inletValueAbove_->value(t)),
Field(localPoints.size(), inletValueAbove_->value(t)),
Field(this->size(), inletValueBelow_->value(t)),
Field(localPoints.size(), inletValueBelow_->value(t))
);
this->valueFraction() = 1 - pos0(phip);
mixedFvPatchField::updateCoeffs();
}
template
void Foam::waveInletOutletFvPatchField::write(Ostream& os) const
{
fvPatchField::write(os);
writeEntry
(
os,
this->time().userUnits(),
this->internalField().dimensions(),
inletValueAbove_()
);
writeEntry
(
os,
this->time().userUnits(),
this->internalField().dimensions(),
inletValueBelow_()
);
writeEntryIfDifferent(os, "phi", "phi", phiName_);
}
// ************************************************************************* //