OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

cellModeller.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Constructor of cellModeller: just sets the cellModeller's params.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "cellModeller.H"
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 Foam::cellModeller::cellModeller()
00035 {
00036     if (modelPtrs_.size())
00037     {
00038         FatalErrorIn("cellModeller::cellModeller(const fileName&)")
00039             << "attempt to re-construct cellModeller when it already exists"
00040             << exit(FatalError);
00041     }
00042 
00043     label maxIndex = 0;
00044     forAll(models_, i)
00045     {
00046         if (models_[i].index() > maxIndex) maxIndex = models_[i].index();
00047     }
00048 
00049     modelPtrs_.setSize(maxIndex + 1);
00050     modelPtrs_ = NULL;
00051 
00052     // For all the words in the wordlist, set the details of the model
00053     // to those specified by the word name and the other parameters
00054     // given. This should result in an automatic 'read' of the model
00055     // from its File (see cellModel class).
00056     forAll(models_, i)
00057     {
00058         if (modelPtrs_[models_[i].index()])
00059         {
00060             FatalErrorIn("cellModeller::cellModeller(const fileName&)")
00061                 << "more than one model share the index "
00062                 << models_[i].index()
00063                 << exit(FatalError);
00064         }
00065 
00066         modelPtrs_[models_[i].index()] = &models_[i];
00067 
00068         if (modelDictionary_.found(models_[i].name()))
00069         {
00070             FatalErrorIn("cellModeller::cellModeller(const fileName&)")
00071                 << "more than one model share the name "
00072                 << models_[i].name()
00073                 << exit(FatalError);
00074         }
00075 
00076         modelDictionary_.insert(models_[i].name(), &models_[i]);
00077     }
00078 }
00079 
00080 
00081 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00082 
00083 Foam::cellModeller::~cellModeller()
00084 {}
00085 
00086 
00087 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00088 
00089 // Returns a pointer to a model which matches the string symbol
00090 // supplied. A null pointer is returned if there is no suitable match.
00091 
00092 const Foam::cellModel* Foam::cellModeller::lookup(const word& name)
00093 {
00094     HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name);
00095 
00096     if (iter != modelDictionary_.end())
00097     {
00098         return iter();
00099     }
00100     else
00101     {
00102         return NULL;
00103     }
00104 }
00105 
00106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00107 
00108 
00109 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd