seriesProfile.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "seriesProfile.H"
28 #include "IFstream.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(seriesProfile, 0);
35  addToRunTimeSelectionTable(profileModel, seriesProfile, dictionary);
36 }
37 
38 
39 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
40 
42 (
43  const scalar& xIn,
44  const List<scalar>& values
45 ) const
46 {
47  scalar result = 0.0;
48 
49  forAll(values, i)
50  {
51  result += values[i]*cos(i*xIn);
52  }
53 
54  return result;
55 }
56 
57 
59 (
60  const scalar& xIn,
61  const List<scalar>& values
62 ) const
63 {
64  scalar result = 0.0;
65 
66  forAll(values, i)
67  {
68  // note: first contribution always zero since sin(0) = 0, but
69  // keep zero base to be consistent with drag coeffs
70  result += values[i]*sin(i*xIn);
71  }
72 
73  return result;
74 }
75 
76 
77 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
78 
80 (
81  const dictionary& dict,
82  const word& modelName
83 )
84 :
85  profileModel(dict, modelName),
86  CdCoeffs_(),
87  ClCoeffs_()
88 {
89  if (readFromFile())
90  {
91  IFstream is(fName_);
92  is >> CdCoeffs_ >> ClCoeffs_;
93  }
94  else
95  {
96  dict.lookup("CdCoeffs") >> CdCoeffs_;
97  dict.lookup("ClCoeffs") >> ClCoeffs_;
98  }
99 
100 
101  if (CdCoeffs_.empty())
102  {
104  << "CdCoeffs must be specified" << exit(FatalError);
105  }
106  if (ClCoeffs_.empty())
107  {
109  << "ClCoeffs must be specified" << exit(FatalError);
110  }
111 }
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
116 void Foam::seriesProfile::Cdl(const scalar alpha, scalar& Cd, scalar& Cl) const
117 {
118  Cd = evaluateDrag(alpha, CdCoeffs_);
119  Cl = evaluateLift(alpha, ClCoeffs_);
120 }
121 
122 
123 // ************************************************************************* //
virtual void Cdl(const scalar alpha, scalar &Cd, scalar &Cl) const
Return the Cd and Cl for a given angle-of-attack.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar evaluateLift(const scalar &xIn, const List< scalar > &values) const
Lift.
Definition: seriesProfile.C:59
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
seriesProfile(const dictionary &dict, const word &modelName)
Constructor.
Definition: seriesProfile.C:80
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Macros for easy insertion into run-time selection tables.
dimensionedScalar cos(const dimensionedScalar &ds)
A class for handling words, derived from string.
Definition: word.H:59
Base class for profile models.
Definition: profileModel.H:50
dimensionedScalar sin(const dimensionedScalar &ds)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
Input from file stream.
Definition: IFstream.H:81
scalar evaluateDrag(const scalar &xIn, const List< scalar > &values) const
Drag.
Definition: seriesProfile.C:42
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844