Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright held by original author
- \\/ 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 "turbulentVolumeFlowVelocityFvPatchVectorField.H"
- #include "addToRunTimeSelectionTable.H"
- #include "fvPatchFieldMapper.H"
- #include "volFields.H"
- #include "surfaceFields.H"
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- namespace Foam
- {
- // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
- turbulentVolumeFlowVelocityFvPatchVectorField::turbulentVolumeFlowVelocityFvPatchVectorField
- (
- const fvPatch& p,
- const DimensionedField<vector, volMesh>& iF
- )
- :
- fixedValueFvPatchVectorField(p, iF),
- volumeFlowRate_(0),
- n_(1, 0, 0),
- y_(0, 1, 0)
- {}
- turbulentVolumeFlowVelocityFvPatchVectorField::turbulentVolumeFlowVelocityFvPatchVectorField
- (
- const turbulentVolumeFlowVelocityFvPatchVectorField& ptf,
- const fvPatch& p,
- const DimensionedField<vector, volMesh>& iF,
- const fvPatchFieldMapper& mapper
- )
- :
- fixedValueFvPatchVectorField(ptf, p, iF, mapper),
- volumeFlowRate_(ptf.volumeFlowRate_),
- n_(ptf.n_),
- y_(ptf.y_)
- {}
- turbulentVolumeFlowVelocityFvPatchVectorField::turbulentVolumeFlowVelocityFvPatchVectorField
- (
- const fvPatch& p,
- const DimensionedField<vector, volMesh>& iF,
- const dictionary& dict
- )
- :
- fixedValueFvPatchVectorField(p, iF),
- volumeFlowRate_(readScalar(dict.lookup("volumeFlowRate"))),
- n_(dict.lookup("n")),
- y_(dict.lookup("y"))
- {
- if (mag(n_) < SMALL || mag(y_) < SMALL)
- {
- FatalErrorIn("turbulentVolumeFlowVelocityFvPatchVectorField(dict)")
- << "n or y given with zero size not correct"
- << abort(FatalError);
- }
- n_ /= mag(n_);
- y_ /= mag(y_);
- evaluate();
- }
- turbulentVolumeFlowVelocityFvPatchVectorField::turbulentVolumeFlowVelocityFvPatchVectorField
- (
- const turbulentVolumeFlowVelocityFvPatchVectorField& fcvpvf,
- const DimensionedField<vector, volMesh>& iF
- )
- :
- fixedValueFvPatchVectorField(fcvpvf, iF),
- volumeFlowRate_(fcvpvf.volumeFlowRate_),
- n_(fcvpvf.n_),
- y_(fcvpvf.y_)
- {}
- // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
- void turbulentVolumeFlowVelocityFvPatchVectorField::updateCoeffs()
- {
- if (updated())
- {
- return;
- }
- // Get range and orientation
- boundBox bb(patch().patch().localPoints(), true);
- vector ctr = 0.5*(bb.max() + bb.min());
- const vectorField& c = patch().Cf();
- // Calculate mean flow velocity and peak velocity
- double dHid = mag(bb.max() - bb.min());
- double rHid = 0.5*dHid;
- double nPowerInverse = 1.0/nPower_;
- double meanU = volumeFlowRate_/(constant::mathematical::pi*pow(rHid,2.0));
- double peakU = meanU*(((nPower_ + 1.0)*(2.0*nPower_ + 1.0))/(2.0*pow(nPower_,2.0)));
- // Calculate local 1-D coordinate for the n-power law profile
- scalarField coord = 2*((c - ctr) & y_)/((bb.max() - bb.min()) & y_);
- vectorField::operator=(n_*peakU*pow((1.0 - coord),nPowerInverse));
- }
- // Write
- void turbulentVolumeFlowVelocityFvPatchVectorField::write(Ostream& os) const
- {
- fvPatchVectorField::write(os);
- os.writeKeyword("volumeFlowRate")
- << volumeFlowRate_ << token::END_STATEMENT << nl;
- os.writeKeyword("n")
- << y_ << token::END_STATEMENT << nl;
- os.writeKeyword("nPower")
- << n_ << token::END_STATEMENT << nl;
- os.writeKeyword("y")
- << y_ << token::END_STATEMENT << nl;
- writeEntry("value", os);
- }
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- makePatchTypeField(fvPatchVectorField, turbulentVolumeFlowVelocityFvPatchVectorField);
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- } // End namespace Foam
- // ************************************************************************* //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement