194 lines
5.5 KiB
C
194 lines
5.5 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | www.openfoam.com
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
|
Copyright (C) 2017-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 <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "pressureInletOutletParSlipVelocityFvPatchVectorField.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
#include "fvPatchFieldMapper.H"
|
|
#include "volFields.H"
|
|
#include "surfaceFields.H"
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::
|
|
pressureInletOutletParSlipVelocityFvPatchVectorField
|
|
(
|
|
const fvPatch& p,
|
|
const DimensionedField<vector, volMesh>& iF
|
|
)
|
|
:
|
|
mixedFvPatchVectorField(p, iF),
|
|
phiName_("phi"),
|
|
rhoName_("rho")
|
|
{
|
|
refValue() = *this;
|
|
refGrad() = Zero;
|
|
valueFraction() = 0.0;
|
|
}
|
|
|
|
|
|
Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::
|
|
pressureInletOutletParSlipVelocityFvPatchVectorField
|
|
(
|
|
const pressureInletOutletParSlipVelocityFvPatchVectorField& ptf,
|
|
const fvPatch& p,
|
|
const DimensionedField<vector, volMesh>& iF,
|
|
const fvPatchFieldMapper& mapper
|
|
)
|
|
:
|
|
mixedFvPatchVectorField(ptf, p, iF, mapper),
|
|
phiName_(ptf.phiName_),
|
|
rhoName_(ptf.rhoName_)
|
|
{}
|
|
|
|
|
|
Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::
|
|
pressureInletOutletParSlipVelocityFvPatchVectorField
|
|
(
|
|
const fvPatch& p,
|
|
const DimensionedField<vector, volMesh>& iF,
|
|
const dictionary& dict
|
|
)
|
|
:
|
|
mixedFvPatchVectorField(p, iF),
|
|
phiName_(dict.getOrDefault<word>("phi", "phi")),
|
|
rhoName_(dict.getOrDefault<word>("rho", "rho"))
|
|
{
|
|
fvPatchFieldBase::readDict(dict);
|
|
this->readValueEntry(dict, IOobjectOption::MUST_READ);
|
|
refValue() = *this;
|
|
refGrad() = Zero;
|
|
valueFraction() = 0.0;
|
|
}
|
|
|
|
|
|
Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::
|
|
pressureInletOutletParSlipVelocityFvPatchVectorField
|
|
(
|
|
const pressureInletOutletParSlipVelocityFvPatchVectorField& pivpvf
|
|
)
|
|
:
|
|
mixedFvPatchVectorField(pivpvf),
|
|
phiName_(pivpvf.phiName_),
|
|
rhoName_(pivpvf.rhoName_)
|
|
{}
|
|
|
|
|
|
Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::
|
|
pressureInletOutletParSlipVelocityFvPatchVectorField
|
|
(
|
|
const pressureInletOutletParSlipVelocityFvPatchVectorField& pivpvf,
|
|
const DimensionedField<vector, volMesh>& iF
|
|
)
|
|
:
|
|
mixedFvPatchVectorField(pivpvf, iF),
|
|
phiName_(pivpvf.phiName_),
|
|
rhoName_(pivpvf.rhoName_)
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::updateCoeffs()
|
|
{
|
|
if (updated())
|
|
{
|
|
return;
|
|
}
|
|
|
|
const auto& phip = patch().lookupPatchField<surfaceScalarField>(phiName_);
|
|
|
|
tmp<vectorField> n = patch().nf();
|
|
const Field<scalar>& magSf = patch().magSf();
|
|
|
|
// Get the tangential component from the internalField (zero-gradient)
|
|
vectorField Ut(patchInternalField());
|
|
Ut -= n()*(Ut & n());
|
|
|
|
if (phip.internalField().dimensions() == dimVolume/dimTime)
|
|
{
|
|
refValue() = Ut + n*phip/magSf;
|
|
}
|
|
else if (phip.internalField().dimensions() == dimMass/dimTime)
|
|
{
|
|
const auto& rhop = patch().lookupPatchField<volScalarField>(rhoName_);
|
|
|
|
refValue() = Ut + n*phip/(rhop*magSf);
|
|
}
|
|
else
|
|
{
|
|
FatalErrorInFunction
|
|
<< "dimensions of phi are not correct" << nl
|
|
<< " on patch " << this->patch().name()
|
|
<< " of field " << this->internalField().name()
|
|
<< " in file " << this->internalField().objectPath()
|
|
<< exit(FatalError);
|
|
}
|
|
|
|
valueFraction() = neg(phip);
|
|
|
|
mixedFvPatchVectorField::updateCoeffs();
|
|
}
|
|
|
|
|
|
void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::write
|
|
(
|
|
Ostream& os
|
|
) const
|
|
{
|
|
fvPatchField<vector>::write(os);
|
|
os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
|
|
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
|
|
fvPatchField<vector>::writeValueEntry(os);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
|
|
|
void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::operator=
|
|
(
|
|
const fvPatchField<vector>& pvf
|
|
)
|
|
{
|
|
fvPatchField<vector>::operator=(pvf);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
makePatchTypeField
|
|
(
|
|
fvPatchVectorField,
|
|
pressureInletOutletParSlipVelocityFvPatchVectorField
|
|
);
|
|
}
|
|
|
|
// ************************************************************************* //
|