profileModelList.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-2024 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 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:131
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
~profileModelList()
Destructor.
profileModelList(const dictionary &dict, const bool readFields=true)
Constructor.
void connectBlades(const List< word > &names, List< label > &addr) const
Set blade->profile addressing.
Base class for profile models.
Definition: profileModel.H:51
const word & name() const
Return const access to the source name.
Definition: profileModel.C:65
static autoPtr< profileModel > New(const dictionary &dict)
Return a reference to the selected fvModel model.
Definition: profileModel.C:72
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
messageStream Info
error FatalError
dictionary dict