cellModeller.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-2016 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 Description
25  Constructor of cellModeller: just sets the cellModeller's params.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "cellModeller.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 {
35  if (modelPtrs_.size())
36  {
38  << "attempt to re-construct cellModeller when it already exists"
39  << exit(FatalError);
40  }
41 
42  label maxIndex = 0;
43  forAll(models_, i)
44  {
45  if (models_[i].index() > maxIndex) maxIndex = models_[i].index();
46  }
47 
48  modelPtrs_.setSize(maxIndex + 1);
49  modelPtrs_ = NULL;
50 
51  // For all the words in the wordlist, set the details of the model
52  // to those specified by the word name and the other parameters
53  // given. This should result in an automatic 'read' of the model
54  // from its File (see cellModel class).
55  forAll(models_, i)
56  {
57  if (modelPtrs_[models_[i].index()])
58  {
60  << "more than one model share the index "
61  << models_[i].index()
62  << exit(FatalError);
63  }
64 
65  modelPtrs_[models_[i].index()] = &models_[i];
66 
67  if (modelDictionary_.found(models_[i].name()))
68  {
70  << "more than one model share the name "
71  << models_[i].name()
72  << exit(FatalError);
73  }
74 
75  modelDictionary_.insert(models_[i].name(), &models_[i]);
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
83 {}
84 
85 
86 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
87 
89 {
90  HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name);
91 
92  if (iter != modelDictionary_.end())
93  {
94  return iter();
95  }
96  else
97  {
98  return NULL;
99  }
100 }
101 
102 
103 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
Definition: cellModeller.C:88
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
~cellModeller()
Destructor.
Definition: cellModeller.C:82
An STL-conforming iterator.
Definition: HashTable.H:415
A class for handling words, derived from string.
Definition: word.H:59
cellModeller()
Construct from central "cellModels" file.
Definition: cellModeller.C:33
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:64