mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
201 lines
5.7 KiB
C
201 lines
5.7 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2006-2009 OpenCFD Ltd.
|
|
\\/ 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 2 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, write to the Free Software Foundation,
|
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "swirlMassFlowRateInletVelocityFvPatchVectorField.H"
|
|
#include "volFields.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
#include "fvPatchFieldMapper.H"
|
|
#include "surfaceFields.H"
|
|
#include "mathematicalConstants.H"
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField
|
|
(
|
|
const fvPatch& p,
|
|
const DimensionedField<vector, volMesh>& iF
|
|
)
|
|
:
|
|
fixedValueFvPatchField<vector>(p, iF),
|
|
flowRate_(0),
|
|
phiName_("phi"),
|
|
rhoName_("rho"),
|
|
rpm_(0)
|
|
{}
|
|
|
|
|
|
Foam::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField
|
|
(
|
|
const swirlMassFlowRateInletVelocityFvPatchVectorField& ptf,
|
|
const fvPatch& p,
|
|
const DimensionedField<vector, volMesh>& iF,
|
|
const fvPatchFieldMapper& mapper
|
|
)
|
|
:
|
|
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
|
|
flowRate_(ptf.flowRate_),
|
|
phiName_(ptf.phiName_),
|
|
rhoName_(ptf.rhoName_)
|
|
{}
|
|
|
|
|
|
Foam::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField
|
|
(
|
|
const fvPatch& p,
|
|
const DimensionedField<vector, volMesh>& iF,
|
|
const dictionary& dict
|
|
)
|
|
:
|
|
fixedValueFvPatchField<vector>(p, iF, dict),
|
|
flowRate_(readScalar(dict.lookup("flowRate"))),
|
|
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
|
|
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
|
|
rpm_(readScalar(dict.lookup("rpm")))
|
|
{}
|
|
|
|
|
|
Foam::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField
|
|
(
|
|
const swirlMassFlowRateInletVelocityFvPatchVectorField& ptf
|
|
)
|
|
:
|
|
fixedValueFvPatchField<vector>(ptf),
|
|
flowRate_(ptf.flowRate_),
|
|
phiName_(ptf.phiName_),
|
|
rhoName_(ptf.rhoName_),
|
|
rpm_(ptf.rpm_)
|
|
{}
|
|
|
|
|
|
Foam::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField::
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField
|
|
(
|
|
const swirlMassFlowRateInletVelocityFvPatchVectorField& ptf,
|
|
const DimensionedField<vector, volMesh>& iF
|
|
)
|
|
:
|
|
fixedValueFvPatchField<vector>(ptf, iF),
|
|
flowRate_(ptf.flowRate_),
|
|
phiName_(ptf.phiName_),
|
|
rhoName_(ptf.rhoName_),
|
|
rpm_(ptf.rpm_)
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
|
{
|
|
if (updated())
|
|
{
|
|
return;
|
|
}
|
|
|
|
scalar totArea = gSum(patch().magSf());
|
|
// a simpler way of doing this would be nice
|
|
scalar avgU = -flowRate_/totArea;
|
|
|
|
vector center = gSum(patch().Cf()*patch().magSf())/totArea;
|
|
vector normal = gSum(patch().nf()*patch().magSf())/totArea;
|
|
|
|
vectorField tangVelo =
|
|
(rpm_*constant::mathematical::pi/30.0)
|
|
*(patch().Cf() - center) ^ normal;
|
|
|
|
vectorField n = patch().nf();
|
|
|
|
const surfaceScalarField& phi =
|
|
db().lookupObject<surfaceScalarField>(phiName_);
|
|
|
|
if (phi.dimensions() == dimVelocity*dimArea)
|
|
{
|
|
// volumetric flow-rate
|
|
operator==(tangVelo + n*avgU);
|
|
}
|
|
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
|
|
{
|
|
const fvPatchField<scalar>& rhop =
|
|
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
|
|
|
// mass flow-rate
|
|
operator==(tangVelo + n*avgU/rhop);
|
|
}
|
|
else
|
|
{
|
|
FatalErrorIn
|
|
(
|
|
"swirlMassFlowRateInletVelocityFvPatchVectorField::updateCoeffs()"
|
|
) << "dimensions of " << phiName_ << " are incorrect" << nl
|
|
<< " on patch " << this->patch().name()
|
|
<< " of field " << this->dimensionedInternalField().name()
|
|
<< " in file " << this->dimensionedInternalField().objectPath()
|
|
<< nl << exit(FatalError);
|
|
}
|
|
|
|
fixedValueFvPatchField<vector>::updateCoeffs();
|
|
}
|
|
|
|
|
|
void Foam::swirlMassFlowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
|
|
{
|
|
fvPatchField<vector>::write(os);
|
|
os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
|
|
if (phiName_ != "phi")
|
|
{
|
|
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
|
|
}
|
|
if (rhoName_ != "rho")
|
|
{
|
|
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
|
|
}
|
|
os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << nl;
|
|
writeEntry("value", os);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
makePatchTypeField
|
|
(
|
|
fvPatchVectorField,
|
|
swirlMassFlowRateInletVelocityFvPatchVectorField
|
|
);
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|