Time-Dependent Boundary Conditions in OpenFOAM
- 1. #ifndef rotatingWallVelocityFvPatchVectorField_H
#define rotatingWallVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*¥
Class rotatingWallVelocityFvPatchVectorField Declaration
¥*---------------------------------------------------------------------------*/
class rotatingWallVelocityFvPatchVectorField
:
public fixedValueFvPatchVectorField
{
// Private data
//- Origin of the rotation
vector origin_;
//- Axis of the rotation
vector axis_;
//- Rotational speed
autoPtr<DataEntry<scalar> > omega_;
public:
In header file (.H)
• Including “DataEntry.H” file
• Defining time-varying parameter
In source file (.C)
• Reading the parameter
• Calculating the parameter value
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::rotatingWallVelocityFvPatchVectorField::
rotatingWallVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchField<vector>(p, iF),
origin_(dict.lookup("origin")),
axis_(dict.lookup("axis")),
omega_(DataEntry<scalar>::New("omega", dict))
{
if (dict.found("value"))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
}
else
{
// Evaluate the wall velocity
updateCoeffs();
}
}
// * * * * * * * * * * * * * * * 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();
}
Time-Dependent BCs
in OpenFOAM
BCs with time-varying options
Source Code (rotatingWallVelocity)
Ref.: Release Note Version 2.1.0
uniformFixedValue
General fixed value condition with time-
varying value (uniformValue)
rotatingWallVelocity
Velocity condition for a rotating boundary
with time-varying angular velocity [rad/s]
(omega)
flowRateInletVelocity
Inlet velocity condition with time-varying
flow-rate (volumetricFlowRate or
massFlowRate)
a good many others
Examples of BC Specification
inlet
{
type uniformFixedValue;
uniformValue table
(
(0 (10 0 0))
(0.1 (12 0 0))
(0.2 (12 0 0))
(0.3 (11 0 0))
);
}
Ux [m/s]
Time [s]
rotatingWallVelocityFvPatchVectorField.H
rotatingWallVelocityFvPatchVectorField.C
1
2
1
2
3
4
3
4