Commit dd506c3f authored by andy's avatar andy
Browse files

ENH: Added new rotorDiskSource momentum source model for rotor blades/airfoils

parent 3b0e4537
......@@ -390,6 +390,12 @@ $(basicSource)/actuationDiskSource/actuationDiskSource.C
$(basicSource)/radialActuationDiskSource/radialActuationDiskSource.C
$(basicSource)/explicitSource/explicitSource.C
$(basicSource)/explicitSetValue/explicitSetValue.C
$(basicSource)/rotorDiskSource/rotorDiskSource.C
$(basicSource)/rotorDiskSource/bladeModel/bladeModel.C
$(basicSource)/rotorDiskSource/profileModel/profileModel.C
$(basicSource)/rotorDiskSource/profileModel/profileModelList.C
$(basicSource)/rotorDiskSource/profileModel/lookup/lookupProfile.C
$(basicSource)/rotorDiskSource/profileModel/series/seriesProfile.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "bladeModel.H"
#include "unitConversion.H"
#include "Tuple2.H"
#include "vector.H"
#include "IFstream.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
bool Foam::bladeModel::readFromFile() const
{
return fName_ != fileName::null;
}
void Foam::bladeModel::interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const
{
scalar x = -GREAT;
label nElem = values.size();
i2 = 0;
while ((x < xIn) && (i2 < nElem))
{
x = values[i2];
i2++;
}
if (i2 == 0)
{
i1 = i2;
ddx = 0.0;
return;
}
else if (i2 == values.size())
{
i2 = values.size() - 1;
i1 = i2;
ddx = 0.0;
return;
}
else
{
i1 = i2 - 1;
ddx = (xIn - values[i1])/(values[i2] - values[i1]);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::bladeModel::bladeModel(const dictionary& dict)
:
profileName_(),
profileID_(),
radius_(),
twist_(),
chord_(),
fName_(fileName::null)
{
List<Tuple2<word, vector> > data;
if (readFromFile())
{
IFstream is(fName_);
is >> data;
}
else
{
dict.lookup("data") >> data;
}
if (data.size() > 0)
{
profileName_.setSize(data.size());
profileID_.setSize(data.size());
radius_.setSize(data.size());
twist_.setSize(data.size());
chord_.setSize(data.size());
forAll(data, i)
{
profileName_[i] = data[i].first();
profileID_[i] = -1;
radius_[i] = data[i].second()[0];
twist_[i] = degToRad(data[i].second()[1]);
chord_[i] = data[i].second()[2];
}
}
else
{
FatalErrorIn
(
"Foam::bladeModel::bladeModel"
"("
"const dictionary&, "
"const word&"
")"
) << "No blade data specified" << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::bladeModel::~bladeModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::List<Foam::word>& Foam::bladeModel::profileName() const
{
return profileName_;
}
const Foam::List<Foam::label>& Foam::bladeModel::profileID() const
{
return profileID_;
}
const Foam::List<Foam::scalar>& Foam::bladeModel::radius() const
{
return radius_;
}
const Foam::List<Foam::scalar>& Foam::bladeModel::twist() const
{
return twist_;
}
const Foam::List<Foam::scalar>& Foam::bladeModel::chord() const
{
return chord_;
}
Foam::List<Foam::label>& Foam::bladeModel::profileID()
{
return profileID_;
}
void Foam::bladeModel::interpolate
(
const scalar radius,
scalar& twist,
scalar& chord,
label& i1,
label& i2,
scalar& invDr
) const
{
interpolateWeights(radius, radius_, i1, i2, invDr);
twist = invDr*(twist_[i2] - twist_[i1]) + twist_[i1];
chord = invDr*(chord_[i2] - chord_[i1]) + chord_[i1];
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, see <http://www.gnu.org/licenses/>.
Class
Foam::bladeModel
Description
Blade model class
SourceFiles
bladeModel.C
\*---------------------------------------------------------------------------*/
#ifndef bladeModel_H
#define bladeModel_H
#include "List.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class bladeModel Declaration
\*---------------------------------------------------------------------------*/
class bladeModel
{
protected:
// Protected data
//- Corresponding profile name per section
List<word> profileName_;
//- Corresponding profile ID per section
List<label> profileID_;
//- Radius [m]
List<scalar> radius_;
//- Twist [deg] on input, converted to [rad]
List<scalar> twist_;
//- Chord [m]
List<scalar> chord_;
//- File name (optional)
fileName fName_;
// Protected Member Functions
//- Return ture if file name is set
bool readFromFile() const;
//- Return the interpolation indices and gradient
void interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const;
public:
//- Constructor
bladeModel(const dictionary& dict);
//- Destructor
virtual ~bladeModel();
// Member functions
// Access
//- Return const access to the profile name list
const List<word>& profileName() const;
//- Return const access to the profile ID list
const List<label>& profileID() const;
//- Return const access to the radius list
const List<scalar>& radius() const;
//- Return const access to the twist list
const List<scalar>& twist() const;
//- Return const access to the chord list
const List<scalar>& chord() const;
// Edit
//- Return non-const access to the profile ID list
List<label>& profileID();
// Evaluation
//- Return the twist and chord for a given radius
virtual void interpolate
(
const scalar radius,
scalar& twist,
scalar& chord,
label& i1,
label& i2,
scalar& invDr
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "lookupProfile.H"
#include "addToRunTimeSelectionTable.H"
#include "vector.H"
#include "unitConversion.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(lookupProfile, 0);
addToRunTimeSelectionTable(profileModel, lookupProfile, dictionary);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::lookupProfile::interpolateWeights
(
const scalar& xIn,
const List<scalar>& values,
label& i1,
label& i2,
scalar& ddx
) const
{
scalar x = -GREAT;
label nElem = values.size();
i2 = 0;
while ((x < xIn) && (i2 < nElem))
{
x = values[i2];
i2++;
}
if (i2 == 0)
{
i1 = i2;
ddx = 0.0;
return;
}
else if (i2 == values.size())
{
i2 = values.size() - 1;
i1 = i2;
ddx = 0.0;
return;
}
else
{
i1 = i2 - 1;
ddx = (xIn - values[i1])/(values[i2] - values[i1]);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::lookupProfile::lookupProfile
(
const dictionary& dict,
const word& modelName
)
:
profileModel(dict, modelName),
AOA_(),
Cd_(),
Cl_()
{
List<vector> data;
if (readFromFile())
{
IFstream is(fName_);
is >> data;
}
else
{
dict.lookup("data") >> data;
}
if (data.size() > 0)
{
AOA_.setSize(data.size());
Cd_.setSize(data.size());
Cl_.setSize(data.size());
forAll(data, i)
{
AOA_[i] = degToRad(data[i][0]);
Cd_[i] = data[i][1];
Cl_[i] = data[i][2];
}
}
else
{
FatalErrorIn
(
"Foam::lookupProfile::lookupProfile"
"("
"const dictionary&, "
"const word&"
")"
) << "No profile data specified" << exit(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::lookupProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
{
label i1 = -1;
label i2 = -1;
scalar invAlpha = -1.0;
interpolateWeights(alpha, AOA_, i1, i2, invAlpha);
Cd = invAlpha*(Cd_[i2] - Cd_[i1]) + Cd_[i1];
Cl = invAlpha*(Cl_[i2] - Cl_[i1]) + Cl_[i1];
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, see <http://www.gnu.org/licenses/>.
Class
Foam::lookupProfile
Description
Look-up based profile data - drag and lift coefficients are lineraly
interpolated based on the supplied angle of attack
Input in list format:
data
(
(AOA1 Cd1 Cl2)
(AOA2 Cd2 Cl2)
...
(AOAN CdN CdN)
);
where:
AOA = angle of attack [deg] converted to [rad] internally
Cd = drag coefficient
Cl = lift coefficient
SourceFiles
lookupProfile.C
\*---------------------------------------------------------------------------*/
#ifndef lookupProfile_H
#define lookupProfile_H
#include "profileModel.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class lookupProfile Declaration
\*---------------------------------------------------------------------------*/
class lookupProfile
: