From 77b7beb6af2b10d94d890ecf247c98ea16379a8b Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 13 Jul 2017 16:08:30 +0100 Subject: [PATCH] swirlFlowRateInletVelocity: Added support for specifying the origin and axis of rotation --- ...lFlowRateInletVelocityFvPatchVectorField.C | 72 ++++++++++++------- ...lFlowRateInletVelocityFvPatchVectorField.H | 10 ++- 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C index 2576d5ef0e..beca9fea93 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,11 +42,45 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField(p, iF), phiName_("phi"), rhoName_("rho"), + origin_(), + axis_(Zero), flowRate_(), rpm_() {} +Foam::swirlFlowRateInletVelocityFvPatchVectorField:: +swirlFlowRateInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF, dict), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), + origin_ + ( + dict.lookupOrDefault + ( + "origin", + gSum(patch().Cf()*patch().magSf())/gSum(patch().magSf()) + ) + ), + axis_ + ( + dict.lookupOrDefault + ( + "axis", + -gSum(patch().Sf())/gSum(patch().magSf()) + ) + ), + flowRate_(Function1::New("flowRate", dict)), + rpm_(Function1::New("rpm", dict)) +{} + + Foam::swirlFlowRateInletVelocityFvPatchVectorField:: swirlFlowRateInletVelocityFvPatchVectorField ( @@ -59,27 +93,13 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField(ptf, p, iF, mapper), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), + origin_(ptf.origin_), + axis_(ptf.axis_), flowRate_(ptf.flowRate_, false), rpm_(ptf.rpm_, false) {} -Foam::swirlFlowRateInletVelocityFvPatchVectorField:: -swirlFlowRateInletVelocityFvPatchVectorField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchField(p, iF, dict), - phiName_(dict.lookupOrDefault("phi", "phi")), - rhoName_(dict.lookupOrDefault("rho", "rho")), - flowRate_(Function1::New("flowRate", dict)), - rpm_(Function1::New("rpm", dict)) -{} - - Foam::swirlFlowRateInletVelocityFvPatchVectorField:: swirlFlowRateInletVelocityFvPatchVectorField ( @@ -89,6 +109,8 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField(ptf), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), + origin_(ptf.origin_), + axis_(ptf.axis_), flowRate_(ptf.flowRate_, false), rpm_(ptf.rpm_, false) {} @@ -104,6 +126,8 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField(ptf, iF), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), + origin_(ptf.origin_), + axis_(ptf.axis_), flowRate_(ptf.flowRate_, false), rpm_(ptf.rpm_, false) {} @@ -122,18 +146,16 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs() const scalar flowRate = flowRate_->value(t); const scalar rpm = rpm_->value(t); - const scalar totArea = gSum(patch().magSf()); + const scalar totArea = gSum(patch().magSf()); const scalar avgU = -flowRate/totArea; - const vector avgCenter = gSum(patch().Cf()*patch().magSf())/totArea; - const vector avgNormal = gSum(patch().Sf())/totArea; + const vector axisHat = axis_/mag(axis_); // Update angular velocity - convert [rpm] to [rad/s] tmp tangentialVelocity - ( - (rpm*constant::mathematical::pi/30.0) - * (patch().Cf() - avgCenter) ^ avgNormal - ); + ( + axisHat ^ (rpm*constant::mathematical::pi/30.0)*(patch().Cf() - origin_) + ); tmp n = patch().nf(); @@ -175,6 +197,8 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write fvPatchField::write(os); writeEntryIfDifferent(os, "phi", "phi", phiName_); writeEntryIfDifferent(os, "rho", "rho", rhoName_); + os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; + os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; flowRate_->writeData(os); rpm_->writeData(os); writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H index 1bbc14668e..0c21c886ec 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,6 +42,8 @@ Usage Property | Description | Required | Default value phi | flux field name | no | phi rho | density field name | no | rho + origin | origin of rotation | no | patch centre + axis | axis of rotation | no | -(patch normal) flowRate | flow rate profile | yes | rpm | rotational speed profile | yes | \endtable @@ -97,6 +99,12 @@ class swirlFlowRateInletVelocityFvPatchVectorField //- Name of the density field used to normalize the mass flux const word rhoName_; + //- Origin of the rotation + const vector origin_; + + //- Axis of the rotation + const vector axis_; + //- Inlet integral flow rate autoPtr> flowRate_;