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 
76 void Foam::profileModelList::connectBlades
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 // ************************************************************************* //