/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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, see .
\*---------------------------------------------------------------------------*/
#include "rotorDiskSource.H"
#include "addToRunTimeSelectionTable.H"
#include "trimModel.H"
#include "fvMatrices.H"
#include "geometricOneField.H"
#include "syncTools.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(rotorDiskSource, 0);
addToRunTimeSelectionTable(option, rotorDiskSource, dictionary);
}
template<> const char* NamedEnum::
names[] =
{
"auto",
"specified"
};
const NamedEnum
fv::rotorDiskSource::geometryModeTypeNames_;
template<> const char* NamedEnum::
names[] =
{
"fixed",
"surfaceNormal",
"local"
};
const NamedEnum
fv::rotorDiskSource::inletFlowTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fv::rotorDiskSource::checkData()
{
// Set inflow type
switch (selectionMode())
{
case smCellSet:
case smCellZone:
case smAll:
{
// Set the profile ID for each blade section
profiles_.connectBlades(blade_.profileName(), blade_.profileID());
switch (inletFlow_)
{
case ifFixed:
{
coeffs_.lookup("inletVelocity") >> inletVelocity_;
break;
}
case ifSurfaceNormal:
{
scalar UIn
(
readScalar(coeffs_.lookup("inletNormalVelocity"))
);
inletVelocity_ = -coordSys_.R().e3()*UIn;
break;
}
case ifLocal:
{
break;
}
default:
{
FatalErrorInFunction
<< "Unknown inlet velocity type" << abort(FatalError);
}
}
break;
}
default:
{
FatalErrorInFunction
<< "Source cannot be used with '"
<< selectionModeTypeNames_[selectionMode()]
<< "' mode. Please use one of: " << nl
<< selectionModeTypeNames_[smCellSet] << nl
<< selectionModeTypeNames_[smCellZone] << nl
<< selectionModeTypeNames_[smAll]
<< exit(FatalError);
}
}
}
void Foam::fv::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
{
area_ = 0.0;
static const scalar tol = 0.8;
const label nInternalFaces = mesh_.nInternalFaces();
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
const vectorField& Sf = mesh_.Sf();
const scalarField& magSf = mesh_.magSf();
vector n = Zero;
// Calculate cell addressing for selected cells
labelList cellAddr(mesh_.nCells(), -1);
UIndirectList