From c09f9589b70f7ae1bc598fe177fbd91dd6166ba6 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 3 Apr 2009 17:46:26 +0100 Subject: [PATCH 1/2] Added new BC for rotating walls, e.g. wheels. --- src/finiteVolume/Make/files | 1 + .../rotatingWallVelocityFvPatchVectorField.C | 153 ++++++++++++++ .../rotatingWallVelocityFvPatchVectorField.H | 192 ++++++++++++++++++ 3 files changed, 346 insertions(+) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 34a4606e08..99f3085854 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -105,6 +105,7 @@ $(derivedFvPatchFields)/inletOutlet/inletOutletFvPatchFields.C $(derivedFvPatchFields)/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C $(derivedFvPatchFields)/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C $(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields.C $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C $(derivedFvPatchFields)/partialSlip/partialSlipFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C new file mode 100644 index 0000000000..7b5a1dbc45 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 "rotatingWallVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchField(p, iF), + origin_(vector::zero), + axis_(vector::zero), + omega_(0) +{} + + +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_) +{} + + +rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF), + origin_(dict.lookup("origin")), + axis_(dict.lookup("axis")), + omega_(readScalar(dict.lookup("omega"))) +{ + // Evaluate the wall velocity + updateCoeffs(); +} + + +rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField +( + const rotatingWallVelocityFvPatchVectorField& pivpvf +) +: + fixedValueFvPatchField(pivpvf), + origin_(pivpvf.origin_), + axis_(pivpvf.axis_), + omega_(pivpvf.omega_) +{} + + +rotatingWallVelocityFvPatchVectorField::rotatingWallVelocityFvPatchVectorField +( + const rotatingWallVelocityFvPatchVectorField& pivpvf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(pivpvf, iF), + origin_(pivpvf.origin_), + axis_(pivpvf.axis_), + omega_(pivpvf.omega_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void rotatingWallVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Calculate the rotating wall velocity from the specification of the motion + vectorField Up = (-omega_)*((patch().Cf() - origin_) ^ (axis_/mag(axis_))); + + // Remove the component of Up normal to the wall + // just in case it is not exactly circular + vectorField n = patch().nf(); + vectorField::operator=(Up - n*(n & Up)); + + fixedValueFvPatchVectorField::updateCoeffs(); +} + + +void rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; + os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; + os.writeKeyword("omega") << omega_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchVectorField, + rotatingWallVelocityFvPatchVectorField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..5eed0e60ea --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-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 + +Class + Foam::rotatingWallVelocityFvPatchVectorField + +Description + Foam::rotatingWallVelocityFvPatchVectorField + +SourceFiles + rotatingWallVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef rotatingWallVelocityFvPatchVectorField_H +#define rotatingWallVelocityFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class rotatingWallVelocityFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class rotatingWallVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Origin of the rotation + vector origin_; + + //- Axis of the rotation + vector axis_; + + //- Rotational speed + scalar omega_; + + +public: + + //- Runtime type information + TypeName("rotatingWallVelocity"); + + + // Constructors + + //- Construct from patch and internal field + rotatingWallVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + rotatingWallVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given rotatingWallVelocityFvPatchVectorField + // onto a new patch + rotatingWallVelocityFvPatchVectorField + ( + const rotatingWallVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + rotatingWallVelocityFvPatchVectorField + ( + const rotatingWallVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new rotatingWallVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + rotatingWallVelocityFvPatchVectorField + ( + const rotatingWallVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new rotatingWallVelocityFvPatchVectorField(*this, iF) + ); + } + + + + // Member functions + + // Access functions + + //- Return the origin of the rotation + const vector& origin() const + { + return origin_; + } + + //- Return the axis of the rotation + const vector& axis() const + { + return axis_; + } + + //- Return the rotational speed + const scalar& omega() const + { + return omega_; + } + + //- Return non-const access to the origin of the rotation + vector& origin() + { + return origin_; + } + + //- Return non-const access to the axis of the rotation + vector& axis() + { + return axis_; + } + + //- Return non-const access to the rotational speed + scalar& omega() + { + return omega_; + } + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 5b42b30b5d31b9cf95c7e4268bd50fd30f3c970d Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 3 Apr 2009 23:02:46 +0100 Subject: [PATCH 2/2] Use scoped class names to avoid name clashes when both the compressible and incompressible libraries are linked into the same executable. --- .../turbulentHeatFluxTemperatureFvPatchScalarField.H | 2 +- ...urbulentMixingLengthDissipationRateInletFvPatchScalarField.H | 2 +- .../turbulentMixingLengthFrequencyInletFvPatchScalarField.H | 2 +- .../alphatWallFunction/alphatWallFunctionFvPatchScalarField.H | 2 +- .../epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H | 2 +- .../kQRWallFunction/kQRWallFunctionFvPatchField.H | 2 +- .../omegaWallFunction/omegaWallFunctionFvPatchScalarField.H | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H index 4640acc7db..f7581102df 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H @@ -66,7 +66,7 @@ class turbulentHeatFluxTemperatureFvPatchScalarField public: //- Runtime type information - TypeName("turbulentHeatFluxTemperature"); + TypeName("compressible::turbulentHeatFluxTemperature"); // Constructors diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H index dcadbdd8b9..1eb669f06b 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -72,7 +72,7 @@ class turbulentMixingLengthDissipationRateInletFvPatchScalarField public: //- Runtime type information - TypeName("turbulentMixingLengthDissipationRateInlet"); + TypeName("compressible::turbulentMixingLengthDissipationRateInlet"); // Constructors diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H index 90d374a336..45d8d2663c 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H @@ -76,7 +76,7 @@ class turbulentMixingLengthFrequencyInletFvPatchScalarField public: //- Runtime type information - TypeName("turbulentMixingLengthFrequencyInlet"); + TypeName("compressible::turbulentMixingLengthFrequencyInlet"); // Constructors diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H index da71e80a2f..c49a0bc482 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H @@ -66,7 +66,7 @@ class alphatWallFunctionFvPatchScalarField public: //- Runtime type information - TypeName("alphatWallFunction"); + TypeName("compressible::alphatWallFunction"); // Constructors diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H index 42bdeea681..506e9f8c2d 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -87,7 +87,7 @@ class epsilonWallFunctionFvPatchScalarField public: //- Runtime type information - TypeName("epsilonWallFunction"); + TypeName("compressible::epsilonWallFunction"); // Constructors diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H index 05ed2fbcb8..a4a9ddbc30 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H @@ -67,7 +67,7 @@ class kQRWallFunctionFvPatchField public: //- Runtime type information - TypeName("kQRWallFunction"); + TypeName("compressible::kQRWallFunction"); // Constructors diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H index 6dfe7a772b..675d3a16fb 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -85,7 +85,7 @@ class omegaWallFunctionFvPatchScalarField public: //- Runtime type information - TypeName("omegaWallFunction"); + TypeName("compressible::omegaWallFunction"); // Constructors