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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "seriesProfile.H"
30 #include "IFstream.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(seriesProfile, 0);
37  addToRunTimeSelectionTable(profileModel, seriesProfile, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
44 (
45  const scalar& xIn,
46  const List<scalar>& values
47 ) const
48 {
49  scalar result = 0.0;
50 
51  forAll(values, i)
52  {
53  result += values[i]*cos(i*xIn);
54  }
55 
56  return result;
57 }
58 
59 
61 (
62  const scalar& xIn,
63  const List<scalar>& values
64 ) const
65 {
66  scalar result = 0.0;
67 
68  forAll(values, i)
69  {
70  // note: first contribution always zero since sin(0) = 0, but
71  // keep zero base to be consistent with drag coeffs
72  result += values[i]*sin(i*xIn);
73  }
74 
75  return result;
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 
82 (
83  const dictionary& dict,
84  const word& modelName
85 )
86 :
87  profileModel(dict, modelName),
88  CdCoeffs_(),
89  ClCoeffs_()
90 {
91  if (readFromFile())
92  {
93  IFstream is(fName_);
94  is >> CdCoeffs_ >> ClCoeffs_;
95  }
96  else
97  {
98  dict.readEntry("CdCoeffs", CdCoeffs_);
99  dict.readEntry("ClCoeffs", ClCoeffs_);
100  }
101 
102 
103  if (CdCoeffs_.empty())
104  {
106  << "CdCoeffs must be specified" << exit(FatalError);
107  }
108  if (ClCoeffs_.empty())
109  {
111  << "ClCoeffs must be specified" << exit(FatalError);
112  }
113 }
114 
115 
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 
118 void Foam::seriesProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
119 {
122 }
123 
124 
125 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::seriesProfile::evaluateDrag
scalar evaluateDrag(const scalar &xIn, const List< scalar > &values) const
Drag.
Definition: seriesProfile.C:44
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:97
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:118
Foam::seriesProfile::CdCoeffs_
List< scalar > CdCoeffs_
List of drag coefficient values.
Definition: seriesProfile.H:74
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
IFstream.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
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
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::seriesProfile::evaluateLift
scalar evaluateLift(const scalar &xIn, const List< scalar > &values) const
Lift.
Definition: seriesProfile.C:61
Foam::List< scalar >
Foam::seriesProfile::seriesProfile
seriesProfile(const dictionary &dict, const word &modelName)
Constructor.
Definition: seriesProfile.C:82
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::seriesProfile::ClCoeffs_
List< scalar > ClCoeffs_
List of lift coefficient values.
Definition: seriesProfile.H:77
Foam::profileModel
Base class for profile models.
Definition: profileModel.H:52
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265