Skip to content
Snippets Groups Projects
Commit f1a8e651 authored by Henry Weller's avatar Henry Weller Committed by Andrew Heather
Browse files

swirlFlowRateInletVelocity: Added support for specifying the origin and axis of rotation

parent b486e347
Branches
Tags
1 merge request!144Integration openfoam.org
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -42,6 +42,8 @@ swirlFlowRateInletVelocityFvPatchVectorField ...@@ -42,6 +42,8 @@ swirlFlowRateInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(p, iF), fixedValueFvPatchField<vector>(p, iF),
phiName_("phi"), phiName_("phi"),
rhoName_("rho"), rhoName_("rho"),
origin_(),
axis_(Zero),
flowRate_(), flowRate_(),
rpm_() rpm_()
{} {}
...@@ -50,33 +52,51 @@ swirlFlowRateInletVelocityFvPatchVectorField ...@@ -50,33 +52,51 @@ swirlFlowRateInletVelocityFvPatchVectorField
Foam::swirlFlowRateInletVelocityFvPatchVectorField:: Foam::swirlFlowRateInletVelocityFvPatchVectorField::
swirlFlowRateInletVelocityFvPatchVectorField swirlFlowRateInletVelocityFvPatchVectorField
( (
const swirlFlowRateInletVelocityFvPatchVectorField& ptf,
const fvPatch& p, const fvPatch& p,
const DimensionedField<vector, volMesh>& iF, const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper const dictionary& dict
) )
: :
fixedValueFvPatchField<vector>(ptf, p, iF, mapper), fixedValueFvPatchField<vector>(p, iF, dict),
phiName_(ptf.phiName_), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(ptf.rhoName_), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
flowRate_(ptf.flowRate_, false), origin_
rpm_(ptf.rpm_, false) (
dict.lookupOrDefault
(
"origin",
gSum(patch().Cf()*patch().magSf())/gSum(patch().magSf())
)
),
axis_
(
dict.lookupOrDefault
(
"axis",
-gSum(patch().Sf())/gSum(patch().magSf())
)
),
flowRate_(Function1<scalar>::New("flowRate", dict)),
rpm_(Function1<scalar>::New("rpm", dict))
{} {}
Foam::swirlFlowRateInletVelocityFvPatchVectorField:: Foam::swirlFlowRateInletVelocityFvPatchVectorField::
swirlFlowRateInletVelocityFvPatchVectorField swirlFlowRateInletVelocityFvPatchVectorField
( (
const swirlFlowRateInletVelocityFvPatchVectorField& ptf,
const fvPatch& p, const fvPatch& p,
const DimensionedField<vector, volMesh>& iF, const DimensionedField<vector, volMesh>& iF,
const dictionary& dict const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict), fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(ptf.phiName_),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(ptf.rhoName_),
flowRate_(Function1<scalar>::New("flowRate", dict)), origin_(ptf.origin_),
rpm_(Function1<scalar>::New("rpm", dict)) axis_(ptf.axis_),
flowRate_(ptf.flowRate_, false),
rpm_(ptf.rpm_, false)
{} {}
...@@ -89,6 +109,8 @@ swirlFlowRateInletVelocityFvPatchVectorField ...@@ -89,6 +109,8 @@ swirlFlowRateInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf), fixedValueFvPatchField<vector>(ptf),
phiName_(ptf.phiName_), phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
origin_(ptf.origin_),
axis_(ptf.axis_),
flowRate_(ptf.flowRate_, false), flowRate_(ptf.flowRate_, false),
rpm_(ptf.rpm_, false) rpm_(ptf.rpm_, false)
{} {}
...@@ -104,6 +126,8 @@ swirlFlowRateInletVelocityFvPatchVectorField ...@@ -104,6 +126,8 @@ swirlFlowRateInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(ptf, iF), fixedValueFvPatchField<vector>(ptf, iF),
phiName_(ptf.phiName_), phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
origin_(ptf.origin_),
axis_(ptf.axis_),
flowRate_(ptf.flowRate_, false), flowRate_(ptf.flowRate_, false),
rpm_(ptf.rpm_, false) rpm_(ptf.rpm_, false)
{} {}
...@@ -122,18 +146,16 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs() ...@@ -122,18 +146,16 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
const scalar flowRate = flowRate_->value(t); const scalar flowRate = flowRate_->value(t);
const scalar rpm = rpm_->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 scalar avgU = -flowRate/totArea;
const vector avgCenter = gSum(patch().Cf()*patch().magSf())/totArea; const vector axisHat = axis_/mag(axis_);
const vector avgNormal = gSum(patch().Sf())/totArea;
// Update angular velocity - convert [rpm] to [rad/s] // Update angular velocity - convert [rpm] to [rad/s]
tmp<vectorField> tangentialVelocity tmp<vectorField> tangentialVelocity
( (
(rpm*constant::mathematical::pi/30.0) axisHat ^ (rpm*constant::mathematical::pi/30.0)*(patch().Cf() - origin_)
* (patch().Cf() - avgCenter) ^ avgNormal );
);
tmp<vectorField> n = patch().nf(); tmp<vectorField> n = patch().nf();
...@@ -175,6 +197,8 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write ...@@ -175,6 +197,8 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write
fvPatchField<vector>::write(os); fvPatchField<vector>::write(os);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
flowRate_->writeData(os); flowRate_->writeData(os);
rpm_->writeData(os); rpm_->writeData(os);
writeEntry("value", os); writeEntry("value", os);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -42,6 +42,8 @@ Usage ...@@ -42,6 +42,8 @@ Usage
Property | Description | Required | Default value Property | Description | Required | Default value
phi | flux field name | no | phi phi | flux field name | no | phi
rho | density field name | no | rho 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 | flowRate | flow rate profile | yes |
rpm | rotational speed profile | yes | rpm | rotational speed profile | yes |
\endtable \endtable
...@@ -97,6 +99,12 @@ class swirlFlowRateInletVelocityFvPatchVectorField ...@@ -97,6 +99,12 @@ class swirlFlowRateInletVelocityFvPatchVectorField
//- Name of the density field used to normalize the mass flux //- Name of the density field used to normalize the mass flux
const word rhoName_; const word rhoName_;
//- Origin of the rotation
const vector origin_;
//- Axis of the rotation
const vector axis_;
//- Inlet integral flow rate //- Inlet integral flow rate
autoPtr<Function1<scalar>> flowRate_; autoPtr<Function1<scalar>> flowRate_;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment