/*---------------------------------------------------------------------------*\
========= |
\\ / 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) 2021 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 "rotatingWallVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField& iF
)
:
fixedValueFvPatchField(p, iF),
origin_(Zero),
axis_(Zero),
omega_(nullptr)
{}
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField& iF,
const dictionary& dict
)
:
fixedValueFvPatchField(p, iF, dict, IOobjectOption::NO_READ),
origin_(dict.get("origin")),
axis_(dict.get("axis")),
omega_(Function1::New("omega", dict, &db()))
{
if (!this->readValueEntry(dict))
{
// Evaluate the wall velocity
updateCoeffs();
}
}
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const rotatingWallVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField(ptf, p, iF, mapper),
origin_(ptf.origin_),
axis_(ptf.axis_),
omega_(ptf.omega_.clone())
{}
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const rotatingWallVelocityFvPatchVectorField& rwvpvf
)
:
fixedValueFvPatchField(rwvpvf),
origin_(rwvpvf.origin_),
axis_(rwvpvf.axis_),
omega_(rwvpvf.omega_.clone())
{}
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const rotatingWallVelocityFvPatchVectorField& rwvpvf,
const DimensionedField& iF
)
:
fixedValueFvPatchField(rwvpvf, iF),
origin_(rwvpvf.origin_),
axis_(rwvpvf.axis_),
omega_(rwvpvf.omega_.clone())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotatingWallVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
const scalar t = this->db().time().timeOutputValue();
scalar om = omega_->value(t);
// Calculate the rotating wall velocity from the specification of the motion
const vectorField Up
(
(-om)*((patch().Cf() - origin_) ^ (axis_/mag(axis_)))
);
// Remove the component of Up normal to the wall
// just in case it is not exactly circular
const vectorField n(patch().nf());
vectorField::operator=(Up - n*(n & Up));
fixedValueFvPatchVectorField::updateCoeffs();
}
void Foam::rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField::write(os);
os.writeEntry("origin", origin_);
os.writeEntry("axis", axis_);
omega_->writeData(os);
fvPatchField::writeValueEntry(os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
rotatingWallVelocityFvPatchVectorField
);
}
// ************************************************************************* //