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 {
38  if (readFields)
39  {
40  wordList modelNames(dict.toc());
41 
42  Info<< " Constructing blade profiles:" << endl;
43 
44  if (modelNames.size() > 0)
45  {
46  this->setSize(modelNames.size());
47 
48  forAll(modelNames, i)
49  {
50  const word& modelName = modelNames[i];
51 
52  this->set
53  (
54  i,
56  );
57  }
58  }
59  else
60  {
61  Info<< " none" << endl;
62  }
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
68 
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
76 (
77  const List<word>& names,
78  List<label>& addr
79 ) const
80 {
81  // construct the addressing between blade sections and profiles
82  forAll(names, bI)
83  {
84  label index = -1;
85  const word& profileName = names[bI];
86 
87  forAll(*this, pI)
88  {
89  const profileModel& pm = this->operator[](pI);
90 
91  if (pm.name() == profileName)
92  {
93  index = pI;
94  break;
95  }
96  }
97 
98  if (index == -1)
99  {
100  List<word> profileNames(size());
101  forAll(*this, i)
102  {
103  const profileModel& pm = this->operator[](i);
104  profileNames[i] = pm.name();
105  }
106 
108  << "Profile " << profileName << " could not be found "
109  << "in profile list. Available profiles are"
110  << profileNames << exit(FatalError);
111  }
112  else
113  {
114  addr[bI] = index;
115  }
116  }
117 }
118 
119 
120 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:64
static autoPtr< profileModel > New(const dictionary &dict)
Return a reference to the selected fvModel model.
Definition: profileModel.C:71
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:258
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