cellModeller - cosmetics

This commit is contained in:
Mark Olesen
2008-12-12 20:02:50 +01:00
parent c90a167e5a
commit 4c6a7ca707
6 changed files with 67 additions and 126 deletions

View File

@ -289,7 +289,6 @@ $(tetCell)/tetCell.C
cellModeller = $(meshShapes)/cellModeller
$(cellModeller)/cellModeller.C
$(cellModeller)/cellModellerIO.C
cellModel = $(meshShapes)/cellModel
$(cellModel)/cellModel.C

View File

@ -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
// ************************************************************************* //

View File

@ -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<const cellModel*>::iterator iter = modelDictionary_.find(symbol);
HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name);
if (iter != modelDictionary_.end())
{
@ -57,9 +103,7 @@ const cellModel* cellModeller::lookup(const word& symbol)
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -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];

View File

@ -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
// ************************************************************************* //

View File

@ -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<cellModel> cellModeller::models_
Foam::PtrList<Foam::cellModel> Foam::cellModeller::models_
(
IFstream(findEtcFile("cellModels", true))()
);
// List of model pointers
List<cellModel*> cellModeller::modelPtrs_;
Foam::List<Foam::cellModel*> Foam::cellModeller::modelPtrs_;
// HashTable of model pointers
HashTable<const cellModel*> cellModeller::modelDictionary_;
Foam::HashTable<const Foam::cellModel*> Foam::cellModeller::modelDictionary_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Construct a dummy cellModeller which reads the models and fills
// the above tables