Files
openfoam/src/finiteVolume/cfdTools/general/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSourceTemplates.C

95 lines
3.0 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*----------------------------------------------------------------------------*/
#include "radialActuationDiskSource.H"
#include "volFields.H"
#include "fvMatrix.H"
#include "fvm.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class RhoFieldType>
void Foam::radialActuationDiskSource::
addRadialActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,
const scalarField& Vcells,
const RhoFieldType& rho,
const vectorField& U
) const
{
scalar a = 1.0 - Cp_/Ct_;
scalarField T(cells.size());
scalarField Tr(cells.size());
const vector uniDiskDir = diskDir_/mag(diskDir_);
tensor E(tensor::zero);
E.xx() = uniDiskDir.x();
E.yy() = uniDiskDir.y();
E.zz() = uniDiskDir.z();
const Field<vector> zoneCellCentres(mesh().cellCentres(), cells);
const Field<scalar> zoneCellVolumes(mesh().cellVolumes(), cells);
const vector avgCentre = gSum(zoneCellVolumes*zoneCellCentres)/V();
const scalar maxR = gMax(mag(zoneCellCentres - avgCentre));
scalar intCoeffs =
radialCoeffs_[0]
+ radialCoeffs_[1]*sqr(maxR)/2.0
+ radialCoeffs_[2]*pow4(maxR)/3.0;
forAll(cells, i)
{
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a);
scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre);
Tr[i] =
T[i]
*(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2))
/intCoeffs;
}
forAll(cells, i)
{
Usource[cells[i]] += ((Vcells[cells[i]]/V_)*Tr[i]*E) & U[cells[i]];
}
if (debug)
{
Info<< "Source name: " << name() << nl
<< "Average centre: " << avgCentre << nl
<< "Maximum radius: " << maxR << endl;
}
}
// ************************************************************************* //