From 65fcc20630d521452f91a0bc2f6a48203fc26f32 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 21 Aug 2018 14:37:27 +0100 Subject: [PATCH] Aded swirlInletVelocity boundary condition --- src/finiteVolume/Make/files | 1 + .../swirlInletVelocityFvPatchVectorField.C | 170 ++++++++++++++++ .../swirlInletVelocityFvPatchVectorField.H | 192 ++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index dbc7cacd5..e4d78c78e 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -158,6 +158,7 @@ $(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C $(derivedFvPatchFields)/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/timeVaryingMappedPressureDirectedInletVelocity/timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/pressureInletUniformVelocity/pressureInletUniformVelocityFvPatchVectorField.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..cb736275e --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "swirlInletVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::swirlInletVelocityFvPatchVectorField:: +swirlInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + origin_(vector::zero), + axis_(vector::zero), + axialVelocity_(), + radialVelocity_(), + tangentialVelocity_() +{} + + +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, + 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 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..e75c809b8 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::swirlInletVelocityFvPatchVectorField + +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 + +// ************************************************************************* //