seriesProfile.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "seriesProfile.H"
31#include "IFstream.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
39}
40
41
42// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43
45(
46 const scalar& xIn,
47 const List<scalar>& values
48) const
49{
50 scalar result = 0.0;
51
52 forAll(values, i)
53 {
54 result += values[i]*cos(i*xIn);
55 }
56
57 return result;
58}
59
60
62(
63 const scalar& xIn,
64 const List<scalar>& values
65) const
66{
67 scalar result = 0.0;
68
69 forAll(values, i)
70 {
71 // note: first contribution always zero since sin(0) = 0, but
72 // keep zero base to be consistent with drag coeffs
73 result += values[i]*sin(i*xIn);
74 }
75
76 return result;
77}
78
79
80// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81
83(
84 const dictionary& dict,
85 const word& modelName
86)
87:
88 profileModel(dict, modelName),
89 CdCoeffs_(),
90 ClCoeffs_()
91{
92 if (readFromFile())
93 {
94 IFstream is(fName_);
95 is >> CdCoeffs_ >> ClCoeffs_;
96 }
97 else
98 {
99 dict.readEntry("CdCoeffs", CdCoeffs_);
100 dict.readEntry("ClCoeffs", ClCoeffs_);
101 }
102
103
104 if (CdCoeffs_.empty())
105 {
107 << "CdCoeffs must be specified"
108 << exit(FatalIOError);
109 }
110 if (ClCoeffs_.empty())
111 {
113 << "ClCoeffs must be specified"
114 << exit(FatalIOError);
115 }
116}
117
118
119// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120
121void Foam::seriesProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
122{
123 Cd = evaluateDrag(alpha, CdCoeffs_);
124 Cl = evaluateLift(alpha, ClCoeffs_);
125}
126
127
128// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Input from file stream, using an ISstream.
Definition: IFstream.H:57
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Base class for profile models for handling aerofoil lift and drag polar diagrams.
Definition: profileModel.H:121
bool readFromFile() const
Return true if file name is set.
Definition: profileModel.C:43
fileName fName_
File name (optional)
Definition: profileModel.H:133
Profile model where polar lift and drag coefficients are computed as sum of trigonometric series by u...
scalar evaluateDrag(const scalar &xIn, const List< scalar > &values) const
Drag.
Definition: seriesProfile.C:45
List< scalar > ClCoeffs_
List of lift coefficient values.
List< scalar > CdCoeffs_
List of drag coefficient values.
virtual void Cdl(const scalar alpha, scalar &Cd, scalar &Cl) const
Return the Cd and Cl for a given angle-of-attack.
scalar evaluateLift(const scalar &xIn, const List< scalar > &values) const
Lift.
Definition: seriesProfile.C:62
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
dimensionedScalar sin(const dimensionedScalar &ds)
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dimensionedScalar cos(const dimensionedScalar &ds)
volScalarField & alpha
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333