profileModelList.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 "profileModelList.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const dictionary& dict,
35  const bool readFields
36 )
37 :
39  dict_(dict)
40 {
41  if (readFields)
42  {
43  wordList modelNames(dict.toc());
44 
45  Info<< " Constructing blade profiles:" << endl;
46 
47  if (modelNames.size())
48  {
49  this->setSize(modelNames.size());
50 
51  forAll(modelNames, i)
52  {
53  const word& modelName = modelNames[i];
54 
55  this->set
56  (
57  i,
58  profileModel::New(dict.subDict(modelName))
59  );
60  }
61  }
62  else
63  {
64  Info<< " none" << endl;
65  }
66  }
67 }
68 
69 
70 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 
73 (
74  const List<word>& names,
75  List<label>& addr
76 ) const
77 {
78  // construct the addressing between blade sections and profiles
79  forAll(names, bI)
80  {
81  label index = -1;
82  const word& profileName = names[bI];
83 
84  forAll(*this, pI)
85  {
86  const profileModel& pm = this->operator[](pI);
87 
88  if (pm.name() == profileName)
89  {
90  index = pI;
91  break;
92  }
93  }
94 
95  if (index == -1)
96  {
97  List<word> profileNames(size());
98  forAll(*this, i)
99  {
100  const profileModel& pm = this->operator[](i);
101  profileNames[i] = pm.name();
102  }
103 
105  << "Profile " << profileName << " could not be found "
106  << "in profile list. Available profiles are"
107  << profileNames << exit(FatalError);
108  }
109  else
110  {
111  addr[bI] = index;
112  }
113  }
114 }
115 
116 
117 // ************************************************************************* //
setSize
points setSize(newPointi)
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::profileModel::name
const word & name() const
Return const access to the source name.
Definition: profileModel.C:61
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::profileModelList::profileModelList
profileModelList(const dictionary &dict, const bool readFields=true)
Constructor.
Definition: profileModelList.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::PtrList< profileModel >
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:123
profileModelList.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List< word >
Foam::profileModelList::connectBlades
void connectBlades(const List< word > &names, List< label > &addr) const
Set blade->profile addressing.
Definition: profileModelList.C:73
Foam::PtrListOps::names
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Foam::profileModel
Base class for profile models for handling aerofoil lift and drag polar diagrams.
Definition: profileModel.H:120