/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 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 "pressureInletVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pressureInletVelocityFvPatchVectorField::
pressureInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField& iF
)
:
fixedValueFvPatchVectorField(p, iF),
phiName_("phi"),
rhoName_("rho")
{}
Foam::pressureInletVelocityFvPatchVectorField::
pressureInletVelocityFvPatchVectorField
(
const pressureInletVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_)
{}
Foam::pressureInletVelocityFvPatchVectorField::
pressureInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF, dict),
phiName_(dict.getOrDefault("phi", "phi")),
rhoName_(dict.getOrDefault("rho", "rho"))
{}
Foam::pressureInletVelocityFvPatchVectorField::
pressureInletVelocityFvPatchVectorField
(
const pressureInletVelocityFvPatchVectorField& pivpvf
)
:
fixedValueFvPatchVectorField(pivpvf),
phiName_(pivpvf.phiName_),
rhoName_(pivpvf.rhoName_)
{}
Foam::pressureInletVelocityFvPatchVectorField::
pressureInletVelocityFvPatchVectorField
(
const pressureInletVelocityFvPatchVectorField& pivpvf,
const DimensionedField& iF
)
:
fixedValueFvPatchVectorField(pivpvf, iF),
phiName_(pivpvf.phiName_),
rhoName_(pivpvf.rhoName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::pressureInletVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
const auto& phip = patch().lookupPatchField(phiName_);
tmp n = patch().nf();
const Field& magS = patch().magSf();
if (phip.internalField().dimensions() == dimVolume/dimTime)
{
operator==(n*phip/magS);
}
else if (phip.internalField().dimensions() == dimMass/dimTime)
{
const auto& rhop = patch().lookupPatchField(rhoName_);
operator==(n*phip/(rhop*magS));
}
else
{
FatalErrorInFunction
<< "dimensions of phi are not correct"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< exit(FatalError);
}
fixedValueFvPatchVectorField::updateCoeffs();
}
void Foam::pressureInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField::write(os);
os.writeEntryIfDifferent("phi", "phi", phiName_);
os.writeEntryIfDifferent("rho", "rho", rhoName_);
fvPatchField::writeValueEntry(os);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::pressureInletVelocityFvPatchVectorField::operator=
(
const fvPatchField& pvf
)
{
fvPatchField::operator=(patch().nf()*(patch().nf() & pvf));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
pressureInletVelocityFvPatchVectorField
);
}
// ************************************************************************* //