Merge branch 'master' of /home/hunt2/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2008-10-16 13:09:46 +01:00
82 changed files with 1113 additions and 657 deletions

View File

@ -83,6 +83,19 @@ HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
}
}
template<class T, class Key, class Hash>
HashTable<T, Key, Hash>::HashTable(const xfer<HashTable<T, Key, Hash> >& ht)
:
HashTableName(),
tableSize_(0),
table_(NULL),
nElmts_(0),
endIter_(*this, NULL, 0),
endConstIter_(*this, NULL, 0)
{
transfer(*ht);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -41,6 +41,7 @@ SourceFiles
#include "label.H"
#include "word.H"
#include "className.H"
#include "xfer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -155,6 +156,9 @@ public:
//- Construct as copy
HashTable(const HashTable<T, Key, Hash>&);
//- Construct by transferring the parameter contents
HashTable(const xfer<HashTable<T, Key, Hash> >&);
// Destructor

View File

@ -76,6 +76,24 @@ StaticHashTable<T, Key, Hash>::StaticHashTable
{}
template<class T, class Key, class Hash>
StaticHashTable<T, Key, Hash>::StaticHashTable
(
const xfer<StaticHashTable<T, Key, Hash> >& ht
)
:
StaticHashTableName(),
keys_(0),
objects_(0),
nElmts_(0),
endIter_(*this, 0, 0),
endConstIter_(*this, 0, 0)
{
transfer(*ht);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class T, class Key, class Hash>

View File

@ -46,6 +46,7 @@ SourceFiles
#include "label.H"
#include "word.H"
#include "className.H"
#include "xfer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -146,6 +147,8 @@ public:
//- Construct as copy
StaticHashTable(const StaticHashTable<T, Key, Hash>&);
//- Construct as copy
StaticHashTable(const xfer<StaticHashTable<T, Key, Hash> >&);
// Destructor

View File

@ -92,6 +92,12 @@ CompactListList<T>::CompactListList(const UList<label>& rowSizes, const T& t)
}
template<class T>
CompactListList<T>::CompactListList(const xfer<CompactListList<T> >& lst)
{
transfer(*lst);
}
template<class T>
CompactListList<T>::CompactListList(CompactListList<T>& cll, bool reUse)
:

View File

@ -103,6 +103,9 @@ public:
//- Construct given list of row-sizes
CompactListList(const UList<label>& rowSizes, const T&);
//- Construct by transferring the parameter contents
CompactListList(const xfer<CompactListList<T> >&);
//- Construct as copy or re-use as specified.
CompactListList(CompactListList<T>&, bool reUse);

View File

@ -84,6 +84,10 @@ class DynamicList
//- Allocated size for underlying List.
label allocSize_;
// Private Member Functions
// Disabled, since the usefulness and semantics are not quite clear
void setSize(const label, const T&);
public:
@ -117,12 +121,14 @@ public:
// Edit
//- Reset size of List.
//- Alter the list size.
// When the new size is greater than the addressed list size, the
// allocated list sizes is adjusted and the
// addressed size does not change.
// Otherwise the addressed list size is just reduced and the
// allocated size does not change.
inline void setSize(const label);
//- Reset size of List and value for new elements.
inline void setSize(const label, const T&);
//- Clear the list, i.e. set the size to zero.
// Allocated size does not change
inline void clear();
@ -156,7 +162,7 @@ public:
// resizing the list if necessary
inline T& operator()(const label);
//- Assignment of all entries to the given value
//- Assignment of all addressed entries to the given value
inline void operator=(const T&);
//- Assignment from List<T>. Also handles assignment from DynamicList.

View File

@ -33,7 +33,7 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
List<T>(SizeInc),
allocSize_(SizeInc)
{
List<T>::size() = 0;
List<T>::size(0);
}
@ -47,7 +47,7 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
List<T>(s),
allocSize_(s)
{
List<T>::size() = 0;
List<T>::size(0);
}
@ -79,18 +79,19 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
const label s
)
{
if (s <= List<T>::size())
label nextFree = List<T>::size();
if (s <= nextFree)
{
// shrink addressable size, leave allocated size untouched
List<T>::size() = s;
// adjust addressed size, leave allocated size untouched
nextFree = s;
}
else
{
label nextFree = List<T>::size();
// adjust allocated size, leave addressed size untouched
allocSize_ = s;
List<T>::setSize(allocSize_);
List<T>::size() = nextFree;
}
List<T>::size(nextFree);
}
@ -112,14 +113,17 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
allocSize_ = s;
List<T>::setSize(allocSize_, t);
List<T>::size() = nextFree;
=======
>>>>>>> olesenm:src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
}
List<T>::size(nextFree);
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear()
{
List<T>::size() = 0;
List<T>::size(0);
}
@ -193,7 +197,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append(const T& e)
List<T>::setSize(allocSize_);
}
List<T>::size() = nextFree;
List<T>::size(nextFree);
this->operator[](nextFree - 1) = e;
}
@ -214,7 +218,7 @@ inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
const T& val = List<T>::operator[](nextFree);
List<T>::size() = nextFree;
List<T>::size(nextFree);
return val;
}
@ -242,7 +246,7 @@ inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator()
List<T>::setSize(allocSize_);
}
List<T>::size() = nextFree;
List<T>::size(nextFree);
return this->operator[](i);
}
@ -255,7 +259,6 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
)
{
List<T>::operator=(t);
allocSize_ = List<T>::size();
}

View File

@ -125,6 +125,14 @@ Foam::List<T>::List(const List<T>& a)
}
// Construct by transferring the parameter contents
template<class T>
Foam::List<T>::List(const xfer<List<T> >& lst)
{
transfer(*lst);
}
// Construct as copy or re-use as specified.
template<class T>
Foam::List<T>::List(List<T>& a, bool reUse)

View File

@ -43,6 +43,7 @@ SourceFiles
#include "UList.H"
#include "autoPtr.H"
#include "xfer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -77,6 +78,12 @@ class List
public UList<T>
{
protected:
//- Override size to be inconsistent with allocated storage.
// Use with care.
inline void size(const label);
public:
// Constructors
@ -93,6 +100,9 @@ public:
//- Copy constructor.
List(const List<T>&);
//- Construct by transferring the parameter contents
List(const xfer<List<T> >&);
//- Construct as copy or re-use as specified.
List(List<T>&, bool reUse);
@ -142,9 +152,6 @@ public:
//- Return the number of elements in the UList.
inline label size() const;
//- Override size to be inconsistent with allocated storage.
// Use with care.
inline label& size();
// Edit

View File

@ -53,19 +53,18 @@ inline T& Foam::List<T>::newElmt(const label i)
template<class T>
inline Foam::label Foam::List<T>::size() const
inline void Foam::List<T>::size(const label n)
{
return UList<T>::size_;
UList<T>::size_ = n;
}
template<class T>
inline Foam::label& Foam::List<T>::size()
inline Foam::label Foam::List<T>::size() const
{
return UList<T>::size_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>

View File

@ -44,6 +44,7 @@ PackedList<nBits>::PackedList(const label size, const unsigned int val)
}
//- Copy constructor.
template<int nBits>
PackedList<nBits>::PackedList(const PackedList<nBits>& PList)
@ -53,6 +54,13 @@ PackedList<nBits>::PackedList(const PackedList<nBits>& PList)
{}
template<int nBits>
PackedList<nBits>::PackedList(const xfer<PackedList<nBits> >& lst)
{
transfer(*lst);
}
//- Construct from labelList
template<int nBits>
PackedList<nBits>::PackedList(const labelList& lst)

View File

@ -134,6 +134,9 @@ public:
//- Copy constructor.
PackedList(const PackedList<nBits>& PList);
//- Construct by transferring the parameter contents
PackedList(const xfer<PackedList<nBits> >&);
//- Construct from labelList.
PackedList(const labelList&);

View File

@ -71,6 +71,13 @@ Foam::PtrList<T>::PtrList(const PtrList<T>& a, const CloneArg& cloneArg)
}
template<class T>
Foam::PtrList<T>::PtrList(const xfer<PtrList<T> >& lst)
{
transfer(*lst);
}
template<class T>
Foam::PtrList<T>::PtrList(PtrList<T>& a, bool reUse)
:

View File

@ -129,6 +129,9 @@ public:
template<class CloneArg>
PtrList(const PtrList<T>&, const CloneArg&);
//- Construct by transferring the parameter contents
PtrList(const xfer<PtrList<T> >&);
//- Construct as copy or re-use as specified.
PtrList(PtrList<T>&, bool reUse);

View File

@ -40,6 +40,17 @@ Foam::SortableList<Type>::SortableList(const List<Type>& values)
sort();
}
// Construct from List by transferring
template <class Type>
Foam::SortableList<Type>::SortableList(const xfer<List<Type> >& values)
:
List<Type>(),
indices_((*values).size())
{
List<Type>::transfer(*values);
sort();
}
// Construct given size. Sort later on.
template <class Type>
@ -86,7 +97,7 @@ void Foam::SortableList<Type>::sort()
indices_[i] = i;
}
//Foam::sort(indices_, less(*this));
// Foam::sort(indices_, less(*this));
Foam::stableSort(indices_, less(*this));
List<Type> tmpValues(this->size());

View File

@ -29,6 +29,8 @@ Description
A list that is sorted upon construction or when explicitly requested
with the sort() method.
Uses the Foam::stableSort() algorithm.
SourceFiles
SortableList.C
@ -84,10 +86,14 @@ public:
// Constructors
//- Construct from List, sorting the elements. Starts with indices set
// to index in argument
//- Construct from List, sorting the elements.
// Starts with indices set to index in argument
explicit SortableList(const List<Type>&);
//- Construct from tranferred List, sorting the elements.
// Starts with indices set to index in argument
explicit SortableList(const xfer<List<Type> >&);
//- Construct given size. Sort later on.
explicit SortableList(const label size);

View File

@ -60,7 +60,7 @@ void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
template<class T>
Foam::Ostream& Foam:: operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
{
// Write list contents depending on data format
if (os.format() == IOstream::ASCII || !contiguous<T>())

View File

@ -50,6 +50,13 @@ UPtrList<T>::UPtrList(const label s)
{}
template<class T>
UPtrList<T>::UPtrList(const xfer<UPtrList<T> >& lst)
{
transfer(*lst);
}
template<class T>
UPtrList<T>::UPtrList(UPtrList<T>& a, bool reUse)
:

View File

@ -110,6 +110,9 @@ public:
//- Construct with length specified.
explicit UPtrList(const label);
//- Construct by transferring the parameter contents
UPtrList(const xfer<UPtrList<T> >&);
//- Construct as copy or re-use as specified.
UPtrList(UPtrList<T>&, bool reUse);

View File

@ -0,0 +1,155 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::xfer
Description
A simple container that can be used to copy or transfer the contents
of objects of type \<T\>.
Since it is decided upon construction of the xfer object whether the
parameter is to be copied or transferred, the contents of resulting
object can be transferred unconditionally.
This greatly simplifies defining the constructors for other classes
with mixed transfer/copy semantics.
The wrapped object of type \<T\> must implement a transfer() method and
an operator=() copy method.
Note
The macros xferCopy(T,arg) and xferMove(T,arg) can be used as
workarounds for passing temporaries to copy-constructors.
SourceFiles
xferI.H
\*---------------------------------------------------------------------------*/
#ifndef xfer_H
#define xfer_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class xfer Declaration
\*---------------------------------------------------------------------------*/
template<class T>
class xfer
{
// Private data
//- Pointer to temporary object
mutable T* ptr_;
public:
// Constructors
//- Store object pointer and manage its deletion
// Can also be used later to transfer by assignment
inline explicit xfer(T* = 0);
//- Construct by copying or by transferring the parameter contents
inline xfer(T&, bool allowTransfer=false);
//- Construct by copying the parameter contents
inline xfer(const T&);
//- Construct by transferring the contents
inline xfer(const xfer<T>&);
// Destructor
inline ~xfer();
// Member Operators
//- Transfer the contents into the object
inline void operator=(T&);
//- Transfer the contents into the object
inline void operator=(const xfer<T>&);
//- Return a non-const reference to const object
// @sa xferCopy, xferMove macros alternatives for copy-constructors
inline const xfer<T>& operator()() const;
//- Reference to the underlying datatype
inline T& operator*() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
/**
* @def xferCopy(T,arg)
* Construct by copying the contents of the @a arg
* and return a const reference to an xfer of type \<T\>
*
* Useful for constructors where the argument is temporary.
* This is a workaround for a template resolution issue.
*
* @sa xferMove and Foam::xfer
*/
#define xferCopy(T,arg) \
(static_cast<const Foam::xfer< T >&>(Foam::xfer< T >(arg)()))
/**
* @def xferMove(T,arg)
* Construct by transferring the contents of the @a arg
* and return a const reference to an xfer of type \<T\>
*
* Useful for constructors where the argument is temporary.
* This is a workaround for a template resolution issue.
*
* @par Example Use
* @code
* List<label> a;
* ...
* List<label> b(xferMove(List<label>, a));
* @endcode
*
* @sa xferCopy and Foam::xfer
*/
#define xferMove(T,arg) \
(static_cast<const Foam::xfer< T >&>(Foam::xfer< T >(arg, true)()))
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "xferI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
inline Foam::xfer<T>::xfer(T* p)
:
ptr_(p ? p : new T)
{}
template<class T>
inline Foam::xfer<T>::xfer(T& t, bool allowTransfer)
:
ptr_(new T)
{
if (allowTransfer)
{
ptr_->transfer(t);
}
else
{
ptr_->operator=(t);
}
}
template<class T>
inline Foam::xfer<T>::xfer(const T& t)
:
ptr_(new T)
{
ptr_->operator=(t);
}
template<class T>
inline Foam::xfer<T>::xfer(const xfer<T>& t)
:
ptr_(new T)
{
ptr_->transfer(*(t.ptr_));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class T>
inline Foam::xfer<T>::~xfer()
{
delete ptr_;
ptr_ = 0;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
inline void Foam::xfer<T>::operator=(T& t)
{
ptr_->transfer(t);
}
template<class T>
inline void Foam::xfer<T>::operator=(const xfer<T>& t)
{
// silently ignore copy to self
if (this != &t)
{
ptr_->transfer(*(t.ptr_));
}
}
template<class T>
inline const Foam::xfer<T>& Foam::xfer<T>::operator()() const
{
return *this;
}
template<class T>
inline T& Foam::xfer<T>::operator*() const
{
return *ptr_;
}
// ************************************************************************* //

View File

@ -155,7 +155,7 @@ protected:
// Protected member functions
//- Construct and return an IFstream for the object.
// The results is NULL if the stream constuction failed
// The results is NULL if the stream construction failed
Istream* objectStream();
//- Set the object state to bad

View File

@ -29,41 +29,15 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::IOField<Type>::IOField
(
const IOobject& io
)
Foam::IOField<Type>::IOField(const IOobject& io)
:
regIOobject(io),
Field<Type>(readStream(typeName))
regIOobject(io)
{
close();
}
template<class Type>
Foam::IOField<Type>::IOField
(
const IOobject& io,
const label size
)
:
regIOobject(io),
Field<Type>(size)
{}
template<class Type>
Foam::IOField<Type>::IOField
(
const IOobject& io,
const Field<Type>& f
)
:
regIOobject(io),
Field<Type>(f)
{
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
@ -71,11 +45,77 @@ Foam::IOField<Type>::IOField
}
template<class Type>
Foam::IOField<Type>::IOField(const IOobject& io, const label size)
:
regIOobject(io)
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{
Field<Type>::setSize(size);
}
}
template<class Type>
Foam::IOField<Type>::IOField(const IOobject& io, const Field<Type>& f)
:
regIOobject(io)
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{
Field<Type>::operator=(f);
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class T>
Foam::IOField<T>::~IOField()
template<class Type>
Foam::IOField<Type>::~IOField()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
bool Foam::IOField<Type>::writeData(Ostream& os) const
{
return (os << static_cast<const Field<Type>&>(*this)).good();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void Foam::IOField<Type>::operator=(const IOField<Type>& rhs)
{
Field<Type>::operator=(rhs);
}
template<class Type>
void Foam::IOField<Type>::operator=(const Field<Type>& rhs)
{
Field<Type>::operator=(rhs);
}
// ************************************************************************* //

View File

@ -63,24 +63,13 @@ public:
// Constructors
//- Construct from IOobject
IOField
(
const IOobject&
);
IOField(const IOobject&);
//- Construct from components
IOField
(
const IOobject&,
const Field<Type>&
);
IOField(const IOobject&, const Field<Type>&);
//- Construct from IOobject and size (does not set values)
IOField
(
const IOobject&,
const label size
);
IOField(const IOobject&, const label size);
// Destructor
@ -90,23 +79,14 @@ public:
// Member functions
bool writeData(Ostream& os) const
{
return (os << static_cast<const Field<Type>&>(*this)).good();
}
bool writeData(Ostream&) const;
// Member operators
void operator=(const IOField<Type>& iof)
{
Field<Type>::operator=(iof);
}
void operator=(const IOField<Type>&);
void operator=(const Field<Type>& f)
{
Field<Type>::operator=(f);
}
void operator=(const Field<Type>&);
};

View File

@ -84,7 +84,6 @@ Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list)
{
List<T>::operator=(list);
}
}
@ -95,6 +94,16 @@ Foam::IOList<T>::~IOList()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
bool Foam::IOList<T>::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
@ -111,11 +120,4 @@ void Foam::IOList<T>::operator=(const List<T>& rhs)
}
template<class T>
bool Foam::IOList<T>::writeData(Ostream& os) const
{
return (os << *this).good();
}
// ************************************************************************* //

View File

@ -31,8 +31,7 @@ License
template<class T>
Foam::IOMap<T>::IOMap(const IOobject& io)
:
regIOobject(io),
Map<T>()
regIOobject(io)
{
if
(

View File

@ -91,14 +91,7 @@ Foam::IOPtrList<T>::~IOPtrList()
{}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
{
PtrList<T>::operator=(rhs);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
bool Foam::IOPtrList<T>::writeData(Ostream& os) const
@ -107,4 +100,12 @@ bool Foam::IOPtrList<T>::writeData(Ostream& os) const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
{
PtrList<T>::operator=(rhs);
}
// ************************************************************************* //

View File

@ -42,15 +42,10 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IOdictionary::IOdictionary
(
const IOobject& io
)
Foam::IOdictionary::IOdictionary(const IOobject& io)
:
regIOobject(io)
{
dictionary::name() = IOobject::objectPath();
if
(
io.readOpt() == IOobject::MUST_READ
@ -60,18 +55,29 @@ Foam::IOdictionary::IOdictionary
readStream(typeName) >> *this;
close();
}
dictionary::name() = IOobject::objectPath();
}
Foam::IOdictionary::IOdictionary
(
const IOobject& io,
const dictionary& dict
)
Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict)
:
regIOobject(io),
dictionary(dict)
regIOobject(io)
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{
dictionary::operator=(dict);
}
dictionary::name() = IOobject::objectPath();
}
@ -92,9 +98,9 @@ const Foam::word& Foam::IOdictionary::name() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::IOdictionary::operator=(const IOdictionary& d)
void Foam::IOdictionary::operator=(const IOdictionary& rhs)
{
dictionary::operator=(d);
dictionary::operator=(rhs);
}

View File

@ -34,27 +34,17 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool IOdictionary::readData(Istream& is)
bool Foam::IOdictionary::readData(Istream& is)
{
is >> *this;
return !is.bad();
}
bool IOdictionary::writeData(Ostream& os) const
bool Foam::IOdictionary::writeData(Ostream& os) const
{
dictionary::write(os, false);
return os.good();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -63,7 +63,7 @@ class functionObjectList
//- Dictionary containing the list of function object specifications
const dictionary& foDict_;
//- Switch for the execultion of the functionObjects
//- Switch for the execution of the functionObjects
bool execution_;
@ -84,7 +84,7 @@ public:
// The functionObject specifications are read from the controlDict
functionObjectList
(
const Time& t,
const Time&,
const bool execution = true
);
@ -93,7 +93,7 @@ public:
// setting
functionObjectList
(
const Time& t,
const Time&,
const dictionary& foDict,
const bool execution = true
);

View File

@ -101,7 +101,7 @@ public:
//- Construct as copy
regIOobject(const regIOobject&);
//- Construct as copy, and transfering registry registration to copy
//- Construct as copy, and transferring registry registration to copy
// if registerCopy is true
regIOobject(const regIOobject&, bool registerCopy);

View File

@ -105,35 +105,31 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
(
"GeometricField<Type, PatchField, GeoMesh>::readIfPresent()"
) << "read option IOobject::MUST_READ "
<< "suggests that a read constuctor for field " << this->name()
<< "suggests that a read constructor for field " << this->name()
<< " would be more appropriate." << endl;
}
else if (this->readOpt() == IOobject::READ_IF_PRESENT)
else if (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
{
if (this->headerOk())
boundaryField_.transfer(readField(this->readStream(typeName))());
this->close();
// Check compatibility between field and mesh
if (this->size() != GeoMesh::size(this->mesh()))
{
boundaryField_.transfer(readField(this->readStream(typeName))());
this->close();
// Check compatibility between field and mesh
if (this->size() != GeoMesh::size(this->mesh()))
{
FatalIOErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::"
"readIfPresent()",
this->readStream(typeName)
) << " number of field elements = " << this->size()
<< " number of mesh elements = "
<< GeoMesh::size(this->mesh())
<< exit(FatalIOError);
}
readOldTimeIfPresent();
return true;
FatalIOErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::"
"readIfPresent()",
this->readStream(typeName)
) << " number of field elements = " << this->size()
<< " number of mesh elements = "
<< GeoMesh::size(this->mesh())
<< exit(FatalIOError);
}
readOldTimeIfPresent();
return true;
}
return false;
@ -149,7 +145,7 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
this->name() + "_0",
this->time().timeName(),
this->db(),
IOobject::MUST_READ,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
);

View File

@ -214,7 +214,7 @@ public:
//- Construct from IOobject
explicit polyMesh(const IOobject& io);
//- Construct from components without boundary.
//- Construct without boundary from components.
// Boundary is added using addPatches() member function
polyMesh
(
@ -226,8 +226,7 @@ public:
const bool syncPar = true
);
//- Construct from components with cells rather than owner
// and neighbourwithout boundary.
//- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function
polyMesh
(
@ -263,8 +262,7 @@ public:
// Database
//- Over-ride the objectRegistry dbDir
// if this is single-region case
//- Override the objectRegistry dbDir for a single-region case
virtual const fileName& dbDir() const;
//- Return the local mesh directory (dbDir()/meshSubDir)
@ -311,17 +309,17 @@ public:
return bounds_;
}
//- Return the vector of valid directions in mesh
// defined according to the presence of empty patches.
//- Return the vector of valid directions in mesh.
// Defined according to the presence of empty patches.
// 1 indicates valid direction and -1 an invalid direction.
const Vector<label>& directions() const;
//- Return the number of valid geoemtric dimensions in the mesh
//- Return the number of valid geometric dimensions in the mesh
label nGeometricD() const;
//- Return the number of valid solution dimensions in the mesh
//- Return the number of valid solution dimensions in the mesh.
// For wedge cases this includes the circumferential direction
// in case of swirl
// in case of swirl.
label nSolutionD() const;
//- Return point zone mesh

View File

@ -114,6 +114,22 @@ Foam::cellZone::cellZone
{}
Foam::cellZone::cellZone
(
const word& name,
const xfer<labelList>& addr,
const label index,
const cellZoneMesh& zm
)
:
labelList(addr),
name_(name),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
{}
// Construct from dictionary
Foam::cellZone::cellZone
(
@ -148,6 +164,21 @@ Foam::cellZone::cellZone
cellLookupMapPtr_(NULL)
{}
Foam::cellZone::cellZone
(
const cellZone& cz,
const xfer<labelList>& addr,
const label index,
const cellZoneMesh& zm
)
:
labelList(addr),
name_(cz.name()),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -128,26 +128,45 @@ public:
const word& name,
const labelList& addr,
const label index,
const cellZoneMesh& zm
const cellZoneMesh&
);
//- Construct from components, transferring contents
cellZone
(
const word& name,
const xfer<labelList>& addr,
const label index,
const cellZoneMesh&
);
//- Construct from dictionary
cellZone
(
const word& name,
const dictionary& dict,
const dictionary&,
const label index,
const cellZoneMesh& zm
const cellZoneMesh&
);
//- Construct given the original zone and resetting the
// cell list and zone mesh information
cellZone
(
const cellZone& cz,
const cellZone&,
const labelList& addr,
const label index,
const cellZoneMesh& zm
const cellZoneMesh&
);
//- Construct given the original zone, resetting the
// cell list and zone mesh information
cellZone
(
const cellZone&,
const xfer<labelList>& addr,
const label index,
const cellZoneMesh&
);
//- Construct and return a clone, resetting the zone mesh
@ -182,7 +201,7 @@ public:
static autoPtr<cellZone> New
(
const word& name,
const dictionary& dict,
const dictionary&,
const label index,
const cellZoneMesh&
);

View File

@ -242,6 +242,30 @@ Foam::faceZone::faceZone
}
Foam::faceZone::faceZone
(
const word& name,
const xfer<labelList>& addr,
const xfer<boolList>& fm,
const label index,
const faceZoneMesh& zm
)
:
labelList(addr),
name_(name),
flipMap_(fm),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
{
checkAddressing();
}
// Construct from dictionary
Foam::faceZone::faceZone
(
@ -292,6 +316,30 @@ Foam::faceZone::faceZone
}
Foam::faceZone::faceZone
(
const faceZone& fz,
const xfer<labelList>& addr,
const xfer<boolList>& fm,
const label index,
const faceZoneMesh& zm
)
:
labelList(addr),
name_(fz.name()),
flipMap_(fm),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
{
checkAddressing();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceZone::~faceZone()

View File

@ -163,24 +163,45 @@ public:
const faceZoneMesh& zm
);
//- Construct from components, transferring contents
faceZone
(
const word& name,
const xfer<labelList>& addr,
const xfer<boolList>& fm,
const label index,
const faceZoneMesh&
);
//- Construct from dictionary
faceZone
(
const word& name,
const dictionary& dict,
const dictionary&,
const label index,
const faceZoneMesh& zm
const faceZoneMesh&
);
//- Construct given the original zone and resetting the
// face list and zone mesh information
faceZone
(
const faceZone& fz,
const faceZone&,
const labelList& addr,
const boolList& fm,
const label index,
const faceZoneMesh& zm
const faceZoneMesh&
);
//- Construct given the original zone, resetting the
// face list and zone mesh information
faceZone
(
const faceZone&,
const xfer<labelList>& addr,
const xfer<boolList>& fm,
const label index,
const faceZoneMesh&
);
//- Construct and return a clone, resetting the zone mesh
@ -216,9 +237,9 @@ public:
static autoPtr<faceZone> New
(
const word& name,
const dictionary& dict,
const dictionary&,
const label index,
const faceZoneMesh& zm
const faceZoneMesh&
);

View File

@ -112,6 +112,22 @@ Foam::pointZone::pointZone
{}
Foam::pointZone::pointZone
(
const word& name,
const xfer<labelList>& addr,
const label index,
const pointZoneMesh& zm
)
:
labelList(addr),
name_(name),
index_(index),
zoneMesh_(zm),
pointLookupMapPtr_(NULL)
{}
// Construct from dictionary
Foam::pointZone::pointZone
(
@ -147,6 +163,22 @@ Foam::pointZone::pointZone
{}
Foam::pointZone::pointZone
(
const pointZone& pz,
const xfer<labelList>& addr,
const label index,
const pointZoneMesh& zm
)
:
labelList(addr),
name_(pz.name()),
index_(index),
zoneMesh_(zm),
pointLookupMapPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointZone::~pointZone()

View File

@ -130,26 +130,45 @@ public:
const word& name,
const labelList& addr,
const label index,
const pointZoneMesh& zm
const pointZoneMesh&
);
//- Construct from components, transferring contents
pointZone
(
const word& name,
const xfer<labelList>& addr,
const label index,
const pointZoneMesh&
);
//- Construct from dictionary
pointZone
(
const word& name,
const dictionary& dict,
const dictionary&,
const label index,
const pointZoneMesh& zm
const pointZoneMesh&
);
//- Construct given the original zone and resetting the
// point list and zone mesh information
pointZone
(
const pointZone& pz,
const pointZone&,
const labelList& addr,
const label index,
const pointZoneMesh& zm
const pointZoneMesh&
);
//- Construct given the original zone, resetting the
// face list and zone mesh information
pointZone
(
const pointZone&,
const xfer<labelList>& addr,
const label index,
const pointZoneMesh&
);
//- Construct and return a clone, resetting the zone mesh
@ -184,7 +203,7 @@ public:
static autoPtr<pointZone> New
(
const word& name,
const dictionary& dict,
const dictionary&,
const label index,
const pointZoneMesh&
);

View File

@ -167,7 +167,7 @@ const labelList& primitiveMesh::pointCells
}
}
storage.size() = n;
storage.setSize(n);
return storage;
}

View File

@ -60,8 +60,7 @@ protected:
// Private data
//- Name of this set of forces,
// Also used as the name of the probes directory.
//- Name of this set of system calls
word name_;
const objectRegistry& obr_;