/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 3 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, see . \*---------------------------------------------------------------------------*/ #include "swirlInletVelocityFvPatchVectorField.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::swirlInletVelocityFvPatchVectorField:: swirlInletVelocityFvPatchVectorField ( const fvPatch& p, const DimensionedField& iF ) : fixedValueFvPatchField(p, iF), origin_(Zero), axis_(Zero), axialVelocity_(), radialVelocity_(), tangentialVelocity_() {} 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_.clone()), radialVelocity_(ptf.radialVelocity_.clone()), tangentialVelocity_(ptf.tangentialVelocity_.clone()) {} Foam::swirlInletVelocityFvPatchVectorField:: swirlInletVelocityFvPatchVectorField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : fixedValueFvPatchField(p, iF, dict), origin_(dict.get("origin")), axis_(dict.get("axis")), axialVelocity_(Function1::New("axialVelocity", dict, &db())), radialVelocity_ ( Function1::New("radialVelocity", dict, &db()) ), tangentialVelocity_ ( Function1::New("tangentialVelocity", dict, &db()) ) {} Foam::swirlInletVelocityFvPatchVectorField:: swirlInletVelocityFvPatchVectorField ( const swirlInletVelocityFvPatchVectorField& ptf ) : fixedValueFvPatchField(ptf), origin_(ptf.origin_), axis_(ptf.axis_), axialVelocity_(ptf.axialVelocity_.clone()), radialVelocity_(ptf.radialVelocity_.clone()), tangentialVelocity_(ptf.tangentialVelocity_.clone()) {} Foam::swirlInletVelocityFvPatchVectorField:: swirlInletVelocityFvPatchVectorField ( const swirlInletVelocityFvPatchVectorField& ptf, const DimensionedField& iF ) : fixedValueFvPatchField(ptf, iF), origin_(ptf.origin_), axis_(ptf.axis_), axialVelocity_(ptf.axialVelocity_.clone()), radialVelocity_(ptf.radialVelocity_.clone()), tangentialVelocity_(ptf.tangentialVelocity_.clone()) {} // * * * * * * * * * * * * * * * 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.writeEntry("origin", origin_); os.writeEntry("axis", axis_); axialVelocity_->writeData(os); radialVelocity_->writeData(os); tangentialVelocity_->writeData(os); fvPatchField::writeValueEntry(os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { makePatchTypeField ( fvPatchVectorField, swirlInletVelocityFvPatchVectorField ); } // ************************************************************************* //