diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 593833047..c92022046 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -160,6 +160,7 @@ $(derivedFvPatchFields)/mappedFixedPushedInternalValue/mappedFixedPushedInternal $(derivedFvPatchFields)/mappedFixedValue/mappedFixedValueFvPatchFields.C $(derivedFvPatchFields)/mappedFlowRate/mappedFlowRateFvPatchVectorField.C $(derivedFvPatchFields)/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C +$(derivedFvPatchFields)/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/noSlip/noSlipFvPatchVectorField.C $(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C @@ -181,6 +182,7 @@ $(derivedFvPatchFields)/slip/slipFvPatchFields.C $(derivedFvPatchFields)/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C $(derivedFvPatchFields)/surfaceNormalFixedValue/surfaceNormalFixedValueFvPatchVectorField.C $(derivedFvPatchFields)/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/syringePressure/syringePressureFvPatchScalarField.C $(derivedFvPatchFields)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchFields.C $(derivedFvPatchFields)/totalPressure/totalPressureFvPatchScalarField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C new file mode 100644 index 000000000..007c4ad93 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ 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 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 "swirlInletVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::swirlInletVelocityFvPatchVectorField:: +swirlInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + origin_(Zero), + axis_(Zero), + axialVelocity_(), + radialVelocity_(), + tangentialVelocity_() +{} + + +Foam::swirlInletVelocityFvPatchVectorField:: +swirlInletVelocityFvPatchVectorField +( + const swirlInletVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(ptf, p, iF, mapper), + origin_(ptf.origin_), + axis_(ptf.axis_), + axialVelocity_(ptf.axialVelocity_, false), + radialVelocity_(ptf.radialVelocity_, false), + tangentialVelocity_(ptf.tangentialVelocity_, false) +{} + + +Foam::swirlInletVelocityFvPatchVectorField:: +swirlInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF, dict), + origin_(dict.lookup("origin")), + axis_(dict.lookup("axis")), + axialVelocity_(Function1::New("axialVelocity", dict)), + radialVelocity_(Function1::New("radialVelocity", dict)), + tangentialVelocity_(Function1::New("tangentialVelocity", dict)) +{} + + +Foam::swirlInletVelocityFvPatchVectorField:: +swirlInletVelocityFvPatchVectorField +( + const swirlInletVelocityFvPatchVectorField& ptf +) +: + fixedValueFvPatchField(ptf), + origin_(ptf.origin_), + axis_(ptf.axis_), + axialVelocity_(ptf.axialVelocity_, false), + radialVelocity_(ptf.radialVelocity_, false), + tangentialVelocity_(ptf.tangentialVelocity_, false) +{} + + +Foam::swirlInletVelocityFvPatchVectorField:: +swirlInletVelocityFvPatchVectorField +( + const swirlInletVelocityFvPatchVectorField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(ptf, iF), + origin_(ptf.origin_), + axis_(ptf.axis_), + axialVelocity_(ptf.axialVelocity_, false), + radialVelocity_(ptf.radialVelocity_, false), + tangentialVelocity_(ptf.tangentialVelocity_, false) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::swirlInletVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const vector axisHat = axis_/mag(axis_); + + // Radius vector in plane of rotation + vectorField r(patch().Cf() - origin_); + r -= (axisHat & r)*axisHat; + const scalarField magr(mag(r)); + const vectorField rHat(r/magr); + + const scalarField axialVelocity = axialVelocity_->value(magr); + const scalarField radialVelocity = radialVelocity_->value(magr); + const scalarField tangentialVelocity = tangentialVelocity_->value(magr); + + operator== + ( + axialVelocity*axisHat + + radialVelocity*rHat + + tangentialVelocity*(axisHat ^ rHat) + ); + + fixedValueFvPatchField::updateCoeffs(); +} + + +void Foam::swirlInletVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchField::write(os); + os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; + os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + axialVelocity_->writeData(os); + radialVelocity_->writeData(os); + tangentialVelocity_->writeData(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + swirlInletVelocityFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H new file mode 100644 index 000000000..d56fcc8f2 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ 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 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 . + +Class + Foam::swirlInletVelocityFvPatchVectorField + +Group + grpInletBoundaryConditions + +Description + This boundary condition describes an inlet vector boundary condition in + swirl co-ordinates given a central axis, central point, axial, radial and + tangential velocity profiles. + +Usage + \table + Property | Description | Required | Default value + axis | Axis of rotation | yes | + origin |Origin of rotation | yes | + axialVelocity | Axial velocity profile [m/s] | yes | + radialVelocity | Radial velocity profile [m/s] | yes | + tangentialVelocity | tangential velocity profile [m/s] | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + + { + type swirlInletVelocity; + axis (0 0 1); + origin (0 0 0); + axialVelocity constant 30; + radialVelocity constant 10; + tangentialVelocity constant 100; + } + \endverbatim + +Note + The \c axialVelocity, \c radialVelocity and \c tangentialVelocity entries + are Function1 types, able to describe time varying functions. The example + above gives the usage for supplying constant values. + +See also + Foam::fixedValueFvPatchField + Foam::Function1Types + +SourceFiles + swirlInletVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef swirlInletVelocityFvPatchVectorField_H +#define swirlInletVelocityFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" +#include "Function1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class swirlInletVelocityFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class swirlInletVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Origin of the rotation + const vector origin_; + + //- Axis of the rotation + const vector axis_; + + //- Axial velocity + autoPtr> axialVelocity_; + + //- Radial velocity + autoPtr> radialVelocity_; + + //- Tangential velocity + autoPtr> tangentialVelocity_; + + +public: + + //- Runtime type information + TypeName("swirlInletVelocity"); + + + // Constructors + + //- Construct from patch and internal field + swirlInletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + swirlInletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // flowRateInletVelocityFvPatchVectorField + // onto a new patch + swirlInletVelocityFvPatchVectorField + ( + const swirlInletVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + swirlInletVelocityFvPatchVectorField + ( + const swirlInletVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new swirlInletVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + swirlInletVelocityFvPatchVectorField + ( + const swirlInletVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new swirlInletVelocityFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //