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 -------------------------------------------------------------------------------
11 License
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 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(seriesProfile, 0);
38  addToRunTimeSelectionTable(profileModel, seriesProfile, dictionary);
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 
121 void Foam::seriesProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
122 {
125 }
126 
127 
128 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::seriesProfile::evaluateDrag
scalar evaluateDrag(const scalar &xIn, const List< scalar > &values) const
Drag.
Definition: seriesProfile.C:45
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:53
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:264
Foam::seriesProfile::Cdl
virtual void Cdl(const scalar alpha, scalar &Cd, scalar &Cl) const
Return the Cd and Cl for a given angle-of-attack.
Definition: seriesProfile.C:121
Foam::FatalIOError
IOerror FatalIOError
Foam::seriesProfile::CdCoeffs_
List< scalar > CdCoeffs_
List of drag coefficient values.
Definition: seriesProfile.H:146
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
IFstream.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
seriesProfile.H
Foam::seriesProfile::evaluateLift
scalar evaluateLift(const scalar &xIn, const List< scalar > &values) const
Lift.
Definition: seriesProfile.C:62
Foam::List< scalar >
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
Foam::seriesProfile::seriesProfile
seriesProfile(const dictionary &dict, const word &modelName)
Constructor from dictionary and model name.
Definition: seriesProfile.C:83
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::seriesProfile::ClCoeffs_
List< scalar > ClCoeffs_
List of lift coefficient values.
Definition: seriesProfile.H:149
Foam::profileModel
Base class for profile models for handling aerofoil lift and drag polar diagrams.
Definition: profileModel.H:120
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265