fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / meshes / meshShapes / cellModeller / cellModeller.C
blob1143f7ef165708a2e98501936b32694da286beaf
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26     Constructor of cellModeller: just sets the cellModeller's params.
28 \*---------------------------------------------------------------------------*/
30 #include "cellModeller.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 Foam::cellModeller::cellModeller()
36     if (modelPtrs_.size())
37     {
38         FatalErrorIn("cellModeller::cellModeller(const fileName&)")
39             << "attempt to re-construct cellModeller when it already exists"
40             << exit(FatalError);
41     }
43     label maxIndex = 0;
44     forAll(models_, i)
45     {
46         if (models_[i].index() > maxIndex) maxIndex = models_[i].index();
47     }
49     modelPtrs_.setSize(maxIndex + 1);
50     modelPtrs_ = NULL;
52     // For all the words in the wordlist, set the details of the model
53     // to those specified by the word name and the other parameters
54     // given. This should result in an automatic 'read' of the model
55     // from its File (see cellModel class).
56     forAll(models_, i)
57     {
58         if (modelPtrs_[models_[i].index()])
59         {
60             FatalErrorIn("cellModeller::cellModeller(const fileName&)")
61                 << "more than one model share the index "
62                 << models_[i].index()
63                 << exit(FatalError);
64         }
66         modelPtrs_[models_[i].index()] = &models_[i];
68         if (modelDictionary_.found(models_[i].name()))
69         {
70             FatalErrorIn("cellModeller::cellModeller(const fileName&)")
71                 << "more than one model share the name "
72                 << models_[i].name()
73                 << exit(FatalError);
74         }
76         modelDictionary_.insert(models_[i].name(), &models_[i]);
77     }
81 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
83 Foam::cellModeller::~cellModeller()
87 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
89 // Returns a pointer to a model which matches the string symbol
90 // supplied. A null pointer is returned if there is no suitable match.
92 const Foam::cellModel* Foam::cellModeller::lookup(const word& name)
94     HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name);
96     if (iter != modelDictionary_.end())
97     {
98         return iter();
99     }
100     else
101     {
102         return NULL;
103     }
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 // ************************************************************************* //