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-2015 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 
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 // ************************************************************************* //
setSize
points setSize(newPointi)
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::profileModel::name
const word & name() const
Return const access to the source name.
Definition: profileModel.C:65
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::readFields
This function object reads fields from the time directories and adds them to the mesh database for fu...
Definition: readFields.H:104
Foam::profileModelList::profileModelList
profileModelList(const dictionary &dict, const bool readFields=true)
Constructor.
Definition: profileModelList.C:31
Foam::label
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
Foam::Info
messageStream Info
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 any number of values (e....
Definition: dictionary.H:137
profileModelList.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::profileModelList::~profileModelList
~profileModelList()
Destructor.
Definition: profileModelList.C:70
Foam::profileModelList::connectBlades
void connectBlades(const List< word > &names, List< label > &addr) const
Set blade->profile addressing.
Definition: profileModelList.C:77
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::profileModel
Base class for profile models.
Definition: profileModel.H:50