mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into cvm
This commit is contained in:
@ -157,7 +157,7 @@ public:
|
||||
// The begin-of-line (^) and end-of-line ($) anchors are implicit
|
||||
bool match(const string&, List<string>& groups) const;
|
||||
|
||||
//- Return true if the regex was found in within string
|
||||
//- Return true if the regex was found within string
|
||||
bool search(const std::string& str) const
|
||||
{
|
||||
return std::string::npos != find(str);
|
||||
|
||||
@ -52,8 +52,8 @@ $(strings)/word/word.C
|
||||
$(strings)/word/wordIO.C
|
||||
$(strings)/fileName/fileName.C
|
||||
$(strings)/fileName/fileNameIO.C
|
||||
$(strings)/keyType/keyTypeIO.C
|
||||
$(strings)/wordRe/wordReIO.C
|
||||
$(strings)/keyType/keyType.C
|
||||
$(strings)/wordRe/wordRe.C
|
||||
|
||||
primitives/hashes/Hasher/Hasher.C
|
||||
|
||||
@ -66,7 +66,8 @@ primitives/random/Random.C
|
||||
containers/HashTables/HashTable/HashTableCore.C
|
||||
containers/HashTables/StaticHashTable/StaticHashTableCore.C
|
||||
containers/Lists/SortableList/ParSortableListName.C
|
||||
containers/Lists/PackedList/PackedListName.C
|
||||
containers/Lists/PackedList/PackedListCore.C
|
||||
containers/Lists/PackedList/PackedBoolList.C
|
||||
containers/Lists/ListOps/ListOps.C
|
||||
containers/LinkedLists/linkTypes/SLListBase/SLListBase.C
|
||||
containers/LinkedLists/linkTypes/DLListBase/DLListBase.C
|
||||
@ -329,7 +330,7 @@ $(cellShape)/cellShapeEqual.C
|
||||
$(cellShape)/cellShapeIO.C
|
||||
$(cellShape)/cellShapeIOList.C
|
||||
|
||||
meshes/patchIdentifier/patchIdentifier.C
|
||||
meshes/Identifiers/patch/patchIdentifier.C
|
||||
|
||||
polyMesh = meshes/polyMesh
|
||||
|
||||
|
||||
@ -180,13 +180,22 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Append an element at the end of the list
|
||||
inline void append(const T&);
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
const T&
|
||||
);
|
||||
|
||||
//- Append a List at the end of this list
|
||||
inline void append(const UList<T>&);
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
const UList<T>&
|
||||
);
|
||||
|
||||
//- Append a UIndirectList at the end of this list
|
||||
inline void append(const UIndirectList<T>&);
|
||||
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||
(
|
||||
const UIndirectList<T>&
|
||||
);
|
||||
|
||||
//- Remove and return the top element
|
||||
inline T remove();
|
||||
|
||||
@ -305,7 +305,8 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer()
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
(
|
||||
const T& t
|
||||
)
|
||||
@ -314,11 +315,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
setSize(elemI + 1);
|
||||
|
||||
this->operator[](elemI) = t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
(
|
||||
const UList<T>& lst
|
||||
)
|
||||
@ -339,11 +342,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
{
|
||||
this->operator[](nextFree++) = lst[elemI];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
(
|
||||
const UIndirectList<T>& lst
|
||||
)
|
||||
@ -355,6 +360,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||
{
|
||||
this->operator[](nextFree++) = lst[elemI];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,11 @@ Class
|
||||
Foam::IndirectList
|
||||
|
||||
Description
|
||||
A List with indirect addressing
|
||||
A List with indirect addressing.
|
||||
|
||||
SeeAlso
|
||||
Foam::UIndirectList for a version without any allocation for the
|
||||
addressing.
|
||||
|
||||
SourceFiles
|
||||
IndirectListI.H
|
||||
@ -35,24 +39,79 @@ SourceFiles
|
||||
#ifndef IndirectList_H
|
||||
#define IndirectList_H
|
||||
|
||||
#include "List.H"
|
||||
#include "UIndirectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IndirectListAddressing Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- A helper class for storing addresses.
|
||||
class IndirectListAddressing
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Storage for the list addressing
|
||||
List<label> addressing_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
IndirectListAddressing(const IndirectListAddressing&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const IndirectListAddressing&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct by copying the addressing array
|
||||
explicit inline IndirectListAddressing(const UList<label>& addr);
|
||||
|
||||
//- Construct by transferring addressing array
|
||||
explicit inline IndirectListAddressing(const Xfer<List<label> >& addr);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the list addressing
|
||||
inline const List<label>& addressing() const;
|
||||
|
||||
// Edit
|
||||
|
||||
//- Reset addressing
|
||||
inline void resetAddressing(const UList<label>&);
|
||||
inline void resetAddressing(const Xfer<List<label> >&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IndirectList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
class IndirectList
|
||||
:
|
||||
private IndirectListAddressing,
|
||||
public UIndirectList<T>
|
||||
{
|
||||
// Private data
|
||||
// Private Member Functions
|
||||
|
||||
UList<T>& completeList_;
|
||||
List<label> addressing_;
|
||||
//- Disable default assignment operator
|
||||
void operator=(const IndirectList<T>&);
|
||||
|
||||
//- Disable assignment from UIndirectList
|
||||
void operator=(const UIndirectList<T>&);
|
||||
|
||||
|
||||
public:
|
||||
@ -65,59 +124,32 @@ public:
|
||||
//- Construct given the complete list and by transferring addressing
|
||||
inline IndirectList(const UList<T>&, const Xfer<List<label> >&);
|
||||
|
||||
//- Copy constructor
|
||||
inline IndirectList(const IndirectList<T>&);
|
||||
|
||||
//- Construct from UIndirectList
|
||||
explicit inline IndirectList(const UIndirectList<T>&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the number of elements in the list
|
||||
inline label size() const;
|
||||
|
||||
//- Return true if the list is empty (ie, size() is zero).
|
||||
inline bool empty() const;
|
||||
|
||||
//- Return the first element of the list.
|
||||
inline T& first();
|
||||
|
||||
//- Return first element of the list.
|
||||
inline const T& first() const;
|
||||
|
||||
//- Return the last element of the list.
|
||||
inline T& last();
|
||||
|
||||
//- Return the last element of the list.
|
||||
inline const T& last() const;
|
||||
|
||||
//- Return the complete list
|
||||
inline const UList<T>& completeList() const;
|
||||
|
||||
//- Return the list addressing
|
||||
inline const List<label>& addressing() const;
|
||||
using UIndirectList<T>::addressing;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Reset addressing
|
||||
inline void resetAddressing(const UList<label>&);
|
||||
inline void resetAddressing(const Xfer<List<label> >&);
|
||||
using IndirectListAddressing::resetAddressing;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return the addressed elements as a List
|
||||
inline List<T> operator()() const;
|
||||
|
||||
//- Return non-const access to an element
|
||||
inline T& operator[](const label);
|
||||
|
||||
//- Return const access to an element
|
||||
inline const T& operator[](const label) const;
|
||||
|
||||
//- Assignment from UList of addressed elements
|
||||
inline void operator=(const UList<T>&);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T&);
|
||||
//- Assignment operator
|
||||
using UIndirectList<T>::operator=;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,25 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
inline Foam::IndirectListAddressing::IndirectListAddressing
|
||||
(
|
||||
const UList<label>& addr
|
||||
)
|
||||
:
|
||||
addressing_(addr)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::IndirectListAddressing::IndirectListAddressing
|
||||
(
|
||||
const Xfer<List<label> >& addr
|
||||
)
|
||||
:
|
||||
addressing_(addr)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::IndirectList<T>::IndirectList
|
||||
(
|
||||
@ -32,8 +51,12 @@ inline Foam::IndirectList<T>::IndirectList
|
||||
const UList<label>& addr
|
||||
)
|
||||
:
|
||||
completeList_(const_cast<UList<T>&>(completeList)),
|
||||
addressing_(addr)
|
||||
IndirectListAddressing(addr),
|
||||
UIndirectList<T>
|
||||
(
|
||||
completeList,
|
||||
IndirectListAddressing::addressing()
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -44,71 +67,55 @@ inline Foam::IndirectList<T>::IndirectList
|
||||
const Xfer<List<label> >& addr
|
||||
)
|
||||
:
|
||||
completeList_(const_cast<UList<T>&>(completeList)),
|
||||
addressing_(addr)
|
||||
IndirectListAddressing(addr),
|
||||
UIndirectList<T>
|
||||
(
|
||||
completeList,
|
||||
IndirectListAddressing::addressing()
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::IndirectList<T>::IndirectList
|
||||
(
|
||||
const IndirectList<T>& lst
|
||||
)
|
||||
:
|
||||
IndirectListAddressing(lst.addressing()),
|
||||
UIndirectList<T>
|
||||
(
|
||||
lst.completeList(),
|
||||
IndirectListAddressing::addressing()
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::IndirectList<T>::IndirectList
|
||||
(
|
||||
const UIndirectList<T>& lst
|
||||
)
|
||||
:
|
||||
IndirectListAddressing(lst.addressing()),
|
||||
UIndirectList<T>
|
||||
(
|
||||
lst.completeList(),
|
||||
IndirectListAddressing::addressing()
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::IndirectList<T>::size() const
|
||||
{
|
||||
return addressing_.size();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::IndirectList<T>::empty() const
|
||||
{
|
||||
return addressing_.empty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::IndirectList<T>::first()
|
||||
{
|
||||
return completeList_[addressing_.first()];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::IndirectList<T>::first() const
|
||||
{
|
||||
return completeList_[addressing_.first()];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::IndirectList<T>::last()
|
||||
{
|
||||
return completeList_[addressing_.last()];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::IndirectList<T>::last() const
|
||||
{
|
||||
return completeList_[addressing_.last()];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const Foam::UList<T>& Foam::IndirectList<T>::completeList() const
|
||||
{
|
||||
return completeList_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const Foam::List<Foam::label>& Foam::IndirectList<T>::addressing() const
|
||||
inline const Foam::List<Foam::label>&
|
||||
Foam::IndirectListAddressing::addressing() const
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::IndirectList<T>::resetAddressing
|
||||
inline void Foam::IndirectListAddressing::resetAddressing
|
||||
(
|
||||
const UList<label>& addr
|
||||
)
|
||||
@ -117,8 +124,7 @@ inline void Foam::IndirectList<T>::resetAddressing
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::IndirectList<T>::resetAddressing
|
||||
inline void Foam::IndirectListAddressing::resetAddressing
|
||||
(
|
||||
const Xfer<List<label> >& addr
|
||||
)
|
||||
@ -127,63 +133,4 @@ inline void Foam::IndirectList<T>::resetAddressing
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::List<T> Foam::IndirectList<T>::operator()() const
|
||||
{
|
||||
List<T> result(size());
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
result[i] = operator[](i);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::IndirectList<T>::operator[](const label i)
|
||||
{
|
||||
return completeList_[addressing_[i]];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::IndirectList<T>::operator[](const label i) const
|
||||
{
|
||||
return completeList_[addressing_[i]];
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::IndirectList<T>::operator=(const UList<T>& ae)
|
||||
{
|
||||
if (addressing_.size() != ae.size())
|
||||
{
|
||||
FatalErrorIn("IndirectList<T>::operator=(const UList<T>&)")
|
||||
<< "Addressing and list of addressed elements "
|
||||
"have different sizes: "
|
||||
<< addressing_.size() << " " << ae.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
completeList_[addressing_[i]] = ae[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::IndirectList<T>::operator=(const T& t)
|
||||
{
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
completeList_[addressing_[i]] = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -266,24 +266,6 @@ Foam::List<T>::List(const SLList<T>& lst)
|
||||
}
|
||||
|
||||
|
||||
// Construct as copy of IndirectList<T>
|
||||
template<class T>
|
||||
Foam::List<T>::List(const IndirectList<T>& lst)
|
||||
:
|
||||
UList<T>(NULL, lst.size())
|
||||
{
|
||||
if (this->size_)
|
||||
{
|
||||
this->v_ = new T[this->size_];
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->operator[](i) = lst[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct as copy of UIndirectList<T>
|
||||
template<class T>
|
||||
Foam::List<T>::List(const UIndirectList<T>& lst)
|
||||
@ -381,7 +363,7 @@ void Foam::List<T>::setSize(const label newSize)
|
||||
template<class T>
|
||||
void Foam::List<T>::setSize(const label newSize, const T& a)
|
||||
{
|
||||
label oldSize = this->size_;
|
||||
label oldSize = label(this->size_);
|
||||
this->setSize(newSize);
|
||||
|
||||
if (newSize > oldSize)
|
||||
@ -517,25 +499,6 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
|
||||
}
|
||||
|
||||
|
||||
// Assignment operator. Takes linear time.
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(const IndirectList<T>& lst)
|
||||
{
|
||||
if (lst.size() != this->size_)
|
||||
{
|
||||
if (this->v_) delete[] this->v_;
|
||||
this->v_ = 0;
|
||||
this->size_ = lst.size();
|
||||
if (this->size_) this->v_ = new T[this->size_];
|
||||
}
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->operator[](i) = lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Assignment operator. Takes linear time.
|
||||
template<class T>
|
||||
void Foam::List<T>::operator=(const UIndirectList<T>& lst)
|
||||
|
||||
@ -131,9 +131,6 @@ public:
|
||||
//- Construct as copy of SLList<T>
|
||||
explicit List(const SLList<T>&);
|
||||
|
||||
//- Construct as copy of IndirectList<T>
|
||||
explicit List(const IndirectList<T>&);
|
||||
|
||||
//- Construct as copy of UIndirectList<T>
|
||||
explicit List(const UIndirectList<T>&);
|
||||
|
||||
@ -219,9 +216,6 @@ public:
|
||||
//- Assignment from SLList operator. Takes linear time.
|
||||
void operator=(const SLList<T>&);
|
||||
|
||||
//- Assignment from IndirectList operator. Takes linear time.
|
||||
void operator=(const IndirectList<T>&);
|
||||
|
||||
//- Assignment from UIndirectList operator. Takes linear time.
|
||||
void operator=(const UIndirectList<T>&);
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
// Putback the openning bracket
|
||||
// Putback the opening bracket
|
||||
is.putBack(firstToken);
|
||||
|
||||
// Now read as a singly-linked list
|
||||
|
||||
375
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
Normal file
375
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
Normal file
@ -0,0 +1,375 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PackedBoolList.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::PackedBoolList::bitorPrepare
|
||||
(
|
||||
const PackedList<1>& lst,
|
||||
label& maxPackLen
|
||||
)
|
||||
{
|
||||
const StorageList& lhs = this->storage();
|
||||
const StorageList& rhs = lst.storage();
|
||||
|
||||
const label packLen1 = this->packedLength();
|
||||
const label packLen2 = lst.packedLength();
|
||||
|
||||
|
||||
// check how the lists interact and if bit trimming is needed
|
||||
bool needTrim = false;
|
||||
maxPackLen = packLen1;
|
||||
|
||||
if (packLen1 == packLen2)
|
||||
{
|
||||
// identical packed lengths - only resize if absolutely necessary
|
||||
if
|
||||
(
|
||||
this->size() != lst.size()
|
||||
&& maxPackLen
|
||||
&& rhs[maxPackLen-1] > lhs[maxPackLen-1]
|
||||
)
|
||||
{
|
||||
// second list has a higher bit set
|
||||
// extend addressable area and use trim
|
||||
resize(lst.size());
|
||||
needTrim = true;
|
||||
}
|
||||
}
|
||||
else if (packLen2 < packLen1)
|
||||
{
|
||||
// second list is shorter, this limits the or
|
||||
maxPackLen = packLen2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// second list is longer, find the highest bit set
|
||||
for (label storeI = packLen1; storeI < packLen2; ++storeI)
|
||||
{
|
||||
if (rhs[storeI])
|
||||
{
|
||||
maxPackLen = storeI+1;
|
||||
}
|
||||
}
|
||||
|
||||
// the upper limit moved - resize for full coverage and trim later
|
||||
if (maxPackLen > packLen1)
|
||||
{
|
||||
resize(maxPackLen * packing());
|
||||
needTrim = true;
|
||||
}
|
||||
}
|
||||
|
||||
return needTrim;
|
||||
}
|
||||
|
||||
|
||||
template<class LabelListType>
|
||||
Foam::label Foam::PackedBoolList::setIndices(const LabelListType& indices)
|
||||
{
|
||||
// no better information, just guess something about the size
|
||||
reserve(indices.size());
|
||||
|
||||
label cnt = 0;
|
||||
forAll(indices, elemI)
|
||||
{
|
||||
if (set(indices[elemI]))
|
||||
{
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
template<class LabelListType>
|
||||
Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices)
|
||||
{
|
||||
label cnt = 0;
|
||||
forAll(indices, elemI)
|
||||
{
|
||||
if (unset(indices[elemI]))
|
||||
{
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
template<class LabelListType>
|
||||
Foam::label Foam::PackedBoolList::subsetIndices(const LabelListType& indices)
|
||||
{
|
||||
// handle trivial case
|
||||
if (empty() || indices.empty())
|
||||
{
|
||||
clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// normal case
|
||||
PackedBoolList anded;
|
||||
anded.reserve(size());
|
||||
|
||||
label cnt = 0;
|
||||
forAll(indices, elemI)
|
||||
{
|
||||
const label& index = indices[elemI];
|
||||
if (operator[](index))
|
||||
{
|
||||
anded.set(index);
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
transfer(anded);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::PackedBoolList::PackedBoolList(Istream& is)
|
||||
:
|
||||
PackedList<1>()
|
||||
{
|
||||
is >> *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::PackedBoolList::set(const PackedList<1>& lst)
|
||||
{
|
||||
// extend addressable area if needed, return maximum size possible
|
||||
label len = 0;
|
||||
const bool needTrim = bitorPrepare(lst, len);
|
||||
|
||||
// operate directly with the underlying storage
|
||||
StorageList& lhs = this->storage();
|
||||
const StorageList& rhs = lst.storage();
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
lhs[i] |= rhs[i];
|
||||
}
|
||||
|
||||
if (needTrim)
|
||||
{
|
||||
trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::PackedBoolList::set(const UList<label>& indices)
|
||||
{
|
||||
return setIndices(indices);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::PackedBoolList::set(const UIndirectList<label>& indices)
|
||||
{
|
||||
return setIndices(indices);
|
||||
}
|
||||
|
||||
|
||||
void Foam::PackedBoolList::unset(const PackedList<1>& lst)
|
||||
{
|
||||
// operate directly with the underlying storage
|
||||
StorageList& lhs = this->storage();
|
||||
const StorageList& rhs = lst.storage();
|
||||
|
||||
// overlapping storage size
|
||||
const label len = min(this->packedLength(), lst.packedLength());
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
lhs[i] &= ~rhs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::PackedBoolList::unset(const UList<label>& indices)
|
||||
{
|
||||
return unsetIndices(indices);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::PackedBoolList::unset(const UIndirectList<label>& indices)
|
||||
{
|
||||
return unsetIndices(indices);
|
||||
}
|
||||
|
||||
|
||||
void Foam::PackedBoolList::subset(const PackedList<1>& lst)
|
||||
{
|
||||
// shrink addressable area if needed
|
||||
if (this->size() > lst.size())
|
||||
{
|
||||
this->resize(lst.size());
|
||||
}
|
||||
|
||||
// operate directly with the underlying storage
|
||||
StorageList& lhs = this->storage();
|
||||
const StorageList& rhs = lst.storage();
|
||||
|
||||
const label len = this->packedLength();
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
lhs[i] &= rhs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::PackedBoolList::subset(const UList<label>& indices)
|
||||
{
|
||||
return subsetIndices(indices);
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::PackedBoolList::subset(const UIndirectList<label>& indices)
|
||||
{
|
||||
return subsetIndices(indices);
|
||||
}
|
||||
|
||||
|
||||
Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const
|
||||
{
|
||||
labelList lst(this->count());
|
||||
|
||||
if (lst.size())
|
||||
{
|
||||
label nElem = 0;
|
||||
|
||||
forAll(*this, elemI)
|
||||
{
|
||||
if (get(elemI))
|
||||
{
|
||||
lst[nElem++] = elemI;
|
||||
}
|
||||
}
|
||||
|
||||
lst.setSize(nElem);
|
||||
}
|
||||
|
||||
return lst.xfer();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator=(const UList<bool>& lst)
|
||||
{
|
||||
this->setSize(lst.size());
|
||||
|
||||
// overwrite with new true/false values
|
||||
forAll(*this, elemI)
|
||||
{
|
||||
set(elemI, lst[elemI]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator^=(const PackedList<1>& lst)
|
||||
{
|
||||
// extend addressable area if needed, return maximum size possible
|
||||
label len = 0;
|
||||
const bool needTrim = bitorPrepare(lst, len);
|
||||
|
||||
// operate directly with the underlying storage
|
||||
StorageList& lhs = this->storage();
|
||||
const StorageList& rhs = lst.storage();
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
lhs[i] ^= rhs[i];
|
||||
}
|
||||
|
||||
if (needTrim)
|
||||
{
|
||||
trim();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::PackedBoolList Foam::operator&
|
||||
(
|
||||
const PackedBoolList& lst1,
|
||||
const PackedBoolList& lst2
|
||||
)
|
||||
{
|
||||
PackedBoolList result(lst1);
|
||||
result &= lst2;
|
||||
|
||||
// trim to bits actually used
|
||||
result.trim();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Foam::PackedBoolList Foam::operator^
|
||||
(
|
||||
const PackedBoolList& lst1,
|
||||
const PackedBoolList& lst2
|
||||
)
|
||||
{
|
||||
PackedBoolList result(lst1);
|
||||
result ^= lst2;
|
||||
|
||||
// trim to bits actually used
|
||||
result.trim();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Foam::PackedBoolList Foam::operator|
|
||||
(
|
||||
const PackedBoolList& lst1,
|
||||
const PackedBoolList& lst2
|
||||
)
|
||||
{
|
||||
PackedBoolList result(lst1);
|
||||
result |= lst2;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
296
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
Normal file
296
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
Normal file
@ -0,0 +1,296 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::PackedBoolList
|
||||
|
||||
Description
|
||||
A bit-packed bool list.
|
||||
|
||||
In addition to the obvious memory advantage over using a
|
||||
List\<bool\>, this class also provides a number of bit-like
|
||||
operations.
|
||||
|
||||
SourceFiles
|
||||
PackedBoolListI.H
|
||||
PackedBoolList.C
|
||||
|
||||
SeeAlso
|
||||
Foam::PackedList
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PackedBoolList_H
|
||||
#define PackedBoolList_H
|
||||
|
||||
#include "PackedList.H"
|
||||
#include "UIndirectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PackedBoolList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class PackedBoolList
|
||||
:
|
||||
public PackedList<1>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Preparation, resizing before a bitor operation
|
||||
// returns true if the later result needs trimming
|
||||
bool bitorPrepare(const PackedList<1>& lst, label& maxPackLen);
|
||||
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
template<class LabelListType>
|
||||
label setIndices(const LabelListType& indices);
|
||||
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
template<class LabelListType>
|
||||
label unsetIndices(const LabelListType& indices);
|
||||
|
||||
//- Subset with the listed indices. Return number of elements subsetted.
|
||||
template<class LabelListType>
|
||||
label subsetIndices(const LabelListType& indices);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline PackedBoolList();
|
||||
|
||||
//- Construct from Istream
|
||||
PackedBoolList(Istream&);
|
||||
|
||||
//- Construct with given size, initializes list to 0
|
||||
explicit inline PackedBoolList(const label size);
|
||||
|
||||
//- Construct with given size and value for all elements
|
||||
inline PackedBoolList(const label size, const bool val);
|
||||
|
||||
//- Copy constructor
|
||||
inline PackedBoolList(const PackedBoolList&);
|
||||
|
||||
//- Copy constructor
|
||||
explicit inline PackedBoolList(const PackedList<1>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
inline PackedBoolList(const Xfer<PackedBoolList>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
inline PackedBoolList(const Xfer<PackedList<1> >&);
|
||||
|
||||
//- Construct from a list of bools
|
||||
explicit inline PackedBoolList(const UList<bool>&);
|
||||
|
||||
//- Construct from a list of labels
|
||||
// using the labels as indices to indicate which bits are set
|
||||
explicit inline PackedBoolList(const UList<label>& indices);
|
||||
|
||||
//- Construct from a list of labels
|
||||
// using the labels as indices to indicate which bits are set
|
||||
explicit inline PackedBoolList(const UIndirectList<label>& indices);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr<PackedBoolList> clone() const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
using PackedList<1>::set;
|
||||
using PackedList<1>::unset;
|
||||
|
||||
//- Set specified bits.
|
||||
void set(const PackedList<1>&);
|
||||
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
label set(const UList<label>& indices);
|
||||
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
label set(const UIndirectList<label>& indices);
|
||||
|
||||
//- Unset specified bits.
|
||||
void unset(const PackedList<1>&);
|
||||
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
label unset(const UList<label>& indices);
|
||||
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
label unset(const UIndirectList<label>& indices);
|
||||
|
||||
//- Subset with the specified list.
|
||||
void subset(const PackedList<1>&);
|
||||
|
||||
//- Subset with the listed indices.
|
||||
// Return number of elements subsetted.
|
||||
label subset(const UList<label>& indices);
|
||||
|
||||
//- Subset with the listed indices.
|
||||
// Return number of elements subsetted.
|
||||
label subset(const UIndirectList<label>& indices);
|
||||
|
||||
|
||||
//- Return indices of the used (true) elements as a list of labels
|
||||
Xfer<labelList> used() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedBoolList&);
|
||||
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedList<1>&);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedBoolList> xfer();
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assignment of all entries to the given value.
|
||||
inline PackedBoolList& operator=(const bool val);
|
||||
|
||||
//- Assignment operator.
|
||||
inline PackedBoolList& operator=(const PackedBoolList&);
|
||||
|
||||
//- Assignment operator.
|
||||
inline PackedBoolList& operator=(const PackedList<1>&);
|
||||
|
||||
//- Assignment operator.
|
||||
PackedBoolList& operator=(const UList<bool>&);
|
||||
|
||||
//- Assignment operator,
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator=(const UList<label>& indices);
|
||||
|
||||
//- Assignment operator,
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator=(const UIndirectList<label>&);
|
||||
|
||||
//- Complement operator
|
||||
inline PackedBoolList operator~() const;
|
||||
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
inline PackedBoolList& operator&=(const PackedList<1>&);
|
||||
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator&=(const UList<label>& indices);
|
||||
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator&=(const UIndirectList<label>&);
|
||||
|
||||
//- Xor operator (lists may be dissimilar sizes)
|
||||
// Retains unique entries
|
||||
PackedBoolList& operator^=(const PackedList<1>&);
|
||||
|
||||
//- Or operator (lists may be dissimilar sizes)
|
||||
inline PackedBoolList& operator|=(const PackedList<1>&);
|
||||
|
||||
//- Or operator (lists may be dissimilar sizes),
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator|=(const UList<label>& indices);
|
||||
|
||||
//- Or operator (lists may be dissimilar sizes),
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator|=(const UIndirectList<label>&);
|
||||
|
||||
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const PackedList<1>&);
|
||||
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const UList<label>& indices);
|
||||
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const UIndirectList<label>&);
|
||||
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const PackedList<1>&);
|
||||
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const UList<label>& indices);
|
||||
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const UIndirectList<label>&);
|
||||
};
|
||||
|
||||
|
||||
// Global Operators
|
||||
|
||||
//- Intersect lists - the result is trimmed to the smallest intersecting size
|
||||
PackedBoolList operator&
|
||||
(
|
||||
const PackedBoolList& lst1,
|
||||
const PackedBoolList& lst2
|
||||
);
|
||||
|
||||
|
||||
//- Combine to form a unique list (xor)
|
||||
// The result is trimmed to the smallest intersecting size
|
||||
PackedBoolList operator^
|
||||
(
|
||||
const PackedBoolList& lst1,
|
||||
const PackedBoolList& lst2
|
||||
);
|
||||
|
||||
|
||||
//- Combine lists
|
||||
PackedBoolList operator|
|
||||
(
|
||||
const PackedBoolList& lst1,
|
||||
const PackedBoolList& lst2
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PackedBoolListI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
276
src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
Normal file
276
src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
Normal file
@ -0,0 +1,276 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList()
|
||||
:
|
||||
PackedList<1>()
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const label size)
|
||||
:
|
||||
PackedList<1>(size)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList
|
||||
(
|
||||
const label size,
|
||||
const bool val
|
||||
)
|
||||
:
|
||||
PackedList<1>(size, (val ? 1u : 0u))
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const PackedBoolList& lst)
|
||||
:
|
||||
PackedList<1>(lst)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const PackedList<1>& lst)
|
||||
:
|
||||
PackedList<1>(lst)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedBoolList>& lst)
|
||||
:
|
||||
PackedList<1>()
|
||||
{
|
||||
transfer(lst());
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedList<1> >& lst)
|
||||
:
|
||||
PackedList<1>(lst)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
|
||||
:
|
||||
PackedList<1>()
|
||||
{
|
||||
operator=(lst);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const UList<label>& indices)
|
||||
:
|
||||
PackedList<1>(indices.size(), 0u)
|
||||
{
|
||||
set(indices);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList::PackedBoolList(const UIndirectList<label>& indices)
|
||||
:
|
||||
PackedList<1>(indices.size(), 0u)
|
||||
{
|
||||
set(indices);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::autoPtr<Foam::PackedBoolList>
|
||||
Foam::PackedBoolList::clone() const
|
||||
{
|
||||
return autoPtr<PackedBoolList>(new PackedBoolList(*this));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::PackedBoolList::transfer(PackedBoolList& lst)
|
||||
{
|
||||
PackedList<1>::transfer(static_cast<PackedList<1>&>(lst));
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::PackedBoolList::transfer(PackedList<1>& lst)
|
||||
{
|
||||
PackedList<1>::transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::Xfer<Foam::PackedBoolList> Foam::PackedBoolList::xfer()
|
||||
{
|
||||
return xferMove(*this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator=(const bool val)
|
||||
{
|
||||
PackedList<1>::operator=(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator=(const PackedBoolList& lst)
|
||||
{
|
||||
PackedList<1>::operator=(lst);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator=(const PackedList<1>& lst)
|
||||
{
|
||||
PackedList<1>::operator=(lst);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator=(const UList<label>& indices)
|
||||
{
|
||||
clear();
|
||||
set(indices);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator=(const UIndirectList<label>& indices)
|
||||
{
|
||||
clear();
|
||||
set(indices);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList
|
||||
Foam::PackedBoolList::operator~() const
|
||||
{
|
||||
PackedBoolList result(*this);
|
||||
result.flip();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator&=(const PackedList<1>& lst)
|
||||
{
|
||||
subset(lst);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator&=(const UList<label>& indices)
|
||||
{
|
||||
subset(indices);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator&=(const UIndirectList<label>& indices)
|
||||
{
|
||||
subset(indices);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator|=(const PackedList<1>& lst)
|
||||
{
|
||||
set(lst);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator|=(const UList<label>& indices)
|
||||
{
|
||||
set(indices);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator|=(const UIndirectList<label>& indices)
|
||||
{
|
||||
set(indices);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator+=(const PackedList<1>& lst)
|
||||
{
|
||||
return operator|=(lst);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator+=(const UList<label>& indices)
|
||||
{
|
||||
return operator|=(indices);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator+=(const UIndirectList<label>& indices)
|
||||
{
|
||||
return operator|=(indices);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator-=(const PackedList<1>& lst)
|
||||
{
|
||||
unset(lst);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator-=(const UList<label>& indices)
|
||||
{
|
||||
unset(indices);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::PackedBoolList&
|
||||
Foam::PackedBoolList::operator-=(const UIndirectList<label>& indices)
|
||||
{
|
||||
unset(indices);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,35 +24,11 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PackedList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
|
||||
:
|
||||
StorageList(packedLength(size), 0u),
|
||||
size_(size)
|
||||
{
|
||||
operator=(val);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
:
|
||||
StorageList(packedLength(lst.size()), 0u),
|
||||
size_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
}
|
||||
#include "IOstreams.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
#if (UINT_MAX == 0xFFFFFFFF)
|
||||
// 32-bit counting, Hamming weight method
|
||||
# define COUNT_PACKEDBITS(sum, x) \
|
||||
@ -82,25 +58,10 @@ unsigned int Foam::PackedList<nBits>::count() const
|
||||
|
||||
if (size_)
|
||||
{
|
||||
// mask value for complete segments
|
||||
unsigned int mask = maskLower(packing());
|
||||
|
||||
const unsigned int endSeg = size_ / packing();
|
||||
const unsigned int endOff = size_ % packing();
|
||||
|
||||
// count bits in complete segments
|
||||
for (unsigned i = 0; i < endSeg; ++i)
|
||||
const label packLen = packedLength();
|
||||
for (label i = 0; i < packLen; ++i)
|
||||
{
|
||||
register unsigned int bits = StorageList::operator[](i) & mask;
|
||||
COUNT_PACKEDBITS(c, bits);
|
||||
}
|
||||
|
||||
// count bits in partial segment
|
||||
if (endOff)
|
||||
{
|
||||
mask = maskLower(endOff);
|
||||
|
||||
register unsigned int bits = StorageList::operator[](endSeg) & mask;
|
||||
register unsigned int bits = StorageList::operator[](i);
|
||||
COUNT_PACKEDBITS(c, bits);
|
||||
}
|
||||
}
|
||||
@ -117,64 +78,60 @@ bool Foam::PackedList<nBits>::trim()
|
||||
return false;
|
||||
}
|
||||
|
||||
// mask value for complete segments
|
||||
unsigned int mask = maskLower(packing());
|
||||
|
||||
label currElem = packedLength(size_) - 1;
|
||||
unsigned int endOff = size_ % packing();
|
||||
|
||||
// clear trailing bits on final segment
|
||||
if (endOff)
|
||||
const label oldSize = size_;
|
||||
for (label storeI = packedLength()-1; storeI >= 0; --storeI)
|
||||
{
|
||||
StorageList::operator[](currElem) &= maskLower(endOff);
|
||||
}
|
||||
size_ = storeI * packing();
|
||||
unsigned int bits = StorageList::operator[](storeI);
|
||||
|
||||
// test entire segment
|
||||
while (currElem > 0 && !(StorageList::operator[](currElem) &= mask))
|
||||
{
|
||||
currElem--;
|
||||
}
|
||||
|
||||
// test segment
|
||||
label newsize = (currElem + 1) * packing();
|
||||
|
||||
// mask for the final segment
|
||||
mask = max_value() << (nBits * (packing() - 1));
|
||||
|
||||
for (endOff = packing(); endOff >= 1; --endOff, --newsize)
|
||||
{
|
||||
if (StorageList::operator[](currElem) & mask)
|
||||
// found some bits
|
||||
if (bits)
|
||||
{
|
||||
while (bits)
|
||||
{
|
||||
bits >>= nBits;
|
||||
++size_;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
mask >>= nBits;
|
||||
}
|
||||
|
||||
if (size_ == newsize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_ = newsize;
|
||||
return false;
|
||||
return (size_ != oldSize);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
void Foam::PackedList<nBits>::flip()
|
||||
{
|
||||
label packLen = packedLength(size_);
|
||||
|
||||
for (label i=0; i < packLen; i++)
|
||||
if (!size_)
|
||||
{
|
||||
StorageList::operator[](i) = ~StorageList::operator[](i);
|
||||
return;
|
||||
}
|
||||
|
||||
// mask value for complete segments
|
||||
const unsigned int mask = maskLower(packing());
|
||||
|
||||
const label packLen = packedLength();
|
||||
for (label i=0; i < packLen; ++i)
|
||||
{
|
||||
StorageList::operator[](i) = mask & ~StorageList::operator[](i);
|
||||
}
|
||||
|
||||
// mask off the final partial segment
|
||||
{
|
||||
const unsigned int off = size_ % packing();
|
||||
if (off)
|
||||
{
|
||||
const unsigned int seg = size_ / packing();
|
||||
|
||||
StorageList::operator[](seg) &= maskLower(off);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::labelList Foam::PackedList<nBits>::values() const
|
||||
Foam::Xfer<Foam::labelList> Foam::PackedList<nBits>::values() const
|
||||
{
|
||||
labelList elems(size_);
|
||||
|
||||
@ -182,12 +139,16 @@ Foam::labelList Foam::PackedList<nBits>::values() const
|
||||
{
|
||||
elems[i] = get(i);
|
||||
}
|
||||
return elems;
|
||||
|
||||
return elems.xfer();
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
|
||||
Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::printInfo
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "iterator<" << label(nBits) << "> ["
|
||||
<< this->index_ << "]"
|
||||
@ -201,78 +162,381 @@ Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
||||
Foam::Ostream& Foam::PackedList<nBits>::printBits
|
||||
(
|
||||
Ostream& os,
|
||||
const bool fullOutput
|
||||
) const
|
||||
{
|
||||
const label packLen = packedLength(size_);
|
||||
|
||||
os << "PackedList<" << nBits << ">"
|
||||
<< " max_value:" << max_value()
|
||||
<< " packing:" << packing() << nl
|
||||
<< " count: " << count() << nl
|
||||
<< " size/capacity: " << size_ << "/" << capacity() << nl
|
||||
<< " storage/capacity: " << packLen << "/" << StorageList::size()
|
||||
<< "\n(\n";
|
||||
const label packLen = packedLength();
|
||||
|
||||
// mask value for complete segments
|
||||
unsigned int mask = maskLower(packing());
|
||||
const label outputLen = fullOutput ? StorageList::size() : packLen;
|
||||
|
||||
for (label i=0; i < packLen; i++)
|
||||
os << "(\n";
|
||||
for (label i=0; i < outputLen; ++i)
|
||||
{
|
||||
const StorageType& rawBits = StorageList::operator[](i);
|
||||
|
||||
// the final segment may not be full, modify mask accordingly
|
||||
if (i+1 == packLen)
|
||||
if (i == packLen-1)
|
||||
{
|
||||
unsigned int endOff = size_ % packing();
|
||||
const unsigned int off = size_ % packing();
|
||||
|
||||
if (endOff)
|
||||
if (off)
|
||||
{
|
||||
mask = maskLower(endOff);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
mask = maskLower(off);
|
||||
}
|
||||
}
|
||||
else if (i == packLen)
|
||||
{
|
||||
// no mask for unaddressed bit
|
||||
mask = 0u;
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int testBit = (1u << max_bits()); testBit; testBit >>= 1)
|
||||
{
|
||||
if (mask & testBit)
|
||||
{
|
||||
// addressable region
|
||||
if (rawBits & testBit)
|
||||
{
|
||||
os << '1';
|
||||
os << '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '-';
|
||||
os << '-';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
os << 'x';
|
||||
if (rawBits & testBit)
|
||||
{
|
||||
os << '!';
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
os << '\n';
|
||||
os << '\n';
|
||||
}
|
||||
os << ")\n";
|
||||
os << ")\n";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::printInfo
|
||||
(
|
||||
Ostream& os,
|
||||
const bool fullOutput
|
||||
) const
|
||||
{
|
||||
os << "PackedList<" << nBits << ">"
|
||||
<< " max_value:" << max_value()
|
||||
<< " packing:" << packing() << nl
|
||||
<< " count: " << count() << nl
|
||||
<< " size/capacity: " << size_ << "/" << capacity() << nl
|
||||
<< " storage/capacity: "
|
||||
<< packedLength() << "/" << StorageList::size()
|
||||
<< "\n";
|
||||
|
||||
return printBits(os, fullOutput);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Istream& Foam::PackedList<nBits>::read(Istream& is)
|
||||
{
|
||||
PackedList<nBits>& lst = *this;
|
||||
|
||||
lst.clear();
|
||||
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||
|
||||
token firstTok(is);
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&) : "
|
||||
"reading first token"
|
||||
);
|
||||
|
||||
if (firstTok.isLabel())
|
||||
{
|
||||
const label sz = firstTok.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
lst.resize(sz);
|
||||
|
||||
// Read list contents depending on data format
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
// Read beginning of contents
|
||||
const char delimiter = is.readBeginList("PackedList<nBits>");
|
||||
|
||||
if (sz)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (register label i=0; i<sz; ++i)
|
||||
{
|
||||
lst[i] = lst.readValue(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (delimiter == token::BEGIN_BLOCK)
|
||||
{
|
||||
// assign for all entries
|
||||
lst = lst.readValue(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&) : "
|
||||
"reading the single entry"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&)",
|
||||
is
|
||||
)
|
||||
<< "incorrect list token, expected '(' or '{', found "
|
||||
<< firstTok.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
// Read end of contents
|
||||
is.readEndList("PackedList<nBits>");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sz)
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(lst.storage().data()),
|
||||
lst.byteSize()
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (firstTok.isPunctuation())
|
||||
{
|
||||
if (firstTok.pToken() == token::BEGIN_LIST)
|
||||
{
|
||||
token nextTok(is);
|
||||
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||
|
||||
while
|
||||
(
|
||||
!( nextTok.isPunctuation()
|
||||
&& nextTok.pToken() == token::END_LIST
|
||||
)
|
||||
)
|
||||
{
|
||||
is.putBack(nextTok);
|
||||
lst.append(lst.readValue(is));
|
||||
|
||||
is >> nextTok;
|
||||
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||
}
|
||||
}
|
||||
else if (firstTok.pToken() == token::BEGIN_BLOCK)
|
||||
{
|
||||
token nextTok(is);
|
||||
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||
|
||||
while
|
||||
(
|
||||
!( nextTok.isPunctuation()
|
||||
&& nextTok.pToken() == token::END_BLOCK
|
||||
)
|
||||
)
|
||||
{
|
||||
is.putBack(nextTok);
|
||||
lst.setPair(is);
|
||||
|
||||
is >> nextTok;
|
||||
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&)",
|
||||
is
|
||||
)
|
||||
<< "incorrect first token, expected '(', found "
|
||||
<< firstTok.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"PackedList<nBits>::read(Istream&)",
|
||||
is
|
||||
)
|
||||
<< "incorrect first token, expected <int>, '(' or '{', found "
|
||||
<< firstTok.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const bool indexedOutput
|
||||
) const
|
||||
{
|
||||
const PackedList<nBits>& lst = *this;
|
||||
const label sz = lst.size();
|
||||
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
bool uniform = false;
|
||||
|
||||
if (sz > 1 && !indexedOutput)
|
||||
{
|
||||
uniform = true;
|
||||
|
||||
forAll(lst, i)
|
||||
{
|
||||
if (lst[i] != lst[0])
|
||||
{
|
||||
uniform = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uniform)
|
||||
{
|
||||
// uniform values:
|
||||
os << sz << token::BEGIN_BLOCK << lst[0] << token::END_BLOCK;
|
||||
}
|
||||
else if (indexedOutput)
|
||||
{
|
||||
// indexed output
|
||||
os << nl << token::BEGIN_BLOCK << nl;
|
||||
|
||||
for
|
||||
(
|
||||
typename PackedList<nBits>::const_iterator iter = lst.cbegin();
|
||||
iter != lst.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
if (iter.writeIfSet(os))
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
os << token::END_BLOCK << nl;
|
||||
}
|
||||
else if (sz < 11)
|
||||
{
|
||||
// short list:
|
||||
os << sz << token::BEGIN_LIST;
|
||||
forAll(lst, i)
|
||||
{
|
||||
if (i)
|
||||
{
|
||||
os << token::SPACE;
|
||||
}
|
||||
os << lst[i];
|
||||
}
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// longer list:
|
||||
os << nl << sz << nl << token::BEGIN_LIST;
|
||||
forAll(lst, i)
|
||||
{
|
||||
os << nl << lst[i];
|
||||
}
|
||||
os << nl << token::END_LIST << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << sz << nl;
|
||||
if (sz)
|
||||
{
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(lst.storage().cdata()),
|
||||
lst.byteSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
void Foam::PackedList<nBits>::writeEntry(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
void Foam::PackedList<nBits>::writeEntry
|
||||
(
|
||||
const word& keyword,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword(keyword);
|
||||
writeEntry(os);
|
||||
os << token::END_STATEMENT << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<unsigned nBits>
|
||||
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||
Foam::PackedList<nBits>&
|
||||
Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||
{
|
||||
StorageList::operator=(lst);
|
||||
size_ = lst.size();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||
Foam::PackedList<nBits>&
|
||||
Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||
{
|
||||
setCapacity(lst.size());
|
||||
size_ = lst.size();
|
||||
@ -281,19 +545,39 @@ void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
template<unsigned nBits>
|
||||
Foam::PackedList<nBits>&
|
||||
Foam::PackedList<nBits>::operator=(const UIndirectList<label>& lst)
|
||||
{
|
||||
setCapacity(lst.size());
|
||||
size_ = lst.size();
|
||||
|
||||
//template<unsigned nBits>
|
||||
//Foam::Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
|
||||
//{
|
||||
// os << lst();
|
||||
// return os;
|
||||
//}
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, PackedList<nBits>& lst)
|
||||
{
|
||||
return lst.read(is);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
|
||||
{
|
||||
return lst.write(os, false);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -72,6 +72,23 @@ Note
|
||||
list[8] = 1;
|
||||
@endcode
|
||||
|
||||
Also note that all unused internal storage elements are guaranteed to
|
||||
always be bit-wise zero. This property must not be violated by any
|
||||
inheriting classes.
|
||||
|
||||
In addition to the normal output format, PackedList also supports a
|
||||
compact ASCII format that may be convenient for user input in some
|
||||
situations. The general format is a group of index/value pairs:
|
||||
@verbatim
|
||||
{ (index1 value1) (index2 value2) (index3 value3) }
|
||||
@endverbatim
|
||||
The bool specialization just uses the indices corresponding to
|
||||
non-zero entries instead of a index/value pair:
|
||||
@verbatim
|
||||
{ index1 index2 index3 }
|
||||
@endverbatim
|
||||
In both cases, the supplied indices can be randomly ordered.
|
||||
|
||||
SeeAlso
|
||||
Foam::DynamicList
|
||||
|
||||
@ -85,6 +102,7 @@ SourceFiles
|
||||
#define PackedList_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "UIndirectList.H"
|
||||
#include "StaticAssert.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -92,18 +110,34 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<unsigned nBits> class PackedList;
|
||||
|
||||
// template<unsigned nBits>
|
||||
// Ostream& operator<<(Ostream&, const PackedList<nBits>&);
|
||||
template<unsigned nBits>
|
||||
Istream& operator>>(Istream&, PackedList<nBits>&);
|
||||
template<unsigned nBits>
|
||||
Ostream& operator<<(Ostream&, const PackedList<nBits>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PackedListName Declaration
|
||||
Class PackedListCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
TemplateName(PackedList);
|
||||
//- Template-invariant bits for PackedList
|
||||
struct PackedListCore
|
||||
{
|
||||
//- Construct null
|
||||
PackedListCore()
|
||||
{}
|
||||
|
||||
//- Define template name and debug
|
||||
ClassName("PackedList");
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PackedList Declaration
|
||||
@ -112,25 +146,41 @@ TemplateName(PackedList);
|
||||
template<unsigned nBits=1>
|
||||
class PackedList
|
||||
:
|
||||
public PackedListCore,
|
||||
private List<unsigned int>
|
||||
{
|
||||
protected:
|
||||
|
||||
typedef unsigned int StorageType;
|
||||
typedef List<StorageType> StorageList;
|
||||
|
||||
//- nBits must be positive (non-zero) and fit within the storage
|
||||
// For simplicity, assume 8-bit bytes
|
||||
StaticAssert(nBits && nBits < (sizeof(StorageType) << 3));
|
||||
// Protected Member Functions
|
||||
|
||||
//- Calculate the list length when packed
|
||||
inline static label packedLength(const label);
|
||||
|
||||
//- Read a list entry (allows for specialization)
|
||||
inline static unsigned int readValue(Istream&);
|
||||
|
||||
//- Read an index/value pair and set accordingly.
|
||||
// For bool specialization, read a single index value
|
||||
inline void setPair(Istream&);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- nBits must be positive (non-zero) and fit within the storage.
|
||||
// For efficiency, however, require packing at least 2 items otherwise
|
||||
// it is more efficient to use a normal list.
|
||||
// Thus max nBits is 1/2 of the base storage size.
|
||||
// For simplicity, assume 8-bit bytes in the assert.
|
||||
StaticAssert(nBits && nBits <= (sizeof(StorageType) << 2));
|
||||
|
||||
// Private data
|
||||
|
||||
//- Number of nBits entries
|
||||
label size_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the list length when packed
|
||||
inline static label packedLength(const label);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -163,20 +213,26 @@ public:
|
||||
//- Null constructor
|
||||
inline PackedList();
|
||||
|
||||
//- Construct with given size, initializes list to 0.
|
||||
//- Construct with given size, initializes list to 0
|
||||
explicit inline PackedList(const label size);
|
||||
|
||||
//- Construct with given size and value for all elements.
|
||||
PackedList(const label size, const unsigned val);
|
||||
//- Construct with given size and value for all elements
|
||||
inline PackedList(const label size, const unsigned val);
|
||||
|
||||
//- Copy constructor.
|
||||
//- Construct from Istream
|
||||
inline PackedList(Istream&);
|
||||
|
||||
//- Copy constructor
|
||||
inline PackedList(const PackedList<nBits>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
inline PackedList(const Xfer<PackedList<nBits> >&);
|
||||
|
||||
//- Construct from a list of labels
|
||||
explicit PackedList(const UList<label>&);
|
||||
explicit inline PackedList(const UList<label>&);
|
||||
|
||||
//- Construct from an indirect list of labels
|
||||
explicit inline PackedList(const UIndirectList<label>&);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr< PackedList<nBits> > clone() const;
|
||||
@ -209,30 +265,52 @@ public:
|
||||
inline bool unset(const label);
|
||||
|
||||
//- Return the underlying packed storage
|
||||
// Manipulate with utmost caution
|
||||
inline List<unsigned int>& storage();
|
||||
|
||||
//- Return the underlying packed storage
|
||||
inline const List<unsigned int>& storage() const;
|
||||
|
||||
//- The list length when packed
|
||||
inline label packedLength() const;
|
||||
|
||||
//- Return the binary size in number of characters
|
||||
// used in the underlying storage
|
||||
inline label byteSize() const;
|
||||
|
||||
//- Count number of bits set, O(log(n))
|
||||
// Uses the Hamming weight (population count) method
|
||||
// http://en.wikipedia.org/wiki/Hamming_weight
|
||||
unsigned int count() const;
|
||||
|
||||
//- Return the values as a labelList
|
||||
labelList values() const;
|
||||
//- Return the values as a list of labels
|
||||
Xfer<labelList> values() const;
|
||||
|
||||
//- Print bit patterns, optionally output unused elements
|
||||
//
|
||||
// addressable bits:
|
||||
// on: '1', off: '-'
|
||||
//
|
||||
// non-addressable bits:
|
||||
// on: '!', off: '.'
|
||||
//
|
||||
Ostream& printBits(Ostream&, const bool fullOutput=false) const;
|
||||
|
||||
//- Print information and bit patterns (with printBits)
|
||||
Ostream& printInfo(Ostream&, const bool fullOutput=false) const;
|
||||
|
||||
//- Print values and information
|
||||
Ostream& print(Ostream&) const;
|
||||
|
||||
// Edit
|
||||
|
||||
//- Trim any trailing zero elements
|
||||
bool trim();
|
||||
|
||||
//- Invert the bits in the addressable region.
|
||||
//- Invert the bits in the addressable region
|
||||
void flip();
|
||||
|
||||
//- Clear all bits
|
||||
inline void reset();
|
||||
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
@ -240,10 +318,10 @@ public:
|
||||
|
||||
//- Reset addressable list size, does not shrink the allocated size.
|
||||
// Optionally specify a value for new elements.
|
||||
inline void resize(const label, const unsigned int& val = 0);
|
||||
inline void resize(const label, const unsigned int& val = 0u);
|
||||
|
||||
//- Alias for resize()
|
||||
inline void setSize(const label, const unsigned int& val = 0);
|
||||
inline void setSize(const label, const unsigned int& val = 0u);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size.
|
||||
@ -269,10 +347,43 @@ public:
|
||||
inline Xfer<PackedList<nBits> > xfer();
|
||||
|
||||
|
||||
// IO
|
||||
|
||||
//- Clear list and read from stream
|
||||
Istream& read(Istream&);
|
||||
|
||||
//- Write, optionally with indexedOutput
|
||||
//
|
||||
// The indexed output may be convenient in some situations.
|
||||
// The general format is a group of index/value pairs:
|
||||
// @verbatim
|
||||
// { (index1 value1) (index2 value2) (index3 value3) }
|
||||
// @endverbatim
|
||||
// The bool specialization just uses the indices corresponding to
|
||||
// non-zero entries instead of a index/value pair:
|
||||
// @verbatim
|
||||
// { index1 index2 index3 }
|
||||
// @endverbatim
|
||||
//
|
||||
// Note the indexed output is only supported for ASCII streams.
|
||||
Ostream& write
|
||||
(
|
||||
Ostream&,
|
||||
const bool indexedOutput=false
|
||||
) const;
|
||||
|
||||
|
||||
//- Write as a dictionary entry
|
||||
void writeEntry(Ostream&) const;
|
||||
|
||||
//- Write as a dictionary entry with keyword
|
||||
void writeEntry(const word& keyword, Ostream&) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Append a value at the end of the list
|
||||
inline void append(const unsigned int val);
|
||||
inline PackedList<nBits>& append(const unsigned int val);
|
||||
|
||||
//- Remove and return the last element
|
||||
inline unsigned int remove();
|
||||
@ -287,23 +398,16 @@ public:
|
||||
inline iteratorBase operator[](const label);
|
||||
|
||||
//- Assignment of all entries to the given value. Takes linear time.
|
||||
inline void operator=(const unsigned int val);
|
||||
inline PackedList<nBits>& operator=(const unsigned int val);
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
void operator=(const PackedList<nBits>&);
|
||||
//- Assignment operator.
|
||||
PackedList<nBits>& operator=(const PackedList<nBits>&);
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
void operator=(const UList<label>&);
|
||||
//- Assignment operator.
|
||||
PackedList<nBits>& operator=(const UList<label>&);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
|
||||
// // Write PackedList to Ostream.
|
||||
// friend Ostream& operator<< <nBits>
|
||||
// (
|
||||
// Ostream&,
|
||||
// const PackedList<nBits>&
|
||||
// );
|
||||
//- Assignment operator.
|
||||
PackedList<nBits>& operator=(const UIndirectList<label>&);
|
||||
|
||||
|
||||
// Iterators and helpers
|
||||
@ -347,6 +451,15 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the element index corresponding to the iterator
|
||||
inline label key() const;
|
||||
|
||||
//- Write index/value for a non-zero entry
|
||||
// The bool specialization writes the index only
|
||||
inline bool writeIfSet(Ostream&) const;
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Compare values (not positions)
|
||||
@ -365,8 +478,8 @@ public:
|
||||
// Never auto-vivify entries.
|
||||
inline operator unsigned int () const;
|
||||
|
||||
//- Print value and information
|
||||
Ostream& print(Ostream&) const;
|
||||
//- Print information and values
|
||||
Ostream& printInfo(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
@ -376,11 +489,12 @@ public:
|
||||
public iteratorBase
|
||||
{
|
||||
|
||||
//- Disallow copy constructor from const_iterator -
|
||||
// violates const-ness!
|
||||
//- Disallow copy constructor from const_iterator
|
||||
// This would violate const-ness!
|
||||
iterator(const const_iterator&);
|
||||
|
||||
//- Disallow assignment from const_iterator - violates const-ness!
|
||||
//- Disallow assignment from const_iterator
|
||||
// This would violate const-ness!
|
||||
void operator=(const const_iterator&);
|
||||
|
||||
|
||||
@ -497,6 +611,20 @@ public:
|
||||
//- const_iterator set to beyond the end of the PackedList
|
||||
inline const_iterator end() const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>> <nBits>
|
||||
(
|
||||
Istream&,
|
||||
PackedList<nBits>&
|
||||
);
|
||||
|
||||
friend Ostream& operator<< <nBits>
|
||||
(
|
||||
Ostream&,
|
||||
const PackedList<nBits>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::PackedListName, 0);
|
||||
defineTypeNameAndDebug(Foam::PackedListCore, 0);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -21,7 +21,6 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
@ -67,11 +66,117 @@ inline Foam::label Foam::PackedList<nBits>::packedLength(const label nElem)
|
||||
}
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Template specialization for bool entries
|
||||
template<>
|
||||
inline unsigned int Foam::PackedList<1>::readValue(Istream& is)
|
||||
{
|
||||
return readBool(is);
|
||||
}
|
||||
|
||||
// Template specialization for bool entries
|
||||
template<>
|
||||
inline void Foam::PackedList<1>::setPair(Istream& is)
|
||||
{
|
||||
set(readLabel(is), true);
|
||||
}
|
||||
|
||||
// Template specialization for bool entries
|
||||
template<>
|
||||
inline bool Foam::PackedList<1>::iteratorBase::writeIfSet(Ostream& os) const
|
||||
{
|
||||
if (this->get())
|
||||
{
|
||||
os << index_;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline unsigned int Foam::PackedList<nBits>::readValue(Istream& is)
|
||||
{
|
||||
const unsigned int val = readLabel(is);
|
||||
|
||||
if (val > max_value())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"PackedList<nBits>::readValue(Istream&)",
|
||||
is
|
||||
)
|
||||
<< "Out-of-range value " << val << " for PackedList<" << nBits
|
||||
<< ">. Maximum permitted value is " << max_value() << "."
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::setPair(Istream& is)
|
||||
{
|
||||
is.readBegin("Tuple2<label, unsigned int>");
|
||||
|
||||
const label ind = readLabel(is);
|
||||
const unsigned int val = readLabel(is);
|
||||
|
||||
is.readEnd("Tuple2<label, unsigned int>");
|
||||
|
||||
if (val > max_value())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"PackedList<nBits>::setPair(Istream&)",
|
||||
is
|
||||
)
|
||||
<< "Out-of-range value " << val << " for PackedList<" << nBits
|
||||
<< "> at index " << ind
|
||||
<< ". Maximum permitted value is " << max_value() << "."
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
set(ind, val);
|
||||
|
||||
// Check state of Istream
|
||||
is.check("PackedList<nBits>::setPair(Istream&)");
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::iteratorBase::writeIfSet(Ostream& os) const
|
||||
{
|
||||
const label val = this->get();
|
||||
|
||||
if (val)
|
||||
{
|
||||
os << token::BEGIN_LIST
|
||||
<< index_ << token::SPACE << val
|
||||
<< token::END_LIST;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList()
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(),
|
||||
size_(0)
|
||||
{}
|
||||
@ -80,14 +185,45 @@ inline Foam::PackedList<nBits>::PackedList()
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const label size)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(packedLength(size), 0u),
|
||||
size_(size)
|
||||
{}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList
|
||||
(
|
||||
const label size,
|
||||
const unsigned int val
|
||||
)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(packedLength(size), 0u),
|
||||
size_(size)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
operator=(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(Istream& is)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(),
|
||||
size_(0)
|
||||
{
|
||||
read(is);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(lst),
|
||||
size_(lst.size_)
|
||||
{}
|
||||
@ -100,6 +236,34 @@ inline Foam::PackedList<nBits>::PackedList(const Xfer<PackedList<nBits> >& lst)
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(packedLength(lst.size()), 0u),
|
||||
size_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const UIndirectList<label>& lst)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(packedLength(lst.size()), 0u),
|
||||
size_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::autoPtr<Foam::PackedList<nBits> >
|
||||
Foam::PackedList<nBits>::clone() const
|
||||
@ -151,27 +315,34 @@ Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val)
|
||||
const unsigned int seg = index_ / packing();
|
||||
const unsigned int off = index_ % packing();
|
||||
|
||||
const unsigned int startBit = nBits * off;
|
||||
const unsigned int mask = max_value() << startBit;
|
||||
|
||||
unsigned int& stored = list_->StorageList::operator[](seg);
|
||||
const unsigned int prev = stored;
|
||||
|
||||
const unsigned int startBit = nBits * off;
|
||||
const unsigned int maskNew = max_value() << startBit;
|
||||
|
||||
if (val & ~max_value())
|
||||
if (val >= max_value())
|
||||
{
|
||||
// overflow is max_value, fill everything
|
||||
stored |= maskNew;
|
||||
stored |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
stored &= ~maskNew;
|
||||
stored |= maskNew & (val << startBit);
|
||||
stored &= ~mask;
|
||||
stored |= mask & (val << startBit);
|
||||
}
|
||||
|
||||
return prev != stored;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::iteratorBase::key() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::iteratorBase::operator==
|
||||
(
|
||||
@ -564,24 +735,27 @@ inline bool Foam::PackedList<nBits>::empty() const
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const label newSize,
|
||||
const unsigned int& val
|
||||
)
|
||||
{
|
||||
reserve(nElem);
|
||||
reserve(newSize);
|
||||
|
||||
if (nElem > size_)
|
||||
const label oldSize = size_;
|
||||
size_ = newSize;
|
||||
|
||||
if (size_ > oldSize)
|
||||
{
|
||||
// fill new elements or newly exposed elements
|
||||
if (size_)
|
||||
if (val)
|
||||
{
|
||||
// fill value for complete segments
|
||||
unsigned int fill = val;
|
||||
|
||||
if (fill & ~max_value())
|
||||
if (val >= max_value())
|
||||
{
|
||||
// overflow is max_value, fill everything
|
||||
fill = ~0u;
|
||||
// fill everything
|
||||
fill = maskLower(packing());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -591,36 +765,64 @@ inline void Foam::PackedList<nBits>::resize
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int seg = size_ / packing();
|
||||
unsigned int off = size_ % packing();
|
||||
|
||||
// partial segment, preserve existing value
|
||||
if (off)
|
||||
// fill in complete segments
|
||||
const label oldLen = packedLength(oldSize);
|
||||
const label newLen = packedLength(size_);
|
||||
for (label i=oldLen; i < newLen; ++i)
|
||||
{
|
||||
unsigned int maskOld = maskLower(off);
|
||||
|
||||
StorageList::operator[](seg) &= maskOld;
|
||||
StorageList::operator[](seg) |= ~maskOld & fill;
|
||||
|
||||
// continue with the next segment
|
||||
seg++;
|
||||
StorageList::operator[](i) = fill;
|
||||
}
|
||||
|
||||
unsigned int endSeg = nElem / packing();
|
||||
// fill in complete elements
|
||||
while (seg < endSeg)
|
||||
// finish previous partial segment, preserve existing value
|
||||
{
|
||||
StorageList::operator[](seg++) = fill;
|
||||
const unsigned int off = oldSize % packing();
|
||||
if (off)
|
||||
{
|
||||
const unsigned int seg = oldSize / packing();
|
||||
const unsigned int mask = maskLower(off);
|
||||
|
||||
StorageList::operator[](seg) &= mask;
|
||||
StorageList::operator[](seg) |= ~mask & fill;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mask off the (new) final partial segment
|
||||
{
|
||||
const unsigned int off = size_ % packing();
|
||||
if (off)
|
||||
{
|
||||
const unsigned int seg = size_ / packing();
|
||||
|
||||
StorageList::operator[](seg) &= maskLower(off);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no original size - simply flood-fill
|
||||
operator=(val);
|
||||
}
|
||||
}
|
||||
else if (size_ < oldSize)
|
||||
{
|
||||
// resize shrinking
|
||||
// - clear newly exposed elements
|
||||
|
||||
size_ = nElem;
|
||||
// fill in complete segments
|
||||
const label oldLen = packedLength(oldSize);
|
||||
const label newLen = packedLength(size_);
|
||||
for (label i=newLen; i < oldLen; ++i)
|
||||
{
|
||||
StorageList::operator[](i) = 0u;
|
||||
}
|
||||
|
||||
// mask off the final partial segment
|
||||
{
|
||||
const unsigned int off = size_ % packing();
|
||||
if (off)
|
||||
{
|
||||
const unsigned int seg = size_ / packing();
|
||||
|
||||
StorageList::operator[](seg) &= maskLower(off);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -648,21 +850,27 @@ inline void Foam::PackedList<nBits>::setCapacity(const label nElem)
|
||||
{
|
||||
StorageList::setSize(packedLength(nElem), 0u);
|
||||
|
||||
// truncate addressed size too?
|
||||
// truncate addressed size too
|
||||
if (size_ > nElem)
|
||||
{
|
||||
size_ = nElem;
|
||||
|
||||
// mask off the final partial segment
|
||||
const unsigned int off = size_ % packing();
|
||||
if (off)
|
||||
{
|
||||
const unsigned int seg = size_ / packing();
|
||||
|
||||
StorageList::operator[](seg) &= maskLower(off);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::reserve
|
||||
(
|
||||
const label nElem
|
||||
)
|
||||
inline void Foam::PackedList<nBits>::reserve(const label nElem)
|
||||
{
|
||||
label len = packedLength(nElem);
|
||||
const label len = packedLength(nElem);
|
||||
|
||||
// need more capacity?
|
||||
if (len > StorageList::size())
|
||||
@ -681,9 +889,17 @@ inline void Foam::PackedList<nBits>::reserve
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::reset()
|
||||
{
|
||||
StorageList::operator=(0u);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::clear()
|
||||
{
|
||||
reset();
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
@ -699,9 +915,8 @@ inline void Foam::PackedList<nBits>::clearStorage()
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::shrink()
|
||||
{
|
||||
label len = packedLength(size_);
|
||||
|
||||
// we have unused space?
|
||||
// any uneed space allocated?
|
||||
const label len = packedLength();
|
||||
if (len < StorageList::size())
|
||||
{
|
||||
StorageList::setSize(len);
|
||||
@ -722,6 +937,20 @@ inline const Foam::List<unsigned int>& Foam::PackedList<nBits>::storage() const
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::packedLength() const
|
||||
{
|
||||
return packedLength(size_);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::byteSize() const
|
||||
{
|
||||
return packedLength() * sizeof(StorageType);
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::transfer(PackedList<nBits>& lst)
|
||||
{
|
||||
@ -742,23 +971,14 @@ inline Foam::Xfer<Foam::PackedList<nBits> > Foam::PackedList<nBits>::xfer()
|
||||
template<unsigned nBits>
|
||||
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
if (i < 0)
|
||||
{
|
||||
FatalErrorIn("PackedList<nBits>::get(const label)")
|
||||
<< "negative index " << i << " max=" << size_-1
|
||||
<< abort(FatalError);
|
||||
}
|
||||
# endif
|
||||
|
||||
// lazy evaluation - return 0 for out-of-range
|
||||
if (i < size_)
|
||||
if (i < 0 || i >= size_)
|
||||
{
|
||||
return iteratorBase(this, i).get();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return iteratorBase(this, i).get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -767,13 +987,13 @@ template<unsigned nBits>
|
||||
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
||||
{
|
||||
// lazy evaluation - return 0 for out-of-range
|
||||
if (i < size_)
|
||||
if (i < 0 || i >= size_)
|
||||
{
|
||||
return iteratorBase(this, i).get();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return iteratorBase(this, i).get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,18 +1005,14 @@ inline bool Foam::PackedList<nBits>::set
|
||||
const unsigned int val
|
||||
)
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
if (i < 0)
|
||||
{
|
||||
FatalErrorIn("PackedList<nBits>::set(const label)")
|
||||
<< "negative index " << i << " max=" << size_-1
|
||||
<< abort(FatalError);
|
||||
// lazy evaluation - ignore out-of-bounds
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
|
||||
// lazy evaluation - increase size on assigment
|
||||
if (i >= size_)
|
||||
else if (i >= size_)
|
||||
{
|
||||
// lazy evaluation - increase size on assigment
|
||||
resize(i + 1);
|
||||
}
|
||||
|
||||
@ -807,24 +1023,28 @@ inline bool Foam::PackedList<nBits>::set
|
||||
template<unsigned nBits>
|
||||
inline bool Foam::PackedList<nBits>::unset(const label i)
|
||||
{
|
||||
// lazy - ignore out-of-bounds
|
||||
// lazy evaluation - ignore out-of-bounds
|
||||
if (i < 0 || i >= size_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return iteratorBase(this, i).set(0u);
|
||||
else
|
||||
{
|
||||
return iteratorBase(this, i).set(0u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::append(const unsigned int val)
|
||||
inline Foam::PackedList<nBits>&
|
||||
Foam::PackedList<nBits>::append(const unsigned int val)
|
||||
{
|
||||
label elemI = size_;
|
||||
const label elemI = size_;
|
||||
reserve(elemI + 1);
|
||||
size_++;
|
||||
|
||||
iteratorBase(this, elemI).set(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -855,35 +1075,20 @@ Foam::PackedList<nBits>::operator[](const label i)
|
||||
}
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// specialization for nBits=1
|
||||
template<>
|
||||
inline void Foam::PackedList<1>::operator=(const unsigned int val)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
StorageList::operator=(~0u);
|
||||
}
|
||||
else
|
||||
{
|
||||
StorageList::operator=(0u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||
inline Foam::PackedList<nBits>&
|
||||
Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||
{
|
||||
if (val)
|
||||
const label packLen = packedLength();
|
||||
|
||||
if (val && size_)
|
||||
{
|
||||
unsigned int fill = val;
|
||||
|
||||
if (fill & ~max_value())
|
||||
if (val >= max_value())
|
||||
{
|
||||
// treat overflow as max_value
|
||||
fill = ~0u;
|
||||
// fill everything
|
||||
fill = maskLower(packing());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -893,12 +1098,31 @@ inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||
}
|
||||
}
|
||||
|
||||
StorageList::operator=(fill);
|
||||
for (label i=0; i < packLen; ++i)
|
||||
{
|
||||
StorageList::operator[](i) = fill;
|
||||
}
|
||||
|
||||
// mask off the final partial segment
|
||||
{
|
||||
const unsigned int off = size_ % packing();
|
||||
if (off)
|
||||
{
|
||||
const unsigned int seg = size_ / packing();
|
||||
|
||||
StorageList::operator[](seg) &= maskLower(off);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StorageList::operator=(0u);
|
||||
for (label i=0; i < packLen; ++i)
|
||||
{
|
||||
StorageList::operator[](i) = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,13 +23,13 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T, class BaseType>
|
||||
void Foam::IOFieldField<T, BaseType>::readFromStream()
|
||||
void Foam::CompactIOField<T, BaseType>::readFromStream()
|
||||
{
|
||||
Istream& is = readStream(word::null);
|
||||
|
||||
@ -47,7 +47,7 @@ void Foam::IOFieldField<T, BaseType>::readFromStream()
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"IOFieldField<T, BaseType>::readFromStream()",
|
||||
"CompactIOField<T, BaseType>::readFromStream()",
|
||||
is
|
||||
) << "unexpected class name " << headerClassName()
|
||||
<< " expected " << typeName << " or " << IOField<T>::typeName
|
||||
@ -61,7 +61,7 @@ void Foam::IOFieldField<T, BaseType>::readFromStream()
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::IOFieldField<T, BaseType>::IOFieldField(const IOobject& io)
|
||||
Foam::CompactIOField<T, BaseType>::CompactIOField(const IOobject& io)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
@ -77,7 +77,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField(const IOobject& io)
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::IOFieldField<T, BaseType>::IOFieldField
|
||||
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||
(
|
||||
const IOobject& io,
|
||||
const label size
|
||||
@ -101,7 +101,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::IOFieldField<T, BaseType>::IOFieldField
|
||||
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Field<T>& list
|
||||
@ -125,7 +125,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::IOFieldField<T, BaseType>::IOFieldField
|
||||
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Xfer<Field<T> >& list
|
||||
@ -149,7 +149,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField
|
||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::IOFieldField<T, BaseType>::~IOFieldField()
|
||||
Foam::CompactIOField<T, BaseType>::~CompactIOField()
|
||||
{}
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ Foam::IOFieldField<T, BaseType>::~IOFieldField()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class BaseType>
|
||||
bool Foam::IOFieldField<T, BaseType>::writeObject
|
||||
bool Foam::CompactIOField<T, BaseType>::writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
@ -186,7 +186,7 @@ bool Foam::IOFieldField<T, BaseType>::writeObject
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
bool Foam::IOFieldField<T, BaseType>::writeData(Ostream& os) const
|
||||
bool Foam::CompactIOField<T, BaseType>::writeData(Ostream& os) const
|
||||
{
|
||||
return (os << *this).good();
|
||||
}
|
||||
@ -195,9 +195,9 @@ bool Foam::IOFieldField<T, BaseType>::writeData(Ostream& os) const
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class BaseType>
|
||||
void Foam::IOFieldField<T, BaseType>::operator=
|
||||
void Foam::CompactIOField<T, BaseType>::operator=
|
||||
(
|
||||
const IOFieldField<T, BaseType>& rhs
|
||||
const CompactIOField<T, BaseType>& rhs
|
||||
)
|
||||
{
|
||||
Field<T>::operator=(rhs);
|
||||
@ -205,7 +205,7 @@ void Foam::IOFieldField<T, BaseType>::operator=
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
void Foam::IOFieldField<T, BaseType>::operator=(const Field<T>& rhs)
|
||||
void Foam::CompactIOField<T, BaseType>::operator=(const Field<T>& rhs)
|
||||
{
|
||||
Field<T>::operator=(rhs);
|
||||
}
|
||||
@ -217,7 +217,7 @@ template<class T, class BaseType>
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Foam::Istream& is,
|
||||
Foam::IOFieldField<T, BaseType>& L
|
||||
Foam::CompactIOField<T, BaseType>& L
|
||||
)
|
||||
{
|
||||
// Read compact
|
||||
@ -248,7 +248,7 @@ template<class T, class BaseType>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Foam::Ostream& os,
|
||||
const Foam::IOFieldField<T, BaseType>& L
|
||||
const Foam::CompactIOField<T, BaseType>& L
|
||||
)
|
||||
{
|
||||
// Keep ascii writing same.
|
||||
@ -22,18 +22,22 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::IOFieldField
|
||||
Foam::CompactIOField
|
||||
|
||||
Description
|
||||
A Field of objects of type \<T\> with automated input and output.
|
||||
A Field of objects of type \<T\> with automated input and output using
|
||||
a compact storage. Behaves like IOField except when binary output in
|
||||
case it writes a CompactListList.
|
||||
|
||||
Useful for fields of small subfields e.g. in lagrangian
|
||||
|
||||
SourceFiles
|
||||
IOFieldField.C
|
||||
CompactIOField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOFieldField_H
|
||||
#define IOFieldField_H
|
||||
#ifndef CompactIOField_H
|
||||
#define CompactIOField_H
|
||||
|
||||
#include "IOField.H"
|
||||
#include "regIOobject.H"
|
||||
@ -47,25 +51,25 @@ class Istream;
|
||||
class Ostream;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class T, class BaseType> class IOFieldField;
|
||||
template<class T, class BaseType> class CompactIOField;
|
||||
|
||||
template<class T, class BaseType> Istream& operator>>
|
||||
(
|
||||
Istream&,
|
||||
IOFieldField<T, BaseType>&
|
||||
CompactIOField<T, BaseType>&
|
||||
);
|
||||
template<class T, class BaseType> Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const IOFieldField<T, BaseType>&
|
||||
const CompactIOField<T, BaseType>&
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOFieldField Declaration
|
||||
Class CompactIOField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T, class BaseType>
|
||||
class IOFieldField
|
||||
class CompactIOField
|
||||
:
|
||||
public regIOobject,
|
||||
public Field<T>
|
||||
@ -84,21 +88,21 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
IOFieldField(const IOobject&);
|
||||
CompactIOField(const IOobject&);
|
||||
|
||||
//- Construct from IOobject and size of IOFieldField
|
||||
IOFieldField(const IOobject&, const label);
|
||||
//- Construct from IOobject and size
|
||||
CompactIOField(const IOobject&, const label);
|
||||
|
||||
//- Construct from IOobject and a Field
|
||||
IOFieldField(const IOobject&, const Field<T>&);
|
||||
CompactIOField(const IOobject&, const Field<T>&);
|
||||
|
||||
//- Construct by transferring the Field contents
|
||||
IOFieldField(const IOobject&, const Xfer<Field<T> >&);
|
||||
CompactIOField(const IOobject&, const Xfer<Field<T> >&);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~IOFieldField();
|
||||
virtual ~CompactIOField();
|
||||
|
||||
|
||||
// Member functions
|
||||
@ -115,7 +119,7 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
void operator=(const IOFieldField<T, BaseType>&);
|
||||
void operator=(const CompactIOField<T, BaseType>&);
|
||||
|
||||
void operator=(const Field<T>&);
|
||||
|
||||
@ -126,14 +130,14 @@ public:
|
||||
friend Istream& operator>> <T, BaseType>
|
||||
(
|
||||
Istream&,
|
||||
IOFieldField<T, BaseType>&
|
||||
CompactIOField<T, BaseType>&
|
||||
);
|
||||
|
||||
// Write Field to Ostream.
|
||||
friend Ostream& operator<< <T, BaseType>
|
||||
(
|
||||
Ostream&,
|
||||
const IOFieldField<T, BaseType>&
|
||||
const CompactIOField<T, BaseType>&
|
||||
);
|
||||
};
|
||||
|
||||
@ -145,7 +149,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "IOFieldField.C"
|
||||
# include "CompactIOField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -22,11 +22,12 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Read of a non-delimited hex label
|
||||
Read a non-delimited hex label
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "readHexLabel.H"
|
||||
#include <cctype>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,7 +56,7 @@ Foam::label Foam::readHexLabel(ISstream& is)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
result *= 16;
|
||||
result <<= 4;
|
||||
|
||||
if (isdigit(c))
|
||||
{
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
diagTensorIOFieldField,
|
||||
"diagTensorCompactFieldField",
|
||||
diagTensorFieldCompactIOField,
|
||||
"diagTensorFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,15 +33,15 @@ Description
|
||||
#define diagTensorFieldIOField_H
|
||||
|
||||
#include "diagTensorField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<diagTensorField> diagTensorFieldIOField;
|
||||
typedef IOFieldField<diagTensorField, diagTensor> diagTensorIOFieldField;
|
||||
typedef CompactIOField<diagTensorField, diagTensor>
|
||||
diagTensorFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
labelIOFieldField,
|
||||
"labelCompactFieldField",
|
||||
labelFieldCompactIOField,
|
||||
"labelFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -34,14 +34,14 @@ Description
|
||||
|
||||
#include "labelField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<labelField> labelFieldIOField;
|
||||
typedef IOFieldField<labelField, label> labelIOFieldField;
|
||||
typedef CompactIOField<labelField, label> labelFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
scalarIOFieldField,
|
||||
"scalarCompactFieldField",
|
||||
scalarFieldCompactIOField,
|
||||
"scalarFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,15 +33,14 @@ Description
|
||||
#define scalarFieldIOField_H
|
||||
|
||||
#include "scalarField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<scalarField> scalarFieldIOField;
|
||||
typedef IOFieldField<scalarField, scalar> scalarIOFieldField;
|
||||
typedef CompactIOField<scalarField, scalar> scalarFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
sphericalTensorIOFieldField,
|
||||
"sphericalTensorCompactFieldField",
|
||||
sphericalTensorFieldCompactIOField,
|
||||
"sphericalTensorFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,8 +33,7 @@ Description
|
||||
#define sphericalTensorFieldIOField_H
|
||||
|
||||
#include "sphericalTensorField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -42,8 +41,8 @@ namespace Foam
|
||||
{
|
||||
typedef IOField<sphericalTensorField> sphericalTensorFieldIOField;
|
||||
|
||||
typedef IOFieldField<sphericalTensorField, sphericalTensor>
|
||||
sphericalTensorIOFieldField;
|
||||
typedef CompactIOField<sphericalTensorField, sphericalTensor>
|
||||
sphericalTensorFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
symmTensorIOFieldField,
|
||||
"symmTensorCompactFieldField",
|
||||
symmTensorFieldCompactIOField,
|
||||
"symmTensorFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,15 +33,15 @@ Description
|
||||
#define symmTensorFieldIOField_H
|
||||
|
||||
#include "symmTensorField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<symmTensorField> symmTensorFieldIOField;
|
||||
typedef IOFieldField<symmTensorField, symmTensor> symmTensorIOFieldField;
|
||||
typedef CompactIOField<symmTensorField, symmTensor>
|
||||
symmTensorFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
tensorIOFieldField,
|
||||
"tensorCompactFieldField",
|
||||
tensorFieldCompactIOField,
|
||||
"tensorFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,15 +33,14 @@ Description
|
||||
#define tensorFieldIOField_H
|
||||
|
||||
#include "tensorField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<tensorField> tensorFieldIOField;
|
||||
typedef IOFieldField<tensorField, tensor> tensorIOFieldField;
|
||||
typedef CompactIOField<tensorField, tensor> tensorFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
vector2DIOFieldField,
|
||||
"vector2DCompactFieldField",
|
||||
vector2DFieldCompactIOField,
|
||||
"vector2DFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,15 +33,14 @@ Description
|
||||
#define vector2DFieldIOField_H
|
||||
|
||||
#include "vector2DField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<vector2DField> vector2DFieldIOField;
|
||||
typedef IOFieldField<vector2DField, vector2D> vector2DIOFieldField;
|
||||
typedef CompactIOField<vector2DField, vector2D> vector2DFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,8 +41,8 @@ namespace Foam
|
||||
|
||||
defineTemplateTypeNameAndDebugWithName
|
||||
(
|
||||
vectorIOFieldField,
|
||||
"vectorCompactFieldField",
|
||||
vectorFieldCompactIOField,
|
||||
"vectorFieldCompactField",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@ -33,15 +33,14 @@ Description
|
||||
#define vectorFieldIOField_H
|
||||
|
||||
#include "vectorField.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOField<vectorField> vectorFieldIOField;
|
||||
typedef IOFieldField<vectorField, vector> vectorIOFieldField;
|
||||
typedef CompactIOField<vectorField, vector> vectorFieldCompactIOField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,51 +22,48 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ZoneID
|
||||
Foam::DynamicID
|
||||
|
||||
Description
|
||||
A class that holds the data needed to identify a zone in a dynamic mesh.
|
||||
A class that holds the data needed to identify things (zones, patches)
|
||||
in a dynamic mesh.
|
||||
|
||||
The zone is identified by name.
|
||||
Its index in the zoneMesh is updated if the mesh has changed.
|
||||
The thing is identified by name.
|
||||
Its indices are updated if the mesh has changed.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ZoneID_H
|
||||
#define ZoneID_H
|
||||
#ifndef DynamicID_H
|
||||
#define DynamicID_H
|
||||
|
||||
#include "label.H"
|
||||
#include "word.H"
|
||||
#include "polyMesh.H"
|
||||
#include "keyType.H"
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class ZoneType, class MeshType> class ZoneMesh;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class> class DynamicID;
|
||||
|
||||
template<class ZoneType> class ZoneID;
|
||||
|
||||
template<class ZoneType>
|
||||
Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&);
|
||||
template<class ObjectType>
|
||||
Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ZoneID Declaration
|
||||
Class DynamicID Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ZoneType>
|
||||
class ZoneID
|
||||
template<class ObjectType>
|
||||
class DynamicID
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Zone name
|
||||
word name_;
|
||||
keyType key_;
|
||||
|
||||
//- Zone index
|
||||
label index_;
|
||||
//- Zone indices
|
||||
labelList indices_;
|
||||
|
||||
|
||||
public:
|
||||
@ -74,17 +71,17 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from name
|
||||
ZoneID(const word& name, const ZoneMesh<ZoneType, polyMesh>& zm)
|
||||
DynamicID(const keyType& key, const ObjectType& obj)
|
||||
:
|
||||
name_(name),
|
||||
index_(zm.findZoneID(name))
|
||||
key_(key),
|
||||
indices_(obj.findIndices(key_))
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
ZoneID(Istream& is, const ZoneMesh<ZoneType, polyMesh>& zm)
|
||||
DynamicID(Istream& is, const ObjectType& obj)
|
||||
:
|
||||
name_(is),
|
||||
index_(zm.findZoneID(name_))
|
||||
key_(is),
|
||||
indices_(obj.findIndices(key_))
|
||||
{}
|
||||
|
||||
|
||||
@ -96,57 +93,57 @@ public:
|
||||
// Access
|
||||
|
||||
//- Return name
|
||||
const word& name() const
|
||||
const keyType& name() const
|
||||
{
|
||||
return name_;
|
||||
return key_;
|
||||
}
|
||||
|
||||
//- Return index
|
||||
//- Return indices of matching zones
|
||||
const labelList& indices() const
|
||||
{
|
||||
return indices_;
|
||||
}
|
||||
|
||||
//- Return index of first matching zone
|
||||
label index() const
|
||||
{
|
||||
return index_;
|
||||
return indices_.empty() ? -1 : indices_[0];
|
||||
}
|
||||
|
||||
//- Has the zone been found
|
||||
bool active() const
|
||||
{
|
||||
return index_ > -1;
|
||||
return !indices_.empty();
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Update
|
||||
void update(const ZoneMesh<ZoneType, polyMesh>& zm)
|
||||
void update(const ObjectType& obj)
|
||||
{
|
||||
index_ = zm.findZoneID(name_);
|
||||
indices_ = obj.findIndices(key_);
|
||||
}
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<< <ZoneType>
|
||||
(
|
||||
Ostream& os, const ZoneID<ZoneType>& p
|
||||
);
|
||||
friend Ostream& operator<< <ObjectType>
|
||||
(Ostream&, const DynamicID<ObjectType>&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ZoneType>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream& os, const ZoneID<ZoneType>& p
|
||||
)
|
||||
template<class ObjectType>
|
||||
Ostream& operator<<(Ostream& os, const DynamicID<ObjectType>& dynId)
|
||||
{
|
||||
os << token::BEGIN_LIST
|
||||
<< p.name_ << token::SPACE
|
||||
<< p.index_
|
||||
<< dynId.name() << token::SPACE << dynId.index()
|
||||
<< token::END_LIST;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&)");
|
||||
os.check("Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,25 +21,20 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::PackedBoolList
|
||||
|
||||
Description
|
||||
A bit-packed bool list
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PackedBoolList_H
|
||||
#define PackedBoolList_H
|
||||
#ifndef polyPatchID_H
|
||||
#define polyPatchID_H
|
||||
|
||||
#include "bool.H"
|
||||
#include "PackedList.H"
|
||||
#include "DynamicID.H"
|
||||
#include "polyBoundaryMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef PackedList<> PackedBoolList;
|
||||
//- Foam::polyPatchID
|
||||
typedef DynamicID<polyBoundaryMesh> polyPatchID;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,21 +26,26 @@ License
|
||||
#ifndef ZoneIDs_H
|
||||
#define ZoneIDs_H
|
||||
|
||||
#include "ZoneID.H"
|
||||
#include "pointZone.H"
|
||||
#include "faceZone.H"
|
||||
#include "cellZone.H"
|
||||
#include "DynamicID.H"
|
||||
|
||||
#include "cellZoneMeshFwd.H"
|
||||
#include "faceZoneMeshFwd.H"
|
||||
#include "pointZoneMeshFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
//- Foam::pointZoneID
|
||||
typedef ZoneID<pointZone> pointZoneID;
|
||||
//- Foam::faceZoneID
|
||||
typedef ZoneID<faceZone> faceZoneID;
|
||||
|
||||
//- Foam::cellZoneID
|
||||
typedef ZoneID<cellZone> cellZoneID;
|
||||
typedef DynamicID<cellZoneMesh> cellZoneID;
|
||||
|
||||
//- Foam::faceZoneID
|
||||
typedef DynamicID<faceZoneMesh> faceZoneID;
|
||||
|
||||
//- Foam::pointZoneID
|
||||
typedef DynamicID<pointZoneMesh> pointZoneID;
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -31,6 +31,7 @@ License
|
||||
#include "PstreamBuffers.H"
|
||||
#include "lduSchedule.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "stringListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -413,6 +414,66 @@ Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList Foam::polyBoundaryMesh::findIndices(const keyType& key) const
|
||||
{
|
||||
labelList indices;
|
||||
|
||||
if (!key.empty())
|
||||
{
|
||||
if (key.isPattern())
|
||||
{
|
||||
indices = findStrings(key, this->names());
|
||||
}
|
||||
else
|
||||
{
|
||||
indices.setSize(this->size());
|
||||
label nFound = 0;
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
indices[nFound++] = i;
|
||||
}
|
||||
}
|
||||
indices.setSize(nFound);
|
||||
}
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyBoundaryMesh::findIndex(const keyType& key) const
|
||||
{
|
||||
if (!key.empty())
|
||||
{
|
||||
if (key.isPattern())
|
||||
{
|
||||
labelList indices = this->findIndices(key);
|
||||
|
||||
// return first element
|
||||
if (!indices.empty())
|
||||
{
|
||||
return indices[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyBoundaryMesh::findPatchID(const word& patchName) const
|
||||
{
|
||||
const polyPatchList& patches = *this;
|
||||
@ -444,7 +505,11 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
|
||||
// with patch start labels.
|
||||
// If the face is internal, return -1;
|
||||
// if it is off the end of the list, abort
|
||||
if (faceIndex >= mesh().nFaces())
|
||||
if (faceIndex < mesh().nInternalFaces())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (faceIndex >= mesh().nFaces())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -453,10 +518,6 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (faceIndex < mesh().nInternalFaces())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
forAll(*this, patchI)
|
||||
{
|
||||
@ -578,7 +639,7 @@ bool Foam::polyBoundaryMesh::checkParallelSync(const bool report) const
|
||||
|
||||
// Have every processor check but only master print error.
|
||||
|
||||
for (label procI = 1; procI < allNames.size(); procI++)
|
||||
for (label procI = 1; procI < allNames.size(); ++procI)
|
||||
{
|
||||
if
|
||||
(
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
#include "polyPatchList.H"
|
||||
#include "regIOobject.H"
|
||||
#include "labelPair.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -151,6 +152,12 @@ public:
|
||||
//- Return a list of physical types
|
||||
wordList physicalTypes() const;
|
||||
|
||||
//- Return patch indices for all matches
|
||||
labelList findIndices(const keyType&) const;
|
||||
|
||||
//- Return patch index for the first match, return -1 if not found
|
||||
label findIndex(const keyType&) const;
|
||||
|
||||
//- Find patch index given a name
|
||||
label findPatchID(const word& patchName) const;
|
||||
|
||||
|
||||
@ -1,142 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::polyPatchID
|
||||
|
||||
Description
|
||||
A class holds the data needed to identify a patch in a dynamic mesh.
|
||||
|
||||
The patch is identified by name and its index in the boundary mesh
|
||||
is updated if the mesh has changed.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef polyPatchID_H
|
||||
#define polyPatchID_H
|
||||
|
||||
#include "polyBoundaryMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class polyPatchID;
|
||||
Ostream& operator<<(Ostream& os, const polyPatchID& p);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class polyPatchID Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class polyPatchID
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Patch name
|
||||
word name_;
|
||||
|
||||
//- Patch index
|
||||
label index_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name
|
||||
polyPatchID(const word& name, const polyBoundaryMesh& bm)
|
||||
:
|
||||
name_(name),
|
||||
index_(bm.findPatchID(name))
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
polyPatchID(Istream& is, const polyBoundaryMesh& bm)
|
||||
:
|
||||
name_(is),
|
||||
index_(bm.findPatchID(name_))
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return name
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return index
|
||||
label index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Has the patch been found
|
||||
bool active() const
|
||||
{
|
||||
return index_ > -1;
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Update
|
||||
void update(const polyBoundaryMesh& bm)
|
||||
{
|
||||
index_ = bm.findPatchID(name_);
|
||||
}
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const polyPatchID& p)
|
||||
{
|
||||
os << token::BEGIN_LIST
|
||||
<< p.name_ << token::SPACE
|
||||
<< p.index_
|
||||
<< token::END_LIST;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const polyPatchID&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -250,23 +250,27 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::findIndices
|
||||
) const
|
||||
{
|
||||
labelList indices;
|
||||
if (key.isPattern())
|
||||
|
||||
if (!key.empty())
|
||||
{
|
||||
indices = findStrings(key, this->names());
|
||||
}
|
||||
else
|
||||
{
|
||||
indices.setSize(this->size());
|
||||
label nFound = 0;
|
||||
forAll(*this, i)
|
||||
if (key.isPattern())
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
indices[nFound++] = i;
|
||||
}
|
||||
indices = findStrings(key, this->names());
|
||||
}
|
||||
indices.setSize(nFound);
|
||||
}
|
||||
else
|
||||
{
|
||||
indices.setSize(this->size());
|
||||
label nFound = 0;
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
indices[nFound++] = i;
|
||||
}
|
||||
}
|
||||
indices.setSize(nFound);
|
||||
}
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
@ -278,22 +282,26 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndex
|
||||
const keyType& key
|
||||
) const
|
||||
{
|
||||
if (key.isPattern())
|
||||
if (!key.empty())
|
||||
{
|
||||
labelList indices = this->findIndices(key);
|
||||
// return first element
|
||||
if (!indices.empty())
|
||||
if (key.isPattern())
|
||||
{
|
||||
return indices[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
labelList indices = this->findIndices(key);
|
||||
|
||||
// return first element
|
||||
if (!indices.empty())
|
||||
{
|
||||
return i;
|
||||
return indices[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -332,6 +340,24 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findZoneID
|
||||
}
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::PackedBoolList Foam::ZoneMesh<ZoneType, MeshType>::findMatching
|
||||
(
|
||||
const keyType& key
|
||||
) const
|
||||
{
|
||||
PackedBoolList lst;
|
||||
|
||||
const labelList indices = this->findIndices(key);
|
||||
forAll(indices, i)
|
||||
{
|
||||
lst |= static_cast<const labelList&>(this->operator[](indices[i]));
|
||||
}
|
||||
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
void Foam::ZoneMesh<ZoneType, MeshType>::clearAddressing()
|
||||
{
|
||||
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::ZoneMesh
|
||||
|
||||
Description
|
||||
List of mesh zones
|
||||
A list of mesh zones.
|
||||
|
||||
SourceFiles
|
||||
ZoneMesh.C
|
||||
@ -37,8 +37,9 @@ SourceFiles
|
||||
|
||||
#include "List.H"
|
||||
#include "regIOobject.H"
|
||||
#include "HashSet.H"
|
||||
#include "pointFieldsFwd.H"
|
||||
#include "Map.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -131,15 +132,18 @@ public:
|
||||
//- Return a list of zone names
|
||||
wordList names() const;
|
||||
|
||||
//- Find zone index given a name
|
||||
label findZoneID(const word& zoneName) const;
|
||||
|
||||
//- Return zone indices for all matches
|
||||
labelList findIndices(const keyType&) const;
|
||||
|
||||
//- Return zone index for the first match, return -1 if not found
|
||||
label findIndex(const keyType&) const;
|
||||
|
||||
//- Find zone index given a name
|
||||
label findZoneID(const word& zoneName) const;
|
||||
|
||||
//- Mark cells that match the zone specification
|
||||
PackedBoolList findMatching(const keyType&) const;
|
||||
|
||||
//- Clear addressing
|
||||
void clearAddressing();
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ const char * const Foam::cellZone::labelsName = "cellLabels";
|
||||
Foam::cellZone::cellZone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const cellZoneMesh& zm
|
||||
)
|
||||
@ -86,7 +86,7 @@ Foam::cellZone::cellZone
|
||||
Foam::cellZone::cellZone
|
||||
(
|
||||
const cellZone& cz,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const cellZoneMesh& zm
|
||||
)
|
||||
@ -154,7 +154,14 @@ void Foam::cellZone::operator=(const cellZone& zn)
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZone::operator=(const labelList& addr)
|
||||
void Foam::cellZone::operator=(const unallocLabelList& addr)
|
||||
{
|
||||
clearAddressing();
|
||||
labelList::operator=(addr);
|
||||
}
|
||||
|
||||
|
||||
void Foam::cellZone::operator=(const Xfer<labelList>& addr)
|
||||
{
|
||||
clearAddressing();
|
||||
labelList::operator=(addr);
|
||||
|
||||
@ -113,7 +113,7 @@ public:
|
||||
cellZone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const cellZoneMesh&
|
||||
);
|
||||
@ -141,7 +141,7 @@ public:
|
||||
cellZone
|
||||
(
|
||||
const cellZone&,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const cellZoneMesh&
|
||||
);
|
||||
@ -169,7 +169,7 @@ public:
|
||||
// and zone mesh
|
||||
virtual autoPtr<cellZone> clone
|
||||
(
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const cellZoneMesh& zm
|
||||
) const
|
||||
@ -222,11 +222,14 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assign to zone clearing demand-driven data
|
||||
//- Assign to zone, clearing demand-driven data
|
||||
void operator=(const cellZone&);
|
||||
|
||||
//- Assign addressing clearing demand-driven data
|
||||
void operator=(const labelList&);
|
||||
//- Assign addressing, clearing demand-driven data
|
||||
void operator=(const unallocLabelList&);
|
||||
|
||||
//- Assign addressing, clearing demand-driven data
|
||||
void operator=(const Xfer<labelList>&);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
@ -180,7 +180,7 @@ void Foam::faceZone::checkAddressing() const
|
||||
Foam::faceZone::faceZone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const boolList& fm,
|
||||
const label index,
|
||||
const faceZoneMesh& zm
|
||||
@ -242,7 +242,7 @@ Foam::faceZone::faceZone
|
||||
Foam::faceZone::faceZone
|
||||
(
|
||||
const faceZone& fz,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const boolList& fm,
|
||||
const label index,
|
||||
const faceZoneMesh& zm
|
||||
@ -392,7 +392,7 @@ void Foam::faceZone::clearAddressing()
|
||||
|
||||
void Foam::faceZone::resetAddressing
|
||||
(
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const boolList& flipMap
|
||||
)
|
||||
{
|
||||
@ -414,7 +414,7 @@ void Foam::faceZone::updateMesh(const mapPolyMesh& mpm)
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
label faceI = operator[](i);
|
||||
const label faceI = operator[](i);
|
||||
|
||||
if (faceMap[faceI] >= 0)
|
||||
{
|
||||
@ -454,7 +454,7 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
|
||||
boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false);
|
||||
forAll(*this, i)
|
||||
{
|
||||
label faceI = operator[](i);
|
||||
const label faceI = operator[](i);
|
||||
|
||||
if (!mesh.isInternalFace(faceI))
|
||||
{
|
||||
@ -469,13 +469,12 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
label faceI = operator[](i);
|
||||
|
||||
label patchI = bm.whichPatch(faceI);
|
||||
const label faceI = operator[](i);
|
||||
const label patchI = bm.whichPatch(faceI);
|
||||
|
||||
if (patchI != -1 && bm[patchI].coupled())
|
||||
{
|
||||
label bFaceI = faceI-mesh.nInternalFaces();
|
||||
const label bFaceI = faceI-mesh.nInternalFaces();
|
||||
|
||||
// Check face in zone on both sides
|
||||
if (myZoneFace[bFaceI] != neiZoneFace[bFaceI])
|
||||
|
||||
@ -154,7 +154,7 @@ public:
|
||||
faceZone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const boolList& fm,
|
||||
const label index,
|
||||
const faceZoneMesh& zm
|
||||
@ -184,7 +184,7 @@ public:
|
||||
faceZone
|
||||
(
|
||||
const faceZone&,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const boolList& fm,
|
||||
const label index,
|
||||
const faceZoneMesh&
|
||||
@ -214,7 +214,7 @@ public:
|
||||
// and zone mesh
|
||||
virtual autoPtr<faceZone> clone
|
||||
(
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const boolList& fm,
|
||||
const label index,
|
||||
const faceZoneMesh& zm
|
||||
@ -279,7 +279,7 @@ public:
|
||||
virtual void clearAddressing();
|
||||
|
||||
//- Reset addressing and flip map (clearing demand-driven data)
|
||||
virtual void resetAddressing(const labelList&, const boolList&);
|
||||
virtual void resetAddressing(const unallocLabelList&, const boolList&);
|
||||
|
||||
//- Check zone definition. Return true if in error.
|
||||
virtual bool checkDefinition(const bool report = false) const;
|
||||
|
||||
@ -47,7 +47,7 @@ const char* const Foam::pointZone::labelsName = "pointLabels";
|
||||
Foam::pointZone::pointZone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const pointZoneMesh& zm
|
||||
)
|
||||
@ -86,7 +86,7 @@ Foam::pointZone::pointZone
|
||||
Foam::pointZone::pointZone
|
||||
(
|
||||
const pointZone& pz,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const pointZoneMesh& zm
|
||||
)
|
||||
@ -198,7 +198,14 @@ void Foam::pointZone::operator=(const pointZone& zn)
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZone::operator=(const labelList& addr)
|
||||
void Foam::pointZone::operator=(const unallocLabelList& addr)
|
||||
{
|
||||
clearAddressing();
|
||||
labelList::operator=(addr);
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointZone::operator=(const Xfer<labelList>& addr)
|
||||
{
|
||||
clearAddressing();
|
||||
labelList::operator=(addr);
|
||||
|
||||
@ -112,7 +112,7 @@ public:
|
||||
pointZone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const pointZoneMesh&
|
||||
);
|
||||
@ -140,7 +140,7 @@ public:
|
||||
pointZone
|
||||
(
|
||||
const pointZone&,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index,
|
||||
const pointZoneMesh&
|
||||
);
|
||||
@ -170,7 +170,7 @@ public:
|
||||
(
|
||||
const pointZoneMesh& zm,
|
||||
const label index,
|
||||
const labelList& addr
|
||||
const unallocLabelList& addr
|
||||
) const
|
||||
{
|
||||
return autoPtr<pointZone>
|
||||
@ -222,11 +222,14 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assign to zone clearing demand-driven data
|
||||
//- Assign to zone, clearing demand-driven data
|
||||
void operator=(const pointZone&);
|
||||
|
||||
//- Assign addressing clearing demand-driven data
|
||||
void operator=(const labelList&);
|
||||
//- Assign addressing, clearing demand-driven data
|
||||
void operator=(const unallocLabelList&);
|
||||
|
||||
//- Assign addressing, clearing demand-driven data
|
||||
void operator=(const Xfer<labelList>&);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
@ -85,7 +85,7 @@ void Foam::zone::calcLookupMap() const
|
||||
Foam::zone::zone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
@ -128,7 +128,7 @@ Foam::zone::zone
|
||||
Foam::zone::zone
|
||||
(
|
||||
const zone& z,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
|
||||
@ -101,7 +101,7 @@ public:
|
||||
zone
|
||||
(
|
||||
const word& name,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index
|
||||
);
|
||||
|
||||
@ -127,7 +127,7 @@ public:
|
||||
zone
|
||||
(
|
||||
const zone&,
|
||||
const labelList& addr,
|
||||
const unallocLabelList& addr,
|
||||
const label index
|
||||
);
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ const char* Foam::Switch::names[Foam::Switch::INVALID+1] =
|
||||
"off", "on",
|
||||
"no", "yes",
|
||||
"n", "y",
|
||||
"f", "t",
|
||||
"none", "true", // is there a reasonable counterpart to "none"?
|
||||
"invalid"
|
||||
};
|
||||
@ -54,18 +55,39 @@ Foam::Switch::switchType Foam::Switch::asEnum
|
||||
{
|
||||
if (str == names[sw])
|
||||
{
|
||||
// convert n/y to no/yes - perhaps should deprecate y/n
|
||||
if (sw == Switch::NO_1 || sw == Switch::NONE)
|
||||
// handle aliases
|
||||
switch (sw)
|
||||
{
|
||||
return Switch::NO;
|
||||
}
|
||||
else if (sw == Switch::YES_1)
|
||||
{
|
||||
return Switch::YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return switchType(sw);
|
||||
case Switch::NO_1:
|
||||
case Switch::NONE:
|
||||
{
|
||||
return Switch::NO;
|
||||
break;
|
||||
}
|
||||
|
||||
case Switch::YES_1:
|
||||
{
|
||||
return Switch::YES;
|
||||
break;
|
||||
}
|
||||
|
||||
case Switch::FALSE_1:
|
||||
{
|
||||
return Switch::FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
case Switch::TRUE_1:
|
||||
{
|
||||
return Switch::TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return switchType(sw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ Class
|
||||
|
||||
Description
|
||||
A simple wrapper around bool so that it can be read as a word:
|
||||
true/false, on/off, yes/no or y/n or none.
|
||||
true/false, on/off, yes/no, y/n, t/f, or none.
|
||||
|
||||
SourceFiles
|
||||
Switch.C
|
||||
@ -78,6 +78,8 @@ public:
|
||||
#undef YES
|
||||
#undef NO_1
|
||||
#undef YES_1
|
||||
#undef FALSE_1
|
||||
#undef TRUE_1
|
||||
#undef NONE
|
||||
#undef PLACEHOLDER
|
||||
#undef INVALID
|
||||
@ -86,11 +88,12 @@ public:
|
||||
// These also correspond to the entries in names.
|
||||
enum switchType
|
||||
{
|
||||
FALSE = 0, TRUE = 1,
|
||||
OFF = 2, ON = 3,
|
||||
NO = 4, YES = 5,
|
||||
NO_1 = 6, YES_1 = 7,
|
||||
NONE = 8, PLACEHOLDER = 9,
|
||||
FALSE = 0, TRUE = 1,
|
||||
OFF = 2, ON = 3,
|
||||
NO = 4, YES = 5,
|
||||
NO_1 = 6, YES_1 = 7,
|
||||
FALSE_1 = 8, TRUE_1 = 9,
|
||||
NONE = 10, PLACEHOLDER = 11,
|
||||
INVALID
|
||||
};
|
||||
|
||||
|
||||
@ -93,6 +93,8 @@ public:
|
||||
|
||||
static const char* const typeName;
|
||||
static int debug;
|
||||
|
||||
//- An empty fileName
|
||||
static const fileName null;
|
||||
|
||||
|
||||
|
||||
@ -22,24 +22,54 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Istream constructor and IOstream operators for word.
|
||||
Istream constructor and IOstream operators for keyType.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "keyType.H"
|
||||
#include "regExp.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::keyType Foam::keyType::null;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::keyType::keyType(Istream& is)
|
||||
:
|
||||
word()
|
||||
word(),
|
||||
isPattern_(false)
|
||||
{
|
||||
is >> *this;
|
||||
is >> *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::keyType::match
|
||||
(
|
||||
const std::string& str,
|
||||
bool literalMatch
|
||||
) const
|
||||
{
|
||||
if (literalMatch || !isPattern_)
|
||||
{
|
||||
// check as string
|
||||
return (str == *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check as regex
|
||||
return regExp(*this).match(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, keyType& kw)
|
||||
{
|
||||
token t(is);
|
||||
|
||||
@ -51,15 +81,16 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
||||
|
||||
if (t.isWord())
|
||||
{
|
||||
w = t.wordToken();
|
||||
kw = t.wordToken();
|
||||
}
|
||||
else if (t.isString())
|
||||
{
|
||||
// Assign from string. Sets regular expression.
|
||||
w = t.stringToken();
|
||||
// Assign from string. Set as regular expression.
|
||||
kw = t.stringToken();
|
||||
kw.isPattern_ = true;
|
||||
|
||||
// flag empty strings as an error
|
||||
if (w.empty())
|
||||
if (kw.empty())
|
||||
{
|
||||
is.setBad();
|
||||
FatalIOErrorIn("operator>>(Istream&, keyType&)", is)
|
||||
@ -86,9 +117,9 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& w)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& kw)
|
||||
{
|
||||
os.write(w);
|
||||
os.write(kw);
|
||||
os.check("Ostream& operator<<(Ostream&, const keyType&)");
|
||||
return os;
|
||||
}
|
||||
@ -32,7 +32,6 @@ Description
|
||||
|
||||
SourceFiles
|
||||
keyType.C
|
||||
keyTypeIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -52,14 +51,14 @@ class Ostream;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class keyType Declaration
|
||||
Class keyType Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class keyType
|
||||
:
|
||||
public word
|
||||
{
|
||||
// Private member data
|
||||
// Private data
|
||||
|
||||
//- Is the keyType a pattern (regular expression)
|
||||
bool isPattern_;
|
||||
@ -71,6 +70,11 @@ class keyType
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- An empty keyType
|
||||
static const keyType null;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -80,19 +84,21 @@ public:
|
||||
//- Construct as copy
|
||||
inline keyType(const keyType&);
|
||||
|
||||
//- Construct as copy of word
|
||||
//- Construct as copy of word. Not treated as a regular expression
|
||||
inline keyType(const word&);
|
||||
|
||||
//- Construct as copy of string. Expect it to be regular expression.
|
||||
//- Construct as copy of string. Treat as regular expression.
|
||||
inline keyType(const string&);
|
||||
|
||||
//- Construct as copy of character array
|
||||
//- Construct as copy of character array.
|
||||
// Not treated as a regular expression
|
||||
inline keyType(const char*);
|
||||
|
||||
//- Construct as copy of std::string
|
||||
//- Construct as copy of std::string with specified treatment
|
||||
inline keyType(const std::string&, const bool isPattern);
|
||||
|
||||
//- Construct from Istream
|
||||
// Treat as regular expression if surrounded by quotation marks.
|
||||
keyType(Istream&);
|
||||
|
||||
|
||||
@ -101,15 +107,24 @@ public:
|
||||
//- Should be treated as a match rather than a literal string
|
||||
inline bool isPattern() const;
|
||||
|
||||
//- Smart match as regular expression or as a string
|
||||
// Optionally force a literal match only
|
||||
bool match(const std::string&, bool literalMatch=false) const;
|
||||
|
||||
// Member operators
|
||||
|
||||
// Assignment
|
||||
|
||||
//- Assignment operator
|
||||
inline const keyType& operator=(const keyType&);
|
||||
|
||||
//- Assign as word, not as non regular expression
|
||||
inline const keyType& operator=(const word&);
|
||||
|
||||
//- Assign from regular expression.
|
||||
//- Assign as regular expression
|
||||
inline const keyType& operator=(const string&);
|
||||
|
||||
//- Assign as word, not as non regular expression
|
||||
inline const keyType& operator=(const char*);
|
||||
|
||||
|
||||
|
||||
@ -23,10 +23,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::keyType::keyType()
|
||||
@ -50,7 +46,6 @@ inline Foam::keyType::keyType(const word& s)
|
||||
{}
|
||||
|
||||
|
||||
// Construct as copy of string. Expect it to be regular expression
|
||||
inline Foam::keyType::keyType(const string& s)
|
||||
:
|
||||
word(s, false),
|
||||
@ -58,7 +53,6 @@ inline Foam::keyType::keyType(const string& s)
|
||||
{}
|
||||
|
||||
|
||||
// Construct as copy of character array
|
||||
inline Foam::keyType::keyType(const char* s)
|
||||
:
|
||||
word(s, false),
|
||||
@ -66,7 +60,6 @@ inline Foam::keyType::keyType(const char* s)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct as copy of std::string
|
||||
inline Foam::keyType::keyType
|
||||
(
|
||||
const std::string& s,
|
||||
|
||||
@ -82,6 +82,8 @@ public:
|
||||
|
||||
static const char* const typeName;
|
||||
static int debug;
|
||||
|
||||
//- An empty string
|
||||
static const string null;
|
||||
|
||||
|
||||
@ -143,6 +145,9 @@ public:
|
||||
template<class String>
|
||||
static inline string quotemeta(const string&, const char quote='\\');
|
||||
|
||||
//- True when strings match literally
|
||||
inline bool match(const std::string&) const;
|
||||
|
||||
//- Avoid masking the normal std::string replace
|
||||
using std::string::replace;
|
||||
|
||||
|
||||
@ -176,6 +176,12 @@ inline String Foam::string::validate(const string& str)
|
||||
return ss;
|
||||
}
|
||||
|
||||
inline bool Foam::string::match(const std::string& str) const
|
||||
{
|
||||
// check as string
|
||||
return (str == *this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -73,6 +73,8 @@ public:
|
||||
|
||||
static const char* const typeName;
|
||||
static int debug;
|
||||
|
||||
//- An empty word
|
||||
static const word null;
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,12 @@ License
|
||||
#include "IOstreams.H"
|
||||
#include "InfoProxy.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::wordRe Foam::wordRe::null;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wordRe::wordRe(Istream& is)
|
||||
:
|
||||
@ -38,6 +43,8 @@ Foam::wordRe::wordRe(Istream& is)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, wordRe& w)
|
||||
{
|
||||
token t(is);
|
||||
@ -44,7 +44,6 @@ Note
|
||||
|
||||
SourceFiles
|
||||
wordRe.C
|
||||
wordReIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -84,6 +83,12 @@ class wordRe
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- An empty wordRe
|
||||
static const wordRe null;
|
||||
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration with compile options
|
||||
@ -168,7 +173,7 @@ public:
|
||||
//- Searching
|
||||
|
||||
//- Smart match as regular expression or as a string
|
||||
// Optionally specify a literal match only
|
||||
// Optionally force a literal match only
|
||||
inline bool match(const std::string&, bool literalMatch=false) const;
|
||||
|
||||
//- Miscellaneous
|
||||
|
||||
@ -143,7 +143,7 @@ void Foam::PorousZones<ZoneType>::addResistance
|
||||
) const
|
||||
{
|
||||
// addResistance for each zone, delaying the correction of the
|
||||
// precessor BCs of AU
|
||||
// processor BCs of AU
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->operator[](i).addResistance(UEqn, AU, false);
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "geometricOneField.H"
|
||||
#include "stringListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ void Foam::porousZone::addPowerLawResistance
|
||||
forAll(cells, i)
|
||||
{
|
||||
Udiag[cells[i]] +=
|
||||
V[cells[i]]*rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2);
|
||||
V[cells[i]]*rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,16 +66,16 @@ directMappedVelocityFluxFixedValueFvPatchField
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedVelocityFluxFixedValueFvPatchField::"
|
||||
"directMappedVelocityFluxFixedValueFvPatchField\n"
|
||||
"(\n"
|
||||
" const directMappedVelocityFluxFixedValueFvPatchField&,\n"
|
||||
" const fvPatch&,\n"
|
||||
" const DimensionedField<vector, volMesh>&,\n"
|
||||
" const fvPatchFieldMapper&\n"
|
||||
")\n"
|
||||
) << "\n patch type '" << p.type()
|
||||
"directMappedVelocityFluxFixedValueFvPatchField"
|
||||
"("
|
||||
"const directMappedVelocityFluxFixedValueFvPatchField&, "
|
||||
"const fvPatch&, "
|
||||
"const DimensionedField<vector, volMesh>&, "
|
||||
"const fvPatchFieldMapper&"
|
||||
")"
|
||||
) << "Patch type '" << p.type()
|
||||
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
||||
<< "\n for patch " << p.name()
|
||||
<< " for patch " << p.name()
|
||||
<< " of field " << dimensionedInternalField().name()
|
||||
<< " in file " << dimensionedInternalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
@ -102,10 +102,10 @@ directMappedVelocityFluxFixedValueFvPatchField
|
||||
"directMappedVelocityFluxFixedValueFvPatchField"
|
||||
"("
|
||||
"const fvPatch&, "
|
||||
"const DimensionedField<vector, volMesh>& iF, "
|
||||
"const DimensionedField<vector, volMesh>&, "
|
||||
"const dictionary&"
|
||||
")"
|
||||
) << "patch type '" << p.type()
|
||||
) << "Patch type '" << p.type()
|
||||
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
||||
<< " for patch " << p.name()
|
||||
<< " of field " << dimensionedInternalField().name()
|
||||
@ -191,8 +191,8 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
|
||||
forAll(Upf, faceI)
|
||||
{
|
||||
allUValues[faceStart++] = Upf[faceI];
|
||||
allPhiValues[faceStart] = phipf[faceI];
|
||||
allUValues[faceStart + faceI] = Upf[faceI];
|
||||
allPhiValues[faceStart + faceI] = phipf[faceI];
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
distMap.constructMap(),
|
||||
allUValues
|
||||
);
|
||||
newUValues = patch().patchSlice(newUValues);
|
||||
newUValues = patch().patchSlice(allUValues);
|
||||
|
||||
mapDistribute::distribute
|
||||
(
|
||||
@ -214,9 +214,9 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
distMap.constructMap(),
|
||||
newPhiValues
|
||||
allPhiValues
|
||||
);
|
||||
newPhiValues = patch().patchSlice(newPhiValues);
|
||||
newPhiValues = patch().patchSlice(allPhiValues);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -257,9 +257,10 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()"
|
||||
)<< "patch can only be used in NEARESTPATCHFACE or NEARESTFACE "
|
||||
<< "mode" << nl << abort(FatalError);
|
||||
"directMappedVelocityFluxFixedValueFvPatchField::"
|
||||
"updateCoeffs()"
|
||||
) << "patch can only be used in NEARESTPATCHFACE or NEARESTFACE "
|
||||
<< "mode" << nl << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ SourceFiles
|
||||
#include "cloud.H"
|
||||
#include "IDLList.H"
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
#include "polyMesh.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "treeDataCell.H"
|
||||
@ -350,7 +350,7 @@ public:
|
||||
void checkFieldFieldIOobject
|
||||
(
|
||||
const Cloud<ParticleType>& c,
|
||||
const IOFieldField<Field<DataType>, DataType>& data
|
||||
const CompactIOField<Field<DataType>, DataType>& data
|
||||
) const;
|
||||
|
||||
//- Read the field data for the cloud of particles. Dummy at
|
||||
|
||||
@ -225,7 +225,7 @@ template<class DataType>
|
||||
void Foam::Cloud<ParticleType>::checkFieldFieldIOobject
|
||||
(
|
||||
const Cloud<ParticleType>& c,
|
||||
const IOFieldField<Field<DataType>, DataType>& data
|
||||
const CompactIOField<Field<DataType>, DataType>& data
|
||||
) const
|
||||
{
|
||||
if (data.size() != c.size())
|
||||
@ -235,7 +235,7 @@ void Foam::Cloud<ParticleType>::checkFieldFieldIOobject
|
||||
"void Cloud<ParticleType>::checkFieldFieldIOobject"
|
||||
"("
|
||||
"const Cloud<ParticleType>&, "
|
||||
"const IOFieldField<Field<DataType>, DataType>&"
|
||||
"const CompactIOField<Field<DataType>, DataType>&"
|
||||
") const"
|
||||
) << "Size of " << data.name()
|
||||
<< " field " << data.size()
|
||||
|
||||
@ -62,8 +62,8 @@ namespace Foam
|
||||
{
|
||||
|
||||
typedef CollisionRecordList<vector, vector> collisionRecordList;
|
||||
typedef vectorIOFieldField pairDataIOFieldField;
|
||||
typedef vectorIOFieldField wallDataIOFieldField;
|
||||
typedef vectorFieldCompactIOField pairDataFieldCompactIOField;
|
||||
typedef vectorFieldCompactIOField wallDataFieldCompactIOField;
|
||||
|
||||
template<class ParcelType>
|
||||
class KinematicParcel;
|
||||
|
||||
@ -181,13 +181,13 @@ void Foam::KinematicParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
|
||||
IOField<vector> UTurb(c.fieldIOobject("UTurb", IOobject::MUST_READ));
|
||||
c.checkFieldIOobject(c, UTurb);
|
||||
|
||||
labelIOFieldField collisionRecordsPairAccessed
|
||||
labelFieldCompactIOField collisionRecordsPairAccessed
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsPairAccessed", IOobject::MUST_READ)
|
||||
);
|
||||
c.checkFieldFieldIOobject(c, collisionRecordsPairAccessed);
|
||||
|
||||
labelIOFieldField collisionRecordsPairOrigProcOfOther
|
||||
labelFieldCompactIOField collisionRecordsPairOrigProcOfOther
|
||||
(
|
||||
c.fieldIOobject
|
||||
(
|
||||
@ -197,7 +197,7 @@ void Foam::KinematicParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
|
||||
);
|
||||
c.checkFieldFieldIOobject(c, collisionRecordsPairOrigProcOfOther);
|
||||
|
||||
labelIOFieldField collisionRecordsPairOrigIdOfOther
|
||||
labelFieldCompactIOField collisionRecordsPairOrigIdOfOther
|
||||
(
|
||||
c.fieldIOobject
|
||||
(
|
||||
@ -207,25 +207,25 @@ void Foam::KinematicParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
|
||||
);
|
||||
c.checkFieldFieldIOobject(c, collisionRecordsPairOrigProcOfOther);
|
||||
|
||||
pairDataIOFieldField collisionRecordsPairData
|
||||
pairDataFieldCompactIOField collisionRecordsPairData
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsPairData", IOobject::MUST_READ)
|
||||
);
|
||||
c.checkFieldFieldIOobject(c, collisionRecordsPairData);
|
||||
|
||||
labelIOFieldField collisionRecordsWallAccessed
|
||||
labelFieldCompactIOField collisionRecordsWallAccessed
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsWallAccessed", IOobject::MUST_READ)
|
||||
);
|
||||
c.checkFieldFieldIOobject(c, collisionRecordsWallAccessed);
|
||||
|
||||
vectorIOFieldField collisionRecordsWallPRel
|
||||
vectorFieldCompactIOField collisionRecordsWallPRel
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsWallPRel", IOobject::MUST_READ)
|
||||
);
|
||||
c.checkFieldFieldIOobject(c, collisionRecordsWallPRel);
|
||||
|
||||
wallDataIOFieldField collisionRecordsWallData
|
||||
wallDataFieldCompactIOField collisionRecordsWallData
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsWallData", IOobject::MUST_READ)
|
||||
);
|
||||
@ -292,12 +292,12 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
|
||||
IOField<scalar> tTurb(c.fieldIOobject("tTurb", IOobject::NO_READ), np);
|
||||
IOField<vector> UTurb(c.fieldIOobject("UTurb", IOobject::NO_READ), np);
|
||||
|
||||
labelIOFieldField collisionRecordsPairAccessed
|
||||
labelFieldCompactIOField collisionRecordsPairAccessed
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsPairAccessed", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
labelIOFieldField collisionRecordsPairOrigProcOfOther
|
||||
labelFieldCompactIOField collisionRecordsPairOrigProcOfOther
|
||||
(
|
||||
c.fieldIOobject
|
||||
(
|
||||
@ -306,27 +306,27 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
|
||||
),
|
||||
np
|
||||
);
|
||||
labelIOFieldField collisionRecordsPairOrigIdOfOther
|
||||
labelFieldCompactIOField collisionRecordsPairOrigIdOfOther
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsPairOrigIdOfOther", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
pairDataIOFieldField collisionRecordsPairData
|
||||
pairDataFieldCompactIOField collisionRecordsPairData
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsPairData", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
labelIOFieldField collisionRecordsWallAccessed
|
||||
labelFieldCompactIOField collisionRecordsWallAccessed
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsWallAccessed", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
vectorIOFieldField collisionRecordsWallPRel
|
||||
vectorFieldCompactIOField collisionRecordsWallPRel
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsWallPRel", IOobject::NO_READ),
|
||||
np
|
||||
);
|
||||
wallDataIOFieldField collisionRecordsWallData
|
||||
wallDataFieldCompactIOField collisionRecordsWallData
|
||||
(
|
||||
c.fieldIOobject("collisionRecordsWallData", IOobject::NO_READ),
|
||||
np
|
||||
|
||||
@ -3116,11 +3116,12 @@ void Foam::autoLayerDriver::addLayers
|
||||
);
|
||||
|
||||
// Update numbering of baffles
|
||||
List<labelPair> newMeshBaffles(baffles.size());
|
||||
forAll(baffles, i)
|
||||
{
|
||||
labelPair& p = baffles[i];
|
||||
p[0] = map().reverseFaceMap()[p[0]];
|
||||
p[1] = map().reverseFaceMap()[p[1]];
|
||||
const labelPair& p = baffles[i];
|
||||
newMeshBaffles[i][0] = map().reverseFaceMap()[p[0]];
|
||||
newMeshBaffles[i][1] = map().reverseFaceMap()[p[1]];
|
||||
}
|
||||
|
||||
// Collect layer faces and cells for outside loop.
|
||||
@ -3167,7 +3168,7 @@ void Foam::autoLayerDriver::addLayers
|
||||
(
|
||||
addLayer,
|
||||
meshQualityDict,
|
||||
baffles,
|
||||
newMeshBaffles,
|
||||
pp(),
|
||||
newMesh,
|
||||
|
||||
@ -3235,6 +3236,16 @@ void Foam::autoLayerDriver::addLayers
|
||||
|
||||
meshRefiner_.updateMesh(map, labelList(0));
|
||||
|
||||
|
||||
// Update numbering on baffles
|
||||
forAll(baffles, i)
|
||||
{
|
||||
labelPair& p = baffles[i];
|
||||
p[0] = map().reverseFaceMap()[p[0]];
|
||||
p[1] = map().reverseFaceMap()[p[1]];
|
||||
}
|
||||
|
||||
|
||||
label nBaffles = returnReduce(baffles.size(), sumOp<label>());
|
||||
if (nBaffles > 0)
|
||||
{
|
||||
|
||||
@ -2056,6 +2056,180 @@ void Foam::indexedOctree<Type>::findBox
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
template <class CompareOp>
|
||||
void Foam::indexedOctree<Type>::findNear
|
||||
(
|
||||
const scalar nearDist,
|
||||
const bool okOrder,
|
||||
const indexedOctree<Type>& tree1,
|
||||
const labelBits index1,
|
||||
const treeBoundBox& bb1,
|
||||
const indexedOctree<Type>& tree2,
|
||||
const labelBits index2,
|
||||
const treeBoundBox& bb2,
|
||||
CompareOp& cop
|
||||
)
|
||||
{
|
||||
const vector nearSpan(nearDist, nearDist, nearDist);
|
||||
|
||||
if (tree1.isNode(index1))
|
||||
{
|
||||
const node& nod1 = tree1.nodes()[tree1.getNode(index1)];
|
||||
const treeBoundBox searchBox
|
||||
(
|
||||
bb1.min()-nearSpan,
|
||||
bb1.max()+nearSpan
|
||||
);
|
||||
|
||||
if (tree2.isNode(index2))
|
||||
{
|
||||
if (bb2.overlaps(searchBox))
|
||||
{
|
||||
const node& nod2 = tree2.nodes()[tree2.getNode(index2)];
|
||||
|
||||
for (direction i2 = 0; i2 < nod2.subNodes_.size(); i2++)
|
||||
{
|
||||
labelBits subIndex2 = nod2.subNodes_[i2];
|
||||
const treeBoundBox subBb2
|
||||
(
|
||||
tree2.isNode(subIndex2)
|
||||
? tree2.nodes()[tree2.getNode(subIndex2)].bb_
|
||||
: bb2.subBbox(i2)
|
||||
);
|
||||
|
||||
findNear
|
||||
(
|
||||
nearDist,
|
||||
!okOrder,
|
||||
tree2,
|
||||
subIndex2,
|
||||
subBb2,
|
||||
tree1,
|
||||
index1,
|
||||
bb1,
|
||||
cop
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tree2.isContent(index2))
|
||||
{
|
||||
// index2 is leaf, index1 not yet.
|
||||
for (direction i1 = 0; i1 < nod1.subNodes_.size(); i1++)
|
||||
{
|
||||
labelBits subIndex1 = nod1.subNodes_[i1];
|
||||
const treeBoundBox subBb1
|
||||
(
|
||||
tree1.isNode(subIndex1)
|
||||
? tree1.nodes()[tree1.getNode(subIndex1)].bb_
|
||||
: bb1.subBbox(i1)
|
||||
);
|
||||
|
||||
findNear
|
||||
(
|
||||
nearDist,
|
||||
!okOrder,
|
||||
tree2,
|
||||
index2,
|
||||
bb2,
|
||||
tree1,
|
||||
subIndex1,
|
||||
subBb1,
|
||||
cop
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tree1.isContent(index1))
|
||||
{
|
||||
const treeBoundBox searchBox
|
||||
(
|
||||
bb1.min()-nearSpan,
|
||||
bb1.max()+nearSpan
|
||||
);
|
||||
|
||||
if (tree2.isNode(index2))
|
||||
{
|
||||
const node& nod2 =
|
||||
tree2.nodes()[tree2.getNode(index2)];
|
||||
|
||||
if (bb2.overlaps(searchBox))
|
||||
{
|
||||
for (direction i2 = 0; i2 < nod2.subNodes_.size(); i2++)
|
||||
{
|
||||
labelBits subIndex2 = nod2.subNodes_[i2];
|
||||
const treeBoundBox subBb2
|
||||
(
|
||||
tree2.isNode(subIndex2)
|
||||
? tree2.nodes()[tree2.getNode(subIndex2)].bb_
|
||||
: bb2.subBbox(i2)
|
||||
);
|
||||
|
||||
findNear
|
||||
(
|
||||
nearDist,
|
||||
!okOrder,
|
||||
tree2,
|
||||
subIndex2,
|
||||
subBb2,
|
||||
tree1,
|
||||
index1,
|
||||
bb1,
|
||||
cop
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tree2.isContent(index2))
|
||||
{
|
||||
// Both are leaves. Check n^2.
|
||||
|
||||
const labelList& indices1 =
|
||||
tree1.contents()[tree1.getContent(index1)];
|
||||
const labelList& indices2 =
|
||||
tree2.contents()[tree2.getContent(index2)];
|
||||
|
||||
forAll(indices1, i)
|
||||
{
|
||||
label shape1 = indices1[i];
|
||||
|
||||
forAll(indices2, j)
|
||||
{
|
||||
label shape2 = indices2[j];
|
||||
|
||||
if ((&tree1 != &tree2) || (shape1 != shape2))
|
||||
{
|
||||
if (okOrder)
|
||||
{
|
||||
cop
|
||||
(
|
||||
nearDist,
|
||||
tree1.shapes(),
|
||||
shape1,
|
||||
tree2.shapes(),
|
||||
shape2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
cop
|
||||
(
|
||||
nearDist,
|
||||
tree2.shapes(),
|
||||
shape2,
|
||||
tree1.shapes(),
|
||||
shape1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Number of elements in node.
|
||||
template <class Type>
|
||||
Foam::label Foam::indexedOctree<Type>::countElements
|
||||
|
||||
@ -164,8 +164,8 @@ private:
|
||||
|
||||
// Construction
|
||||
|
||||
//- Split list of indices into 8 bins according to where they are in
|
||||
// relation to mid.
|
||||
//- Split list of indices into 8 bins
|
||||
// according to where they are in relation to mid.
|
||||
void divide
|
||||
(
|
||||
const labelList& indices,
|
||||
@ -173,8 +173,8 @@ private:
|
||||
labelListList& result
|
||||
) const;
|
||||
|
||||
//- Subdivide the contents node at position contentI. Appends to
|
||||
// contents.
|
||||
//- Subdivide the contents node at position contentI.
|
||||
// Appends to contents.
|
||||
node divide
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
@ -336,6 +336,22 @@ private:
|
||||
labelHashSet& elements
|
||||
) const;
|
||||
|
||||
|
||||
template <class CompareOp>
|
||||
static void findNear
|
||||
(
|
||||
const scalar nearDist,
|
||||
const bool okOrder,
|
||||
const indexedOctree<Type>& tree1,
|
||||
const labelBits index1,
|
||||
const treeBoundBox& bb1,
|
||||
const indexedOctree<Type>& tree2,
|
||||
const labelBits index2,
|
||||
const treeBoundBox& bb2,
|
||||
CompareOp& cop
|
||||
);
|
||||
|
||||
|
||||
// Other
|
||||
|
||||
//- Count number of elements on this and sublevels
|
||||
@ -581,6 +597,16 @@ public:
|
||||
const point& sample
|
||||
);
|
||||
|
||||
//- Find near pairs and apply CompareOp to them.
|
||||
// tree2 can be *this or different tree.
|
||||
template <class CompareOp>
|
||||
void findNear
|
||||
(
|
||||
const scalar nearDist,
|
||||
const indexedOctree<Type>& tree2,
|
||||
CompareOp& cop
|
||||
) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
|
||||
@ -64,19 +64,7 @@ Foam::treeBoundBox Foam::treeDataCell::calcCellBb(const label cellI) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& cellLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
cellLabels_(cellLabels),
|
||||
cacheBb_(cacheBb)
|
||||
void Foam::treeDataCell::update()
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
@ -90,6 +78,38 @@ Foam::treeDataCell::treeDataCell
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const unallocLabelList& cellLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
cellLabels_(cellLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const Xfer<labelList>& cellLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
cellLabels_(cellLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
@ -100,15 +120,7 @@ Foam::treeDataCell::treeDataCell
|
||||
cellLabels_(identity(mesh_.nCells())),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
bbs_.setSize(cellLabels_.size());
|
||||
|
||||
forAll(cellLabels_, i)
|
||||
{
|
||||
bbs_[i] = calcCellBb(cellLabels_[i]);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +171,7 @@ bool Foam::treeDataCell::contains
|
||||
// nearestPoint.
|
||||
void Foam::treeDataCell::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
|
||||
@ -48,7 +48,7 @@ class primitiveMesh;
|
||||
template<class Type> class indexedOctree;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeDataCell Declaration
|
||||
Class treeDataCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class treeDataCell
|
||||
@ -72,6 +72,9 @@ class treeDataCell
|
||||
//- Calculate cell bounding box
|
||||
treeBoundBox calcCellBb(const label cellI) const;
|
||||
|
||||
//- Initialise all member data
|
||||
void update();
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
@ -85,7 +88,15 @@ public:
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const labelList&
|
||||
const unallocLabelList&
|
||||
);
|
||||
|
||||
//- Construct from mesh and subset of cells, transferring contents
|
||||
treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const Xfer<labelList>&
|
||||
);
|
||||
|
||||
//- Construct from mesh. Uses all cells in mesh.
|
||||
@ -96,18 +107,18 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
const labelList& cellLabels() const
|
||||
inline const labelList& cellLabels() const
|
||||
{
|
||||
return cellLabels_;
|
||||
}
|
||||
|
||||
const primitiveMesh& mesh() const
|
||||
inline const primitiveMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return cellLabels_.size();
|
||||
}
|
||||
@ -153,7 +164,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -165,7 +176,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -177,7 +188,7 @@ public:
|
||||
notImplemented
|
||||
(
|
||||
"treeDataCell::findNearest"
|
||||
"(const labelList&, const linePointRef&, ..)"
|
||||
"(const unallocLabelList&, const linePointRef&, ..)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -43,21 +43,7 @@ Foam::treeBoundBox Foam::treeDataEdge::calcBb(const label edgeI) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataEdge::treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const labelList& edgeLabels
|
||||
)
|
||||
:
|
||||
edges_(edges),
|
||||
points_(points),
|
||||
edgeLabels_(edgeLabels),
|
||||
cacheBb_(cacheBb)
|
||||
void Foam::treeDataEdge::update()
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
@ -71,6 +57,42 @@ Foam::treeDataEdge::treeDataEdge
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::treeDataEdge::treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const unallocLabelList& edgeLabels
|
||||
)
|
||||
:
|
||||
edges_(edges),
|
||||
points_(points),
|
||||
edgeLabels_(edgeLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataEdge::treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const Xfer<labelList>& edgeLabels
|
||||
)
|
||||
:
|
||||
edges_(edges),
|
||||
points_(points),
|
||||
edgeLabels_(edgeLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointField Foam::treeDataEdge::points() const
|
||||
@ -121,7 +143,7 @@ bool Foam::treeDataEdge::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataEdge::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -131,7 +153,7 @@ void Foam::treeDataEdge::findNearest
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const edge& e = edges_[edgeLabels_[index]];
|
||||
|
||||
@ -153,7 +175,7 @@ void Foam::treeDataEdge::findNearest
|
||||
// Returns point and distance (squared)
|
||||
void Foam::treeDataEdge::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -167,7 +189,7 @@ void Foam::treeDataEdge::findNearest
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const edge& e = edges_[edgeLabels_[index]];
|
||||
|
||||
|
||||
@ -81,6 +81,9 @@ class treeDataEdge
|
||||
//- Calculate edge bounding box
|
||||
treeBoundBox calcBb(const label edgeI) const;
|
||||
|
||||
//- Initialise all member data
|
||||
void update();
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
@ -95,7 +98,17 @@ public:
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const labelList& edgeLabels
|
||||
const unallocLabelList& edgeLabels
|
||||
);
|
||||
|
||||
//- Construct from selected edges, transferring contents.
|
||||
// !Holds references to edges and points
|
||||
treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const Xfer<labelList>& edgeLabels
|
||||
);
|
||||
|
||||
|
||||
@ -139,7 +152,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -151,7 +164,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
|
||||
@ -76,12 +76,27 @@ void Foam::treeDataFace::update()
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataFace::treeDataFace
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& faceLabels
|
||||
const unallocLabelList& faceLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
faceLabels_(faceLabels),
|
||||
isTreeFace_(mesh.nFaces(), 0),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataFace::treeDataFace
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const Xfer<labelList>& faceLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
@ -467,7 +482,7 @@ bool Foam::treeDataFace::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataFace::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -477,7 +492,7 @@ void Foam::treeDataFace::findNearest
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const face& f = mesh_.faces()[faceLabels_[index]];
|
||||
|
||||
@ -514,7 +529,7 @@ bool Foam::treeDataFace::intersects
|
||||
}
|
||||
}
|
||||
|
||||
label faceI = faceLabels_[index];
|
||||
const label faceI = faceLabels_[index];
|
||||
|
||||
const vector dir(end - start);
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ class primitiveMesh;
|
||||
class polyPatch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeDataFace Declaration
|
||||
Class treeDataFace Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class treeDataFace
|
||||
@ -101,7 +101,15 @@ public:
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const labelList&
|
||||
const unallocLabelList&
|
||||
);
|
||||
|
||||
//- Construct from mesh and subset of faces, transferring contents
|
||||
treeDataFace
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const Xfer<labelList>&
|
||||
);
|
||||
|
||||
//- Construct from mesh. Uses all faces in mesh.
|
||||
@ -115,17 +123,17 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
const labelList& faceLabels() const
|
||||
inline const labelList& faceLabels() const
|
||||
{
|
||||
return faceLabels_;
|
||||
}
|
||||
|
||||
const primitiveMesh& mesh() const
|
||||
inline const primitiveMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return faceLabels_.size();
|
||||
}
|
||||
@ -156,7 +164,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -168,7 +176,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -180,7 +188,7 @@ public:
|
||||
notImplemented
|
||||
(
|
||||
"treeDataFace::findNearest"
|
||||
"(const labelList&, const linePointRef&, ..)"
|
||||
"(const unallocLabelList&, const linePointRef&, ..)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ defineTypeNameAndDebug(Foam::treeDataPoint, 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataPoint::treeDataPoint(const pointField& points)
|
||||
:
|
||||
points_(points)
|
||||
@ -78,7 +77,7 @@ bool Foam::treeDataPoint::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataPoint::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -88,7 +87,7 @@ void Foam::treeDataPoint::findNearest
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const point& pt = points_[index];
|
||||
|
||||
@ -108,7 +107,7 @@ void Foam::treeDataPoint::findNearest
|
||||
// Returns point and distance (squared)
|
||||
void Foam::treeDataPoint::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -122,7 +121,7 @@ void Foam::treeDataPoint::findNearest
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const point& shapePt = points_[index];
|
||||
|
||||
|
||||
@ -69,14 +69,14 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components. Holds reference to points!
|
||||
treeDataPoint(const pointField& points);
|
||||
treeDataPoint(const pointField&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return points_.size();
|
||||
}
|
||||
@ -107,7 +107,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -119,7 +119,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
|
||||
@ -477,7 +477,7 @@ void
|
||||
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -489,7 +489,7 @@ findNearest
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const face& f = patch_[index];
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ TemplateName(treeDataPrimitivePatch);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeDataPrimitivePatch Declaration
|
||||
Class treeDataPrimitivePatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template
|
||||
@ -151,7 +151,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -163,7 +163,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -175,7 +175,7 @@ public:
|
||||
notImplemented
|
||||
(
|
||||
"treeDataPrimitivePatch::findNearest"
|
||||
"(const labelList&, const linePointRef&, ..)"
|
||||
"(const unallocLabelList&, const linePointRef&, ..)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ bool Foam::treeDataTriSurface::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataTriSurface::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -398,7 +398,7 @@ void Foam::treeDataTriSurface::findNearest
|
||||
// nearestPoint.
|
||||
void Foam::treeDataTriSurface::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -409,7 +409,7 @@ void Foam::treeDataTriSurface::findNearest
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"treeDataTriSurface::findNearest(const labelList&"
|
||||
"treeDataTriSurface::findNearest(const unallocLabelList&"
|
||||
", const linePointRef&, treeBoundBox&, label&, point&, point&) const"
|
||||
);
|
||||
}
|
||||
|
||||
@ -91,12 +91,12 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
const triSurface& surface() const
|
||||
inline const triSurface& surface() const
|
||||
{
|
||||
return surface_;
|
||||
}
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return surface_.size();
|
||||
}
|
||||
@ -127,7 +127,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -139,7 +139,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
|
||||
@ -38,7 +38,7 @@ SourceFiles
|
||||
#include "cloud.H"
|
||||
#include "polyMesh.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -69,7 +69,7 @@ tmp<IOField<Type> > reconstructLagrangianField
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<IOFieldField<Field<Type>, Type> > reconstructLagrangianFieldField
|
||||
tmp<CompactIOField<Field<Type>, Type> > reconstructLagrangianFieldField
|
||||
(
|
||||
const word& cloudName,
|
||||
const polyMesh& mesh,
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOField.H"
|
||||
#include "IOFieldField.H"
|
||||
#include "CompactIOField.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
@ -89,7 +89,7 @@ Foam::tmp<Foam::IOField<Type> > Foam::reconstructLagrangianField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::IOFieldField<Foam::Field<Type>, Type> >
|
||||
Foam::tmp<Foam::CompactIOField<Foam::Field<Type>, Type> >
|
||||
Foam::reconstructLagrangianFieldField
|
||||
(
|
||||
const word& cloudName,
|
||||
@ -99,9 +99,9 @@ Foam::reconstructLagrangianFieldField
|
||||
)
|
||||
{
|
||||
// Construct empty field on mesh
|
||||
tmp<IOFieldField<Field<Type>, Type > > tfield
|
||||
tmp<CompactIOField<Field<Type>, Type > > tfield
|
||||
(
|
||||
new IOFieldField<Field<Type>, Type>
|
||||
new CompactIOField<Field<Type>, Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -132,7 +132,7 @@ Foam::reconstructLagrangianFieldField
|
||||
|
||||
if (localIOobject.headerOk())
|
||||
{
|
||||
IOFieldField<Field<Type>, Type> fieldi(localIOobject);
|
||||
CompactIOField<Field<Type>, Type> fieldi(localIOobject);
|
||||
|
||||
label offset = field.size();
|
||||
field.setSize(offset + fieldi.size());
|
||||
@ -194,7 +194,7 @@ void Foam::reconstructLagrangianFieldFields
|
||||
)
|
||||
{
|
||||
{
|
||||
const word fieldClassName(IOFieldField<Field<Type>, Type>::typeName);
|
||||
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
|
||||
|
||||
@ -320,20 +320,17 @@ Foam::distanceSurface::distanceSurface
|
||||
signed_(readBool(dict.lookup("signed"))),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
average_(dict.lookupOrDefault("average", false)),
|
||||
zoneName_(word::null),
|
||||
zoneKey_(keyType::null),
|
||||
needsUpdate_(true),
|
||||
isoSurfPtr_(NULL),
|
||||
facesPtr_(NULL)
|
||||
{
|
||||
// dict.readIfPresent("zone", zoneName_);
|
||||
// dict.readIfPresent("zone", zoneKey_);
|
||||
//
|
||||
// if (debug && zoneName_.size())
|
||||
// if (debug && zoneKey_.size() && mesh.cellZones().findZoneID(zoneKey_) < 0)
|
||||
// {
|
||||
// if (mesh.cellZones().findZoneID(zoneName_) < 0)
|
||||
// {
|
||||
// Info<< "cellZone \"" << zoneName_
|
||||
// << "\" not found - using entire mesh" << endl;
|
||||
// }
|
||||
// Info<< "cellZone " << zoneKey_
|
||||
// << " not found - using entire mesh" << endl;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -70,8 +70,8 @@ class distanceSurface
|
||||
//- Whether to recalculate cell values as average of point values
|
||||
const Switch average_;
|
||||
|
||||
//- zone name (if restricted to zones)
|
||||
word zoneName_;
|
||||
//- If restricted to zones, name of this zone or a regular expression
|
||||
keyType zoneKey_;
|
||||
|
||||
//- Track if the surface needs an update
|
||||
mutable bool needsUpdate_;
|
||||
|
||||
@ -205,20 +205,17 @@ Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
|
||||
isoVal_(readScalar(dict.lookup("isoValue"))),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
average_(dict.lookupOrDefault("average", true)),
|
||||
zoneName_(word::null),
|
||||
zoneKey_(keyType::null),
|
||||
facesPtr_(NULL),
|
||||
prevTimeIndex_(-1),
|
||||
meshCells_(0)
|
||||
{
|
||||
// dict.readIfPresent("zone", zoneName_);
|
||||
// dict.readIfPresent("zone", zoneKey_);
|
||||
//
|
||||
// if (debug && zoneName_.size())
|
||||
// if (debug && zoneKey_.size() && mesh.cellZones().findZoneID(zoneKey_) < 0)
|
||||
// {
|
||||
// if (mesh.cellZones().findZoneID(zoneName_) < 0)
|
||||
// {
|
||||
// Info<< "cellZone \"" << zoneName_
|
||||
// << "\" not found - using entire mesh" << endl;
|
||||
// }
|
||||
// Info<< "cellZone " << zoneKey_
|
||||
// << " not found - using entire mesh" << endl;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -68,8 +68,8 @@ class sampledIsoSurfaceCell
|
||||
//- Whether to recalculate cell values as average of point values
|
||||
const Switch average_;
|
||||
|
||||
//- zone name (if restricted to zones)
|
||||
word zoneName_;
|
||||
//- If restricted to zones, name of this zone or a regular expression
|
||||
keyType zoneKey_;
|
||||
|
||||
//- triangles converted to faceList
|
||||
mutable autoPtr<faceList> facesPtr_;
|
||||
|
||||
@ -45,21 +45,18 @@ Foam::sampledPlane::sampledPlane
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const plane& planeDesc,
|
||||
const word& zoneName
|
||||
const keyType& zoneKey
|
||||
)
|
||||
:
|
||||
sampledSurface(name, mesh),
|
||||
cuttingPlane(planeDesc),
|
||||
zoneName_(zoneName),
|
||||
zoneKey_(zoneKey),
|
||||
needsUpdate_(true)
|
||||
{
|
||||
if (debug && zoneName_.size())
|
||||
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
|
||||
{
|
||||
if (mesh.cellZones().findZoneID(zoneName_) < 0)
|
||||
{
|
||||
Info<< "cellZone \"" << zoneName_
|
||||
<< "\" not found - using entire mesh" << endl;
|
||||
}
|
||||
Info<< "cellZone " << zoneKey_
|
||||
<< " not found - using entire mesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +70,7 @@ Foam::sampledPlane::sampledPlane
|
||||
:
|
||||
sampledSurface(name, mesh, dict),
|
||||
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
|
||||
zoneName_(word::null),
|
||||
zoneKey_(keyType::null),
|
||||
needsUpdate_(true)
|
||||
{
|
||||
// make plane relative to the coordinateSystem (Cartesian)
|
||||
@ -89,17 +86,13 @@ Foam::sampledPlane::sampledPlane
|
||||
static_cast<plane&>(*this) = plane(base, norm);
|
||||
}
|
||||
|
||||
dict.readIfPresent("zone", zoneName_);
|
||||
dict.readIfPresent("zone", zoneKey_);
|
||||
|
||||
if (debug && zoneName_.size())
|
||||
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
|
||||
{
|
||||
if (mesh.cellZones().findZoneID(zoneName_) < 0)
|
||||
{
|
||||
Info<< "cellZone \"" << zoneName_
|
||||
<< "\" not found - using entire mesh" << endl;
|
||||
}
|
||||
Info<< "cellZone " << zoneKey_
|
||||
<< " not found - using entire mesh" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -141,19 +134,15 @@ bool Foam::sampledPlane::update()
|
||||
|
||||
sampledSurface::clearGeom();
|
||||
|
||||
label zoneId = -1;
|
||||
if (zoneName_.size())
|
||||
{
|
||||
zoneId = mesh().cellZones().findZoneID(zoneName_);
|
||||
}
|
||||
labelList selectedCells = mesh().cellZones().findMatching(zoneKey_).used();
|
||||
|
||||
if (zoneId < 0)
|
||||
if (selectedCells.empty())
|
||||
{
|
||||
reCut(mesh(), true); // always triangulate. Note:Make option?
|
||||
}
|
||||
else
|
||||
{
|
||||
reCut(mesh(), true, mesh().cellZones()[zoneId]);
|
||||
reCut(mesh(), true, selectedCells);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledPlane Declaration
|
||||
Class sampledPlane Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledPlane
|
||||
@ -57,8 +57,8 @@ class sampledPlane
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- zone name (if restricted to zones)
|
||||
word zoneName_;
|
||||
//- If restricted to zones, name of this zone or a regular expression
|
||||
keyType zoneKey_;
|
||||
|
||||
//- Track if the surface needs an update
|
||||
mutable bool needsUpdate_;
|
||||
@ -92,7 +92,7 @@ public:
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const plane& planeDesc,
|
||||
const word& zoneName = word::null
|
||||
const keyType& zoneKey = word::null
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
|
||||
@ -154,7 +154,7 @@ Foam::sampledThresholdCellFaces::sampledThresholdCellFaces
|
||||
fieldName_(dict.lookup("field")),
|
||||
lowerThreshold_(dict.lookupOrDefault<scalar>("lowerLimit", -VGREAT)),
|
||||
upperThreshold_(dict.lookupOrDefault<scalar>("upperLimit", VGREAT)),
|
||||
zoneName_(word::null),
|
||||
zoneKey_(keyType::null),
|
||||
triangulate_(dict.lookupOrDefault("triangulate", false)),
|
||||
prevTimeIndex_(-1),
|
||||
meshCells_(0)
|
||||
@ -169,16 +169,12 @@ Foam::sampledThresholdCellFaces::sampledThresholdCellFaces
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// dict.readIfPresent("zone", zoneName_);
|
||||
// dict.readIfPresent("zone", zoneKey_);
|
||||
//
|
||||
// if (debug && zoneName_.size())
|
||||
// if (debug && zoneKey_.size() && mesh.cellZones().findZoneID(zoneKey_) < 0)
|
||||
// {
|
||||
// if (mesh.cellZones().findZoneID(zoneName_) < 0)
|
||||
// {
|
||||
// Info<< "cellZone \"" << zoneName_
|
||||
// << "\" not found - using entire mesh" << endl;
|
||||
// }
|
||||
// Info<< "cellZone " << zoneKey_
|
||||
// << " not found - using entire mesh" << endl;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -67,8 +67,8 @@ class sampledThresholdCellFaces
|
||||
//- Threshold value
|
||||
const scalar upperThreshold_;
|
||||
|
||||
//- zone name (if restricted to zones)
|
||||
word zoneName_;
|
||||
//- If restricted to zones, name of this zone or a regular expression
|
||||
keyType zoneKey_;
|
||||
|
||||
//- Triangulated faces or keep faces as is
|
||||
bool triangulate_;
|
||||
|
||||
@ -38,6 +38,9 @@ $(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
|
||||
kqRWallFunctions = $(wallFunctions)/kqRWallFunctions
|
||||
$(kqRWallFunctions)/kqRWallFunction/kqRWallFunctionFvPatchFields.C
|
||||
|
||||
kappatWallFunctions = $(wallFunctions)/kappatWallFunctions
|
||||
$(kappatWallFunctions)/kappatJayatillekeWallFunction/kappatJayatillekeWallFunctionFvPatchScalarField.C
|
||||
|
||||
|
||||
/* Patch fields */
|
||||
derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
|
||||
|
||||
@ -0,0 +1,278 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "kappatJayatillekeWallFunctionFvPatchScalarField.H"
|
||||
#include "RASModel.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace incompressible
|
||||
{
|
||||
namespace RASModels
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
scalar kappatJayatillekeWallFunctionFvPatchScalarField::tolerance_ = 0.01;
|
||||
label kappatJayatillekeWallFunctionFvPatchScalarField::maxIters_ = 10;
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void kappatJayatillekeWallFunctionFvPatchScalarField::checkType()
|
||||
{
|
||||
if (!isA<wallFvPatch>(patch()))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"kappatJayatillekeWallFunctionFvPatchScalarField::checkType()"
|
||||
) << "Invalid wall function specification" << nl
|
||||
<< " Patch type for patch " << patch().name()
|
||||
<< " must be wall" << nl
|
||||
<< " Current patch type is " << patch().type() << nl << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scalar kappatJayatillekeWallFunctionFvPatchScalarField::Psmooth
|
||||
(
|
||||
const scalar Prat
|
||||
) const
|
||||
{
|
||||
return 9.24*(pow(Prat, 0.75) - 1.0)*(1.0 + 0.28*exp(-0.007*Prat));
|
||||
}
|
||||
|
||||
|
||||
scalar kappatJayatillekeWallFunctionFvPatchScalarField::yPlusTherm
|
||||
(
|
||||
const scalar P,
|
||||
const scalar Prat
|
||||
) const
|
||||
{
|
||||
scalar ypt = 11.0;
|
||||
|
||||
for (int i=0; i<maxIters_; i++)
|
||||
{
|
||||
scalar f = ypt - (log(E_*ypt)/kappa_ + P)/Prat;
|
||||
scalar df = 1.0 - 1.0/(ypt*kappa_*Prat);
|
||||
scalar yptNew = ypt - f/df;
|
||||
|
||||
if (yptNew < VSMALL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (mag(yptNew - ypt) < tolerance_)
|
||||
{
|
||||
return yptNew;
|
||||
}
|
||||
else
|
||||
{
|
||||
ypt = yptNew;
|
||||
}
|
||||
}
|
||||
|
||||
return ypt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField::
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
Prt_(0.85),
|
||||
Cmu_(0.09),
|
||||
kappa_(0.41),
|
||||
E_(9.8)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField::
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kappatJayatillekeWallFunctionFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
Prt_(ptf.Prt_),
|
||||
Cmu_(ptf.Cmu_),
|
||||
kappa_(ptf.kappa_),
|
||||
E_(ptf.E_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField::
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF, dict),
|
||||
Prt_(readScalar(dict.lookup("Prt"))), // force read to avoid ambiguity
|
||||
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
|
||||
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
|
||||
E_(dict.lookupOrDefault<scalar>("E", 9.8))
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField::
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kappatJayatillekeWallFunctionFvPatchScalarField& wfpsf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(wfpsf),
|
||||
Prt_(wfpsf.Prt_),
|
||||
Cmu_(wfpsf.Cmu_),
|
||||
kappa_(wfpsf.kappa_),
|
||||
E_(wfpsf.E_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField::
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kappatJayatillekeWallFunctionFvPatchScalarField& wfpsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(wfpsf, iF),
|
||||
Prt_(wfpsf.Prt_),
|
||||
Cmu_(wfpsf.Cmu_),
|
||||
kappa_(wfpsf.kappa_),
|
||||
E_(wfpsf.E_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void kappatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const label patchI = patch().index();
|
||||
|
||||
// Retrieve turbulence properties from model
|
||||
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
|
||||
const scalar Cmu25 = pow(Cmu_, 0.25);
|
||||
const scalarField& y = rasModel.y()[patchI];
|
||||
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
|
||||
const tmp<volScalarField> tk = rasModel.k();
|
||||
const volScalarField& k = tk();
|
||||
|
||||
// Molecular Prandtl number
|
||||
const scalar
|
||||
Pr(dimensionedScalar(rasModel.transport().lookup("Pr")).value());
|
||||
|
||||
// Populate boundary values
|
||||
scalarField& kappatw = *this;
|
||||
forAll(kappatw, faceI)
|
||||
{
|
||||
label faceCellI = patch().faceCells()[faceI];
|
||||
|
||||
// y+
|
||||
scalar yPlus = Cmu25*sqrt(k[faceCellI])*y[faceI]/nuw[faceI];
|
||||
|
||||
// Molecular-to-turbulent Prandtl number ratio
|
||||
scalar Prat = Pr/Prt_;
|
||||
|
||||
// Thermal sublayer thickness
|
||||
scalar P = Psmooth(Prat);
|
||||
scalar yPlusTherm = this->yPlusTherm(P, Prat);
|
||||
|
||||
// Evaluate new effective thermal diffusivity
|
||||
scalar kappaEff = 0.0;
|
||||
if (yPlus < yPlusTherm)
|
||||
{
|
||||
kappaEff = Pr*yPlus;
|
||||
}
|
||||
else
|
||||
{
|
||||
kappaEff = nuw[faceI]*yPlus/(Prt_/kappa_*log(E_*yPlusTherm) + P);
|
||||
}
|
||||
|
||||
// Update turbulent thermal diffusivity
|
||||
kappatw[faceI] = max(0.0, kappaEff - nuw[faceI]/Pr);
|
||||
}
|
||||
|
||||
fixedValueFvPatchField<scalar>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void kappatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<scalar>::write(os);
|
||||
os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace RASModels
|
||||
} // End namespace incompressible
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,194 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::incompressible::RASModels::
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
|
||||
Description
|
||||
Boundary condition for (kinematic) turbulent thermal conductivity when
|
||||
using wall functions, using Jayatilleke P function.
|
||||
|
||||
Units of m2/s
|
||||
|
||||
SourceFiles
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef kappatJayatillekeWallFunctionFvPatchScalarField_H
|
||||
#define kappatJayatillekeWallFunctionFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace incompressible
|
||||
{
|
||||
namespace RASModels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class kappatJayatillekeWallFunctionFvPatchScalarField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Turbulent Prandtl number
|
||||
scalar Prt_;
|
||||
|
||||
//- Cmu coefficient
|
||||
scalar Cmu_;
|
||||
|
||||
//- Von Karman constant
|
||||
scalar kappa_;
|
||||
|
||||
//- E coefficient
|
||||
scalar E_;
|
||||
|
||||
|
||||
// Solution parameters
|
||||
|
||||
static scalar tolerance_;
|
||||
static label maxIters_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
//- Check the type of the patch
|
||||
virtual void checkType();
|
||||
|
||||
//- `P' function
|
||||
scalar Psmooth(const scalar Prat) const;
|
||||
|
||||
//- Calculate y+ at the edge of the thermal laminar sublayer
|
||||
scalar yPlusTherm
|
||||
(
|
||||
const scalar P,
|
||||
const scalar Prat
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("kappatJayatillekeWallFunction");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
// onto a new patch
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kappatJayatillekeWallFunctionFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kappatJayatillekeWallFunctionFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new kappatJayatillekeWallFunctionFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
kappatJayatillekeWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kappatJayatillekeWallFunctionFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new kappatJayatillekeWallFunctionFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace RASModels
|
||||
} // End namespace incompressible
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user