mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
set -x
|
||||
|
||||
# force update of Foam::FOAMversion string (git tag or $WM_PROJECT_VERSION)
|
||||
/bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null
|
||||
|
||||
wmakeLnInclude -f OpenFOAM
|
||||
wmakeLnInclude -f OSspecific/$WM_OS
|
||||
Pstream/Allwmake
|
||||
|
||||
@ -2,6 +2,7 @@ signals/sigFpe.C
|
||||
signals/sigSegv.C
|
||||
signals/sigInt.C
|
||||
signals/sigQuit.C
|
||||
regExp.C
|
||||
timer.C
|
||||
fileStat.C
|
||||
Unix.C
|
||||
|
||||
@ -211,7 +211,7 @@ bool Foam::chDir(const fileName& dir)
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::dotFoam(const fileName& name)
|
||||
Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
|
||||
{
|
||||
// Search user files:
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
@ -268,6 +268,15 @@ Foam::fileName Foam::dotFoam(const fileName& name)
|
||||
}
|
||||
|
||||
// Not found
|
||||
// abort if the file is mandatory, otherwise return null
|
||||
if (mandatory)
|
||||
{
|
||||
cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :"
|
||||
" could not find mandatory file\n '"
|
||||
<< name.c_str() << "'\n\n" << std::endl;
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
|
||||
208
src/OSspecific/Unix/regExp.C
Normal file
208
src/OSspecific/Unix/regExp.C
Normal file
@ -0,0 +1,208 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "regExp.H"
|
||||
#include "label.H"
|
||||
#include "string.H"
|
||||
#include "List.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
void Foam::regExp::compile(const char* pat) const
|
||||
{
|
||||
clear();
|
||||
|
||||
// avoid NULL and zero-length patterns
|
||||
if (pat && *pat)
|
||||
{
|
||||
preg_ = new regex_t;
|
||||
|
||||
if (regcomp(preg_, pat, REG_EXTENDED) != 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"regExp::compile(const char*)"
|
||||
) << "Failed to compile regular expression '" << pat << "'"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::regExp::clear() const
|
||||
{
|
||||
if (preg_)
|
||||
{
|
||||
regfree(preg_);
|
||||
delete preg_;
|
||||
preg_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::regExp::regExp()
|
||||
:
|
||||
preg_(0)
|
||||
{}
|
||||
|
||||
|
||||
Foam::regExp::regExp(const string& pat)
|
||||
:
|
||||
preg_(0)
|
||||
{
|
||||
compile(pat.c_str());
|
||||
}
|
||||
|
||||
|
||||
Foam::regExp::regExp(const char* pat)
|
||||
:
|
||||
preg_(0)
|
||||
{
|
||||
compile(pat);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::regExp::~regExp()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
int Foam::regExp::ngroups() const
|
||||
{
|
||||
return preg_ ? preg_->re_nsub : 0;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regExp::match
|
||||
(
|
||||
const string& str,
|
||||
bool partialMatch
|
||||
) const
|
||||
{
|
||||
if (preg_ && str.size())
|
||||
{
|
||||
size_t nmatch = 1;
|
||||
regmatch_t pmatch[1];
|
||||
|
||||
// match and also verify that the entire string was matched
|
||||
// pmatch[0] is the entire match
|
||||
if
|
||||
(
|
||||
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
|
||||
&&
|
||||
(
|
||||
partialMatch
|
||||
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
|
||||
)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regExp::match
|
||||
(
|
||||
const string& str,
|
||||
List<string>& groups,
|
||||
bool partialMatch
|
||||
) const
|
||||
{
|
||||
if (preg_ && str.size())
|
||||
{
|
||||
size_t nmatch = ngroups() + 1;
|
||||
regmatch_t pmatch[nmatch];
|
||||
|
||||
// match and also verify that the entire string was matched
|
||||
// pmatch[0] is the entire match
|
||||
// pmatch[1..] are the (...) sub-groups
|
||||
if
|
||||
(
|
||||
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
|
||||
&&
|
||||
(
|
||||
partialMatch
|
||||
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
|
||||
)
|
||||
)
|
||||
{
|
||||
groups.setSize(ngroups());
|
||||
label groupI = 0;
|
||||
|
||||
for (size_t matchI = 1; matchI < nmatch; matchI++)
|
||||
{
|
||||
if (pmatch[matchI].rm_so != -1 && pmatch[matchI].rm_eo != -1)
|
||||
{
|
||||
groups[groupI] = str.substr
|
||||
(
|
||||
pmatch[matchI].rm_so,
|
||||
pmatch[matchI].rm_eo - pmatch[matchI].rm_so
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
groups[groupI].clear();
|
||||
}
|
||||
groupI++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
groups.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::regExp::operator=(const string& pat)
|
||||
{
|
||||
compile(pat.c_str());
|
||||
}
|
||||
|
||||
|
||||
void Foam::regExp::operator=(const char* pat)
|
||||
{
|
||||
compile(pat);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,94 +23,108 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::regularExpression
|
||||
Foam::regExp
|
||||
|
||||
Description
|
||||
Wrapper around regular expressions.
|
||||
Wrapper around POSIX extended regular expressions.
|
||||
|
||||
The beginning-of-line (^) and the end-of-line ($) anchors are implicit
|
||||
by default.
|
||||
|
||||
SeeAlso
|
||||
The manpage regex(7) for more information about POSIX regular expressions.
|
||||
These differ somewhat from @c Perl and @c sed regular expressions.
|
||||
|
||||
SourceFiles
|
||||
regExp.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef regularExpression_H
|
||||
#define regularExpression_H
|
||||
#ifndef regExp_H
|
||||
#define regExp_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include "string.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class string;
|
||||
template<class T> class List;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class regularExpression Declaration
|
||||
Class regExp Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regularExpression
|
||||
class regExp
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Precompiled regular expression
|
||||
regex_t* preg_;
|
||||
|
||||
mutable regex_t* preg_;
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- release allocated space
|
||||
void clear() const;
|
||||
|
||||
//- compile into a regular expression
|
||||
void compile(const char*) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
regularExpression(const regularExpression&);
|
||||
regExp(const regExp&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const regularExpression&);
|
||||
void operator=(const regExp&);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
regExp();
|
||||
|
||||
//- Construct from string
|
||||
inline regularExpression(const string& s)
|
||||
{
|
||||
preg_ = new regex_t;
|
||||
|
||||
if (regcomp(preg_, s.c_str(), REG_EXTENDED) != 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"regularExpression::regularExpression(const char*)"
|
||||
) << "Failed to compile regular expression " << s
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
regExp(const string&);
|
||||
|
||||
//- Construct from character array
|
||||
regExp(const char*);
|
||||
|
||||
// Destructor
|
||||
|
||||
//- Construct from string
|
||||
inline ~regularExpression()
|
||||
{
|
||||
if (preg_)
|
||||
{
|
||||
regfree(preg_);
|
||||
delete preg_;
|
||||
}
|
||||
}
|
||||
|
||||
~regExp();
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Matches?
|
||||
inline bool matches(const string& s) const
|
||||
{
|
||||
size_t nmatch = 1;
|
||||
regmatch_t pmatch[1];
|
||||
//- Return the number of (groups)
|
||||
int ngroups() const;
|
||||
|
||||
int errVal = regexec(preg_, s.c_str(), nmatch, pmatch, 0);
|
||||
//- Return true if it matches, partial matches are optional
|
||||
bool match
|
||||
(
|
||||
const string&,
|
||||
bool partialMatch=false
|
||||
) const;
|
||||
|
||||
//- Return true if it matches and sets the sub-groups matched,
|
||||
// partial matches are optional
|
||||
bool match
|
||||
(
|
||||
const string&,
|
||||
List<string>& groups,
|
||||
bool partialMatch=false
|
||||
) const;
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assign from a string
|
||||
void operator=(const string&);
|
||||
|
||||
//- Assign from a character array
|
||||
void operator=(const char*);
|
||||
|
||||
return (errVal == 0 && pmatch[0].rm_eo == label(s.size()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -289,7 +289,6 @@ $(tetCell)/tetCell.C
|
||||
|
||||
cellModeller = $(meshShapes)/cellModeller
|
||||
$(cellModeller)/cellModeller.C
|
||||
$(cellModeller)/cellModellerIO.C
|
||||
|
||||
cellModel = $(meshShapes)/cellModel
|
||||
$(cellModel)/cellModel.C
|
||||
|
||||
@ -28,22 +28,15 @@ Description
|
||||
|
||||
#include "Dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
template<class T>
|
||||
Dictionary<T>::Dictionary()
|
||||
Foam::Dictionary<T>::Dictionary()
|
||||
{}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
template<class T>
|
||||
Dictionary<T>::Dictionary(const Dictionary& dict)
|
||||
Foam::Dictionary<T>::Dictionary(const Dictionary& dict)
|
||||
:
|
||||
DictionaryBase<IDLList<T>, T>(dict)
|
||||
{}
|
||||
@ -52,10 +45,10 @@ Dictionary<T>::Dictionary(const Dictionary& dict)
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
bool Dictionary<T>::erase(const word& Keyword)
|
||||
bool Foam::Dictionary<T>::erase(const word& keyword)
|
||||
{
|
||||
T* tPtr;
|
||||
if ((tPtr = this->remove(Keyword)))
|
||||
if (tPtr = this->remove(keyword))
|
||||
{
|
||||
delete tPtr;
|
||||
return true;
|
||||
@ -69,6 +62,4 @@ bool Dictionary<T>::erase(const word& Keyword)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,8 +27,10 @@ Class
|
||||
|
||||
Description
|
||||
Gerneral purpose template dictionary class which manages the storage
|
||||
associated with it. It is derived from DictionaryBase instantiated on
|
||||
a memory managed form of intrusive doubly-linked list of \<T\>.
|
||||
associated with it.
|
||||
|
||||
It is derived from DictionaryBase instantiated on a memory managed form
|
||||
of intrusive doubly-linked list of \<T\>.
|
||||
|
||||
SourceFiles
|
||||
Dictionary.C
|
||||
@ -47,7 +49,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Dictionary Declaration
|
||||
Class Dictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
@ -69,11 +71,9 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
// Editing
|
||||
|
||||
//- Remove an entry specified by keyword from the dictionary
|
||||
// and delete it
|
||||
bool erase(const word& keyword);
|
||||
//- Remove an entry specified by keyword and delete the pointer.
|
||||
// Returns true if the keyword was found
|
||||
bool erase(const word& keyword);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -26,15 +26,10 @@ License
|
||||
|
||||
#include "DictionaryBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class IDLListType, class T>
|
||||
void DictionaryBase<IDLListType, T>::addEntries()
|
||||
void Foam::DictionaryBase<IDLListType, T>::addEntries()
|
||||
{
|
||||
for
|
||||
(
|
||||
@ -51,12 +46,15 @@ void DictionaryBase<IDLListType, T>::addEntries()
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class IDLListType, class T>
|
||||
DictionaryBase<IDLListType, T>::DictionaryBase()
|
||||
Foam::DictionaryBase<IDLListType, T>::DictionaryBase()
|
||||
{}
|
||||
|
||||
|
||||
template<class IDLListType, class T>
|
||||
DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict)
|
||||
Foam::DictionaryBase<IDLListType, T>::DictionaryBase
|
||||
(
|
||||
const DictionaryBase& dict
|
||||
)
|
||||
:
|
||||
IDLListType(dict)
|
||||
{
|
||||
@ -66,17 +64,20 @@ DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict)
|
||||
|
||||
template<class IDLListType, class T>
|
||||
template<class INew>
|
||||
DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is, const INew& inewt)
|
||||
Foam::DictionaryBase<IDLListType, T>::DictionaryBase
|
||||
(
|
||||
Istream& is,
|
||||
const INew& iNew
|
||||
)
|
||||
:
|
||||
IDLListType(is, inewt)
|
||||
IDLListType(is, iNew)
|
||||
{
|
||||
addEntries();
|
||||
}
|
||||
|
||||
|
||||
// Istream constructor
|
||||
template<class IDLListType, class T>
|
||||
DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is)
|
||||
Foam::DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is)
|
||||
:
|
||||
IDLListType(is)
|
||||
{
|
||||
@ -88,25 +89,60 @@ DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is)
|
||||
|
||||
// Find and return T
|
||||
template<class IDLListType, class T>
|
||||
bool DictionaryBase<IDLListType, T>::found(const word& keyword) const
|
||||
bool Foam::DictionaryBase<IDLListType, T>::found(const word& keyword) const
|
||||
{
|
||||
return hashedTs_.found(keyword);
|
||||
}
|
||||
|
||||
|
||||
// Find and return T*
|
||||
// Find and return T*, return NULL if not found
|
||||
template<class IDLListType, class T>
|
||||
const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
|
||||
const T* Foam::DictionaryBase<IDLListType, T>::lookupPtr
|
||||
(
|
||||
const word& keyword
|
||||
) const
|
||||
{
|
||||
typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword);
|
||||
|
||||
if (iter != hashedTs_.end())
|
||||
{
|
||||
return *iter;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find and return T*, return NULL if not found
|
||||
template<class IDLListType, class T>
|
||||
T* Foam::DictionaryBase<IDLListType, T>::lookupPtr(const word& keyword)
|
||||
{
|
||||
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
|
||||
|
||||
if (iter != hashedTs_.end())
|
||||
{
|
||||
return *iter;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find and return T*, FatalError if keyword not found
|
||||
template<class IDLListType, class T>
|
||||
const T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
|
||||
{
|
||||
typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword);
|
||||
|
||||
if (iter == hashedTs_.end())
|
||||
{
|
||||
// If keyword not found print error message ...
|
||||
FatalErrorIn
|
||||
(
|
||||
"DictionaryBase<IDLListType, T>::"
|
||||
"lookup(const word& keyword) const"
|
||||
"DictionaryBase<IDLListType, T>::lookup(const word&) const"
|
||||
) << keyword << " is undefined"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
@ -115,18 +151,17 @@ const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
|
||||
}
|
||||
|
||||
|
||||
// Find and return T*
|
||||
// Find and return T*, FatalError if keyword not found
|
||||
template<class IDLListType, class T>
|
||||
T* DictionaryBase<IDLListType, T>::lookup(const word& keyword)
|
||||
T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword)
|
||||
{
|
||||
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
|
||||
|
||||
if (iter == hashedTs_.end())
|
||||
{
|
||||
// If keyword not found print error message ...
|
||||
FatalErrorIn
|
||||
(
|
||||
"DictionaryBase<IDLListType, T>::lookup(const word& keyword)"
|
||||
"DictionaryBase<IDLListType, T>::lookup(const word&)"
|
||||
) << keyword << " is undefined"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
@ -137,7 +172,7 @@ T* DictionaryBase<IDLListType, T>::lookup(const word& keyword)
|
||||
|
||||
// Return the table of contents
|
||||
template<class IDLListType, class T>
|
||||
wordList DictionaryBase<IDLListType, T>::toc() const
|
||||
Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const
|
||||
{
|
||||
wordList keywords(this->size());
|
||||
|
||||
@ -158,26 +193,28 @@ wordList DictionaryBase<IDLListType, T>::toc() const
|
||||
|
||||
// Add at head of dictionary
|
||||
template<class IDLListType, class T>
|
||||
void DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr)
|
||||
void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr)
|
||||
{
|
||||
IDLListType::insert(tPtr);
|
||||
// NOTE: we should probably check that HashTable::insert actually worked
|
||||
hashedTs_.insert(keyword, tPtr);
|
||||
IDLListType::insert(tPtr);
|
||||
}
|
||||
|
||||
|
||||
// Add at tail of dictionary
|
||||
template<class IDLListType, class T>
|
||||
void DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr)
|
||||
void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr)
|
||||
{
|
||||
IDLListType::append(tPtr);
|
||||
// NOTE: we should probably check that HashTable::insert actually worked
|
||||
hashedTs_.insert(keyword, tPtr);
|
||||
IDLListType::append(tPtr);
|
||||
}
|
||||
|
||||
|
||||
template<class IDLListType, class T>
|
||||
T* DictionaryBase<IDLListType, T>::remove(const word& Keyword)
|
||||
T* Foam::DictionaryBase<IDLListType, T>::remove(const word& keyword)
|
||||
{
|
||||
typename HashTable<T*>::iterator iter = hashedTs_.find(Keyword);
|
||||
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
|
||||
|
||||
if (iter != hashedTs_.end())
|
||||
{
|
||||
@ -192,19 +229,29 @@ T* DictionaryBase<IDLListType, T>::remove(const word& Keyword)
|
||||
}
|
||||
|
||||
|
||||
//- Clear the dictionary
|
||||
template<class IDLListType, class T>
|
||||
void DictionaryBase<IDLListType, T>::clear()
|
||||
void Foam::DictionaryBase<IDLListType, T>::clear()
|
||||
{
|
||||
IDLListType::clear();
|
||||
hashedTs_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class IDLListType, class T>
|
||||
void Foam::DictionaryBase<IDLListType, T>::transfer
|
||||
(
|
||||
DictionaryBase<IDLListType, T>& dict
|
||||
)
|
||||
{
|
||||
IDLListType::transfer(dict);
|
||||
hashedTs_.transfer(dict.hashedTs_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class IDLListType, class T>
|
||||
void DictionaryBase<IDLListType, T>::operator=
|
||||
void Foam::DictionaryBase<IDLListType, T>::operator=
|
||||
(
|
||||
const DictionaryBase<IDLListType, T>& dict
|
||||
)
|
||||
@ -218,25 +265,11 @@ void DictionaryBase<IDLListType, T>::operator=
|
||||
}
|
||||
|
||||
IDLListType::operator=(dict);
|
||||
|
||||
this->hashedTs_.clear();
|
||||
|
||||
for
|
||||
(
|
||||
typename IDLListType::iterator iter = this->begin();
|
||||
iter != this->end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
this->hashedTs_.insert((*iter).keyword(), &(*iter));
|
||||
}
|
||||
this->addEntries();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "DictionaryBaseIO.C"
|
||||
|
||||
@ -29,12 +29,12 @@ Description
|
||||
Base dictionary class templated on both the form of doubly-linked list
|
||||
it uses as well as the type it holds.
|
||||
|
||||
The double templating allows for the instantiation of forms with and
|
||||
The double templating allows for the instantiation of forms with or
|
||||
without storage management.
|
||||
|
||||
Note
|
||||
The IDLListType parameter should itself be a template but this confused
|
||||
gcc 2.95.2 so it has to be instantiated for T when an intantiation of
|
||||
gcc 2.95.2 so it has to be instantiated for T when an instantiation of
|
||||
DictionaryBase is requested
|
||||
|
||||
See Also
|
||||
@ -67,7 +67,7 @@ Ostream& operator<<(Ostream&, const DictionaryBase<IDLListType, T>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DictionaryBase Declaration
|
||||
Class DictionaryBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class IDLListType, class T>
|
||||
@ -77,7 +77,7 @@ class DictionaryBase
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- HashTable of the enries held on the DL-list for quick lookup
|
||||
//- HashTable of the entries held on the IDLListType for quick lookup
|
||||
HashTable<T*> hashedTs_;
|
||||
|
||||
|
||||
@ -99,10 +99,10 @@ public:
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
DictionaryBase(Istream& is, const INew& inewt);
|
||||
DictionaryBase(Istream&, const INew&);
|
||||
|
||||
//- Construct from Istream
|
||||
DictionaryBase(Istream& is);
|
||||
//- Construct from Istream using default Istream constructor class
|
||||
DictionaryBase(Istream&);
|
||||
|
||||
|
||||
// Member functions
|
||||
@ -110,7 +110,13 @@ public:
|
||||
// Search and lookup
|
||||
|
||||
//- Search DictionaryBase for given keyword
|
||||
bool found(const word& keyword) const;
|
||||
bool found(const word&) const;
|
||||
|
||||
//- Find and return an entry if present, otherwise return NULL
|
||||
const T* lookupPtr(const word&) const;
|
||||
|
||||
//- Find and return an entry if present, otherwise return NULL
|
||||
T* lookupPtr(const word&);
|
||||
|
||||
//- Find and return entry
|
||||
const T* lookup(const word&) const;
|
||||
@ -125,17 +131,21 @@ public:
|
||||
// Editing
|
||||
|
||||
//- Add at head of dictionary
|
||||
void insert(const word& keyword, T*);
|
||||
void insert(const word&, T*);
|
||||
|
||||
//- Add at tail of dictionary
|
||||
void append(const word& keyword, T*);
|
||||
void append(const word&, T*);
|
||||
|
||||
//- Remove and return entry specified by keyword
|
||||
T* remove(const word& keyword);
|
||||
//- Remove and return entry specified by keyword.
|
||||
// Return NULL if the keyword was not found.
|
||||
T* remove(const word&);
|
||||
|
||||
//- Clear the dictionary
|
||||
void clear();
|
||||
|
||||
//- Transfer the contents of the argument into this DictionaryBase
|
||||
// and annull the argument.
|
||||
void transfer(DictionaryBase<IDLListType, T>&);
|
||||
|
||||
// Member operators
|
||||
|
||||
|
||||
@ -30,15 +30,13 @@ Description
|
||||
#include "DictionaryBase.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
|
||||
|
||||
template<class IDLListType, class T>
|
||||
Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict)
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DictionaryBase<IDLListType, T>& dict)
|
||||
{
|
||||
for
|
||||
(
|
||||
@ -53,7 +51,7 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict)
|
||||
if (!os.good())
|
||||
{
|
||||
Info
|
||||
<< "operator<<(Ostream& os, const DictionaryBase&) : "
|
||||
<< "operator<<(Ostream&, const DictionaryBase&) : "
|
||||
<< "Can't write entry for DictionaryBase"
|
||||
<< endl;
|
||||
|
||||
@ -67,6 +65,4 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,20 +26,15 @@ License
|
||||
|
||||
#include "PtrDictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
PtrDictionary<T>::PtrDictionary()
|
||||
Foam::PtrDictionary<T>::PtrDictionary()
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict)
|
||||
Foam::PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict)
|
||||
:
|
||||
DictionaryBase<DLPtrList<T>, T>(dict)
|
||||
{}
|
||||
@ -47,14 +42,14 @@ PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict)
|
||||
|
||||
template<class T>
|
||||
template<class INew>
|
||||
PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew)
|
||||
Foam::PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew)
|
||||
:
|
||||
DictionaryBase<DLPtrList<T>, T>(is, iNew)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
PtrDictionary<T>::PtrDictionary(Istream& is)
|
||||
Foam::PtrDictionary<T>::PtrDictionary(Istream& is)
|
||||
:
|
||||
DictionaryBase<DLPtrList<T>, T>(is)
|
||||
{}
|
||||
@ -62,6 +57,4 @@ PtrDictionary<T>::PtrDictionary(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,8 +27,10 @@ Class
|
||||
|
||||
Description
|
||||
Template dictionary class which does not manages the storage
|
||||
associated with it. It is derived from DictionaryBase instantiated on
|
||||
a non-memory managed form of intrusive doubly-linked list of T.
|
||||
associated with it.
|
||||
|
||||
It is derived from DictionaryBase instantiated on a non-memory managed
|
||||
form of intrusive doubly-linked list of T.
|
||||
|
||||
SourceFiles
|
||||
PtrDictionary.C
|
||||
@ -47,7 +49,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PtrDictionary Declaration
|
||||
Class PtrDictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
|
||||
@ -26,22 +26,15 @@ License
|
||||
|
||||
#include "UDictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
template<class T>
|
||||
UDictionary<T>::UDictionary()
|
||||
Foam::UDictionary<T>::UDictionary()
|
||||
{}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
template<class T>
|
||||
UDictionary<T>::UDictionary(const UDictionary& dict)
|
||||
Foam::UDictionary<T>::UDictionary(const UDictionary& dict)
|
||||
:
|
||||
DictionaryBase<UIDLList<T>, T>(dict)
|
||||
{}
|
||||
@ -49,6 +42,4 @@ UDictionary<T>::UDictionary(const UDictionary& dict)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -49,7 +49,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class UDictionary Declaration
|
||||
Class UDictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
|
||||
@ -26,22 +26,15 @@ License
|
||||
|
||||
#include "UPtrDictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
template<class T>
|
||||
UPtrDictionary<T>::UPtrDictionary()
|
||||
Foam::UPtrDictionary<T>::UPtrDictionary()
|
||||
{}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
template<class T>
|
||||
UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict)
|
||||
Foam::UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict)
|
||||
:
|
||||
DictionaryBase<DLList<T*>, T>(dict)
|
||||
{}
|
||||
@ -49,6 +42,4 @@ UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,8 +27,10 @@ Class
|
||||
|
||||
Description
|
||||
Template dictionary class which does not manages the storage
|
||||
associated with it. It is derived from DictionaryBase instantiated on
|
||||
a non-memory managed form of intrusive doubly-linked list of \<T\>.
|
||||
associated with it.
|
||||
|
||||
It is derived from DictionaryBase instantiated on a non-memory managed
|
||||
form of intrusive doubly-linked list of \<T\>.
|
||||
|
||||
SourceFiles
|
||||
UPtrDictionary.C
|
||||
@ -47,7 +49,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class UPtrDictionary Declaration
|
||||
Class UPtrDictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
|
||||
@ -456,6 +456,14 @@ void HashTable<T, Key, Hash>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void HashTable<T, Key, Hash>::clearStorage()
|
||||
{
|
||||
clear();
|
||||
resize(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht)
|
||||
{
|
||||
|
||||
@ -54,6 +54,7 @@ template<class T>
|
||||
class List;
|
||||
|
||||
template<class T, class Key, class Hash> class HashTable;
|
||||
template<class T, class Key, class Hash> class HashPtrTable;
|
||||
|
||||
template<class T, class Key, class Hash> Istream& operator>>
|
||||
(
|
||||
@ -102,7 +103,7 @@ class HashTable
|
||||
//- Construct given key, next pointer and object
|
||||
inline hashedEntry
|
||||
(
|
||||
const Key& key,
|
||||
const Key&,
|
||||
hashedEntry* next,
|
||||
const T& newEntry
|
||||
);
|
||||
@ -127,7 +128,7 @@ class HashTable
|
||||
// Private Member Functions
|
||||
|
||||
//- Assign a new hashedEntry to a possibly already existing key
|
||||
bool set(const Key& key, const T& newElmt, bool protect);
|
||||
bool set(const Key&, const T& newElmt, bool protect);
|
||||
|
||||
public:
|
||||
|
||||
@ -173,15 +174,15 @@ public:
|
||||
inline label size() const;
|
||||
|
||||
//- Return true if hashedEntry is found in table
|
||||
bool found(const Key& key) const;
|
||||
bool found(const Key&) const;
|
||||
|
||||
//- Find and return an iterator set at the hashedEntry
|
||||
// If not found iterator = end()
|
||||
iterator find(const Key& key);
|
||||
iterator find(const Key&);
|
||||
|
||||
//- Find and return an const_iterator set at the hashedEntry
|
||||
// If not found iterator = end()
|
||||
const_iterator find(const Key& key) const;
|
||||
const_iterator find(const Key&) const;
|
||||
|
||||
//- Return the table of contents
|
||||
List<Key> toc() const;
|
||||
@ -190,16 +191,16 @@ public:
|
||||
// Edit
|
||||
|
||||
//- Insert a new hashedEntry
|
||||
inline bool insert(const Key& key, const T& newElmt);
|
||||
inline bool insert(const Key&, const T& newElmt);
|
||||
|
||||
//- Assign a new hashedEntry, overwriting existing entries
|
||||
inline bool set(const Key& key, const T& newElmt);
|
||||
inline bool set(const Key&, const T& newElmt);
|
||||
|
||||
//- Erase an hashedEntry specified by given iterator
|
||||
bool erase(const iterator& it);
|
||||
bool erase(const iterator&);
|
||||
|
||||
//- Erase an hashedEntry specified by given key if in table
|
||||
bool erase(const Key& key);
|
||||
bool erase(const Key&);
|
||||
|
||||
//- Resize the hash table for efficiency
|
||||
void resize(const label newSize);
|
||||
@ -207,6 +208,10 @@ public:
|
||||
//- Clear all entries from table
|
||||
void clear();
|
||||
|
||||
//- Clear the table entries and the table itself.
|
||||
// Equivalent to clear() followed by resize(0)
|
||||
void clearStorage();
|
||||
|
||||
//- Transfer the contents of the argument table into this table
|
||||
// and annull the argument table.
|
||||
void transfer(HashTable<T, Key, Hash>&);
|
||||
@ -215,14 +220,14 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Find and return an hashedEntry
|
||||
inline T& operator[](const Key& key);
|
||||
inline T& operator[](const Key&);
|
||||
|
||||
//- Find and return an hashedEntry
|
||||
inline const T& operator[](const Key& key) const;
|
||||
inline const T& operator[](const Key&) const;
|
||||
|
||||
//- Find and return an hashedEntry and
|
||||
// if it is not present create it null.
|
||||
inline T& operator()(const Key& key);
|
||||
inline T& operator()(const Key&);
|
||||
|
||||
//- Assignment
|
||||
void operator=(const HashTable<T, Key, Hash>&);
|
||||
@ -290,13 +295,13 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const iterator& iter);
|
||||
inline void operator=(const iterator&);
|
||||
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
|
||||
inline T& operator*();
|
||||
inline T& operator()();
|
||||
@ -352,13 +357,13 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const const_iterator& iter);
|
||||
inline void operator=(const const_iterator&);
|
||||
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
|
||||
inline const T& operator*();
|
||||
inline const T& operator()();
|
||||
|
||||
@ -26,22 +26,17 @@ License
|
||||
|
||||
#include "ILList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl)
|
||||
Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst)
|
||||
:
|
||||
UILList<LListBase, T>()
|
||||
{
|
||||
for
|
||||
(
|
||||
typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
|
||||
iter != slpl.end();
|
||||
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -53,9 +48,9 @@ ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl)
|
||||
#ifndef __INTEL_COMPILER
|
||||
template<class LListBase, class T>
|
||||
template<class CloneArg>
|
||||
ILList<LListBase, T>::ILList
|
||||
Foam::ILList<LListBase, T>::ILList
|
||||
(
|
||||
const ILList<LListBase, T>& slpl,
|
||||
const ILList<LListBase, T>& lst,
|
||||
const CloneArg& cloneArg
|
||||
)
|
||||
:
|
||||
@ -63,8 +58,8 @@ ILList<LListBase, T>::ILList
|
||||
{
|
||||
for
|
||||
(
|
||||
typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
|
||||
iter != slpl.end();
|
||||
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -77,7 +72,7 @@ ILList<LListBase, T>::ILList
|
||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
ILList<LListBase, T>::~ILList()
|
||||
Foam::ILList<LListBase, T>::~ILList()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
@ -85,9 +80,8 @@ ILList<LListBase, T>::~ILList()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return and remove head
|
||||
template<class LListBase, class T>
|
||||
bool ILList<LListBase, T>::eraseHead()
|
||||
bool Foam::ILList<LListBase, T>::eraseHead()
|
||||
{
|
||||
T* tPtr;
|
||||
if ((tPtr = this->removeHead()))
|
||||
@ -101,9 +95,8 @@ bool ILList<LListBase, T>::eraseHead()
|
||||
}
|
||||
}
|
||||
|
||||
//- Return and remove element
|
||||
template<class LListBase, class T>
|
||||
bool ILList<LListBase, T>::erase(T* p)
|
||||
bool Foam::ILList<LListBase, T>::erase(T* p)
|
||||
{
|
||||
T* tPtr;
|
||||
if ((tPtr = remove(p)))
|
||||
@ -119,7 +112,7 @@ bool ILList<LListBase, T>::erase(T* p)
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
void ILList<LListBase, T>::clear()
|
||||
void Foam::ILList<LListBase, T>::clear()
|
||||
{
|
||||
label oldSize = this->size();
|
||||
for (label i=0; i<oldSize; i++)
|
||||
@ -131,17 +124,25 @@ void ILList<LListBase, T>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst)
|
||||
{
|
||||
clear();
|
||||
LListBase::transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl)
|
||||
void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst)
|
||||
{
|
||||
this->clear();
|
||||
|
||||
for
|
||||
(
|
||||
typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
|
||||
iter != slpl.end();
|
||||
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -149,11 +150,6 @@ void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "ILListIO.C"
|
||||
|
||||
@ -71,7 +71,7 @@ class ILList
|
||||
|
||||
//- Read from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
void read(Istream&, const INew& inewt);
|
||||
void read(Istream&, const INew&);
|
||||
|
||||
|
||||
public:
|
||||
@ -96,7 +96,7 @@ public:
|
||||
|
||||
//- Copy constructor with additional argument for clone
|
||||
template<class CloneArg>
|
||||
ILList(const ILList<LListBase, T>& slpl, const CloneArg& cloneArg)
|
||||
ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg)
|
||||
#ifdef __INTEL_COMPILER
|
||||
:
|
||||
UILList<LListBase, T>()
|
||||
@ -104,8 +104,8 @@ public:
|
||||
for
|
||||
(
|
||||
typename UILList<LListBase, T>::const_iterator iter =
|
||||
slpl.begin();
|
||||
iter != slpl.end();
|
||||
lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -118,7 +118,7 @@ public:
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
ILList(Istream&, const INew& inewt);
|
||||
ILList(Istream&, const INew&);
|
||||
|
||||
|
||||
// Destructor
|
||||
@ -139,6 +139,10 @@ public:
|
||||
//- Clear the contents of the list
|
||||
void clear();
|
||||
|
||||
//- Transfer the contents of the argument into this List
|
||||
// and annull the argument list.
|
||||
void transfer(ILList<LListBase, T>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
|
||||
@ -30,24 +30,19 @@ Description
|
||||
#include "Istream.H"
|
||||
#include "INew.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
template<class INew>
|
||||
void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
|
||||
{
|
||||
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
|
||||
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
|
||||
|
||||
token firstToken(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream& is, ILList<LListBase, T>& L) : reading first token"
|
||||
"operator>>(Istream&, ILList<LListBase, T>&) : reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
@ -63,26 +58,26 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
{
|
||||
append(inewt(is).ptr());
|
||||
|
||||
append(iNew(is).ptr());
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream& is, ILList<LListBase, T>& L) : "
|
||||
"operator>>(Istream&, ILList<LListBase, T>&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T* tPtr = inewt(is).ptr();
|
||||
T* tPtr = iNew(is).ptr();
|
||||
append(tPtr);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream& is, ILList<LListBase, T>& L) : "
|
||||
"operator>>(Istream&, ILList<LListBase, T>&) : "
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
|
||||
for (label i=1; i<s; i++)
|
||||
{
|
||||
append(new T(*tPtr));
|
||||
@ -99,14 +94,14 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"operator>>(Istream& is, ILList<LListBase, T>& L)",
|
||||
"operator>>(Istream&, ILList<LListBase, T>&)",
|
||||
is
|
||||
) << "incorrect first token, '(', found " << firstToken.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
token lastToken(is);
|
||||
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
|
||||
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
|
||||
|
||||
while
|
||||
(
|
||||
@ -117,36 +112,34 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
)
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
append(inewt(is).ptr());
|
||||
append(iNew(is).ptr());
|
||||
|
||||
is >> lastToken;
|
||||
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
|
||||
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn("operator>>(Istream& is, ILList<LListBase, T>& L)", is)
|
||||
FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
|
||||
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
|
||||
}
|
||||
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class LListBase, class T>
|
||||
template<class INew>
|
||||
ILList<LListBase, T>::ILList(Istream& is, const INew& inewt)
|
||||
Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew)
|
||||
{
|
||||
read(is, inewt);
|
||||
read(is, iNew);
|
||||
}
|
||||
|
||||
|
||||
// Construct from Istream
|
||||
template<class LListBase, class T>
|
||||
ILList<LListBase, T>::ILList(Istream& is)
|
||||
Foam::ILList<LListBase, T>::ILList(Istream& is)
|
||||
{
|
||||
read(is, INew<T>());
|
||||
}
|
||||
@ -155,7 +148,7 @@ ILList<LListBase, T>::ILList(Istream& is)
|
||||
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Istream& operator>>(Istream& is, ILList<LListBase, T>& L)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L)
|
||||
{
|
||||
L.clear();
|
||||
L.read(is, INew<T>());
|
||||
@ -166,6 +159,4 @@ Istream& operator>>(Istream& is, ILList<LListBase, T>& L)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,22 +27,16 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "LList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
LList<LListBase, T>::LList(const LList<LListBase, T>& slpl)
|
||||
Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst)
|
||||
:
|
||||
LListBase()
|
||||
{
|
||||
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
|
||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
||||
{
|
||||
append(iter());
|
||||
}
|
||||
@ -50,7 +44,7 @@ LList<LListBase, T>::LList(const LList<LListBase, T>& slpl)
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
LList<LListBase, T>::~LList()
|
||||
Foam::LList<LListBase, T>::~LList()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
@ -59,7 +53,7 @@ LList<LListBase, T>::~LList()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
void LList<LListBase, T>::clear()
|
||||
void Foam::LList<LListBase, T>::clear()
|
||||
{
|
||||
label oldSize = this->size();
|
||||
for (label i=0; i<oldSize; i++)
|
||||
@ -71,24 +65,28 @@ void LList<LListBase, T>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
void Foam::LList<LListBase, T>::transfer(LList<LListBase, T>& lst)
|
||||
{
|
||||
clear();
|
||||
LListBase::transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
void LList<LListBase, T>::operator=(const LList<LListBase, T>& slpl)
|
||||
void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst)
|
||||
{
|
||||
this->clear();
|
||||
|
||||
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
|
||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
||||
{
|
||||
append(iter());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "LListIO.C"
|
||||
|
||||
@ -67,7 +67,7 @@ Ostream& operator<<
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class LList Declaration
|
||||
Class LList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class LListBase, class T>
|
||||
@ -200,6 +200,9 @@ public:
|
||||
//- Delete contents of list
|
||||
void clear();
|
||||
|
||||
//- Transfer the contents of the argument into this List
|
||||
// and annull the argument list.
|
||||
void transfer(LList<LListBase, T>&);
|
||||
|
||||
// Member operators
|
||||
|
||||
|
||||
@ -30,16 +30,10 @@ Description
|
||||
#include "Istream.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from Istream
|
||||
template<class LListBase, class T>
|
||||
LList<LListBase, T>::LList(Istream& is)
|
||||
Foam::LList<LListBase, T>::LList(Istream& is)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
}
|
||||
@ -48,18 +42,18 @@ LList<LListBase, T>::LList(Istream& is)
|
||||
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Istream& operator>>(Istream& is, LList<LListBase, T>& L)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
|
||||
{
|
||||
// Anull list
|
||||
L.clear();
|
||||
|
||||
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
|
||||
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
|
||||
|
||||
token firstToken(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
" operator>>(Istream& is, LList<LListBase, T>& L) : reading first token"
|
||||
" operator>>(Istream&, LList<LListBase, T>&) : reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
@ -101,14 +95,14 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
" operator>>(Istream& is, LList<LListBase, T>& L)",
|
||||
" operator>>(Istream&, LList<LListBase, T>&)",
|
||||
is
|
||||
) << "incorrect first token, '(', found " << firstToken.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
token lastToken(is);
|
||||
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
|
||||
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
|
||||
|
||||
while
|
||||
(
|
||||
@ -124,19 +118,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L)
|
||||
L.append(element);
|
||||
|
||||
is >> lastToken;
|
||||
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
|
||||
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn(" operator>>(Istream& is, LList<LListBase, T>& L)", is)
|
||||
FatalIOErrorIn(" operator>>(Istream&, LList<LListBase, T>&)", is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
|
||||
is.fatalCheck(" operator>>(Istream&, LList<LListBase,>&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
@ -145,19 +139,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L)
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst)
|
||||
{
|
||||
// Write size of LList
|
||||
os << nl << ll.size();
|
||||
// Write size
|
||||
os << nl << lst.size();
|
||||
|
||||
// Write beginning of contents
|
||||
os << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Write LList contents
|
||||
// Write contents
|
||||
for
|
||||
(
|
||||
typename LList<LListBase, T>::const_iterator iter = ll.begin();
|
||||
iter != ll.end();
|
||||
typename LList<LListBase, T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -168,14 +162,10 @@ Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll)
|
||||
os << token::END_LIST;
|
||||
|
||||
// Check state of IOstream
|
||||
os.check("Ostream& operator<<(Ostream&, const LList&)");
|
||||
os.check("Ostream& operator<<(Ostream&, const LList<LListBase, T>&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,19 +26,14 @@ License
|
||||
|
||||
#include "LPtrList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl)
|
||||
Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
|
||||
:
|
||||
LList<LListBase, T*>()
|
||||
{
|
||||
for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
|
||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
||||
{
|
||||
append(iter().clone().ptr());
|
||||
}
|
||||
@ -48,7 +43,7 @@ LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
LPtrList<LListBase, T>::~LPtrList()
|
||||
Foam::LPtrList<LListBase, T>::~LPtrList()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
@ -56,9 +51,8 @@ LPtrList<LListBase, T>::~LPtrList()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Return and remove head
|
||||
template<class LListBase, class T>
|
||||
bool LPtrList<LListBase, T>::eraseHead()
|
||||
bool Foam::LPtrList<LListBase, T>::eraseHead()
|
||||
{
|
||||
T* tPtr;
|
||||
if ((tPtr = this->removeHead()))
|
||||
@ -74,7 +68,7 @@ bool LPtrList<LListBase, T>::eraseHead()
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
void LPtrList<LListBase, T>::clear()
|
||||
void Foam::LPtrList<LListBase, T>::clear()
|
||||
{
|
||||
label oldSize = this->size();
|
||||
for (label i=0; i<oldSize; i++)
|
||||
@ -86,24 +80,28 @@ void LPtrList<LListBase, T>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
void Foam::LPtrList<LListBase, T>::transfer(LPtrList<LListBase, T>& lst)
|
||||
{
|
||||
clear();
|
||||
LList<LListBase, T*>::transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& slpl)
|
||||
void Foam::LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst)
|
||||
{
|
||||
clear();
|
||||
|
||||
for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
|
||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
||||
{
|
||||
append(iter().clone().ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "LPtrListIO.C"
|
||||
|
||||
@ -149,12 +149,16 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Remove the head element specified from the list and delete it
|
||||
//- Remove the head element from the list and delete the pointer
|
||||
bool eraseHead();
|
||||
|
||||
//- Remove the specified element from the list and delete it
|
||||
//- Clear the contents of the list
|
||||
void clear();
|
||||
|
||||
//- Transfer the contents of the argument into this List
|
||||
// and annull the argument list.
|
||||
void transfer(LPtrList<LListBase, T>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
|
||||
@ -29,16 +29,11 @@ License
|
||||
#include "Ostream.H"
|
||||
#include "INew.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
template<class INew>
|
||||
void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
|
||||
{
|
||||
is.fatalCheck
|
||||
(
|
||||
@ -66,8 +61,8 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
{
|
||||
append(inewt(is).ptr());
|
||||
|
||||
append(iNew(is).ptr());
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"LPtrList<LListBase, T>::read(Istream&, const INew&) : "
|
||||
@ -77,7 +72,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
}
|
||||
else
|
||||
{
|
||||
T* tPtr = inewt(is).ptr();
|
||||
T* tPtr = iNew(is).ptr();
|
||||
append(tPtr);
|
||||
|
||||
is.fatalCheck
|
||||
@ -85,7 +80,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
"LPtrList<LListBase, T>::read(Istream&, const INew&) : "
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
|
||||
for (label i=1; i<s; i++)
|
||||
{
|
||||
append(tPtr->clone().ptr());
|
||||
@ -120,7 +115,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
)
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
append(inewt(is).ptr());
|
||||
append(iNew(is).ptr());
|
||||
|
||||
is >> lastToken;
|
||||
is.fatalCheck
|
||||
@ -148,14 +143,14 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
|
||||
|
||||
template<class LListBase, class T>
|
||||
template<class INew>
|
||||
LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& inewt)
|
||||
Foam::LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& iNew)
|
||||
{
|
||||
read(is, inewt);
|
||||
read(is, iNew);
|
||||
}
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
LPtrList<LListBase, T>::LPtrList(Istream& is)
|
||||
Foam::LPtrList<LListBase, T>::LPtrList(Istream& is)
|
||||
{
|
||||
read(is, INew<T>());
|
||||
}
|
||||
@ -164,11 +159,10 @@ LPtrList<LListBase, T>::LPtrList(Istream& is)
|
||||
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& L)
|
||||
{
|
||||
// Anull list
|
||||
L.clear();
|
||||
|
||||
L.read(is, INew<T>());
|
||||
|
||||
return is;
|
||||
}
|
||||
@ -177,19 +171,19 @@ Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L)
|
||||
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList<LListBase, T>& lst)
|
||||
{
|
||||
// Write size of LPtrList
|
||||
os << nl << slpl.size();
|
||||
// Write size
|
||||
os << nl << lst.size();
|
||||
|
||||
// Write beginning of contents
|
||||
os << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Write LPtrList contents
|
||||
// Write contents
|
||||
for
|
||||
(
|
||||
typename LPtrList<LListBase, T>::const_iterator iter = slpl.begin();
|
||||
iter != slpl.end();
|
||||
typename LPtrList<LListBase, T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -200,14 +194,9 @@ Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl)
|
||||
os << token::END_LIST;
|
||||
|
||||
// Check state of IOstream
|
||||
os.check("Ostream& operator<<(Ostream&, const LPtrList&)");
|
||||
os.check("Ostream& operator<<(Ostream&, const LPtrList<LListBase, T>&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,17 +28,12 @@ Description
|
||||
|
||||
#include "UILList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl)
|
||||
Foam::UILList<LListBase, T>::UILList(const UILList<LListBase, T>& lst)
|
||||
{
|
||||
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
|
||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
||||
{
|
||||
append(&iter());
|
||||
}
|
||||
@ -48,22 +43,24 @@ UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl)
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
void UILList<LListBase, T>::operator=(const UILList<LListBase, T>& slpl)
|
||||
void Foam::UILList<LListBase, T>::operator=(const UILList<LListBase, T>& rhs)
|
||||
{
|
||||
LListBase::clear();
|
||||
|
||||
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
{
|
||||
append(&iter());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Comparison for equality
|
||||
template<class LListBase, class T>
|
||||
bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const
|
||||
bool Foam::UILList<LListBase, T>::operator==
|
||||
(
|
||||
const UILList<LListBase, T>& rhs
|
||||
) const
|
||||
{
|
||||
if (this->size() != slpl.size())
|
||||
if (this->size() != rhs.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -71,7 +68,7 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const
|
||||
bool equal = true;
|
||||
|
||||
const_iterator iter1 = this->begin();
|
||||
const_iterator iter2 = slpl.begin();
|
||||
const_iterator iter2 = rhs.begin();
|
||||
|
||||
for (; iter1 != this->end(); ++iter1, ++iter2)
|
||||
{
|
||||
@ -84,16 +81,15 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const
|
||||
|
||||
// Comparison for inequality
|
||||
template<class LListBase, class T>
|
||||
bool UILList<LListBase, T>::operator!=(const UILList<LListBase, T>& slpl) const
|
||||
bool Foam::UILList<LListBase, T>::operator!=
|
||||
(
|
||||
const UILList<LListBase, T>& rhs
|
||||
) const
|
||||
{
|
||||
return !operator==(slpl);
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "UILListIO.C"
|
||||
|
||||
@ -245,7 +245,7 @@ public:
|
||||
|
||||
const T& operator*()
|
||||
{
|
||||
return
|
||||
return
|
||||
static_cast<const T&>
|
||||
(LListBase_const_iterator::operator*());
|
||||
}
|
||||
@ -266,7 +266,7 @@ public:
|
||||
// STL member operators
|
||||
|
||||
//- Equality operation on ULists of the same type.
|
||||
// Returns true when the ULists are elementwise equal
|
||||
// Returns true when the ULists are element-wise equal
|
||||
// (using UList::value_type::operator==). Takes linear time.
|
||||
bool operator==(const UILList<LListBase, T>&) const;
|
||||
|
||||
|
||||
@ -30,27 +30,22 @@ Description
|
||||
#include "Ostream.H"
|
||||
#include "token.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const UILList<LListBase, T>& lst)
|
||||
{
|
||||
// Write size of UILList
|
||||
os << nl << ill.size();
|
||||
// Write size
|
||||
os << nl << lst.size();
|
||||
|
||||
// Write beginning of contents
|
||||
os << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Write UILList contents
|
||||
// Write contents
|
||||
for
|
||||
(
|
||||
typename UILList<LListBase, T>::const_iterator iter = ill.begin();
|
||||
iter != ill.end();
|
||||
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
|
||||
iter != lst.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
@ -61,14 +56,9 @@ Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill)
|
||||
os << token::END_LIST;
|
||||
|
||||
// Check state of IOstream
|
||||
os.check("Ostream& operator<<(Ostream&, const UILList&)");
|
||||
os.check("Ostream& operator<<(Ostream&, const UILList<LListBase, T>&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -32,17 +32,12 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
DLListBase::iterator DLListBase::endIter
|
||||
Foam::DLListBase::iterator Foam::DLListBase::endIter
|
||||
(
|
||||
const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase()))
|
||||
);
|
||||
|
||||
DLListBase::const_iterator DLListBase::endConstIter
|
||||
Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter
|
||||
(
|
||||
static_cast<const DLListBase&>(DLListBase()),
|
||||
reinterpret_cast<const link*>(NULL)
|
||||
@ -51,7 +46,7 @@ DLListBase::const_iterator DLListBase::endConstIter
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void DLListBase::insert(DLListBase::link* a)
|
||||
void Foam::DLListBase::insert(DLListBase::link* a)
|
||||
{
|
||||
nElmts_++;
|
||||
|
||||
@ -71,7 +66,7 @@ void DLListBase::insert(DLListBase::link* a)
|
||||
}
|
||||
|
||||
|
||||
void DLListBase::append(DLListBase::link* a)
|
||||
void Foam::DLListBase::append(DLListBase::link* a)
|
||||
{
|
||||
nElmts_++;
|
||||
|
||||
@ -91,7 +86,7 @@ void DLListBase::append(DLListBase::link* a)
|
||||
}
|
||||
|
||||
|
||||
bool DLListBase::swapUp(DLListBase::link* a)
|
||||
bool Foam::DLListBase::swapUp(DLListBase::link* a)
|
||||
{
|
||||
if (first_ != a)
|
||||
{
|
||||
@ -132,7 +127,7 @@ bool DLListBase::swapUp(DLListBase::link* a)
|
||||
}
|
||||
|
||||
|
||||
bool DLListBase::swapDown(DLListBase::link* a)
|
||||
bool Foam::DLListBase::swapDown(DLListBase::link* a)
|
||||
{
|
||||
if (last_ != a)
|
||||
{
|
||||
@ -173,7 +168,7 @@ bool DLListBase::swapDown(DLListBase::link* a)
|
||||
}
|
||||
|
||||
|
||||
DLListBase::link* DLListBase::removeHead()
|
||||
Foam::DLListBase::link* Foam::DLListBase::removeHead()
|
||||
{
|
||||
nElmts_--;
|
||||
|
||||
@ -197,7 +192,7 @@ DLListBase::link* DLListBase::removeHead()
|
||||
}
|
||||
|
||||
|
||||
DLListBase::link* DLListBase::remove(DLListBase::link* l)
|
||||
Foam::DLListBase::link* Foam::DLListBase::remove(DLListBase::link* l)
|
||||
{
|
||||
nElmts_--;
|
||||
|
||||
@ -229,7 +224,7 @@ DLListBase::link* DLListBase::remove(DLListBase::link* l)
|
||||
}
|
||||
|
||||
|
||||
DLListBase::link* DLListBase::replace
|
||||
Foam::DLListBase::link* Foam::DLListBase::replace
|
||||
(
|
||||
DLListBase::link* oldLink,
|
||||
DLListBase::link* newLink
|
||||
@ -266,8 +261,4 @@ DLListBase::link* DLListBase::replace
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -167,6 +167,9 @@ public:
|
||||
//- Clear the list
|
||||
inline void clear();
|
||||
|
||||
//- Transfer the contents of the argument into this List
|
||||
// and annull the argument list.
|
||||
inline void transfer(DLListBase&);
|
||||
|
||||
// STL iterator
|
||||
|
||||
|
||||
@ -26,21 +26,16 @@ License
|
||||
|
||||
#include "error.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
inline DLListBase::link::link()
|
||||
inline Foam::DLListBase::link::link()
|
||||
:
|
||||
prev_(0),
|
||||
next_(0)
|
||||
{}
|
||||
|
||||
|
||||
inline DLListBase::DLListBase()
|
||||
inline Foam::DLListBase::DLListBase()
|
||||
:
|
||||
first_(0),
|
||||
last_(0),
|
||||
@ -48,7 +43,7 @@ inline DLListBase::DLListBase()
|
||||
{}
|
||||
|
||||
|
||||
inline DLListBase::DLListBase(link* a)
|
||||
inline Foam::DLListBase::DLListBase(link* a)
|
||||
:
|
||||
first_(a),
|
||||
last_(a),
|
||||
@ -61,32 +56,33 @@ inline DLListBase::DLListBase(link* a)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
inline DLListBase::~DLListBase()
|
||||
inline Foam::DLListBase::~DLListBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline bool DLListBase::link::registered() const
|
||||
inline bool Foam::DLListBase::link::registered() const
|
||||
{
|
||||
return prev_ != 0 && next_ != 0;
|
||||
}
|
||||
|
||||
|
||||
inline void DLListBase::link::deregister()
|
||||
inline void Foam::DLListBase::link::deregister()
|
||||
{
|
||||
prev_ = 0;
|
||||
next_ = 0;
|
||||
}
|
||||
|
||||
|
||||
inline label DLListBase::size() const
|
||||
inline Foam::label Foam::DLListBase::size() const
|
||||
{
|
||||
return nElmts_;
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::link* DLListBase::first()
|
||||
inline Foam::DLListBase::link*
|
||||
Foam::DLListBase::first()
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -98,7 +94,8 @@ inline DLListBase::link* DLListBase::first()
|
||||
}
|
||||
|
||||
|
||||
inline const DLListBase::link* DLListBase::first() const
|
||||
inline const Foam::DLListBase::link*
|
||||
Foam::DLListBase::first() const
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -110,7 +107,8 @@ inline const DLListBase::link* DLListBase::first() const
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::link* DLListBase::last()
|
||||
inline Foam::DLListBase::link*
|
||||
Foam::DLListBase::last()
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -122,7 +120,8 @@ inline DLListBase::link* DLListBase::last()
|
||||
}
|
||||
|
||||
|
||||
inline const DLListBase::link* DLListBase::last() const
|
||||
inline const Foam::DLListBase::link*
|
||||
Foam::DLListBase::last() const
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -134,21 +133,36 @@ inline const DLListBase::link* DLListBase::last() const
|
||||
}
|
||||
|
||||
|
||||
inline void DLListBase::clear()
|
||||
inline void Foam::DLListBase::clear()
|
||||
{
|
||||
nElmts_ = 0;
|
||||
first_ = 0;
|
||||
last_ = 0;
|
||||
last_ = 0;
|
||||
nElmts_ = 0;
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::link* DLListBase::remove(DLListBase::iterator& it)
|
||||
inline void Foam::DLListBase::transfer(DLListBase& lst)
|
||||
{
|
||||
first_ = lst.first_;
|
||||
last_ = lst.last_;
|
||||
nElmts_ = lst.nElmts_;
|
||||
|
||||
lst.clear();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::DLListBase::link*
|
||||
Foam::DLListBase::remove
|
||||
(
|
||||
DLListBase::iterator& it
|
||||
)
|
||||
{
|
||||
return remove(it.curElmt_);
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::link* DLListBase::replace
|
||||
inline Foam::DLListBase::link*
|
||||
Foam::DLListBase::replace
|
||||
(
|
||||
DLListBase::iterator& oldIter,
|
||||
DLListBase::link* newLink
|
||||
@ -160,7 +174,7 @@ inline DLListBase::link* DLListBase::replace
|
||||
|
||||
// * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * //
|
||||
|
||||
inline DLListBase::iterator::iterator(DLListBase& s, link* elmt)
|
||||
inline Foam::DLListBase::iterator::iterator(DLListBase& s, link* elmt)
|
||||
:
|
||||
curList_(s),
|
||||
curElmt_(elmt),
|
||||
@ -168,7 +182,7 @@ inline DLListBase::iterator::iterator(DLListBase& s, link* elmt)
|
||||
{}
|
||||
|
||||
|
||||
inline DLListBase::iterator::iterator(DLListBase& s)
|
||||
inline Foam::DLListBase::iterator::iterator(DLListBase& s)
|
||||
:
|
||||
curList_(s),
|
||||
curElmt_(NULL),
|
||||
@ -176,32 +190,34 @@ inline DLListBase::iterator::iterator(DLListBase& s)
|
||||
{}
|
||||
|
||||
|
||||
inline void DLListBase::iterator::operator=(const iterator& iter)
|
||||
inline void Foam::DLListBase::iterator::operator=(const iterator& iter)
|
||||
{
|
||||
curElmt_ = iter.curElmt_;
|
||||
curLink_ = iter.curLink_;
|
||||
}
|
||||
|
||||
|
||||
inline bool DLListBase::iterator::operator==(const iterator& iter) const
|
||||
inline bool Foam::DLListBase::iterator::operator==(const iterator& iter) const
|
||||
{
|
||||
return curElmt_ == iter.curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline bool DLListBase::iterator::operator!=(const iterator& iter) const
|
||||
inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const
|
||||
{
|
||||
return curElmt_ != iter.curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::link& DLListBase::iterator::operator*()
|
||||
inline Foam::DLListBase::link&
|
||||
Foam::DLListBase::iterator::operator*()
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::iterator& DLListBase::iterator::operator++()
|
||||
inline Foam::DLListBase::iterator&
|
||||
Foam::DLListBase::iterator::operator++()
|
||||
{
|
||||
// Check if the curElmt_ is the last element (if it points to itself)
|
||||
// or if the list is empty because the last element may have been removed
|
||||
@ -219,7 +235,8 @@ inline DLListBase::iterator& DLListBase::iterator::operator++()
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::iterator DLListBase::iterator::operator++(int)
|
||||
inline Foam::DLListBase::iterator
|
||||
Foam::DLListBase::iterator::operator++(int)
|
||||
{
|
||||
iterator tmp = *this;
|
||||
++*this;
|
||||
@ -227,7 +244,8 @@ inline DLListBase::iterator DLListBase::iterator::operator++(int)
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::iterator DLListBase::begin()
|
||||
inline Foam::DLListBase::iterator
|
||||
Foam::DLListBase::begin()
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -240,7 +258,7 @@ inline DLListBase::iterator DLListBase::begin()
|
||||
}
|
||||
|
||||
|
||||
inline const DLListBase::iterator& DLListBase::end()
|
||||
inline const Foam::DLListBase::iterator& Foam::DLListBase::end()
|
||||
{
|
||||
return endIter;
|
||||
}
|
||||
@ -248,7 +266,7 @@ inline const DLListBase::iterator& DLListBase::end()
|
||||
|
||||
// * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * //
|
||||
|
||||
inline DLListBase::const_iterator::const_iterator
|
||||
inline Foam::DLListBase::const_iterator::const_iterator
|
||||
(
|
||||
const DLListBase& s,
|
||||
const link* elmt
|
||||
@ -259,20 +277,23 @@ inline DLListBase::const_iterator::const_iterator
|
||||
{}
|
||||
|
||||
|
||||
inline DLListBase::const_iterator::const_iterator(const iterator& iter)
|
||||
inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter)
|
||||
:
|
||||
curList_(iter.curList_),
|
||||
curElmt_(iter.curElmt_)
|
||||
{}
|
||||
|
||||
|
||||
inline void DLListBase::const_iterator::operator=(const const_iterator& iter)
|
||||
inline void Foam::DLListBase::const_iterator::operator=
|
||||
(
|
||||
const const_iterator& iter
|
||||
)
|
||||
{
|
||||
curElmt_ = iter.curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline bool DLListBase::const_iterator::operator==
|
||||
inline bool Foam::DLListBase::const_iterator::operator==
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
@ -281,7 +302,7 @@ inline bool DLListBase::const_iterator::operator==
|
||||
}
|
||||
|
||||
|
||||
inline bool DLListBase::const_iterator::operator!=
|
||||
inline bool Foam::DLListBase::const_iterator::operator!=
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
@ -290,13 +311,15 @@ inline bool DLListBase::const_iterator::operator!=
|
||||
}
|
||||
|
||||
|
||||
inline const DLListBase::link& DLListBase::const_iterator::operator*()
|
||||
inline const Foam::DLListBase::link&
|
||||
Foam::DLListBase::const_iterator::operator*()
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::const_iterator& DLListBase::const_iterator::operator++()
|
||||
inline Foam::DLListBase::const_iterator&
|
||||
Foam::DLListBase::const_iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.last_)
|
||||
{
|
||||
@ -311,7 +334,8 @@ inline DLListBase::const_iterator& DLListBase::const_iterator::operator++()
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int)
|
||||
inline Foam::DLListBase::const_iterator
|
||||
Foam::DLListBase::const_iterator::operator++(int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
++*this;
|
||||
@ -319,7 +343,8 @@ inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int)
|
||||
}
|
||||
|
||||
|
||||
inline DLListBase::const_iterator DLListBase::begin() const
|
||||
inline Foam::DLListBase::const_iterator
|
||||
Foam::DLListBase::begin() const
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -332,14 +357,11 @@ inline DLListBase::const_iterator DLListBase::begin() const
|
||||
}
|
||||
|
||||
|
||||
inline const DLListBase::const_iterator& DLListBase::end() const
|
||||
inline const Foam::DLListBase::const_iterator&
|
||||
Foam::DLListBase::end() const
|
||||
{
|
||||
return endConstIter;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -25,22 +25,16 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "SLListBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
SLListBase::iterator SLListBase::endIter
|
||||
Foam::SLListBase::iterator Foam::SLListBase::endIter
|
||||
(
|
||||
const_cast<SLListBase&>(static_cast<const SLListBase&>(SLListBase()))
|
||||
);
|
||||
|
||||
SLListBase::const_iterator SLListBase::endConstIter
|
||||
Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter
|
||||
(
|
||||
static_cast<const SLListBase&>(SLListBase()),
|
||||
reinterpret_cast<const link*>(NULL)
|
||||
@ -49,7 +43,7 @@ SLListBase::const_iterator SLListBase::endConstIter
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void SLListBase::insert(SLListBase::link* a)
|
||||
void Foam::SLListBase::insert(SLListBase::link* a)
|
||||
{
|
||||
nElmts_++;
|
||||
|
||||
@ -66,7 +60,7 @@ void SLListBase::insert(SLListBase::link* a)
|
||||
}
|
||||
|
||||
|
||||
void SLListBase::append(SLListBase::link* a)
|
||||
void Foam::SLListBase::append(SLListBase::link* a)
|
||||
{
|
||||
nElmts_++;
|
||||
|
||||
@ -82,7 +76,7 @@ void SLListBase::append(SLListBase::link* a)
|
||||
}
|
||||
|
||||
|
||||
SLListBase::link* SLListBase::removeHead()
|
||||
Foam::SLListBase::link* Foam::SLListBase::removeHead()
|
||||
{
|
||||
nElmts_--;
|
||||
|
||||
@ -108,7 +102,7 @@ SLListBase::link* SLListBase::removeHead()
|
||||
}
|
||||
|
||||
|
||||
SLListBase::link* SLListBase::remove(SLListBase::link* it)
|
||||
Foam::SLListBase::link* Foam::SLListBase::remove(SLListBase::link* it)
|
||||
{
|
||||
SLListBase::iterator iter = begin();
|
||||
SLListBase::link *prev = &(*iter);
|
||||
@ -143,8 +137,4 @@ SLListBase::link* SLListBase::remove(SLListBase::link* it)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -152,6 +152,9 @@ public:
|
||||
//- Clear the list
|
||||
inline void clear();
|
||||
|
||||
//- Transfer the contents of the argument into this List
|
||||
// and annull the argument list.
|
||||
inline void transfer(SLListBase&);
|
||||
|
||||
// STL iterator
|
||||
|
||||
|
||||
@ -29,33 +29,28 @@ Description
|
||||
|
||||
#include "error.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
inline SLListBase::link::link()
|
||||
inline Foam::SLListBase::link::link()
|
||||
:
|
||||
next_(0)
|
||||
{}
|
||||
|
||||
|
||||
inline SLListBase::link::link(link* p)
|
||||
inline Foam::SLListBase::link::link(link* p)
|
||||
:
|
||||
next_(p)
|
||||
{}
|
||||
|
||||
|
||||
inline SLListBase::SLListBase()
|
||||
inline Foam::SLListBase::SLListBase()
|
||||
:
|
||||
last_(0),
|
||||
nElmts_(0)
|
||||
{}
|
||||
|
||||
|
||||
inline SLListBase::SLListBase(link* a)
|
||||
inline Foam::SLListBase::SLListBase(link* a)
|
||||
:
|
||||
last_(a->next_ = a),
|
||||
nElmts_(1)
|
||||
@ -64,19 +59,20 @@ inline SLListBase::SLListBase(link* a)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
inline SLListBase::~SLListBase()
|
||||
inline Foam::SLListBase::~SLListBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline label SLListBase::size() const
|
||||
inline Foam::label Foam::SLListBase::size() const
|
||||
{
|
||||
return nElmts_;
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::link* SLListBase::first()
|
||||
inline Foam::SLListBase::link*
|
||||
Foam::SLListBase::first()
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -88,7 +84,8 @@ inline SLListBase::link* SLListBase::first()
|
||||
}
|
||||
|
||||
|
||||
inline const SLListBase::link* SLListBase::first() const
|
||||
inline const Foam::SLListBase::link*
|
||||
Foam::SLListBase::first() const
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -100,7 +97,8 @@ inline const SLListBase::link* SLListBase::first() const
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::link* SLListBase::last()
|
||||
inline Foam::SLListBase::link*
|
||||
Foam::SLListBase::last()
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -112,7 +110,8 @@ inline SLListBase::link* SLListBase::last()
|
||||
}
|
||||
|
||||
|
||||
inline const SLListBase::link* SLListBase::last() const
|
||||
inline const Foam::SLListBase::link*
|
||||
Foam::SLListBase::last() const
|
||||
{
|
||||
if (!nElmts_)
|
||||
{
|
||||
@ -124,14 +123,26 @@ inline const SLListBase::link* SLListBase::last() const
|
||||
}
|
||||
|
||||
|
||||
inline void SLListBase::clear()
|
||||
inline void Foam::SLListBase::clear()
|
||||
{
|
||||
nElmts_ = 0;
|
||||
last_ = 0;
|
||||
nElmts_ = 0;
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it)
|
||||
inline void Foam::SLListBase::transfer(SLListBase& lst)
|
||||
{
|
||||
last_ = lst.last_;
|
||||
nElmts_ = lst.nElmts_;
|
||||
|
||||
lst.clear();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::SLListBase::link* Foam::SLListBase::remove
|
||||
(
|
||||
SLListBase::iterator& it
|
||||
)
|
||||
{
|
||||
return remove(it.curElmt_);
|
||||
}
|
||||
@ -139,7 +150,7 @@ inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it)
|
||||
|
||||
// * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * //
|
||||
|
||||
inline SLListBase::iterator::iterator(SLListBase& s, link* elmt)
|
||||
inline Foam::SLListBase::iterator::iterator(SLListBase& s, link* elmt)
|
||||
:
|
||||
curList_(s),
|
||||
curElmt_(elmt),
|
||||
@ -147,7 +158,7 @@ inline SLListBase::iterator::iterator(SLListBase& s, link* elmt)
|
||||
{}
|
||||
|
||||
|
||||
inline SLListBase::iterator::iterator(SLListBase& s)
|
||||
inline Foam::SLListBase::iterator::iterator(SLListBase& s)
|
||||
:
|
||||
curList_(s),
|
||||
curElmt_(NULL),
|
||||
@ -155,32 +166,32 @@ inline SLListBase::iterator::iterator(SLListBase& s)
|
||||
{}
|
||||
|
||||
|
||||
inline void SLListBase::iterator::operator=(const iterator& iter)
|
||||
inline void Foam::SLListBase::iterator::operator=(const iterator& iter)
|
||||
{
|
||||
curElmt_ = iter.curElmt_;
|
||||
curLink_ = iter.curLink_;
|
||||
}
|
||||
|
||||
|
||||
inline bool SLListBase::iterator::operator==(const iterator& iter) const
|
||||
inline bool Foam::SLListBase::iterator::operator==(const iterator& iter) const
|
||||
{
|
||||
return curElmt_ == iter.curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline bool SLListBase::iterator::operator!=(const iterator& iter) const
|
||||
inline bool Foam::SLListBase::iterator::operator!=(const iterator& iter) const
|
||||
{
|
||||
return curElmt_ != iter.curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::link& SLListBase::iterator::operator*()
|
||||
inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*()
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::iterator& SLListBase::iterator::operator++()
|
||||
inline Foam::SLListBase::iterator& Foam::SLListBase::iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.last_ || curList_.last_ == 0)
|
||||
{
|
||||
@ -196,7 +207,8 @@ inline SLListBase::iterator& SLListBase::iterator::operator++()
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::iterator SLListBase::iterator::operator++(int)
|
||||
inline Foam::SLListBase::iterator
|
||||
Foam::SLListBase::iterator::operator++(int)
|
||||
{
|
||||
iterator tmp = *this;
|
||||
++*this;
|
||||
@ -204,7 +216,8 @@ inline SLListBase::iterator SLListBase::iterator::operator++(int)
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::iterator SLListBase::begin()
|
||||
inline Foam::SLListBase::iterator
|
||||
Foam::SLListBase::begin()
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -217,7 +230,8 @@ inline SLListBase::iterator SLListBase::begin()
|
||||
}
|
||||
|
||||
|
||||
inline const SLListBase::iterator& SLListBase::end()
|
||||
inline const Foam::SLListBase::iterator&
|
||||
Foam::SLListBase::end()
|
||||
{
|
||||
return endIter;
|
||||
}
|
||||
@ -225,7 +239,7 @@ inline const SLListBase::iterator& SLListBase::end()
|
||||
|
||||
// * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * //
|
||||
|
||||
inline SLListBase::const_iterator::const_iterator
|
||||
inline Foam::SLListBase::const_iterator::const_iterator
|
||||
(
|
||||
const SLListBase& s,
|
||||
const link* elmt
|
||||
@ -236,20 +250,23 @@ inline SLListBase::const_iterator::const_iterator
|
||||
{}
|
||||
|
||||
|
||||
inline SLListBase::const_iterator::const_iterator(const iterator& iter)
|
||||
inline Foam::SLListBase::const_iterator::const_iterator(const iterator& iter)
|
||||
:
|
||||
curList_(iter.curList_),
|
||||
curElmt_(iter.curElmt_)
|
||||
{}
|
||||
|
||||
|
||||
inline void SLListBase::const_iterator::operator=(const const_iterator& iter)
|
||||
inline void Foam::SLListBase::const_iterator::operator=
|
||||
(
|
||||
const const_iterator& iter
|
||||
)
|
||||
{
|
||||
curElmt_ = iter.curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline bool SLListBase::const_iterator::operator==
|
||||
inline bool Foam::SLListBase::const_iterator::operator==
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
@ -258,7 +275,7 @@ inline bool SLListBase::const_iterator::operator==
|
||||
}
|
||||
|
||||
|
||||
inline bool SLListBase::const_iterator::operator!=
|
||||
inline bool Foam::SLListBase::const_iterator::operator!=
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
@ -267,13 +284,15 @@ inline bool SLListBase::const_iterator::operator!=
|
||||
}
|
||||
|
||||
|
||||
inline const SLListBase::link& SLListBase::const_iterator::operator*()
|
||||
inline const Foam::SLListBase::link&
|
||||
Foam::SLListBase::const_iterator::operator*()
|
||||
{
|
||||
return *curElmt_;
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::const_iterator& SLListBase::const_iterator::operator++()
|
||||
inline Foam::SLListBase::const_iterator&
|
||||
Foam::SLListBase::const_iterator::operator++()
|
||||
{
|
||||
if (curElmt_ == curList_.last_)
|
||||
{
|
||||
@ -288,7 +307,8 @@ inline SLListBase::const_iterator& SLListBase::const_iterator::operator++()
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int)
|
||||
inline Foam::SLListBase::const_iterator
|
||||
Foam::SLListBase::const_iterator::operator++(int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
++*this;
|
||||
@ -296,7 +316,8 @@ inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int)
|
||||
}
|
||||
|
||||
|
||||
inline SLListBase::const_iterator SLListBase::begin() const
|
||||
inline Foam::SLListBase::const_iterator
|
||||
Foam::SLListBase::begin() const
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -309,14 +330,11 @@ inline SLListBase::const_iterator SLListBase::begin() const
|
||||
}
|
||||
|
||||
|
||||
inline const SLListBase::const_iterator& SLListBase::end() const
|
||||
inline const Foam::SLListBase::const_iterator&
|
||||
Foam::SLListBase::end() const
|
||||
{
|
||||
return endConstIter;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -31,13 +31,22 @@ License
|
||||
template<class Stream>
|
||||
inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
|
||||
{
|
||||
static bool spacesSet = false;
|
||||
static bool spacesSet(false);
|
||||
static char spaces[40];
|
||||
|
||||
if (!spacesSet)
|
||||
{
|
||||
memset(spaces, ' ', 40);
|
||||
spaces[38 - strlen(Foam::FOAMversion)] = '\0';
|
||||
|
||||
size_t len = strlen(Foam::FOAMversion);
|
||||
if (len < 38)
|
||||
{
|
||||
spaces[38 - len] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
spaces[0] = '\0';
|
||||
}
|
||||
spacesSet = true;
|
||||
}
|
||||
|
||||
@ -56,8 +65,8 @@ inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
|
||||
"| ========= | |\n"
|
||||
"| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n"
|
||||
"| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n"
|
||||
"| \\\\ / A nd | Web: http://www.OpenFOAM.org |\n"
|
||||
"| \\\\/ M anipulation | |\n"
|
||||
"| \\\\ / A nd | |\n"
|
||||
"| \\\\/ M anipulation | www.OpenFOAM.org |\n"
|
||||
"\\*---------------------------------------------------------------------------*/\n";
|
||||
}
|
||||
|
||||
|
||||
@ -32,22 +32,22 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Write keyType
|
||||
Foam::Ostream& Foam::Ostream::write(const keyType& s)
|
||||
// Write keyType
|
||||
Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
||||
{
|
||||
// Write as word?
|
||||
if (s.isWildCard())
|
||||
// Write as word or string
|
||||
if (kw.isPattern())
|
||||
{
|
||||
return write(static_cast<const string&>(s));
|
||||
return write(static_cast<const string&>(kw));
|
||||
}
|
||||
else
|
||||
{
|
||||
return write(static_cast<const word&>(s));
|
||||
return write(static_cast<const word&>(kw));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Decrememt the indent level
|
||||
// Decrement the indent level
|
||||
void Foam::Ostream::decrIndent()
|
||||
{
|
||||
if (indentLevel_ == 0)
|
||||
@ -62,15 +62,26 @@ void Foam::Ostream::decrIndent()
|
||||
}
|
||||
|
||||
|
||||
// Write the keyword to the Ostream followed by appropriate indentation
|
||||
Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::keyType& keyword)
|
||||
// Write the keyword followed by appropriate indentation
|
||||
Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
||||
{
|
||||
indent();
|
||||
write(keyword);
|
||||
write(kw);
|
||||
|
||||
label nSpaces = max(entryIndentation_ - label(keyword.size()), 1);
|
||||
label nSpaces = entryIndentation_ - label(kw.size());
|
||||
|
||||
for (label i=0; i<nSpaces; i++)
|
||||
// pattern is surrounded by quotes
|
||||
if (kw.isPattern())
|
||||
{
|
||||
nSpaces -= 2;
|
||||
}
|
||||
|
||||
if (nSpaces < 1)
|
||||
{
|
||||
nSpaces = 1;
|
||||
}
|
||||
|
||||
while (nSpaces--)
|
||||
{
|
||||
write(char(token::SPACE));
|
||||
}
|
||||
|
||||
@ -60,12 +60,11 @@ protected:
|
||||
//- Number of spaces per indent level
|
||||
static const unsigned short indentSize_ = 4;
|
||||
|
||||
//- Current indent level
|
||||
unsigned short indentLevel_;
|
||||
|
||||
//- Indentation of the entry from the start of the keyword
|
||||
static const unsigned short entryIndentation_ = 16;
|
||||
|
||||
//- Current indent level
|
||||
unsigned short indentLevel_;
|
||||
|
||||
public:
|
||||
|
||||
@ -148,9 +147,8 @@ public:
|
||||
//- Decrememt the indent level
|
||||
void decrIndent();
|
||||
|
||||
//- Write the keyword to the Ostream followed by
|
||||
// appropriate indentation
|
||||
Ostream& writeKeyword(const keyType& keyword);
|
||||
//- Write the keyword followed by an appropriate indentation
|
||||
Ostream& writeKeyword(const keyType&);
|
||||
|
||||
|
||||
// Stream state functions
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OPstream Declaration
|
||||
Class OPstream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OPstream
|
||||
@ -160,7 +160,7 @@ public:
|
||||
void flush()
|
||||
{}
|
||||
|
||||
//- Add '\n' and flush stream
|
||||
//- Add newline and flush stream
|
||||
void endl()
|
||||
{}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OSstream Declaration
|
||||
Class OSstream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OSstream
|
||||
@ -162,20 +162,20 @@ public:
|
||||
//- Flush stream
|
||||
virtual void flush();
|
||||
|
||||
//- Add '\n' and flush stream
|
||||
//- Add newline and flush stream
|
||||
virtual void endl();
|
||||
|
||||
//- Get width of output field
|
||||
virtual int width() const;
|
||||
|
||||
//- Set width of output field (and return old width)
|
||||
virtual int width(const int w);
|
||||
virtual int width(const int);
|
||||
|
||||
//- Get precision of output field
|
||||
virtual int precision() const;
|
||||
|
||||
//- Set precision of output field (and return old precision)
|
||||
virtual int precision(const int p);
|
||||
virtual int precision(const int);
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
@ -131,7 +131,7 @@ void Foam::timeSelector::addOptions
|
||||
argList::validOptions.insert("zeroTime", "");
|
||||
}
|
||||
argList::validOptions.insert("noZero", "");
|
||||
argList::validOptions.insert("time", "time");
|
||||
argList::validOptions.insert("time", "ranges");
|
||||
argList::validOptions.insert("latestTime", "");
|
||||
}
|
||||
|
||||
@ -167,28 +167,40 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
||||
}
|
||||
}
|
||||
|
||||
// determine latestTime selection (if any)
|
||||
// this must appear before the -time option processing
|
||||
label latestIdx = -1;
|
||||
if (args.options().found("latestTime"))
|
||||
{
|
||||
selectTimes = false;
|
||||
latestIdx = timeDirs.size() - 1;
|
||||
|
||||
// avoid false match on constant/
|
||||
if (latestIdx == constantIdx)
|
||||
{
|
||||
latestIdx = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.options().found("time"))
|
||||
{
|
||||
// can match 0/, but can never match constant/
|
||||
selectTimes = timeSelector
|
||||
(
|
||||
IStringStream(args.options()["time"])()
|
||||
).selected(timeDirs);
|
||||
}
|
||||
else if (args.options().found("latestTime"))
|
||||
{
|
||||
selectTimes = false;
|
||||
const label latestIdx = timeDirs.size() - 1;
|
||||
|
||||
// avoid false match on constant/ or 0/
|
||||
if (latestIdx != constantIdx && latestIdx != zeroIdx)
|
||||
{
|
||||
selectTimes[latestIdx] = true;
|
||||
}
|
||||
|
||||
// add in latestTime (if selected)
|
||||
if (latestIdx >= 0)
|
||||
{
|
||||
selectTimes[latestIdx] = true;
|
||||
}
|
||||
|
||||
// special treatment for constant/
|
||||
if (constantIdx >= 0)
|
||||
{
|
||||
// only add constant/ if specifically requested
|
||||
selectTimes[constantIdx] = args.options().found("constant");
|
||||
}
|
||||
|
||||
@ -197,10 +209,12 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
||||
{
|
||||
if (args.options().found("noZero"))
|
||||
{
|
||||
// exclude 0/ if specifically requested
|
||||
selectTimes[zeroIdx] = false;
|
||||
}
|
||||
else if (argList::validOptions.found("zeroTime"))
|
||||
{
|
||||
// with -zeroTime enabled, drop 0/ unless specifically requested
|
||||
selectTimes[zeroIdx] = args.options().found("zeroTime");
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,8 +60,9 @@ Description
|
||||
@endverbatim
|
||||
|
||||
The first argument avoids adding the @b -constant option. The second
|
||||
argument adds an additional @b -zeroTime option and prevents the @c 0/
|
||||
directory from being included in the default time range.
|
||||
argument adds an additional @b -zeroTime option and also prevents the
|
||||
@c 0/ directory from being included in the default time range and in the
|
||||
@b -latestTime selection.
|
||||
|
||||
SourceFiles
|
||||
timeSelector.C
|
||||
@ -121,14 +122,17 @@ public:
|
||||
//
|
||||
// @param constant
|
||||
// Add the @b -constant option to include the @c constant/ directory
|
||||
//
|
||||
// @param zeroTime
|
||||
// Additional to the @b -noZero option (explicitly exclude the
|
||||
// @c 0/ directory), add the @b -zeroTime option to include the
|
||||
// @c 0/ directory. The @b -noZero option has precedence.
|
||||
// Enable the @b -zeroTime option and alter the normal time selection
|
||||
// behaviour (and @b -latestTime behaviour) to exclude the @c 0/
|
||||
// directory. The @c 0/ directory will only be included when
|
||||
// @b -zeroTime is specified.
|
||||
// The @b -noZero option has precedence over the @b -zeroTime option.
|
||||
static void addOptions
|
||||
(
|
||||
const bool constant = true,
|
||||
const bool zeroTime = false
|
||||
const bool constant=true,
|
||||
const bool zeroTime=false
|
||||
);
|
||||
|
||||
//- Return the set of times selected based on the argList options
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "dictionary.H"
|
||||
#include "primitiveEntry.H"
|
||||
#include "dictionaryEntry.H"
|
||||
#include "regularExpression.H"
|
||||
#include "regExp.H"
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
@ -38,26 +38,23 @@ const Foam::dictionary Foam::dictionary::null;
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::dictionary::findInWildcards
|
||||
bool Foam::dictionary::findInPatterns
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::const_iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::const_iterator& reLink
|
||||
DLList<autoPtr<regExp> >::const_iterator& reLink
|
||||
) const
|
||||
{
|
||||
if (wildCardEntries_.size() > 0)
|
||||
if (patternEntries_.size() > 0)
|
||||
{
|
||||
//wcLink = wildCardEntries_.begin();
|
||||
//reLink = wildCardRegexps_.end();
|
||||
|
||||
while (wcLink != wildCardEntries_.end())
|
||||
while (wcLink != patternEntries_.end())
|
||||
{
|
||||
if (!wildCardMatch && wcLink()->keyword() == Keyword)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (wildCardMatch && reLink()->matches(Keyword))
|
||||
if
|
||||
(
|
||||
patternMatch ? reLink()->match(Keyword)
|
||||
: wcLink()->keyword() == Keyword
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -71,23 +68,23 @@ bool Foam::dictionary::findInWildcards
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dictionary::findInWildcards
|
||||
bool Foam::dictionary::findInPatterns
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::iterator& reLink
|
||||
DLList<autoPtr<regExp> >::iterator& reLink
|
||||
)
|
||||
{
|
||||
if (wildCardEntries_.size() > 0)
|
||||
if (patternEntries_.size() > 0)
|
||||
{
|
||||
while (wcLink != wildCardEntries_.end())
|
||||
while (wcLink != patternEntries_.end())
|
||||
{
|
||||
if (!wildCardMatch && wcLink()->keyword() == Keyword)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (wildCardMatch && reLink()->matches(Keyword))
|
||||
if
|
||||
(
|
||||
patternMatch ? reLink()->match(Keyword)
|
||||
: wcLink()->keyword() == Keyword
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -128,15 +125,12 @@ Foam::dictionary::dictionary
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
|
||||
if (iter().keyword().isWildCard())
|
||||
if (iter().keyword().isPattern())
|
||||
{
|
||||
wildCardEntries_.insert(&iter());
|
||||
wildCardRegexps_.insert
|
||||
patternEntries_.insert(&iter());
|
||||
patternRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(iter().keyword())
|
||||
)
|
||||
autoPtr<regExp>(new regExp(iter().keyword()))
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -161,15 +155,12 @@ Foam::dictionary::dictionary
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
|
||||
if (iter().keyword().isWildCard())
|
||||
if (iter().keyword().isPattern())
|
||||
{
|
||||
wildCardEntries_.insert(&iter());
|
||||
wildCardRegexps_.insert
|
||||
patternEntries_.insert(&iter());
|
||||
patternRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(iter().keyword())
|
||||
)
|
||||
autoPtr<regExp>(new regExp(iter().keyword()))
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -226,14 +217,14 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wildCardEntries_.size() > 0)
|
||||
if (patternEntries_.size() > 0)
|
||||
{
|
||||
DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::const_iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
DLList<entry*>::const_iterator wcLink = patternEntries_.begin();
|
||||
DLList<autoPtr<regExp> >::const_iterator reLink =
|
||||
patternRegexps_.begin();
|
||||
|
||||
// Find in wildcards using regular expressions only
|
||||
if (findInWildcards(true, keyword, wcLink, reLink))
|
||||
// Find in patterns using regular expressions only
|
||||
if (findInPatterns(true, keyword, wcLink, reLink))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -255,22 +246,22 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword);
|
||||
|
||||
if (iter == hashedEntries_.end())
|
||||
{
|
||||
if (wildCardMatch && wildCardEntries_.size() > 0)
|
||||
if (patternMatch && patternEntries_.size() > 0)
|
||||
{
|
||||
DLList<entry*>::const_iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::const_iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
patternEntries_.begin();
|
||||
DLList<autoPtr<regExp> >::const_iterator reLink =
|
||||
patternRegexps_.begin();
|
||||
|
||||
// Find in wildcards using regular expressions only
|
||||
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
|
||||
// Find in patterns using regular expressions only
|
||||
if (findInPatterns(patternMatch, keyword, wcLink, reLink))
|
||||
{
|
||||
return wcLink();
|
||||
}
|
||||
@ -278,7 +269,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
|
||||
if (recursive && &parent_ != &dictionary::null)
|
||||
{
|
||||
return parent_.lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -294,21 +285,22 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
)
|
||||
{
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
|
||||
|
||||
if (iter == hashedEntries_.end())
|
||||
{
|
||||
if (wildCardMatch && wildCardEntries_.size() > 0)
|
||||
if (patternMatch && patternEntries_.size() > 0)
|
||||
{
|
||||
DLList<entry*>::iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
// Find in wildcards using regular expressions only
|
||||
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
|
||||
patternEntries_.begin();
|
||||
DLList<autoPtr<regExp> >::iterator reLink =
|
||||
patternRegexps_.begin();
|
||||
|
||||
// Find in patterns using regular expressions only
|
||||
if (findInPatterns(patternMatch, keyword, wcLink, reLink))
|
||||
{
|
||||
return wcLink();
|
||||
}
|
||||
@ -320,7 +312,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
keyword,
|
||||
recursive,
|
||||
wildCardMatch
|
||||
patternMatch
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -337,10 +329,10 @@ const Foam::entry& Foam::dictionary::lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
@ -361,16 +353,16 @@ Foam::ITstream& Foam::dictionary::lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return lookupEntry(keyword, recursive, wildCardMatch).stream();
|
||||
return lookupEntry(keyword, recursive, patternMatch).stream();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dictionary::isDict(const word& keyword) const
|
||||
{
|
||||
// Find non-recursive with wildcards
|
||||
// Find non-recursive with patterns
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
|
||||
|
||||
if (entryPtr)
|
||||
@ -439,7 +431,7 @@ Foam::wordList Foam::dictionary::toc() const
|
||||
{
|
||||
wordList keys(size());
|
||||
|
||||
label i = 0;
|
||||
label nKeys = 0;
|
||||
for
|
||||
(
|
||||
IDLList<entry>::const_iterator iter = begin();
|
||||
@ -447,13 +439,36 @@ Foam::wordList Foam::dictionary::toc() const
|
||||
++iter
|
||||
)
|
||||
{
|
||||
keys[i++] = iter().keyword();
|
||||
keys[nKeys++] = iter().keyword();
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
|
||||
{
|
||||
List<keyType> keys(size());
|
||||
|
||||
label nKeys = 0;
|
||||
for
|
||||
(
|
||||
IDLList<entry>::const_iterator iter = begin();
|
||||
iter != end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
if (iter().keyword().isPattern() ? patterns : !patterns)
|
||||
{
|
||||
keys[nKeys++] = iter().keyword();
|
||||
}
|
||||
}
|
||||
keys.setSize(nKeys);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
||||
{
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find
|
||||
@ -482,15 +497,12 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
||||
{
|
||||
entryPtr->name() = name_ + "::" + entryPtr->keyword();
|
||||
|
||||
if (entryPtr->keyword().isWildCard())
|
||||
if (entryPtr->keyword().isPattern())
|
||||
{
|
||||
wildCardEntries_.insert(entryPtr);
|
||||
wildCardRegexps_.insert
|
||||
patternEntries_.insert(entryPtr);
|
||||
patternRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(entryPtr->keyword())
|
||||
)
|
||||
autoPtr<regExp>(new regExp(entryPtr->keyword()))
|
||||
);
|
||||
}
|
||||
|
||||
@ -514,15 +526,12 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
||||
entryPtr->name() = name_ + "::" + entryPtr->keyword();
|
||||
IDLList<entry>::append(entryPtr);
|
||||
|
||||
if (entryPtr->keyword().isWildCard())
|
||||
if (entryPtr->keyword().isPattern())
|
||||
{
|
||||
wildCardEntries_.insert(entryPtr);
|
||||
wildCardRegexps_.insert
|
||||
patternEntries_.insert(entryPtr);
|
||||
patternRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(entryPtr->keyword())
|
||||
)
|
||||
autoPtr<regExp>(new regExp(entryPtr->keyword()))
|
||||
);
|
||||
}
|
||||
|
||||
@ -612,17 +621,15 @@ bool Foam::dictionary::remove(const word& Keyword)
|
||||
|
||||
if (iter != hashedEntries_.end())
|
||||
{
|
||||
// Delete from wildcards first
|
||||
DLList<entry*>::iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
// Delete from patterns first
|
||||
DLList<entry*>::iterator wcLink = patternEntries_.begin();
|
||||
DLList<autoPtr<regExp> >::iterator reLink = patternRegexps_.begin();
|
||||
|
||||
// Find in wildcards using exact match only
|
||||
if (findInWildcards(false, Keyword, wcLink, reLink))
|
||||
// Find in pattern using exact match only
|
||||
if (findInPatterns(false, Keyword, wcLink, reLink))
|
||||
{
|
||||
wildCardEntries_.remove(wcLink);
|
||||
wildCardRegexps_.remove(reLink);
|
||||
patternEntries_.remove(wcLink);
|
||||
patternRegexps_.remove(reLink);
|
||||
}
|
||||
|
||||
IDLList<entry>::remove(iter());
|
||||
@ -659,14 +666,14 @@ bool Foam::dictionary::changeKeyword
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iter()->keyword().isWildCard())
|
||||
if (iter()->keyword().isPattern())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"dictionary::changeKeyword(const word&, const word&, bool)"
|
||||
) << "Old keyword "<< oldKeyword
|
||||
<< " is a wildcard."
|
||||
<< "Wildcard replacement not yet implemented."
|
||||
<< " is a pattern."
|
||||
<< "Pattern replacement not yet implemented."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -678,26 +685,26 @@ bool Foam::dictionary::changeKeyword
|
||||
{
|
||||
if (forceOverwrite)
|
||||
{
|
||||
if (iter2()->keyword().isWildCard())
|
||||
if (iter2()->keyword().isPattern())
|
||||
{
|
||||
// Delete from wildcards first
|
||||
// Delete from patterns first
|
||||
DLList<entry*>::iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
patternEntries_.begin();
|
||||
DLList<autoPtr<regExp> >::iterator reLink =
|
||||
patternRegexps_.begin();
|
||||
|
||||
// Find in wildcards using exact match only
|
||||
if (findInWildcards(false, iter2()->keyword(), wcLink, reLink))
|
||||
// Find in patterns using exact match only
|
||||
if (findInPatterns(false, iter2()->keyword(), wcLink, reLink))
|
||||
{
|
||||
wildCardEntries_.remove(wcLink);
|
||||
wildCardRegexps_.remove(reLink);
|
||||
patternEntries_.remove(wcLink);
|
||||
patternRegexps_.remove(reLink);
|
||||
}
|
||||
}
|
||||
|
||||
IDLList<entry>::replace(iter2(), iter());
|
||||
delete iter2();
|
||||
hashedEntries_.erase(iter2);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -717,15 +724,12 @@ bool Foam::dictionary::changeKeyword
|
||||
hashedEntries_.erase(oldKeyword);
|
||||
hashedEntries_.insert(newKeyword, iter());
|
||||
|
||||
if (newKeyword.isWildCard())
|
||||
if (newKeyword.isPattern())
|
||||
{
|
||||
wildCardEntries_.insert(iter());
|
||||
wildCardRegexps_.insert
|
||||
patternEntries_.insert(iter());
|
||||
patternRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(newKeyword)
|
||||
)
|
||||
autoPtr<regExp>(new regExp(newKeyword))
|
||||
);
|
||||
}
|
||||
|
||||
@ -789,6 +793,8 @@ void Foam::dictionary::clear()
|
||||
{
|
||||
IDLList<entry>::clear();
|
||||
hashedEntries_.clear();
|
||||
patternEntries_.clear();
|
||||
patternRegexps_.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,12 +27,12 @@ Class
|
||||
|
||||
Description
|
||||
A list of keyword definitions, which are a keyword followed by any number
|
||||
of values (e.g. words and numbers). The keywords can represent wildcards
|
||||
of values (e.g. words and numbers). The keywords can represent patterns
|
||||
which are matched using Posix regular expressions. The general order for
|
||||
searching is
|
||||
searching is as follows:
|
||||
- exact match
|
||||
- wildcard match (in reverse order)
|
||||
- optional recursion into subdictionaries
|
||||
- pattern match (in reverse order)
|
||||
- optional recursion into the enclosing (parent) dictionaries
|
||||
|
||||
The dictionary class is the base class for IOdictionary.
|
||||
It also serves as a bootstrap dictionary for the objectRegistry data
|
||||
@ -67,7 +67,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class regularExpression;
|
||||
class regExp;
|
||||
class dictionary;
|
||||
Istream& operator>>(Istream&, dictionary&);
|
||||
Ostream& operator<<(Ostream&, const dictionary&);
|
||||
@ -92,32 +92,30 @@ class dictionary
|
||||
//- Parent dictionary
|
||||
const dictionary& parent_;
|
||||
|
||||
//- Wildcard entries
|
||||
DLList<entry*> wildCardEntries_;
|
||||
//- Entries of matching patterns
|
||||
DLList<entry*> patternEntries_;
|
||||
|
||||
//- Wildcard precompiled regex
|
||||
DLList<autoPtr<regularExpression> > wildCardRegexps_;
|
||||
//- Patterns as precompiled regular expressions
|
||||
DLList<autoPtr<regExp> > patternRegexps_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Search wildcard table either for exact match or for regular
|
||||
// expression match.
|
||||
bool findInWildcards
|
||||
//- Search patterns table for exact match or regular expression match
|
||||
bool findInPatterns
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::const_iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::const_iterator& reLink
|
||||
DLList<autoPtr<regExp> >::const_iterator& reLink
|
||||
) const;
|
||||
|
||||
//- Search wildcard table either for exact match or for regular
|
||||
// expression match.
|
||||
bool findInWildcards
|
||||
//- Search patterns table for exact match or regular expression match
|
||||
bool findInPatterns
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const bool patternMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::iterator& reLink
|
||||
DLList<autoPtr<regExp> >::iterator& reLink
|
||||
);
|
||||
|
||||
|
||||
@ -163,16 +161,16 @@ public:
|
||||
dictionary(Istream&);
|
||||
|
||||
//- Construct as copy given the parent dictionary
|
||||
dictionary(const dictionary& parentDict, const dictionary& dict);
|
||||
dictionary(const dictionary& parentDict, const dictionary&);
|
||||
|
||||
//- Construct top-level dictionary as copy
|
||||
dictionary(const dictionary& dict);
|
||||
dictionary(const dictionary&);
|
||||
|
||||
//- Construct and return clone
|
||||
Foam::autoPtr<dictionary> clone() const;
|
||||
|
||||
//- Construct top-level dictionary on freestore from Istream
|
||||
static Foam::autoPtr<dictionary> New(Istream& is);
|
||||
static Foam::autoPtr<dictionary> New(Istream&);
|
||||
|
||||
|
||||
// Destructor
|
||||
@ -210,83 +208,88 @@ public:
|
||||
// Search and lookup
|
||||
|
||||
//- Search dictionary for given keyword
|
||||
// If recursive search parent dictionaries
|
||||
bool found(const word& keyword, bool recursive=false) const;
|
||||
// If recursive, search parent dictionaries
|
||||
bool found(const word&, bool recursive=false) const;
|
||||
|
||||
//- Find and return an entry data stream pointer if present
|
||||
// otherwise return NULL.
|
||||
// If recursive search parent dictionaries. If wildCardMatch
|
||||
// use wildcards.
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions
|
||||
const entry* lookupEntryPtr
|
||||
(
|
||||
const word&,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream pointer for manipulation
|
||||
// if present otherwise return NULL.
|
||||
// If recursive search parent dictionaries. If wildCardMatch
|
||||
// use wildcards.
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
entry* lookupEntryPtr
|
||||
(
|
||||
const word&,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
);
|
||||
|
||||
//- Find and return an entry data stream if present otherwise error.
|
||||
// If recursive search parent dictionaries. If wildCardMatch
|
||||
// use wildcards.
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
const entry& lookupEntry
|
||||
(
|
||||
const word&,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream
|
||||
// If recursive search parent dictionaries
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
ITstream& lookup
|
||||
(
|
||||
const word&,
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
bool patternMatch=true
|
||||
) const;
|
||||
|
||||
//- Find and return a T,
|
||||
// if not found return the given default value
|
||||
// If recursive search parent dictionaries
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
template<class T>
|
||||
T lookupOrDefault
|
||||
(
|
||||
const word&,
|
||||
const T&,
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
bool patternMatch=true
|
||||
) const;
|
||||
|
||||
//- Find and return a T, if not found return the given
|
||||
// default value, and add to dictionary.
|
||||
// If recursive search parent dictionaries
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
template<class T>
|
||||
T lookupOrAddDefault
|
||||
(
|
||||
const word&,
|
||||
const T&,
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
bool patternMatch=true
|
||||
);
|
||||
|
||||
//- Find an entry if present, and assign to T
|
||||
// Returns true if the entry was found
|
||||
// Returns true if the entry was found.
|
||||
// If recursive, search parent dictionaries.
|
||||
// If patternMatch, use regular expressions.
|
||||
template<class T>
|
||||
bool readIfPresent
|
||||
(
|
||||
const word&,
|
||||
T&,
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
bool patternMatch=true
|
||||
) const;
|
||||
|
||||
//- Check if entry is a sub-dictionary
|
||||
@ -305,6 +308,9 @@ public:
|
||||
//- Return the table of contents
|
||||
wordList toc() const;
|
||||
|
||||
//- Return the list of available keys or patterns
|
||||
List<keyType> keys(bool patterns=false) const;
|
||||
|
||||
// Editing
|
||||
|
||||
//- Add a new entry
|
||||
@ -331,13 +337,13 @@ public:
|
||||
|
||||
//- Add a scalar entry
|
||||
// optionally overwrite an existing entry
|
||||
void add (const keyType&, const scalar, bool overwrite=false);
|
||||
void add(const keyType&, const scalar, bool overwrite=false);
|
||||
|
||||
//- Add a dictionary entry
|
||||
// optionally merge with an existing sub-dictionary
|
||||
void add
|
||||
(
|
||||
const keyType& keyword,
|
||||
const keyType&,
|
||||
const dictionary&,
|
||||
bool mergeEntry=false
|
||||
);
|
||||
@ -345,7 +351,7 @@ public:
|
||||
//- Add a T entry
|
||||
// optionally overwrite an existing entry
|
||||
template<class T>
|
||||
void add(const keyType& keyword, const T&, bool overwrite=false);
|
||||
void add(const keyType&, const T&, bool overwrite=false);
|
||||
|
||||
//- Assign a new entry, overwrite any existing entry
|
||||
void set(entry*);
|
||||
@ -354,14 +360,14 @@ public:
|
||||
void set(const entry&);
|
||||
|
||||
//- Assign a dictionary entry, overwrite any existing entry
|
||||
void set(const keyType& keyword, const dictionary&);
|
||||
void set(const keyType&, const dictionary&);
|
||||
|
||||
//- Assign a T entry, overwrite any existing entry
|
||||
template<class T>
|
||||
void set(const keyType& keyword, const T&);
|
||||
void set(const keyType&, const T&);
|
||||
|
||||
//- Remove an entry specified by keyword
|
||||
bool remove(const word& keyword);
|
||||
bool remove(const word&);
|
||||
|
||||
//- Change the keyword for an entry,
|
||||
// optionally forcing overwrite of an existing entry
|
||||
@ -369,7 +375,7 @@ public:
|
||||
(
|
||||
const keyType& oldKeyword,
|
||||
const keyType& newKeyword,
|
||||
bool forceOverwrite = false
|
||||
bool forceOverwrite=false
|
||||
);
|
||||
|
||||
//- Merge entries from the given dictionary.
|
||||
@ -382,7 +388,7 @@ public:
|
||||
|
||||
// Write
|
||||
|
||||
void write(Ostream& os, bool subDict = true) const;
|
||||
void write(Ostream&, bool subDict=true) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
@ -393,7 +399,7 @@ public:
|
||||
void operator=(const dictionary&);
|
||||
|
||||
//- Include entries from the given dictionary.
|
||||
// Warn, but do not overwrite existing entries
|
||||
// Warn, but do not overwrite existing entries.
|
||||
void operator+=(const dictionary&);
|
||||
|
||||
//- Conditionally include entries from the given dictionary.
|
||||
@ -417,13 +423,13 @@ public:
|
||||
|
||||
// Global Operators
|
||||
|
||||
//- Combine dictionaries starting from the entries in dict1 and then including
|
||||
// those from dict2.
|
||||
//- Combine dictionaries.
|
||||
// Starting from the entries in dict1 and then including those from dict2.
|
||||
// Warn, but do not overwrite the entries from dict1.
|
||||
dictionary operator+(const dictionary& dict1, const dictionary& dict2);
|
||||
|
||||
//- Combine dictionaries starting from the entries in dict1 and then including
|
||||
// those from dict2.
|
||||
//- Combine dictionaries.
|
||||
// Starting from the entries in dict1 and then including those from dict2.
|
||||
// Do not overwrite the entries from dict1.
|
||||
dictionary operator|(const dictionary& dict1, const dictionary& dict2);
|
||||
|
||||
|
||||
@ -74,20 +74,20 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from the parent dictionary and Istream
|
||||
dictionaryEntry(const dictionary& parentDict, Istream& is);
|
||||
dictionaryEntry(const dictionary& parentDict, Istream&);
|
||||
|
||||
//- Construct from the keyword, parent dictionary and a Istream
|
||||
dictionaryEntry
|
||||
(
|
||||
const keyType& keyword,
|
||||
const keyType&,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
Istream&
|
||||
);
|
||||
|
||||
//- Construct from the keyword, parent dictionary and a dictionary
|
||||
dictionaryEntry
|
||||
(
|
||||
const keyType& keyword,
|
||||
const keyType&,
|
||||
const dictionary& parentDict,
|
||||
const dictionary& dict
|
||||
);
|
||||
@ -96,7 +96,7 @@ public:
|
||||
dictionaryEntry
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
const dictionaryEntry& dictEnt
|
||||
const dictionaryEntry&
|
||||
);
|
||||
|
||||
autoPtr<entry> clone(const dictionary& parentDict) const
|
||||
@ -158,10 +158,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#if defined (__GNUC__)
|
||||
template<>
|
||||
#endif
|
||||
Ostream& operator<<(Ostream& os, const InfoProxy<dictionaryEntry>& ip);
|
||||
Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
#include "dictionary.H"
|
||||
#include "IFstream.H"
|
||||
#include "inputModeEntry.H"
|
||||
#include "regularExpression.H"
|
||||
#include "regExp.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -137,9 +137,6 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
|
||||
functionEntries::inputModeEntry::clear();
|
||||
|
||||
dict.clear();
|
||||
dict.hashedEntries_.clear();
|
||||
dict.wildCardEntries_.clear();
|
||||
dict.wildCardRegexps_.clear();
|
||||
dict.read(is);
|
||||
|
||||
return is;
|
||||
|
||||
@ -35,18 +35,18 @@ T Foam::dictionary::lookupOrDefault
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
if (entryPtr)
|
||||
{
|
||||
return deflt;
|
||||
return pTraits<T>(entryPtr->stream());
|
||||
}
|
||||
else
|
||||
{
|
||||
return pTraits<T>(entryPtr->stream());
|
||||
return deflt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,19 +57,19 @@ T Foam::dictionary::lookupOrAddDefault
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
)
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
if (entryPtr)
|
||||
{
|
||||
add(new primitiveEntry(keyword, deflt));
|
||||
return deflt;
|
||||
return pTraits<T>(entryPtr->stream());
|
||||
}
|
||||
else
|
||||
{
|
||||
return pTraits<T>(entryPtr->stream());
|
||||
add(new primitiveEntry(keyword, deflt));
|
||||
return deflt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,20 +80,20 @@ bool Foam::dictionary::readIfPresent
|
||||
const word& k,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(k, recursive, wildCardMatch);
|
||||
const entry* entryPtr = lookupEntryPtr(k, recursive, patternMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (entryPtr)
|
||||
{
|
||||
entryPtr->stream() >> val;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -92,20 +92,20 @@ public:
|
||||
|
||||
//- Construct on freestore as copy with reference to the
|
||||
// dictionary the copy belongs to
|
||||
virtual Foam::autoPtr<entry> clone
|
||||
virtual autoPtr<entry> clone
|
||||
(
|
||||
const dictionary& parentDict
|
||||
) const = 0;
|
||||
|
||||
//- Construct on freestore as copy
|
||||
// Note: the parent directory is set to dictionary::null
|
||||
virtual Foam::autoPtr<entry> clone() const;
|
||||
virtual autoPtr<entry> clone() const;
|
||||
|
||||
//- Construct from Istream and insert into dictionary
|
||||
static bool New(dictionary& parentDict, Istream& is);
|
||||
|
||||
//- Construct on freestore from Istream and return
|
||||
static Foam::autoPtr<entry> New(Istream& is);
|
||||
static autoPtr<entry> New(Istream& is);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
@ -75,32 +75,32 @@ public:
|
||||
void append
|
||||
(
|
||||
const token& currToken,
|
||||
const dictionary& dict,
|
||||
Istream& is
|
||||
const dictionary&,
|
||||
Istream&
|
||||
);
|
||||
|
||||
//- Append the given tokens starting at the current tokenIndex
|
||||
void append(const tokenList& varTokens);
|
||||
void append(const tokenList&);
|
||||
|
||||
//- Expand the given variable (keyword starts with $)
|
||||
bool expandVariable(const word& keyword, const dictionary& dict);
|
||||
bool expandVariable(const word&, const dictionary&);
|
||||
|
||||
//- Expand the given function (keyword starts with #)
|
||||
bool expandFunction
|
||||
(
|
||||
const word& keyword,
|
||||
const dictionary& dict,
|
||||
Istream& is
|
||||
const word&,
|
||||
const dictionary&,
|
||||
Istream&
|
||||
);
|
||||
|
||||
//- Read tokens from the given stream
|
||||
bool read(const dictionary& dict, Istream&);
|
||||
bool read(const dictionary&, Istream&);
|
||||
|
||||
//- Read the complete entry from the given stream
|
||||
void readEntry(const dictionary& dict, Istream&);
|
||||
void readEntry(const dictionary&, Istream&);
|
||||
|
||||
//- Insert the given tokens at token i
|
||||
void insert(const tokenList& varTokens, const label i);
|
||||
void insert(const tokenList&, const label i);
|
||||
|
||||
|
||||
public:
|
||||
@ -108,13 +108,13 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from keyword and a Istream
|
||||
primitiveEntry(const keyType& keyword, Istream&);
|
||||
primitiveEntry(const keyType&, Istream&);
|
||||
|
||||
//- Construct from keyword, parent dictionary and a Istream
|
||||
primitiveEntry(const keyType& keyword, const dictionary&, Istream&);
|
||||
//- Construct from keyword, parent dictionary and Istream
|
||||
primitiveEntry(const keyType&, const dictionary& parentDict, Istream&);
|
||||
|
||||
//- Construct from keyword and a ITstream
|
||||
primitiveEntry(const keyType& keyword, const ITstream&);
|
||||
primitiveEntry(const keyType&, const ITstream&);
|
||||
|
||||
//- Construct from keyword and a token
|
||||
primitiveEntry(const keyType&, const token&);
|
||||
@ -182,7 +182,7 @@ public:
|
||||
|
||||
|
||||
template<>
|
||||
Ostream& operator<<(Ostream& os, const InfoProxy<primitiveEntry>& ip);
|
||||
Ostream& operator<<(Ostream&, const InfoProxy<primitiveEntry>&);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,6 +27,26 @@ License
|
||||
#include "functionObjectList.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObject* Foam::functionObjectList::remove(const word& key)
|
||||
{
|
||||
functionObject* ptr = 0;
|
||||
|
||||
// Find index of existing functionObject
|
||||
HashTable<label>::iterator fnd = indices_.find(key);
|
||||
|
||||
if (fnd != indices_.end())
|
||||
{
|
||||
// remove the pointer from the old list
|
||||
ptr = functions_.set(fnd(), 0).ptr();
|
||||
indices_.erase(fnd);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectList::functionObjectList
|
||||
@ -35,24 +55,28 @@ Foam::functionObjectList::functionObjectList
|
||||
const bool execution
|
||||
)
|
||||
:
|
||||
HashPtrTable<functionObject>(),
|
||||
functions_(),
|
||||
indices_(),
|
||||
time_(t),
|
||||
foDict_(t.controlDict()),
|
||||
execution_(execution)
|
||||
parentDict_(t.controlDict()),
|
||||
execution_(execution),
|
||||
updated_(false)
|
||||
{}
|
||||
|
||||
|
||||
Foam::functionObjectList::functionObjectList
|
||||
(
|
||||
const Time& t,
|
||||
const dictionary& foDict,
|
||||
const dictionary& parentDict,
|
||||
const bool execution
|
||||
)
|
||||
:
|
||||
HashPtrTable<functionObject>(),
|
||||
functions_(),
|
||||
indices_(),
|
||||
time_(t),
|
||||
foDict_(foDict),
|
||||
execution_(execution)
|
||||
parentDict_(parentDict),
|
||||
execution_(execution),
|
||||
updated_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -66,52 +90,28 @@ Foam::functionObjectList::~functionObjectList()
|
||||
|
||||
bool Foam::functionObjectList::start()
|
||||
{
|
||||
if (execution_)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
if (foDict_.found("functions"))
|
||||
{
|
||||
HashPtrTable<functionObject> functions
|
||||
(
|
||||
foDict_.lookup("functions"),
|
||||
functionObject::iNew(time_)
|
||||
);
|
||||
|
||||
transfer(functions);
|
||||
|
||||
forAllIter(HashPtrTable<functionObject>, *this, iter)
|
||||
{
|
||||
ok = iter()->start() && ok;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return read();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::execute()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
forAllIter(HashPtrTable<functionObject>, *this, iter)
|
||||
if (!updated_)
|
||||
{
|
||||
ok = iter()->execute() && ok;
|
||||
read();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
forAllIter(PtrList<functionObject>, functions_, iter)
|
||||
{
|
||||
ok = iter().execute() && ok;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@ -129,46 +129,108 @@ void Foam::functionObjectList::off()
|
||||
|
||||
bool Foam::functionObjectList::read()
|
||||
{
|
||||
bool read = false;
|
||||
bool ok = true;
|
||||
updated_ = execution_;
|
||||
|
||||
if (foDict_.found("functions"))
|
||||
// avoid reading/initializing if execution is off
|
||||
if (!execution_)
|
||||
{
|
||||
HashPtrTable<dictionary> functionDicts(foDict_.lookup("functions"));
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Update existing and add new functionObjects
|
||||
forAllConstIter(HashPtrTable<dictionary>, functionDicts, iter)
|
||||
// Update existing and add new functionObjects
|
||||
const entry* entryPtr = parentDict_.lookupEntryPtr("functions",false,false);
|
||||
if (entryPtr)
|
||||
{
|
||||
PtrList<functionObject> newPtrs;
|
||||
HashTable<label> newIndices;
|
||||
|
||||
label nFunc = 0;
|
||||
|
||||
if (entryPtr->isDict())
|
||||
{
|
||||
if (found(iter.key()))
|
||||
// a dictionary of functionObjects
|
||||
const dictionary& functionDicts = entryPtr->dict();
|
||||
newPtrs.setSize(functionDicts.size());
|
||||
|
||||
forAllConstIter(dictionary, functionDicts, iter)
|
||||
{
|
||||
read = find(iter.key())()->read(*iter()) && read;
|
||||
// safety:
|
||||
if (!iter().isDict())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const word& key = iter().keyword();
|
||||
const dictionary& dict = iter().dict();
|
||||
|
||||
functionObject* objPtr = remove(key);
|
||||
if (objPtr)
|
||||
{
|
||||
// existing functionObject
|
||||
ok = objPtr->read(dict) && ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
// new functionObject
|
||||
objPtr = functionObject::New(key, time_, dict).ptr();
|
||||
ok = objPtr->start() && ok;
|
||||
}
|
||||
|
||||
newPtrs.set(nFunc, objPtr);
|
||||
newIndices.insert(key, nFunc);
|
||||
nFunc++;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// a list of functionObjects
|
||||
PtrList<entry> functionDicts(entryPtr->stream());
|
||||
newPtrs.setSize(functionDicts.size());
|
||||
|
||||
forAllIter(PtrList<entry>, functionDicts, iter)
|
||||
{
|
||||
functionObject* functionObjectPtr =
|
||||
functionObject::New(iter.key(), time_, *iter()).ptr();
|
||||
// safety:
|
||||
if (!iter().isDict())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const word& key = iter().keyword();
|
||||
const dictionary& dict = iter().dict();
|
||||
|
||||
functionObjectPtr->start();
|
||||
functionObject* objPtr = remove(key);
|
||||
if (objPtr)
|
||||
{
|
||||
// existing functionObject
|
||||
ok = objPtr->read(dict) && ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
// new functionObject
|
||||
objPtr = functionObject::New(key, time_, dict).ptr();
|
||||
ok = objPtr->start() && ok;
|
||||
}
|
||||
|
||||
insert(iter.key(), functionObjectPtr);
|
||||
newPtrs.set(nFunc, objPtr);
|
||||
newIndices.insert(key, nFunc);
|
||||
nFunc++;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove deleted functionObjects
|
||||
forAllIter(HashPtrTable<functionObject>, *this, iter)
|
||||
{
|
||||
if (!functionDicts.found(iter.key()))
|
||||
{
|
||||
erase(iter);
|
||||
}
|
||||
}
|
||||
// safety:
|
||||
newPtrs.setSize(nFunc);
|
||||
|
||||
// update PtrList of functionObjects
|
||||
// also deletes existing, unused functionObjects
|
||||
functions_.transfer(newPtrs);
|
||||
indices_.transfer(newIndices);
|
||||
}
|
||||
else
|
||||
{
|
||||
clear();
|
||||
read = true;
|
||||
functions_.clear();
|
||||
indices_.clear();
|
||||
}
|
||||
|
||||
return read;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,8 +26,8 @@ Class
|
||||
Foam::functionObjectList
|
||||
|
||||
Description
|
||||
List of function objects with execute function which is called for
|
||||
each object.
|
||||
List of function objects with execute() function that is called for each
|
||||
object.
|
||||
|
||||
See Also
|
||||
Foam::functionObject and Foam::OutputFilterFunctionObject
|
||||
@ -41,7 +41,8 @@ SourceFiles
|
||||
#define functionObjectList_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "HashTable.H"
|
||||
#include "PtrList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,26 +50,41 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectList Declaration
|
||||
Class functionObjectList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class functionObjectList
|
||||
:
|
||||
public HashPtrTable<functionObject>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- A list of function objects
|
||||
// Avoid 'is-a' relationship for protection
|
||||
PtrList<functionObject> functions_;
|
||||
|
||||
//- Quick lookup of the index into the PtrList<functionObject>
|
||||
// Currently only used to manage rereading/deletion
|
||||
HashTable<label> indices_;
|
||||
|
||||
const Time& time_;
|
||||
|
||||
//- Dictionary containing the list of function object specifications
|
||||
const dictionary& foDict_;
|
||||
//- Dictionary containing the "functions" entry
|
||||
// This entry can either be a list or a dictionary of
|
||||
// functionObject specifications.
|
||||
const dictionary& parentDict_;
|
||||
|
||||
//- Switch for the execution of the functionObjects
|
||||
bool execution_;
|
||||
|
||||
//- Tracks if read() was called while execution was turned off
|
||||
bool updated_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Remove and return the function object pointer by name.
|
||||
// Return NULL if it didn't exist.
|
||||
functionObject* remove(const word&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectList(const functionObjectList&);
|
||||
|
||||
@ -85,17 +101,17 @@ public:
|
||||
functionObjectList
|
||||
(
|
||||
const Time&,
|
||||
const bool execution = true
|
||||
const bool execution=true
|
||||
);
|
||||
|
||||
|
||||
//- Construct from Time, functionObject dictionary and the execution
|
||||
// setting
|
||||
//- Construct from Time, dictionary with "functions" entry
|
||||
// and the execution setting
|
||||
functionObjectList
|
||||
(
|
||||
const Time&,
|
||||
const dictionary& foDict,
|
||||
const bool execution = true
|
||||
const dictionary& parentDict,
|
||||
const bool execution=true
|
||||
);
|
||||
|
||||
|
||||
@ -118,7 +134,7 @@ public:
|
||||
//- Switch the function objects off
|
||||
virtual void off();
|
||||
|
||||
//- Read and set the function objects if their data has changed
|
||||
//- Read and set the function objects if their data have changed
|
||||
virtual bool read();
|
||||
};
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ Foam::scalarRanges::scalarRanges(Istream& is)
|
||||
}
|
||||
}
|
||||
|
||||
lst.shrink();
|
||||
transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
@ -37,19 +37,17 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
SLList<string> argList::validArgs;
|
||||
HashTable<string> argList::validOptions;
|
||||
HashTable<string> argList::validParOptions;
|
||||
}
|
||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
|
||||
bool Foam::argList::bannerEnabled(true);
|
||||
|
||||
|
||||
Foam::argList::initValidTables::initValidTables()
|
||||
{
|
||||
validOptions.insert("case", "dir");
|
||||
validOptions.insert("parallel", "");
|
||||
validParOptions.insert("parallel", "");
|
||||
validOptions.set("case", "dir");
|
||||
validOptions.set("parallel", "");
|
||||
validParOptions.set("parallel", "");
|
||||
|
||||
Pstream::addValidParOptions(validParOptions);
|
||||
}
|
||||
@ -138,7 +136,7 @@ void Foam::argList::getRootCase()
|
||||
casePath = cwd();
|
||||
|
||||
// we could add this back in as '-case'?
|
||||
// options_.insert("case", casePath);
|
||||
// options_.set("case", casePath);
|
||||
}
|
||||
|
||||
rootPath_ = casePath.path();
|
||||
@ -285,7 +283,7 @@ Foam::argList::argList
|
||||
string timeString = clock::clockTime();
|
||||
|
||||
// Print the banner once only for parallel runs
|
||||
if (Pstream::master())
|
||||
if (Pstream::master() && bannerEnabled)
|
||||
{
|
||||
IOobject::writeBanner(Info, true);
|
||||
Info<< "Exec : " << argListString.c_str() << nl
|
||||
@ -315,8 +313,6 @@ Foam::argList::argList
|
||||
// For the master
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileNameList roots;
|
||||
|
||||
// establish rootPath_/globalCase_/case_ for master
|
||||
getRootCase();
|
||||
|
||||
@ -333,45 +329,25 @@ Foam::argList::argList
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
dictionary decompositionDict(decompDictStream);
|
||||
|
||||
Switch distributed(false);
|
||||
|
||||
if
|
||||
(
|
||||
decompositionDict.readIfPresent("distributed", distributed)
|
||||
&& distributed
|
||||
)
|
||||
{
|
||||
decompositionDict.lookup("roots") >> roots;
|
||||
|
||||
if (roots.size() != Pstream::nProcs()-1)
|
||||
{
|
||||
FatalError
|
||||
<< "number of entries in decompositionDict::roots"
|
||||
<< " is not equal to the number of slaves "
|
||||
<< Pstream::nProcs()-1
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
dictionary decompDict(decompDictStream);
|
||||
|
||||
label dictNProcs
|
||||
(
|
||||
readLabel
|
||||
(
|
||||
decompositionDict.lookup("numberOfSubdomains")
|
||||
decompDict.lookup("numberOfSubdomains")
|
||||
)
|
||||
);
|
||||
|
||||
// Check number of processors. We have nProcs(number of
|
||||
// actual processes), dictNProcs(wanted number of processes read
|
||||
// from decompositionDict) and nProcDirs(number of processor
|
||||
// directories - n/a when running distributed)
|
||||
// Check number of processors.
|
||||
// nProcs => number of actual procs
|
||||
// dictNProcs => number of procs specified in decompositionDict
|
||||
// nProcDirs => number of processor directories
|
||||
// (n/a when running distributed)
|
||||
//
|
||||
// - normal running : nProcs = dictNProcs = nProcDirs
|
||||
// - decomposition to more processors : nProcs = dictNProcs
|
||||
// - decomposition to less processors : nProcs = nProcDirs
|
||||
// - decomposition to more processors : nProcs = dictNProcs
|
||||
// - decomposition to fewer processors : nProcs = nProcDirs
|
||||
if (dictNProcs > Pstream::nProcs())
|
||||
{
|
||||
FatalError
|
||||
@ -382,38 +358,23 @@ Foam::argList::argList
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (!distributed && dictNProcs < Pstream::nProcs())
|
||||
// distributed data
|
||||
if (decompDict.lookupOrDefault<Switch>("distributed", false))
|
||||
{
|
||||
// Possibly going to fewer processors.
|
||||
// Check if all procDirs are there.
|
||||
label nProcDirs = 0;
|
||||
while
|
||||
(
|
||||
dir
|
||||
(
|
||||
rootPath_/globalCase_/"processor"
|
||||
+ name(++nProcDirs)
|
||||
)
|
||||
)
|
||||
{}
|
||||
fileNameList roots;
|
||||
decompDict.lookup("roots") >> roots;
|
||||
|
||||
if (nProcDirs != Pstream::nProcs())
|
||||
if (roots.size() != Pstream::nProcs()-1)
|
||||
{
|
||||
FatalError
|
||||
<< "number of processor directories = "
|
||||
<< nProcDirs
|
||||
<< " is not equal to the number of processors = "
|
||||
<< Pstream::nProcs()
|
||||
<< "number of entries in decompositionDict::roots"
|
||||
<< " is not equal to the number of slaves "
|
||||
<< Pstream::nProcs()-1
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// distributed data
|
||||
if (roots.size())
|
||||
{
|
||||
bool hadOptCase = options_.found("case");
|
||||
|
||||
// Distribute the master's argument list (with new root)
|
||||
bool hadCaseOpt = options_.found("case");
|
||||
for
|
||||
(
|
||||
int slave=Pstream::firstSlave();
|
||||
@ -421,8 +382,7 @@ Foam::argList::argList
|
||||
slave++
|
||||
)
|
||||
{
|
||||
options_.erase("case");
|
||||
options_.insert
|
||||
options_.set
|
||||
(
|
||||
"case",
|
||||
fileName(roots[slave-1])/globalCase_
|
||||
@ -431,17 +391,42 @@ Foam::argList::argList
|
||||
OPstream toSlave(Pstream::scheduled, slave);
|
||||
toSlave << args_ << options_;
|
||||
}
|
||||
|
||||
options_.erase("case");
|
||||
|
||||
// restore [-case dir]
|
||||
if (hadOptCase)
|
||||
if (hadCaseOpt)
|
||||
{
|
||||
options_.insert("case", rootPath_/globalCase_);
|
||||
options_.set("case", rootPath_/globalCase_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Possibly going to fewer processors.
|
||||
// Check if all procDirs are there.
|
||||
if (dictNProcs < Pstream::nProcs())
|
||||
{
|
||||
label nProcDirs = 0;
|
||||
while
|
||||
(
|
||||
dir
|
||||
(
|
||||
rootPath_/globalCase_/"processor"
|
||||
+ name(++nProcDirs)
|
||||
)
|
||||
)
|
||||
{}
|
||||
|
||||
if (nProcDirs != Pstream::nProcs())
|
||||
{
|
||||
FatalError
|
||||
<< "number of processor directories = "
|
||||
<< nProcDirs
|
||||
<< " is not equal to the number of processors = "
|
||||
<< Pstream::nProcs()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// Distribute the master's argument list (unaltered)
|
||||
for
|
||||
(
|
||||
@ -472,7 +457,6 @@ Foam::argList::argList
|
||||
{
|
||||
// establish rootPath_/globalCase_/case_
|
||||
getRootCase();
|
||||
|
||||
case_ = globalCase_;
|
||||
}
|
||||
|
||||
@ -510,21 +494,21 @@ Foam::argList::argList
|
||||
}
|
||||
|
||||
|
||||
if (Pstream::master())
|
||||
if (Pstream::master() && bannerEnabled)
|
||||
{
|
||||
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
|
||||
<< "nProcs : " << nProcs << endl;
|
||||
}
|
||||
|
||||
if (parRunControl_.parRun() && Pstream::master())
|
||||
{
|
||||
Info<< "Slaves : " << slaveProcs << nl
|
||||
<< "Pstream initialized with:" << nl
|
||||
<< " floatTransfer : " << Pstream::floatTransfer << nl
|
||||
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
|
||||
<< " commsType : "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||
<< endl;
|
||||
if (parRunControl_.parRun())
|
||||
{
|
||||
Info<< "Slaves : " << slaveProcs << nl
|
||||
<< "Pstream initialized with:" << nl
|
||||
<< " floatTransfer : " << Pstream::floatTransfer << nl
|
||||
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
|
||||
<< " commsType : "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
jobInfo.add("root", rootPath_);
|
||||
@ -546,7 +530,7 @@ Foam::argList::argList
|
||||
sigQuit_.set();
|
||||
sigSegv_.set();
|
||||
|
||||
if (Pstream::master())
|
||||
if (Pstream::master() && bannerEnabled)
|
||||
{
|
||||
Info<< endl;
|
||||
IOobject::writeDivider(Info);
|
||||
@ -564,6 +548,12 @@ Foam::argList::~argList()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::argList::noBanner()
|
||||
{
|
||||
bannerEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::argList::noParallel()
|
||||
{
|
||||
validOptions.erase("parallel");
|
||||
|
||||
@ -92,6 +92,7 @@ namespace Foam
|
||||
class argList
|
||||
{
|
||||
// Private data
|
||||
static bool bannerEnabled;
|
||||
|
||||
stringList args_;
|
||||
HashTable<string> options_;
|
||||
@ -213,6 +214,9 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Disable emitting the banner information
|
||||
static void noBanner();
|
||||
|
||||
//- Remove the parallel options
|
||||
static void noParallel();
|
||||
|
||||
|
||||
@ -36,19 +36,16 @@ Description
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace debug
|
||||
{
|
||||
|
||||
//! @cond ignoreDocumentation - local scope
|
||||
dictionary* controlDictPtr_(NULL);
|
||||
dictionary* debugSwitchesPtr_(NULL);
|
||||
dictionary* infoSwitchesPtr_(NULL);
|
||||
dictionary* optimisationSwitchesPtr_(NULL);
|
||||
|
||||
//- Class to ensure controlDictPtr_ is deleted at the end of the run
|
||||
// @cond ignore documentation for this class
|
||||
// to ensure controlDictPtr_ is deleted at the end of the run
|
||||
class deleteControlDictPtr
|
||||
{
|
||||
public:
|
||||
@ -61,135 +58,110 @@ public:
|
||||
if (controlDictPtr_)
|
||||
{
|
||||
delete controlDictPtr_;
|
||||
controlDictPtr_ = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
//! @endcond
|
||||
|
||||
deleteControlDictPtr deleteControlDictPtr_;
|
||||
//! @endcond ignoreDocumentation
|
||||
|
||||
|
||||
dictionary& switchSet(const char* switchSetName, dictionary* switchSetPtr)
|
||||
{
|
||||
if (!switchSetPtr)
|
||||
{
|
||||
if (!controlDict().found(switchSetName))
|
||||
{
|
||||
cerr<< "debug::switchSet(const char*, dictionary*): " << std::endl
|
||||
<< " Cannot find " << switchSetName
|
||||
<< " in dictionary " << controlDictPtr_->name().c_str()
|
||||
<< std::endl << std::endl;
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
switchSetPtr =
|
||||
const_cast<dictionary*>(&(controlDict().subDict(switchSetName)));
|
||||
}
|
||||
|
||||
return *switchSetPtr;
|
||||
}
|
||||
|
||||
|
||||
int debugSwitch
|
||||
(
|
||||
dictionary& switchSet,
|
||||
const char* switchName,
|
||||
const int defaultValue
|
||||
)
|
||||
{
|
||||
if (switchSet.found(switchName))
|
||||
{
|
||||
return readInt(switchSet.lookup(switchName));
|
||||
}
|
||||
else
|
||||
{
|
||||
switchSet.add(switchName, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // End namespace debug
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dictionary& debug::controlDict()
|
||||
Foam::dictionary& Foam::debug::controlDict()
|
||||
{
|
||||
if (!controlDictPtr_)
|
||||
{
|
||||
fileName controlDictFileName(dotFoam("controlDict"));
|
||||
|
||||
IFstream dictFile(controlDictFileName);
|
||||
|
||||
if (!dictFile.good())
|
||||
{
|
||||
cerr<< "debug::controlDict(): "
|
||||
<< "Cannot open essential file " << controlDictFileName.c_str()
|
||||
<< std::endl << std::endl;
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
controlDictPtr_ = new dictionary(dictFile);
|
||||
controlDictPtr_ = new dictionary
|
||||
(
|
||||
IFstream(findEtcFile("controlDict", true))()
|
||||
);
|
||||
}
|
||||
|
||||
return *controlDictPtr_;
|
||||
}
|
||||
|
||||
|
||||
dictionary& debug::debugSwitches()
|
||||
Foam::dictionary& Foam::debug::switchSet
|
||||
(
|
||||
const char* subDictName,
|
||||
dictionary*& subDictPtr
|
||||
)
|
||||
{
|
||||
if (!subDictPtr)
|
||||
{
|
||||
entry* ePtr = controlDict().lookupEntryPtr
|
||||
(
|
||||
subDictName, false, false
|
||||
);
|
||||
|
||||
if (!ePtr || !ePtr->isDict())
|
||||
{
|
||||
cerr<< "debug::switchSet(const char*, dictionary*&):\n"
|
||||
<< " Cannot find " << subDictName << " in dictionary "
|
||||
<< controlDict().name().c_str()
|
||||
<< std::endl << std::endl;
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
subDictPtr = &ePtr->dict();
|
||||
}
|
||||
|
||||
return *subDictPtr;
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary& Foam::debug::debugSwitches()
|
||||
{
|
||||
return switchSet("DebugSwitches", debugSwitchesPtr_);
|
||||
}
|
||||
|
||||
|
||||
int debug::debugSwitch(const char* switchName, const int defaultValue)
|
||||
{
|
||||
return debugSwitch
|
||||
(
|
||||
debugSwitches(),
|
||||
switchName,
|
||||
defaultValue
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
dictionary& debug::infoSwitches()
|
||||
Foam::dictionary& Foam::debug::infoSwitches()
|
||||
{
|
||||
return switchSet("InfoSwitches", infoSwitchesPtr_);
|
||||
}
|
||||
|
||||
|
||||
int debug::infoSwitch(const char* switchName, const int defaultValue)
|
||||
{
|
||||
return debugSwitch
|
||||
(
|
||||
infoSwitches(),
|
||||
switchName,
|
||||
defaultValue
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
dictionary& debug::optimisationSwitches()
|
||||
Foam::dictionary& Foam::debug::optimisationSwitches()
|
||||
{
|
||||
return switchSet("OptimisationSwitches", optimisationSwitchesPtr_);
|
||||
}
|
||||
|
||||
|
||||
int debug::optimisationSwitch(const char* switchName, const int defaultValue)
|
||||
int Foam::debug::debugSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return debugSwitch
|
||||
return debugSwitches().lookupOrAddDefault
|
||||
(
|
||||
optimisationSwitches(),
|
||||
switchName,
|
||||
defaultValue
|
||||
name, defaultValue, false, false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int Foam::debug::infoSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return infoSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -41,44 +41,40 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class dictionary;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace debug
|
||||
{
|
||||
//- The central control dictionary.
|
||||
// Located in ~/.OpenFOAM/VERSION or $WM_PROJECT_DIR/etc
|
||||
// @sa Foam::findEtcFile()
|
||||
dictionary& controlDict();
|
||||
|
||||
|
||||
dictionary& switchSet(const char* switchSetName, dictionary* switchSetPtr);
|
||||
|
||||
|
||||
//- The DebugSwitches sub-dictionary in the central controlDict.
|
||||
dictionary& debugSwitches();
|
||||
|
||||
int debugSwitch
|
||||
(
|
||||
const char* switchName,
|
||||
const int defaultValue = 0
|
||||
);
|
||||
|
||||
|
||||
//- The InfoSwitches sub-dictionary in the central controlDict.
|
||||
dictionary& infoSwitches();
|
||||
|
||||
int infoSwitch
|
||||
(
|
||||
const char* switchName,
|
||||
const int defaultValue = 0
|
||||
);
|
||||
|
||||
|
||||
//- The OptimisationSwitches sub-dictionary in the central controlDict.
|
||||
dictionary& optimisationSwitches();
|
||||
|
||||
int optimisationSwitch
|
||||
(
|
||||
const char* switchName,
|
||||
const int defaultValue = 0
|
||||
);
|
||||
}
|
||||
//- Lookup debug switch or add default value.
|
||||
int debugSwitch(const char* name, const int defaultValue=0);
|
||||
|
||||
//- Lookup info switch or add default value.
|
||||
int infoSwitch(const char* name, const int defaultValue=0);
|
||||
|
||||
//- Lookup optimisation switch or add default value.
|
||||
int optimisationSwitch(const char* name, const int defaultValue=0);
|
||||
|
||||
//- Internal function to lookup a sub-dictionary from controlDict.
|
||||
dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr);
|
||||
|
||||
} // End namespace debug
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -102,7 +102,8 @@ bool chDir(const fileName& dir);
|
||||
// - $WM_PROJECT_DIR/etc/
|
||||
//
|
||||
// @return the full path name or fileName::null if the name cannot be found
|
||||
fileName dotFoam(const fileName& name);
|
||||
// Optionally abort if the file cannot be found
|
||||
fileName findEtcFile(const fileName& name, bool mandatory=false);
|
||||
|
||||
//- Make a directory and return an error if it could not be created
|
||||
// and does not already exist
|
||||
|
||||
@ -259,7 +259,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
),
|
||||
(
|
||||
fieldName,
|
||||
@ -267,7 +267,7 @@ public:
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
);
|
||||
|
||||
@ -282,7 +282,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
),
|
||||
(
|
||||
fieldName,
|
||||
@ -290,7 +290,7 @@ public:
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
);
|
||||
|
||||
@ -304,7 +304,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
// Selectors
|
||||
@ -317,7 +317,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
@ -359,7 +359,7 @@ public:
|
||||
|
||||
|
||||
//- Read and reset the solver parameters from the given stream
|
||||
virtual void read(Istream& solverData);
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
virtual solverPerformance solve
|
||||
(
|
||||
@ -396,6 +396,9 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//- Find the smoother name (directly or from a sub-dictionary)
|
||||
static word getName(const dictionary&);
|
||||
|
||||
//- Runtime type information
|
||||
virtual const word& type() const = 0;
|
||||
|
||||
@ -467,7 +470,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& smootherData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
@ -531,6 +534,9 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//- Find the preconditioner name (directly or from a sub-dictionary)
|
||||
static word getName(const dictionary&);
|
||||
|
||||
//- Runtime type information
|
||||
virtual const word& type() const = 0;
|
||||
|
||||
@ -544,9 +550,9 @@ public:
|
||||
symMatrix,
|
||||
(
|
||||
const solver& sol,
|
||||
Istream& preconditionerData
|
||||
const dictionary& solverControls
|
||||
),
|
||||
(sol, preconditionerData)
|
||||
(sol, solverControls)
|
||||
);
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
@ -556,9 +562,9 @@ public:
|
||||
asymMatrix,
|
||||
(
|
||||
const solver& sol,
|
||||
Istream& preconditionerData
|
||||
const dictionary& solverControls
|
||||
),
|
||||
(sol, preconditionerData)
|
||||
(sol, solverControls)
|
||||
);
|
||||
|
||||
|
||||
@ -579,7 +585,7 @@ public:
|
||||
static autoPtr<preconditioner> New
|
||||
(
|
||||
const solver& sol,
|
||||
Istream& preconditionerData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
@ -593,7 +599,7 @@ public:
|
||||
|
||||
//- Read and reset the preconditioner parameters
|
||||
// from the given stream
|
||||
virtual void read(Istream& preconditionerData)
|
||||
virtual void read(const dictionary&)
|
||||
{}
|
||||
|
||||
//- Return wA the preconditioned form of residual rA
|
||||
|
||||
@ -37,29 +37,66 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word
|
||||
Foam::lduMatrix::preconditioner::getName
|
||||
(
|
||||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().lookup("preconditioner") >> name;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.stream() >> name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::lduMatrix::preconditioner>
|
||||
Foam::lduMatrix::preconditioner::New
|
||||
(
|
||||
const solver& sol,
|
||||
Istream& preconditionerData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
word preconditionerName(preconditionerData);
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().lookup("preconditioner") >> name;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.stream() >> name;
|
||||
}
|
||||
|
||||
const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
|
||||
|
||||
if (sol.matrix().symmetric())
|
||||
{
|
||||
symMatrixConstructorTable::iterator constructorIter =
|
||||
symMatrixConstructorTablePtr_->find(preconditionerName);
|
||||
symMatrixConstructorTablePtr_->find(name);
|
||||
|
||||
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::preconditioner::New(const solver&, Istream&)",
|
||||
preconditionerData
|
||||
"lduMatrix::preconditioner::New"
|
||||
"(const solver&, const dictionary&)",
|
||||
controls
|
||||
) << "Unknown symmetric matrix preconditioner "
|
||||
<< preconditionerName << endl << endl
|
||||
<< "Valid symmetric matrix preconditioners are :" << endl
|
||||
<< name << nl << nl
|
||||
<< "Valid symmetric matrix preconditioners :" << endl
|
||||
<< symMatrixConstructorTablePtr_->toc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
@ -69,24 +106,25 @@ Foam::lduMatrix::preconditioner::New
|
||||
constructorIter()
|
||||
(
|
||||
sol,
|
||||
preconditionerData
|
||||
controls
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (sol.matrix().asymmetric())
|
||||
{
|
||||
asymMatrixConstructorTable::iterator constructorIter =
|
||||
asymMatrixConstructorTablePtr_->find(preconditionerName);
|
||||
asymMatrixConstructorTablePtr_->find(name);
|
||||
|
||||
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::preconditioner::New(const solver&, Istream&)",
|
||||
preconditionerData
|
||||
"lduMatrix::preconditioner::New"
|
||||
"(const solver&, const dictionary&)",
|
||||
controls
|
||||
) << "Unknown asymmetric matrix preconditioner "
|
||||
<< preconditionerName << endl << endl
|
||||
<< "Valid asymmetric matrix preconditioners are :" << endl
|
||||
<< name << nl << nl
|
||||
<< "Valid asymmetric matrix preconditioners :" << endl
|
||||
<< asymMatrixConstructorTablePtr_->toc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
@ -96,7 +134,7 @@ Foam::lduMatrix::preconditioner::New
|
||||
constructorIter()
|
||||
(
|
||||
sol,
|
||||
preconditionerData
|
||||
controls
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -104,9 +142,10 @@ Foam::lduMatrix::preconditioner::New
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::preconditioner::New(const solver&, Istream&)",
|
||||
preconditionerData
|
||||
) << "cannot preconditione incomplete matrix, "
|
||||
"lduMatrix::preconditioner::New"
|
||||
"(const solver&, const dictionary&)",
|
||||
controls
|
||||
) << "cannot solve incomplete matrix, "
|
||||
"no diagonal or off-diagonal coefficient"
|
||||
<< exit(FatalIOError);
|
||||
|
||||
|
||||
@ -34,9 +34,31 @@ namespace Foam
|
||||
defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word
|
||||
Foam::lduMatrix::smoother::getName
|
||||
(
|
||||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("smoother", false, false);
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().lookup("smoother") >> name;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.stream() >> name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||
(
|
||||
const word& fieldName,
|
||||
@ -44,23 +66,37 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& smootherData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
word smootherName(smootherData);
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("smoother", false, false);
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().lookup("smoother") >> name;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.stream() >> name;
|
||||
}
|
||||
|
||||
// not (yet?) needed:
|
||||
// const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
|
||||
|
||||
if (matrix.symmetric())
|
||||
{
|
||||
symMatrixConstructorTable::iterator constructorIter =
|
||||
symMatrixConstructorTablePtr_->find(smootherName);
|
||||
symMatrixConstructorTablePtr_->find(name);
|
||||
|
||||
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::smoother::New", smootherData
|
||||
) << "Unknown symmetric matrix smoother " << smootherName
|
||||
<< endl << endl
|
||||
"lduMatrix::smoother::New", solverControls
|
||||
) << "Unknown symmetric matrix smoother "
|
||||
<< name << nl << nl
|
||||
<< "Valid symmetric matrix smoothers are :" << endl
|
||||
<< symMatrixConstructorTablePtr_->toc()
|
||||
<< exit(FatalIOError);
|
||||
@ -81,15 +117,15 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||
else if (matrix.asymmetric())
|
||||
{
|
||||
asymMatrixConstructorTable::iterator constructorIter =
|
||||
asymMatrixConstructorTablePtr_->find(smootherName);
|
||||
asymMatrixConstructorTablePtr_->find(name);
|
||||
|
||||
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::smoother::New", smootherData
|
||||
) << "Unknown asymmetric matrix smoother " << smootherName
|
||||
<< endl << endl
|
||||
"lduMatrix::smoother::New", solverControls
|
||||
) << "Unknown asymmetric matrix smoother "
|
||||
<< name << nl << nl
|
||||
<< "Valid asymmetric matrix smoothers are :" << endl
|
||||
<< asymMatrixConstructorTablePtr_->toc()
|
||||
<< exit(FatalIOError);
|
||||
@ -111,8 +147,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::smoother::New", smootherData
|
||||
) << "cannot solve incomplete matrix, no off-diagonal coefficients"
|
||||
"lduMatrix::smoother::New", solverControls
|
||||
) << "cannot solve incomplete matrix, "
|
||||
"no diagonal or off-diagonal coefficient"
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return autoPtr<lduMatrix::smoother>(NULL);
|
||||
|
||||
@ -45,10 +45,10 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
{
|
||||
word solverName(solverData);
|
||||
word name(solverControls.lookup("solver"));
|
||||
|
||||
if (matrix.diagonal())
|
||||
{
|
||||
@ -61,22 +61,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (matrix.symmetric())
|
||||
{
|
||||
symMatrixConstructorTable::iterator constructorIter =
|
||||
symMatrixConstructorTablePtr_->find(solverName);
|
||||
symMatrixConstructorTablePtr_->find(name);
|
||||
|
||||
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::solver::New", solverData
|
||||
) << "Unknown symmetric matrix solver " << solverName
|
||||
<< endl << endl
|
||||
"lduMatrix::solver::New", solverControls
|
||||
) << "Unknown symmetric matrix solver " << name << nl << nl
|
||||
<< "Valid symmetric matrix solvers are :" << endl
|
||||
<< symMatrixConstructorTablePtr_->toc()
|
||||
<< exit(FatalIOError);
|
||||
@ -91,22 +90,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (matrix.asymmetric())
|
||||
{
|
||||
asymMatrixConstructorTable::iterator constructorIter =
|
||||
asymMatrixConstructorTablePtr_->find(solverName);
|
||||
asymMatrixConstructorTablePtr_->find(name);
|
||||
|
||||
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::solver::New", solverData
|
||||
) << "Unknown asymmetric matrix solver " << solverName
|
||||
<< endl << endl
|
||||
"lduMatrix::solver::New", solverControls
|
||||
) << "Unknown asymmetric matrix solver " << name << nl << nl
|
||||
<< "Valid asymmetric matrix solvers are :" << endl
|
||||
<< asymMatrixConstructorTablePtr_->toc()
|
||||
<< exit(FatalIOError);
|
||||
@ -121,7 +119,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -129,7 +127,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"lduMatrix::solver::New", solverData
|
||||
"lduMatrix::solver::New", solverControls
|
||||
) << "cannot solve incomplete matrix, "
|
||||
"no diagonal or off-diagonal coefficient"
|
||||
<< exit(FatalIOError);
|
||||
@ -148,7 +146,7 @@ Foam::lduMatrix::solver::solver
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
fieldName_(fieldName),
|
||||
@ -156,12 +154,7 @@ Foam::lduMatrix::solver::solver
|
||||
interfaceBouCoeffs_(interfaceBouCoeffs),
|
||||
interfaceIntCoeffs_(interfaceIntCoeffs),
|
||||
interfaces_(interfaces),
|
||||
|
||||
controlDict_(solverData),
|
||||
|
||||
maxIter_(1000),
|
||||
tolerance_(1e-6),
|
||||
relTol_(0)
|
||||
controlDict_(solverControls)
|
||||
{
|
||||
readControls();
|
||||
}
|
||||
@ -171,16 +164,15 @@ Foam::lduMatrix::solver::solver
|
||||
|
||||
void Foam::lduMatrix::solver::readControls()
|
||||
{
|
||||
controlDict_.readIfPresent("maxIter", maxIter_);
|
||||
controlDict_.readIfPresent("tolerance", tolerance_);
|
||||
controlDict_.readIfPresent("relTol", relTol_);
|
||||
maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000);
|
||||
tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6);
|
||||
relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0);
|
||||
}
|
||||
|
||||
|
||||
void Foam::lduMatrix::solver::read(Istream& solverData)
|
||||
void Foam::lduMatrix::solver::read(const dictionary& solverControls)
|
||||
{
|
||||
word solverName(solverData);
|
||||
solverData >> controlDict_;
|
||||
controlDict_ = solverControls;
|
||||
readControls();
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Foam
|
||||
Foam::DICPreconditioner::DICPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream&
|
||||
const dictionary&
|
||||
)
|
||||
:
|
||||
lduMatrix::preconditioner(sol),
|
||||
|
||||
@ -67,11 +67,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and preconditioner data stream
|
||||
//- Construct from matrix components and preconditioner solver controls
|
||||
DICPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const lduMatrix::solver&,
|
||||
const dictionary& solverControlsUnused
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Foam
|
||||
Foam::DILUPreconditioner::DILUPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream&
|
||||
const dictionary&
|
||||
)
|
||||
:
|
||||
lduMatrix::preconditioner(sol),
|
||||
|
||||
@ -67,11 +67,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and preconditioner data stream
|
||||
//- Construct from matrix components and preconditioner solver controls
|
||||
DILUPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const lduMatrix::solver&,
|
||||
const dictionary& solverControlsUnused
|
||||
);
|
||||
|
||||
|
||||
@ -94,8 +94,7 @@ public:
|
||||
const direction cmpt=0
|
||||
) const;
|
||||
|
||||
//- Return wT the transpose-matrix preconditioned form of
|
||||
// residual rT.
|
||||
//- Return wT the transpose-matrix preconditioned form of residual rT.
|
||||
virtual void preconditionT
|
||||
(
|
||||
scalarField& wT,
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Foam
|
||||
Foam::FDICPreconditioner::FDICPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream&
|
||||
const dictionary&
|
||||
)
|
||||
:
|
||||
lduMatrix::preconditioner(sol),
|
||||
@ -164,7 +164,7 @@ void Foam::FDICPreconditioner::precondition
|
||||
__builtin_prefetch (&uPtr[face+96],0,0);
|
||||
__builtin_prefetch (&lPtr[face+96],0,0);
|
||||
__builtin_prefetch (&rDuUpperPtr[face+96],0,0);
|
||||
__builtin_prefetch (&wAPtr[uPtr[face+32]],0,1);
|
||||
__builtin_prefetch (&wAPtr[uPtr[face+32]],0,1);
|
||||
__builtin_prefetch (&wAPtr[lPtr[face+32]],0,1);
|
||||
#endif
|
||||
|
||||
|
||||
@ -80,11 +80,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and preconditioner data stream
|
||||
//- Construct from matrix components and preconditioner solver controls
|
||||
FDICPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const lduMatrix::solver&,
|
||||
const dictionary& solverControlsUnused
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Foam
|
||||
Foam::GAMGPreconditioner::GAMGPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
GAMGSolver
|
||||
@ -55,7 +55,7 @@ Foam::GAMGPreconditioner::GAMGPreconditioner
|
||||
sol.interfaceBouCoeffs(),
|
||||
sol.interfaceIntCoeffs(),
|
||||
sol.interfaces(),
|
||||
preconditionerData
|
||||
solverControls
|
||||
),
|
||||
lduMatrix::preconditioner(sol),
|
||||
nVcycles_(2)
|
||||
@ -75,13 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner()
|
||||
void Foam::GAMGPreconditioner::readControls()
|
||||
{
|
||||
GAMGSolver::readControls();
|
||||
controlDict_.readIfPresent("nVcycles", nVcycles_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::GAMGPreconditioner::read(Istream& solverData)
|
||||
{
|
||||
GAMGSolver::read(solverData);
|
||||
nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -55,17 +55,14 @@ class GAMGPreconditioner
|
||||
public GAMGSolver,
|
||||
public lduMatrix::preconditioner
|
||||
{
|
||||
// Private data
|
||||
protected:
|
||||
// Protected data
|
||||
|
||||
//- Number of V-cycles to perform
|
||||
label nVcycles_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Read control parameters from the control dictionary
|
||||
void readControls();
|
||||
|
||||
//- Read the control parameters from the controlDict_
|
||||
virtual void readControls();
|
||||
|
||||
public:
|
||||
|
||||
@ -75,11 +72,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given solver and preconditioner data stream
|
||||
//- Construct from matrix components and preconditioner solver controls
|
||||
GAMGPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const lduMatrix::solver&,
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
@ -90,9 +87,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read and reset the preconditioner parameters from the given stream
|
||||
virtual void read(Istream& preconditionerData);
|
||||
|
||||
//- Return wA the preconditioned form of residual rA
|
||||
virtual void precondition
|
||||
(
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
Foam::diagonalPreconditioner::diagonalPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream&
|
||||
const dictionary&
|
||||
)
|
||||
:
|
||||
lduMatrix::preconditioner(sol),
|
||||
@ -77,10 +77,6 @@ Foam::diagonalPreconditioner::diagonalPreconditioner
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::diagonalPreconditioner::read(Istream&)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::diagonalPreconditioner::precondition
|
||||
(
|
||||
scalarField& wA,
|
||||
|
||||
@ -56,7 +56,7 @@ class diagonalPreconditioner
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- The reciprocal diagonal
|
||||
//- The reciprocal diagonal
|
||||
scalarField rD;
|
||||
|
||||
|
||||
@ -77,11 +77,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and preconditioner data stream
|
||||
//- Construct from matrix components and preconditioner solver controls
|
||||
diagonalPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const lduMatrix::solver&,
|
||||
const dictionary& solverControlsUnused
|
||||
);
|
||||
|
||||
|
||||
@ -93,9 +93,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read and reset the preconditioner parameters from the given stream
|
||||
virtual void read(Istream& preconditionerData);
|
||||
|
||||
//- Return wA the preconditioned form of residual rA
|
||||
virtual void precondition
|
||||
(
|
||||
@ -104,8 +101,7 @@ public:
|
||||
const direction cmpt=0
|
||||
) const;
|
||||
|
||||
//- Return wT the transpose-matrix preconditioned form of
|
||||
// residual rT.
|
||||
//- Return wT the transpose-matrix preconditioned form of residual rT.
|
||||
virtual void preconditionT
|
||||
(
|
||||
scalarField& wT,
|
||||
@ -113,7 +109,7 @@ public:
|
||||
const direction cmpt=0
|
||||
) const
|
||||
{
|
||||
return(precondition(wT, rT, cmpt));
|
||||
return precondition(wT, rT, cmpt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
Foam::noPreconditioner::noPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream&
|
||||
const dictionary&
|
||||
)
|
||||
:
|
||||
lduMatrix::preconditioner(sol)
|
||||
@ -56,10 +56,6 @@ Foam::noPreconditioner::noPreconditioner
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::noPreconditioner::read(Istream&)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::noPreconditioner::precondition
|
||||
(
|
||||
scalarField& wA,
|
||||
|
||||
@ -68,11 +68,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and preconditioner data stream
|
||||
//- Construct from matrix components and preconditioner solver controls
|
||||
noPreconditioner
|
||||
(
|
||||
const lduMatrix::solver& sol,
|
||||
Istream& preconditionerData
|
||||
const lduMatrix::solver&,
|
||||
const dictionary& solverControlsUnused
|
||||
);
|
||||
|
||||
|
||||
@ -84,9 +84,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read and reset the preconditioner parameters from the given stream
|
||||
virtual void read(Istream& preconditionerData);
|
||||
|
||||
//- Return wA the preconditioned form of residual rA
|
||||
virtual void precondition
|
||||
(
|
||||
@ -95,8 +92,7 @@ public:
|
||||
const direction cmpt=0
|
||||
) const;
|
||||
|
||||
//- Return wT the transpose-matrix preconditioned form of
|
||||
// residual rT.
|
||||
//- Return wT the transpose-matrix preconditioned form of residual rT.
|
||||
virtual void preconditionT
|
||||
(
|
||||
scalarField& wT,
|
||||
@ -104,7 +100,7 @@ public:
|
||||
const direction cmpt=0
|
||||
) const
|
||||
{
|
||||
return(precondition(wT, rT, cmpt));
|
||||
return precondition(wT, rT, cmpt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -27,8 +27,10 @@ Class
|
||||
|
||||
Description
|
||||
Simplified diagonal-based incomplete Cholesky smoother for symmetric
|
||||
matrices. In order to improve efficiency the residual is evaluated after
|
||||
every nSweeps sweeps.
|
||||
matrices.
|
||||
|
||||
To improve efficiency, the residual is evaluated after every nSweeps
|
||||
sweeps.
|
||||
|
||||
SourceFiles
|
||||
DICSmoother.C
|
||||
|
||||
@ -26,9 +26,9 @@ Class
|
||||
Foam::DICGaussSeidelSmoother
|
||||
|
||||
Description
|
||||
Combined DIC/GaussSeidel smoother for symmetric
|
||||
matrices in which DIC smoothing is followed by GaussSeidel to ensure that
|
||||
any "spikes" created by the DIC sweeps are smoothed-out.
|
||||
Combined DIC/GaussSeidel smoother for symmetric matrices in which DIC
|
||||
smoothing is followed by GaussSeidel to ensure that any "spikes" created
|
||||
by the DIC sweeps are smoothed-out.
|
||||
|
||||
SourceFiles
|
||||
DICGaussSeidelSmoother.C
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DICGaussSeidelSmoother Declaration
|
||||
Class DICGaussSeidelSmoother Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class DICGaussSeidelSmoother
|
||||
@ -57,6 +57,7 @@ class DICGaussSeidelSmoother
|
||||
// Private data
|
||||
|
||||
DICSmoother dicSmoother_;
|
||||
|
||||
GaussSeidelSmoother gsSmoother_;
|
||||
|
||||
|
||||
|
||||
@ -27,8 +27,9 @@ Class
|
||||
|
||||
Description
|
||||
Simplified diagonal-based incomplete LU smoother for asymmetric matrices.
|
||||
In order to improve efficiency the residual is evaluated after every
|
||||
nSweeps sweeps.
|
||||
|
||||
To improve efficiency, the residual is evaluated after every nSweeps
|
||||
sweeps.
|
||||
|
||||
SourceFiles
|
||||
DILUSmoother.C
|
||||
@ -46,7 +47,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DILUSmoother Declaration
|
||||
Class DILUSmoother Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class DILUSmoother
|
||||
|
||||
@ -26,9 +26,9 @@ Class
|
||||
Foam::DILUGaussSeidelSmoother
|
||||
|
||||
Description
|
||||
Combined DILU/GaussSeidel smoother for asymmetric
|
||||
matrices in which DILU smoothing is followed by GaussSeidel to ensure that
|
||||
any "spikes" created by the DILU sweeps are smoothed-out.
|
||||
Combined DILU/GaussSeidel smoother for asymmetric matrices in which
|
||||
DILU smoothing is followed by GaussSeidel to ensure that any "spikes"
|
||||
created by the DILU sweeps are smoothed-out.
|
||||
|
||||
SourceFiles
|
||||
DILUGaussSeidelSmoother.C
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DILUGaussSeidelSmoother Declaration
|
||||
Class DILUGaussSeidelSmoother Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class DILUGaussSeidelSmoother
|
||||
@ -57,6 +57,7 @@ class DILUGaussSeidelSmoother
|
||||
// Private data
|
||||
|
||||
DILUSmoother diluSmoother_;
|
||||
|
||||
GaussSeidelSmoother gsSmoother_;
|
||||
|
||||
|
||||
|
||||
@ -37,36 +37,31 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::IStringStream Foam::BICCG::solverDataStream
|
||||
Foam::dictionary Foam::BICCG::solverDict
|
||||
(
|
||||
const scalar tolerance,
|
||||
const scalar tol,
|
||||
const scalar relTol
|
||||
) const
|
||||
)
|
||||
{
|
||||
return IStringStream
|
||||
(
|
||||
"{ preconditioner DILU;"
|
||||
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
|
||||
);
|
||||
dictionary dict(IStringStream("solver PBiCG; preconditioner DILU;")());
|
||||
dict.add("tolerance", tol);
|
||||
dict.add("relTol", relTol);
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
Foam::IStringStream Foam::BICCG::solverDataStream
|
||||
Foam::dictionary Foam::BICCG::solverDict
|
||||
(
|
||||
const word& solverName,
|
||||
Istream& solverData
|
||||
) const
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
scalar tolerance(readScalar(solverData));
|
||||
scalar relTol(readScalar(solverData));
|
||||
scalar tol(readScalar(is));
|
||||
scalar relTol(readScalar(is));
|
||||
|
||||
return IStringStream
|
||||
(
|
||||
solverName + "{ preconditioner DILU;"
|
||||
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
|
||||
);
|
||||
return solverDict(tol, relTol);
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +74,7 @@ Foam::BICCG::BICCG
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
const scalar tolerance,
|
||||
const scalar relTol
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
PBiCG
|
||||
@ -90,7 +84,7 @@ Foam::BICCG::BICCG
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverDataStream(tolerance, relTol)()
|
||||
solverControls
|
||||
)
|
||||
{}
|
||||
|
||||
@ -102,7 +96,8 @@ Foam::BICCG::BICCG
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const scalar tolerance,
|
||||
const scalar relTol
|
||||
)
|
||||
:
|
||||
PBiCG
|
||||
@ -112,18 +107,8 @@ Foam::BICCG::BICCG
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverDataStream(word::null, solverData)()
|
||||
solverDict(tolerance, relTol)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::BICCG::read(Istream& solverData)
|
||||
{
|
||||
word solverName(solverData);
|
||||
PBiCG::read(solverDataStream(solverName, solverData)());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -32,7 +32,7 @@ Description
|
||||
|
||||
Deprecated
|
||||
This solver is present for backward-compatibility and the PBiCG solver
|
||||
should be used for preference.
|
||||
should be used instead.
|
||||
|
||||
SourceFiles
|
||||
BICCG.C
|
||||
@ -65,31 +65,39 @@ class BICCG
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const BICCG&);
|
||||
|
||||
//- Return the dictionary data-stream constructed from the components.
|
||||
// Needed for backward compatibility
|
||||
IStringStream solverDataStream
|
||||
(
|
||||
const scalar tolerance,
|
||||
const scalar relTol
|
||||
) const;
|
||||
|
||||
//- Return the dictionary data-stream constructed from the old-style
|
||||
// data-stream. Needed for backward compatibility
|
||||
IStringStream solverDataStream
|
||||
(
|
||||
const word& solverName,
|
||||
Istream& solverData
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Return the dictionary constructed from the components.
|
||||
// Needed for backward compatibility
|
||||
static dictionary solverDict
|
||||
(
|
||||
const scalar tol,
|
||||
const scalar relTol
|
||||
);
|
||||
|
||||
//- Return the dictionary constructed from the old-style data-stream.
|
||||
// Needed for backward compatibility
|
||||
static dictionary solverDict(Istream&);
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("BICCG");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and solver data stream
|
||||
BICCG
|
||||
(
|
||||
const word& fieldName,
|
||||
const lduMatrix& matrix,
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
//- Construct from matrix components and tolerances
|
||||
BICCG
|
||||
(
|
||||
@ -102,28 +110,11 @@ public:
|
||||
const scalar relTol = 0.0
|
||||
);
|
||||
|
||||
//- Construct from matrix components and solver data stream
|
||||
BICCG
|
||||
(
|
||||
const word& fieldName,
|
||||
const lduMatrix& matrix,
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~BICCG()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read and reset the solver parameters from the given stream
|
||||
void read(Istream& solverData);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ Foam::GAMGSolver::GAMGSolver
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
lduMatrix::solver
|
||||
@ -59,7 +59,7 @@ Foam::GAMGSolver::GAMGSolver
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
),
|
||||
|
||||
// Default values for all controls
|
||||
@ -112,7 +112,7 @@ Foam::GAMGSolver::GAMGSolver
|
||||
"const FieldField<Field, scalar>& interfaceBouCoeffs,"
|
||||
"const FieldField<Field, scalar>& interfaceIntCoeffs,"
|
||||
"const lduInterfaceFieldPtrsList& interfaces,"
|
||||
"Istream& solverData"
|
||||
"const dictionary& solverControls"
|
||||
")"
|
||||
) << "No coarse levels created, either matrix too small for GAMG"
|
||||
" or nCellsInCoarsestLevel too large.\n"
|
||||
@ -154,6 +154,7 @@ void Foam::GAMGSolver::readControls()
|
||||
{
|
||||
lduMatrix::solver::readControls();
|
||||
|
||||
// we could also consider supplying defaults here too
|
||||
controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_);
|
||||
controlDict_.readIfPresent("nPreSweeps", nPreSweeps_);
|
||||
controlDict_.readIfPresent("nPostSweeps", nPostSweeps_);
|
||||
|
||||
@ -212,7 +212,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from lduMatrix
|
||||
//- Construct from lduMatrix and solver controls
|
||||
GAMGSolver
|
||||
(
|
||||
const word& fieldName,
|
||||
@ -220,7 +220,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -374,7 +374,7 @@ void Foam::GAMGSolver::initVcycle
|
||||
interfaceBouCoeffs_,
|
||||
interfaceIntCoeffs_,
|
||||
interfaces_,
|
||||
controlDict_.lookup("smoother")
|
||||
controlDict_
|
||||
)
|
||||
);
|
||||
|
||||
@ -408,7 +408,7 @@ void Foam::GAMGSolver::initVcycle
|
||||
interfaceLevelsBouCoeffs_[leveli],
|
||||
interfaceLevelsIntCoeffs_[leveli],
|
||||
interfaceLevels_[leveli],
|
||||
controlDict_.lookup("smoother")
|
||||
controlDict_
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -36,40 +36,33 @@ namespace Foam
|
||||
addICCGSymMatrixConstructorToTable_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::IStringStream Foam::ICCG::solverDataStream
|
||||
Foam::dictionary Foam::ICCG::solverDict
|
||||
(
|
||||
const scalar tolerance,
|
||||
const scalar tol,
|
||||
const scalar relTol
|
||||
) const
|
||||
)
|
||||
{
|
||||
return IStringStream
|
||||
(
|
||||
"{ preconditioner DIC;"
|
||||
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
|
||||
);
|
||||
dictionary dict(IStringStream("solver PCG; preconditioner DIC;")());
|
||||
dict.add("tolerance", tol);
|
||||
dict.add("relTol", relTol);
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
Foam::IStringStream Foam::ICCG::solverDataStream
|
||||
Foam::dictionary Foam::ICCG::solverDict
|
||||
(
|
||||
const word& solverName,
|
||||
Istream& solverData
|
||||
) const
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
scalar tolerance(readScalar(solverData));
|
||||
scalar relTol(readScalar(solverData));
|
||||
scalar tol(readScalar(is));
|
||||
scalar relTol(readScalar(is));
|
||||
|
||||
return IStringStream
|
||||
(
|
||||
solverName + "{ preconditioner DIC;"
|
||||
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
|
||||
);
|
||||
return solverDict(tol, relTol);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ICCG::ICCG
|
||||
@ -79,8 +72,7 @@ Foam::ICCG::ICCG
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
const scalar tolerance,
|
||||
const scalar relTol
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
PCG
|
||||
@ -90,7 +82,7 @@ Foam::ICCG::ICCG
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverDataStream(tolerance, relTol)()
|
||||
solverControls
|
||||
)
|
||||
{}
|
||||
|
||||
@ -102,7 +94,8 @@ Foam::ICCG::ICCG
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const scalar tolerance,
|
||||
const scalar relTol
|
||||
)
|
||||
:
|
||||
PCG
|
||||
@ -112,18 +105,8 @@ Foam::ICCG::ICCG
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverDataStream(word::null, solverData)()
|
||||
solverDict(tolerance, relTol)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ICCG::read(Istream& solverData)
|
||||
{
|
||||
word solverName(solverData);
|
||||
PCG::read(solverDataStream(solverName, solverData)());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -65,31 +65,38 @@ class ICCG
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ICCG&);
|
||||
|
||||
//- Return the dictionary data-stream constructed from the components.
|
||||
// Needed for backward compatibility
|
||||
IStringStream solverDataStream
|
||||
(
|
||||
const scalar tolerance,
|
||||
const scalar relTol
|
||||
) const;
|
||||
|
||||
//- Return the dictionary data-stream constructed from the old-style
|
||||
// data-stream. Needed for backward compatibility
|
||||
IStringStream solverDataStream
|
||||
(
|
||||
const word& solverName,
|
||||
Istream& solverData
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Return the dictionary constructed from the components.
|
||||
// Needed for backward compatibility
|
||||
static dictionary solverDict
|
||||
(
|
||||
const scalar tol,
|
||||
const scalar relTol
|
||||
);
|
||||
|
||||
//- Return the dictionary constructed from the old-style data-stream.
|
||||
// Needed for backward compatibility
|
||||
static dictionary solverDict(Istream&);
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ICCG");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and solver data stream
|
||||
ICCG
|
||||
(
|
||||
const word& fieldName,
|
||||
const lduMatrix& matrix,
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
//- Construct from matrix components and tolerances
|
||||
ICCG
|
||||
(
|
||||
@ -102,28 +109,11 @@ public:
|
||||
const scalar relTol = 0.0
|
||||
);
|
||||
|
||||
//- Construct from matrix components and solver data stream
|
||||
ICCG
|
||||
(
|
||||
const word& fieldName,
|
||||
const lduMatrix& matrix,
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~ICCG()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read and reset the solver parameters from the given stream
|
||||
void read(Istream& solverData);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::PBiCG::PBiCG
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
lduMatrix::solver
|
||||
@ -56,7 +56,7 @@ Foam::PBiCG::PBiCG
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
{}
|
||||
|
||||
@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve
|
||||
const direction cmpt
|
||||
) const
|
||||
{
|
||||
word preconditionerName(controlDict_.lookup("preconditioner"));
|
||||
|
||||
// --- Setup class containing solver performance data
|
||||
lduMatrix::solverPerformance solverPerf
|
||||
(
|
||||
preconditionerName + typeName,
|
||||
lduMatrix::preconditioner::getName(controlDict_) + typeName,
|
||||
fieldName_
|
||||
);
|
||||
|
||||
@ -128,7 +126,7 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve
|
||||
lduMatrix::preconditioner::New
|
||||
(
|
||||
*this,
|
||||
controlDict_.lookup("preconditioner")
|
||||
controlDict_
|
||||
);
|
||||
|
||||
// --- Solver iteration
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::PCG::PCG
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
)
|
||||
:
|
||||
lduMatrix::solver
|
||||
@ -56,7 +56,7 @@ Foam::PCG::PCG
|
||||
interfaceBouCoeffs,
|
||||
interfaceIntCoeffs,
|
||||
interfaces,
|
||||
solverData
|
||||
solverControls
|
||||
)
|
||||
{}
|
||||
|
||||
@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve
|
||||
const direction cmpt
|
||||
) const
|
||||
{
|
||||
word preconditionerName(controlDict_.lookup("preconditioner"));
|
||||
|
||||
// --- Setup class containing solver performance data
|
||||
lduMatrix::solverPerformance solverPerf
|
||||
(
|
||||
preconditionerName + typeName,
|
||||
lduMatrix::preconditioner::getName(controlDict_) + typeName,
|
||||
fieldName_
|
||||
);
|
||||
|
||||
@ -119,7 +117,7 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve
|
||||
lduMatrix::preconditioner::New
|
||||
(
|
||||
*this,
|
||||
controlDict_.lookup("preconditioner")
|
||||
controlDict_
|
||||
);
|
||||
|
||||
// --- Solver iteration
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
|
||||
Description
|
||||
Preconditioned conjugate gradient solver for symmetric lduMatrices
|
||||
using a run-time selectable preconditiioner.
|
||||
using a run-time selectable preconditioner.
|
||||
|
||||
SourceFiles
|
||||
PCG.C
|
||||
@ -69,7 +69,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from matrix components and solver data stream
|
||||
//- Construct from matrix components and solver controls
|
||||
PCG
|
||||
(
|
||||
const word& fieldName,
|
||||
@ -77,7 +77,7 @@ public:
|
||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||
const lduInterfaceFieldPtrsList& interfaces,
|
||||
Istream& solverData
|
||||
const dictionary& solverControls
|
||||
);
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user