diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index e24fd6b5ec..9162050cc0 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -289,7 +289,6 @@ $(tetCell)/tetCell.C cellModeller = $(meshShapes)/cellModeller $(cellModeller)/cellModeller.C -$(cellModeller)/cellModellerIO.C cellModel = $(meshShapes)/cellModel $(cellModel)/cellModel.C diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C index 0fadb614bb..e545798895 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C @@ -27,14 +27,9 @@ License #include "cellModel.H" #include "pyramid.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -vector cellModel::centre +Foam::vector Foam::cellModel::centre ( const labelList& pointLabels, const pointField& points @@ -91,7 +86,7 @@ vector cellModel::centre } -scalar cellModel::mag +Foam::scalar Foam::cellModel::mag ( const labelList& pointLabels, const pointField& points @@ -143,9 +138,4 @@ scalar cellModel::mag return v; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C index a2656f8384..7d69b5238c 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C @@ -29,12 +29,58 @@ Description #include "cellModeller.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -namespace Foam +Foam::cellModeller::cellModeller() { + if (modelPtrs_.size()) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "attempt to re-construct cellModeller when it already exists" + << exit(FatalError); + } -cellModeller::~cellModeller() + label maxIndex = 0; + forAll(models_, i) + { + if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); + } + + modelPtrs_.setSize(maxIndex + 1); + modelPtrs_ = NULL; + + // For all the words in the wordlist, set the details of the model + // to those specified by the word name and the other parameters + // given. This should result in an automatic 'read' of the model + // from its File (see cellModel class). + forAll(models_, i) + { + if (modelPtrs_[models_[i].index()]) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "more than one model share the index " + << models_[i].index() + << exit(FatalError); + } + + modelPtrs_[models_[i].index()] = &models_[i]; + + if (modelDictionary_.found(models_[i].name())) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "more than one model share the name " + << models_[i].name() + << exit(FatalError); + } + + modelDictionary_.insert(models_[i].name(), &models_[i]); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cellModeller::~cellModeller() {} @@ -43,9 +89,9 @@ cellModeller::~cellModeller() // Returns a pointer to a model which matches the string symbol // supplied. A null pointer is returned if there is no suitable match. -const cellModel* cellModeller::lookup(const word& symbol) +const Foam::cellModel* Foam::cellModeller::lookup(const word& name) { - HashTable::iterator iter = modelDictionary_.find(symbol); + HashTable::iterator iter = modelDictionary_.find(name); if (iter != modelDictionary_.end()) { @@ -57,9 +103,7 @@ const cellModel* cellModeller::lookup(const word& symbol) } } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H index 4f6f2ee70f..11e642d2d4 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cellModeller Declaration + Class cellModeller Declaration \*---------------------------------------------------------------------------*/ class cellModeller @@ -69,10 +69,9 @@ public: // Constructors - //- Construct given file name + //- Construct from central "cellModels" file cellModeller(); - // Destructor ~cellModeller(); @@ -80,12 +79,10 @@ public: // Member functions - //- Look up a model given name and return ptr to model if good - // else zero + //- Look up a model by name and return a pointer to the model or NULL static const cellModel* lookup(const word&); - //- Look up a model given label and return ptr to model if good - // else zero + //- Look up a model by index and return a pointer to the model or NULL static const cellModel* lookup(const label i) { return modelPtrs_[i]; diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C deleted file mode 100644 index ef3eb17df2..0000000000 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C +++ /dev/null @@ -1,91 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - Reads the data portion of a model catalogue File. - -\*---------------------------------------------------------------------------*/ - -#include "cellModeller.H" -#include "dictionary.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -cellModeller::cellModeller() -{ - if (modelPtrs_.size()) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "attempt to re-construct cellModeller when it already exists" - << exit(FatalError); - } - - label maxIndex = 0; - forAll(models_, i) - { - if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); - } - - modelPtrs_.setSize(maxIndex + 1); - modelPtrs_ = NULL; - - // For all the words in the wordlist, set the details of the model - // to those specified by the word name and the other parameters - // given. This should result in an automatic 'read' of the model - // from its File (see cellModel class). - forAll(models_, i) - { - if (modelPtrs_[models_[i].index()]) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "more than one model share the index " - << models_[i].index() - << exit(FatalError); - } - - modelPtrs_[models_[i].index()] = &models_[i]; - - if (modelDictionary_.found(models_[i].name())) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "more than one model share the name " - << models_[i].name() - << exit(FatalError); - } - - modelDictionary_.insert(models_[i].name(), &models_[i]); - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C index f616f2d6df..7f5b627451 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C @@ -23,6 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description + cellModeller global initializations \*---------------------------------------------------------------------------*/ @@ -30,24 +31,25 @@ Description #include "OSspecific.H" #include "IFstream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * * // + // PtrList of models -PtrList cellModeller::models_ +Foam::PtrList Foam::cellModeller::models_ ( IFstream(findEtcFile("cellModels", true))() ); // List of model pointers -List cellModeller::modelPtrs_; +Foam::List Foam::cellModeller::modelPtrs_; // HashTable of model pointers -HashTable cellModeller::modelDictionary_; +Foam::HashTable Foam::cellModeller::modelDictionary_; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ // Construct a dummy cellModeller which reads the models and fills // the above tables