FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025     Constructor of cellModeller: just sets the cellModeller's params.
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include <OpenFOAM/cellModeller.H>
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 Foam::cellModeller::cellModeller()
00034 {
00035     if (modelPtrs_.size())
00036     {
00037         FatalErrorIn("cellModeller::cellModeller(const fileName&)")
00038             << "attempt to re-construct cellModeller when it already exists"
00039             << exit(FatalError);
00040     }
00041 
00042     label maxIndex = 0;
00043     forAll(models_, i)
00044     {
00045         if (models_[i].index() > maxIndex) maxIndex = models_[i].index();
00046     }
00047 
00048     modelPtrs_.setSize(maxIndex + 1);
00049     modelPtrs_ = NULL;
00050 
00051     // For all the words in the wordlist, set the details of the model
00052     // to those specified by the word name and the other parameters
00053     // given. This should result in an automatic 'read' of the model
00054     // from its File (see cellModel class).
00055     forAll(models_, i)
00056     {
00057         if (modelPtrs_[models_[i].index()])
00058         {
00059             FatalErrorIn("cellModeller::cellModeller(const fileName&)")
00060                 << "more than one model share the index "
00061                 << models_[i].index()
00062                 << exit(FatalError);
00063         }
00064 
00065         modelPtrs_[models_[i].index()] = &models_[i];
00066 
00067         if (modelDictionary_.found(models_[i].name()))
00068         {
00069             FatalErrorIn("cellModeller::cellModeller(const fileName&)")
00070                 << "more than one model share the name "
00071                 << models_[i].name()
00072                 << exit(FatalError);
00073         }
00074 
00075         modelDictionary_.insert(models_[i].name(), &models_[i]);
00076     }
00077 }
00078 
00079 
00080 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00081 
00082 Foam::cellModeller::~cellModeller()
00083 {}
00084 
00085 
00086 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00087 
00088 // Returns a pointer to a model which matches the string symbol
00089 // supplied. A null pointer is returned if there is no suitable match.
00090 
00091 const Foam::cellModel* Foam::cellModeller::lookup(const word& name)
00092 {
00093     HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name);
00094 
00095     if (iter != modelDictionary_.end())
00096     {
00097         return iter();
00098     }
00099     else
00100     {
00101         return NULL;
00102     }
00103 }
00104 
00105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00106 
00107 
00108 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines