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 | Copyright (C) 2011-2013 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 "profileModelList.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 (
32  const dictionary& dict,
33  const bool readFields
34 )
35 :
37  dict_(dict)
38 {
39  if (readFields)
40  {
41  wordList modelNames(dict.toc());
42 
43  Info<< " Constructing blade profiles:" << endl;
44 
45  if (modelNames.size() > 0)
46  {
47  this->setSize(modelNames.size());
48 
49  forAll(modelNames, i)
50  {
51  const word& modelName = modelNames[i];
52 
53  this->set
54  (
55  i,
56  profileModel::New(dict.subDict(modelName))
57  );
58  }
59  }
60  else
61  {
62  Info<< " none" << endl;
63  }
64  }
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
69 
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 (
78  const List<word>& names,
79  List<label>& addr
80 ) const
81 {
82  // construct the addressing between blade sections and profiles
83  forAll(names, bI)
84  {
85  label index = -1;
86  const word& profileName = names[bI];
87 
88  forAll(*this, pI)
89  {
90  const profileModel& pm = this->operator[](pI);
91 
92  if (pm.name() == profileName)
93  {
94  index = pI;
95  break;
96  }
97  }
98 
99  if (index == -1)
100  {
101  List<word> profileNames(size());
102  forAll(*this, i)
103  {
104  const profileModel& pm = this->operator[](i);
105  profileNames[i] = pm.name();
106  }
107 
108  FatalErrorIn("void Foam::connectBlades(List<word>& names) const")
109  << "Profile " << profileName << " could not be found "
110  << "in profile list. Available profiles are"
111  << profileNames << exit(FatalError);
112  }
113  else
114  {
115  addr[bI] = index;
116  }
117  }
118 }
119 
120 
121 // ************************************************************************* //
profileModelList(const dictionary &dict, const bool readFields=true)
Constructor.
label size() const
Return the number of elements in the PtrList.
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:638
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const word & name() const
Return const access to the source name.
Definition: profileModel.C:65
wordList toc() const
Return the table of contents.
Definition: dictionary.C:707
#define forAll(list, i)
Definition: UList.H:421
Base class for profile models.
Definition: profileModel.H:50
void connectBlades(const List< word > &names, List< label > &addr) const
Set blade->profile addressing.
~profileModelList()
Destructor.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
points setSize(newPointi)
error FatalError
const profileModel & operator[](const label) const
Return element const reference.