Merge branch 'feature-core-changes' into 'develop'

bugfixes and style changes

See merge request Development/openfoam!522
This commit is contained in:
Andrew Heather
2022-02-01 10:18:20 +00:00
69 changed files with 1060 additions and 888 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -274,9 +274,9 @@ int main(int argc, char *argv[])
{
DLPtrList<Scalar> llist1;
llist1.insert(new Scalar(100));
llist1.insert(new Scalar(200));
llist1.insert(new Scalar(300));
llist1.prepend(new Scalar(100));
llist1.prepend(new Scalar(200));
llist1.prepend(new Scalar(300));
auto citer = llist1.begin();
@ -305,9 +305,9 @@ int main(int argc, char *argv[])
// Same but as SLPtrList
{
SLPtrList<Scalar> llist1;
llist1.insert(new Scalar(100));
llist1.insert(new Scalar(200));
llist1.insert(new Scalar(300));
llist1.prepend(new Scalar(100));
llist1.prepend(new Scalar(200));
llist1.prepend(new Scalar(300));
for (const auto& it : llist1)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -198,15 +198,15 @@ int main(int argc, char *argv[])
// Do the brute-force method as well : collect all cell centres on all
// processors
pointField allCcs(globalNumbering.size());
globalNumbering.gather
(
Pstream::worldComm,
Pstream::procID(Pstream::worldComm),
mesh.cellCentres(),
allCcs
);
Info<< "Gathered/scattered cell centres:" << endl;
labelPair inOut;
pointField allCcs(globalNumbering.gather(mesh.cellCentres()));
inOut[0] = allCcs.size();
Pstream::scatter(allCcs);
inOut[1] = allCcs.size();
Pout<< " " << inOut << endl;
// Compare
forAll(ccs, i)
@ -239,10 +239,13 @@ int main(int argc, char *argv[])
Info<< "local-sizes: " << globalPointsPtr().sizes() << nl;
UIndirectList<point> procPoints(mesh.points(), uniqueMeshPointLabels);
pointField patchPoints;
globalPointsPtr().gather(procPoints, patchPoints);
pointField patchPoints
(
globalPointsPtr().gather
(
UIndirectList<point>(mesh.points(), uniqueMeshPointLabels)
)
);
Info<< "gathered point field = " << patchPoints.size() << " points\n";
}

View File

@ -731,11 +731,7 @@ int main(int argc, char *argv[])
PatchTools::gatherAndMerge
(
tolDim,
primitivePatch
(
SubList<face>(isoFaces, isoFaces.size()),
isoPoints
),
primitivePatch(SubList<face>(isoFaces), isoPoints),
mergedPoints,
mergedFaces,
pointMergeMap

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef regExp_H
#define regExp_H
#ifndef Foam_regExp_H
#define Foam_regExp_H
#include "regExpCxx.H"
#include "regExpFwd.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef regExpFwd_H
#define regExpFwd_H
#ifndef Foam_regExpFwd_H
#define Foam_regExpFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef regExp_H
#define regExp_H
#ifndef Foam_regExp_H
#define Foam_regExp_H
#include "regExpCxx.H"
#include "regExpPosix.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef regExpFwd_H
#define regExpFwd_H
#ifndef Foam_regExpFwd_H
#define Foam_regExpFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -64,8 +64,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef regExpPosix_H
#define regExpPosix_H
#ifndef Foam_regExpPosix_H
#define Foam_regExpPosix_H
#include "regExpCxx.H"
#include <regex.h>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -185,20 +185,20 @@ Foam::wordList Foam::DictionaryBase<IDLListType, T>::sortedToc
template<class IDLListType, class T>
void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr)
void Foam::DictionaryBase<IDLListType, T>::prepend(const word& keyword, T* ptr)
{
// NOTE: we should probably check that HashTable::insert actually worked
hashedTs_.insert(keyword, tPtr);
IDLListType::insert(tPtr);
hashedTs_.insert(keyword, ptr);
IDLListType::prepend(ptr);
}
template<class IDLListType, class T>
void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr)
void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* ptr)
{
// NOTE: we should probably check that HashTable::insert actually worked
hashedTs_.insert(keyword, tPtr);
IDLListType::append(tPtr);
hashedTs_.insert(keyword, ptr);
IDLListType::append(ptr);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,8 +48,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef DictionaryBase_H
#define DictionaryBase_H
#ifndef Foam_DictionaryBase_H
#define Foam_DictionaryBase_H
#include "HashTable.H"
#include "wordList.H"
@ -141,11 +141,11 @@ public:
// Editing
//- Add at head of dictionary
void insert(const word& keyword, T*);
//- Add to front of dictionary
void prepend(const word& keyword, T* ptr);
//- Add at tail of dictionary
void append(const word& keyword, T*);
//- Add to back of dictionary
void append(const word& keyword, T* ptr);
//- Remove and return entry specified by keyword.
// Return nullptr if the keyword was not found.
@ -189,7 +189,6 @@ public:
// Housekeeping
//- Deprecated(2020-03) use cfind()
//
// \deprecated(2020-03) - use cfind() method
FOAM_DEPRECATED_FOR(2020-03, "cfind() method")
const T* lookupPtr(const word& keyword) const
@ -198,13 +197,18 @@ public:
}
//- Deprecated(2020-03) use find()
//
// \deprecated(2020-03) - use find() method
FOAM_DEPRECATED_FOR(2020-03, "find() method")
T* lookupPtr(const word& keyword)
{
return this->find(keyword);
}
//- Add to front of dictionary
void insert(const word& keyword, T* ptr)
{
this->prepend(keyword, ptr);
}
};

View File

@ -1,61 +1 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "PtrDictionary.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::PtrDictionary<T>::PtrDictionary(const label size)
:
DictionaryBase<DLPtrList<T>, T>(size)
{}
template<class T>
Foam::PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict)
:
DictionaryBase<DLPtrList<T>, T>(dict)
{}
template<class T>
template<class INew>
Foam::PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew)
:
DictionaryBase<DLPtrList<T>, T>(is, iNew)
{}
template<class T>
Foam::PtrDictionary<T>::PtrDictionary(Istream& is)
:
DictionaryBase<DLPtrList<T>, T>(is)
{}
// ************************************************************************* //
#warning File removed - left for old dependency check only

View File

@ -32,13 +32,10 @@ Description
It is derived from DictionaryBase instantiated on a memory managed form of
intrusive doubly-linked list of \<T\>.
SourceFiles
PtrDictionary.C
\*---------------------------------------------------------------------------*/
#ifndef PtrDictionary_H
#define PtrDictionary_H
#ifndef Foam_PtrDictionary_H
#define Foam_PtrDictionary_H
#include "DictionaryBase.H"
#include "DLPtrList.H"
@ -57,26 +54,37 @@ class PtrDictionary
:
public DictionaryBase<DLPtrList<T>, T>
{
public:
// Constructors
//- Construct given initial table size
PtrDictionary(const label size = 128);
explicit PtrDictionary(const label size = 128)
:
DictionaryBase<DLPtrList<T>, T>(size)
{}
//- Copy construct
PtrDictionary(const PtrDictionary& dict);
PtrDictionary(const PtrDictionary& dict)
:
DictionaryBase<DLPtrList<T>, T>(dict)
{}
//- Construct from Istream using given Istream constructor class
template<class INew>
PtrDictionary(Istream& is, const INew& inew);
PtrDictionary(Istream& is, const INew& inew)
:
DictionaryBase<DLPtrList<T>, T>(is, inew)
{}
//- Construct from Istream
PtrDictionary(Istream& is);
explicit PtrDictionary(Istream& is)
:
DictionaryBase<DLPtrList<T>, T>(is)
{}
// Member operators
// Member Operators
//- Find and return entry
const T& operator[](const word& key) const
@ -96,14 +104,6 @@ public:
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "PtrDictionary.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef PtrListDictionary_H
#define PtrListDictionary_H
#ifndef Foam_PtrListDictionary_H
#define Foam_PtrListDictionary_H
#include "DictionaryBase.H"
#include "PtrList.H"
@ -57,13 +57,12 @@ class PtrListDictionary
:
public DictionaryBase<PtrList<T>, T>
{
public:
// Constructors
//- Construct given initial list size
PtrListDictionary(const label size);
explicit PtrListDictionary(const label size);
//- Copy construct
PtrListDictionary(const PtrListDictionary& dict);
@ -73,19 +72,19 @@ public:
PtrListDictionary(Istream& is, const INew& inew);
//- Construct from Istream
PtrListDictionary(Istream& is);
explicit PtrListDictionary(Istream& is);
// Member functions
//- Set element to pointer provided and return old element
autoPtr<T> set(const label, const word& key, T*);
autoPtr<T> set(const label i, const word& key, T* ptr);
//- Set element to autoPtr value provided and return old element
autoPtr<T> set(const label, const word& key, autoPtr<T>&);
autoPtr<T> set(const label i, const word& key, autoPtr<T>& aptr);
//- Set element to tmp value provided and return old element
autoPtr<T> set(const label, const word& key, tmp<T>&);
autoPtr<T> set(const label i, const word& key, tmp<T>& t);
// Member operators

View File

@ -1,48 +1 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "UPtrDictionary.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::UPtrDictionary<T>::UPtrDictionary(const label size)
:
DictionaryBase<DLList<T*>, T>(size)
{}
template<class T>
Foam::UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict)
:
DictionaryBase<DLList<T*>, T>(dict)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //
#warning File removed - left for old dependency check only

View File

@ -33,13 +33,10 @@ Description
It is derived from DictionaryBase instantiated on a non-memory managed
form of intrusive doubly-linked list of \<T\>.
SourceFiles
UPtrDictionary.C
\*---------------------------------------------------------------------------*/
#ifndef UPtrDictionary_H
#define UPtrDictionary_H
#ifndef Foam_UPtrDictionary_H
#define Foam_UPtrDictionary_H
#include "DictionaryBase.H"
#include "DLList.H"
@ -58,16 +55,21 @@ class UPtrDictionary
:
public DictionaryBase<DLList<T*>, T>
{
public:
// Constructors
//- Construct given initial table size
UPtrDictionary(const label size = 128);
explicit UPtrDictionary(const label size = 128)
:
DictionaryBase<DLList<T*>, T>(size)
{}
//- Copy construct
UPtrDictionary(const UPtrDictionary&);
UPtrDictionary(const UPtrDictionary& dict)
:
DictionaryBase<DLList<T*>, T>(dict)
{}
};
@ -77,12 +79,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "UPtrDictionary.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,7 +61,7 @@ Foam::ILList<LListBase, T>::ILList
:
UILList<LListBase, T>()
{
for (const auto& item :lst)
for (const auto& item : lst)
{
this->append(item.clone(cloneArg).ptr());
}
@ -83,37 +83,26 @@ template<class LListBase, class T>
bool Foam::ILList<LListBase, T>::eraseHead()
{
T* p = this->removeHead();
if (p)
{
delete p;
return true;
}
return false;
delete p;
return bool(p);
}
template<class LListBase, class T>
bool Foam::ILList<LListBase, T>::erase(T* item)
{
T* p = remove(item);
if (p)
{
delete p;
return true;
}
return false;
delete p;
return bool(p);
}
template<class LListBase, class T>
void Foam::ILList<LListBase, T>::clear()
{
const label len = this->size();
label len = this->size();
for (label i=0; i<len; ++i)
while (len--)
{
eraseHead();
}

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef ILList_H
#define ILList_H
#ifndef Foam_ILList_H
#define Foam_ILList_H
#include "UILList.H"
@ -82,14 +82,14 @@ public:
//- Default construct
ILList() = default;
//- Construct and insert the initial T item pointer
//- Construct and add initial item pointer
explicit ILList(T* item)
:
UILList<LListBase, T>(item)
{}
//- Construct from Istream
ILList(Istream& is);
explicit ILList(Istream& is);
//- Copy construct using the 'clone()' method for each element
ILList(const ILList<LListBase, T>& lst);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,10 +77,11 @@ Foam::LList<LListBase, T>::~LList()
template<class LListBase, class T>
void Foam::LList<LListBase, T>::clear()
{
const label len = this->size();
for (label i=0; i<len; ++i)
label len = this->size();
while (len--)
{
this->removeHead();
this->eraseHead();
}
LListBase::clear();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,11 +36,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef LList_H
#define LList_H
#ifndef Foam_LList_H
#define Foam_LList_H
#include "label.H"
#include <initializer_list>
#include "stdFoam.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -100,11 +100,11 @@ public:
//- The type that can represent the container size
typedef label size_type;
//- The difference between iterator objects
//- The difference between iterators
typedef label difference_type;
// Forward declaration of STL iterators
// Forward Declarations (iterators)
class iterator;
class const_iterator;
@ -119,43 +119,52 @@ public:
public LListBase::link
{
//- Stored object
T obj_;
T val_;
//- Copy construct from given object
link(const T& obj)
link(const T& elem)
:
obj_(obj)
val_(elem)
{}
//- Move construct from given object
link(T&& obj)
link(T&& elem)
:
obj_(std::move(obj))
val_(std::move(elem))
{}
//- Delete linked item and return the element value
static T remove(typename LListBase::link* node)
{
link* p = static_cast<link*>(node);
T val(std::move(p->val_));
delete p;
return val;
}
//- Dereference LListBase::link to obtain address of stored object
static constexpr T* ptr(typename LListBase::link* node)
{
return &(static_cast<link*>(node)->obj_);
return &(static_cast<link*>(node)->val_);
}
//- Dereference LListBase::link to obtain address of stored object
static constexpr const T* ptr(const typename LListBase::link* node)
{
return &(static_cast<const link*>(node)->obj_);
return &(static_cast<const link*>(node)->val_);
}
//- Dereference LListBase::link to obtain the stored object
static constexpr T& ref(typename LListBase::link* node)
{
return static_cast<link*>(node)->obj_;
return static_cast<link*>(node)->val_;
}
//- Dereference LListBase::link to obtain the stored object
static constexpr const T& ref(const typename LListBase::link* node)
{
return static_cast<const link*>(node)->obj_;
return static_cast<const link*>(node)->val_;
}
};
@ -165,16 +174,16 @@ public:
//- Default construct
LList() = default;
//- Construct and copy insert the initial T item
explicit LList(const T& item)
//- Construct and copy add initial item
explicit LList(const T& elem)
{
this->insert(item);
this->prepend(elem);
}
//- Construct and move insert the initial T item
explicit LList(T&& item)
//- Construct and move add initial item
explicit LList(T&& elem)
{
this->insert(std::move(item));
this->prepend(std::move(elem));
}
//- Construct from Istream
@ -221,57 +230,54 @@ public:
}
//- Add copy at head of list
void insert(const T& item)
//- Add copy at front of list
void prepend(const T& elem)
{
LListBase::insert(new link(item));
LListBase::prepend(new link(elem));
}
//- Move construct at head of list
void insert(T&& item)
//- Move construct at front of list
void prepend(T&& elem)
{
LListBase::insert(new link(std::move(item)));
LListBase::prepend(new link(std::move(elem)));
}
//- Add copy at tail of list
void append(const T& item)
//- Add copy at back of list
void append(const T& elem)
{
LListBase::append(new link(item));
LListBase::append(new link(elem));
}
//- Move construct at tail of list
void append(T&& item)
//- Move construct at back of list
void append(T&& elem)
{
LListBase::append(new link(std::move(item)));
LListBase::append(new link(std::move(elem)));
}
//- Erase the first entry
bool eraseHead()
{
link* p = static_cast<link*>(LListBase::removeHead());
delete p;
return bool(p);
}
//- Remove and return head
//- Remove and return first entry
T removeHead()
{
auto p = LListBase::removeHead();
T obj(std::move(link::ref(p)));
delete p;
return obj;
return link::remove(LListBase::removeHead());
}
//- Remove and return element
T remove(link* item)
{
auto p = LListBase::remove(item);
T obj(std::move(link::ref(p)));
delete p;
return obj;
return link::remove(LListBase::remove(item));
}
//- Remove and return element specified by iterator
T remove(iterator& iter)
{
auto p = LListBase::remove(iter);
T obj(std::move(link::ref(p)));
delete p;
return obj;
return link::remove(LListBase::remove(iter));
}
@ -279,7 +285,7 @@ public:
void clear();
//- Transfer the contents of the argument into this List
// and annul the argument list.
//- and annul the argument list.
void transfer(LList<LListBase, T>& lst);
@ -567,6 +573,14 @@ public:
return crend();
}
// Housekeeping
//- Add copy at front of list. Same as prepend()
void insert(const T& elem) { this->prepend(elem); }
//- Move construct at front of list. Same as prepend()
void insert(T&& elem) { this->prepend(std::move(elem)); }
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,19 +68,21 @@ Foam::Istream& Foam::LList<LListBase, T>::readList(Istream& is)
{
for (label i=0; i<len; ++i)
{
T element;
is >> element;
list.append(element);
T elem;
is >> elem;
list.append(std::move(elem));
}
}
else
{
T element;
is >> element;
// Uniform content (delimiter == token::BEGIN_BLOCK)
T elem;
is >> elem;
for (label i=0; i<len; ++i)
{
list.append(element);
list.append(elem);
}
}
}
@ -97,9 +99,9 @@ Foam::Istream& Foam::LList<LListBase, T>::readList(Istream& is)
{
is.putBack(tok);
T element;
is >> element;
list.append(element);
T elem;
is >> elem;
list.append(std::move(elem));
is >> tok;
is.fatalCheck(FUNCTION_NAME);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,22 +66,17 @@ template<class LListBase, class T>
bool Foam::LPtrList<LListBase, T>::eraseHead()
{
T* p = this->removeHead();
if (p)
{
delete p;
return true;
}
return false;
delete p;
return bool(p);
}
template<class LListBase, class T>
void Foam::LPtrList<LListBase, T>::clear()
{
const label len = this->size();
for (label i=0; i<len; ++i)
label len = this->size();
while (len--)
{
eraseHead();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef LPtrList_H
#define LPtrList_H
#ifndef Foam_LPtrList_H
#define Foam_LPtrList_H
#include "LList.H"
@ -46,7 +46,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
template<class LListBase, class T> class LPtrList;
@ -74,8 +74,6 @@ class LPtrList
:
public LList<LListBase, T*>
{
private:
// Private Member Functions
//- Read from Istream using given Istream constructor class
@ -114,13 +112,13 @@ public:
// Constructors
//- Null construct
//- Default construct
LPtrList() = default;
//- Construct and insert the initial T item
//- Construct and add initial item pointer
explicit LPtrList(T* item)
{
this->insert(item);
this->prepend(item);
}
//- Copy construct by using 'clone()' for each element
@ -134,7 +132,7 @@ public:
LPtrList(Istream& is, const INew& inew);
//- Construct from Istream using default Istream constructor class
LPtrList(Istream& is);
explicit LPtrList(Istream& is);
//- Destructor

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef UILList_H
#define UILList_H
#ifndef Foam_UILList_H
#define Foam_UILList_H
#include "label.H"
#include "uLabel.H"
@ -95,7 +95,7 @@ public:
typedef label difference_type;
// Forward declaration of STL iterators
// Forward Declarations (iterators)
class iterator;
class const_iterator;
@ -109,10 +109,10 @@ public:
//- Default construct
UILList() = default;
//- Construct and insert the initial T item
//- Construct and add initial item pointer
explicit UILList(T* item)
{
this->insert(item);
this->prepend(item);
}
//- Construct as copy
@ -446,7 +446,6 @@ public:
{
return crend();
}
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::DLListBase::insert(DLListBase::link* item)
void Foam::DLListBase::prepend(DLListBase::link* item)
{
if (!item)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,8 +43,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef DLListBase_H
#define DLListBase_H
#ifndef Foam_DLListBase_H
#define Foam_DLListBase_H
#include "label.H"
#include "uLabel.H"
@ -76,10 +76,10 @@ public:
link() = default;
//- Check if the node is registered with the list
inline bool registered() const;
inline bool registered() const noexcept;
//- Deregister the node after removal
inline void deregister();
inline void deregister() noexcept;
};
@ -88,10 +88,10 @@ private:
// Private Data
//- Pointer to first element
link *first_ = nullptr;
link* first_ = nullptr;
//- Pointer to last element
link *last_ = nullptr;
link* last_ = nullptr;
//- Number of elements in the list
label size_ = 0;
@ -169,10 +169,10 @@ public:
inline const link* last() const;
//- Add at head of list
void insert(link* item);
//- Add at front of list
void prepend(link* item);
//- Add at tail of list
//- Add at back of list
void append(link* item);
//- Swap this element with the one above unless it is at the top
@ -181,13 +181,13 @@ public:
//- Swap this element with the one below unless it is at the bottom
bool swapDown(link* item);
//- Remove and return head
//- Remove and return first entry
link* removeHead();
//- Remove and return element
link* remove(link* item);
// Remove and return element specified by iterator
//- Remove and return element specified by iterator
inline link* remove(iterator& iter);
//- Replace oldLink with newLink and return element
@ -236,18 +236,10 @@ public:
inline iterator(DLListBase* list, link* item);
//- The storage node
inline link* get_node() const;
inline link* get_node() const noexcept;
//- Pointing at a valid storage node
inline bool good() const;
//- Deprecated(2019-01) Pointing at a valid storage node
// \deprecated(2019-01) - use good() method
FOAM_DEPRECATED_FOR(2019-01, "good() method")
bool found() const
{
return this->good();
}
inline bool good() const noexcept;
//- Move backward through list
inline void prev();
@ -290,18 +282,10 @@ public:
inline const_iterator(const DLListBase::iterator& iter);
//- The storage node
inline const link* get_node() const;
inline const link* get_node() const noexcept;
//- Pointing at a valid storage node
inline bool good() const;
//- Deprecated(2019-01) Pointing at a valid storage node
// \deprecated(2019-01) - use good() method
FOAM_DEPRECATED_FOR(2019-01, "good() method")
bool found() const
{
return this->good();
}
inline bool good() const noexcept;
//- Move backward through list
inline void prev();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -99,13 +99,13 @@ Foam::DLListBase::crend() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::DLListBase::link::registered() const
inline bool Foam::DLListBase::link::registered() const noexcept
{
return prev_ != nullptr && next_ != nullptr;
}
inline void Foam::DLListBase::link::deregister()
inline void Foam::DLListBase::link::deregister() noexcept
{
prev_ = next_ = nullptr;
}
@ -252,13 +252,13 @@ inline Foam::DLListBase::iterator::iterator
inline Foam::DLListBase::link*
Foam::DLListBase::iterator::get_node() const
Foam::DLListBase::iterator::get_node() const noexcept
{
return node_;
}
inline bool Foam::DLListBase::iterator::good() const
inline bool Foam::DLListBase::iterator::good() const noexcept
{
return (node_ != nullptr);
}
@ -358,13 +358,13 @@ inline Foam::DLListBase::const_iterator::const_iterator
inline const Foam::DLListBase::link*
Foam::DLListBase::const_iterator::get_node() const
Foam::DLListBase::const_iterator::get_node() const noexcept
{
return node_;
}
inline bool Foam::DLListBase::const_iterator::good() const
inline bool Foam::DLListBase::const_iterator::good() const noexcept
{
return (node_ != nullptr);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::SLListBase::insert(SLListBase::link* item)
void Foam::SLListBase::prepend(SLListBase::link* item)
{
if (!item)
{

View File

@ -43,8 +43,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef SLListBase_H
#define SLListBase_H
#ifndef Foam_SLListBase_H
#define Foam_SLListBase_H
#include "label.H"
#include "uLabel.H"
@ -157,13 +157,13 @@ public:
inline const link* last() const;
//- Add at head of list
void insert(link* item);
//- Add at front of list
void prepend(link* item);
//- Add at tail of list
//- Add at back of list
void append(link* item);
//- Remove and return head
//- Remove and return first entry
link* removeHead();
// Remove and return element
@ -212,18 +212,10 @@ public:
inline iterator(SLListBase* list, link* item);
//- The storage node
inline link* get_node() const;
inline link* get_node() const noexcept;
//- Pointing at a valid storage node
inline bool good() const;
//- Deprecated(2019-01) Pointing at a valid storage node
// \deprecated(2019-01) - use good() method
FOAM_DEPRECATED_FOR(2019-01, "good() method")
bool found() const
{
return this->good();
}
inline bool good() const noexcept;
//- Cannot move backward through list
inline void prev() = delete;
@ -265,18 +257,10 @@ public:
inline const_iterator(const SLListBase::iterator& iter);
//- The storage node
inline const link* get_node() const;
inline const link* get_node() const noexcept;
//- Pointing at a valid storage node
inline bool good() const;
//- Deprecated(2019-01) Pointing at a valid storage node
// \deprecated(2019-01) - use good() method
FOAM_DEPRECATED_FOR(2019-01, "good() method")
bool found() const
{
return this->good();
}
inline bool good() const noexcept;
//- Cannot move backward through list
inline void prev() = delete;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -196,13 +196,13 @@ inline Foam::SLListBase::iterator::iterator
inline Foam::SLListBase::link*
Foam::SLListBase::iterator::get_node() const
Foam::SLListBase::iterator::get_node() const noexcept
{
return node_;
}
inline bool Foam::SLListBase::iterator::good() const
inline bool Foam::SLListBase::iterator::good() const noexcept
{
return (node_ != nullptr);
}
@ -295,13 +295,13 @@ inline Foam::SLListBase::const_iterator::const_iterator
inline const Foam::SLListBase::link*
Foam::SLListBase::const_iterator::get_node() const
Foam::SLListBase::const_iterator::get_node() const noexcept
{
return node_;
}
inline bool Foam::SLListBase::const_iterator::good() const
inline bool Foam::SLListBase::const_iterator::good() const noexcept
{
return (node_ != nullptr);
}

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef DLList_H
#define DLList_H
#ifndef Foam_DLList_H
#define Foam_DLList_H
#include "LList.H"
#include "DLListBase.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef DLPtrList_H
#define DLPtrList_H
#ifndef Foam_DLPtrList_H
#define Foam_DLPtrList_H
#include "LPtrList.H"
#include "DLListBase.H"

View File

@ -34,8 +34,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef FIFOStack_H
#define FIFOStack_H
#ifndef Foam_FIFOStack_H
#define Foam_FIFOStack_H
#include "SLList.H"
@ -63,28 +63,28 @@ public:
// Member Functions
//- Return a copy of the top element
T top() const
//- Const reference to the top element
const T& top() const
{
return this->last();
}
//- Return a copy of the bottom element
T bottom() const
//- Const reference to the bottom element
const T& bottom() const
{
return this->first();
}
//- Push an element onto the back of the stack
void push(const T& element)
void push(const T& elem)
{
this->append(element);
this->append(elem);
}
//- Move an element onto the back of the stack
void push(T&& element)
void push(T&& elem)
{
this->append(std::move(element));
this->append(std::move(elem));
}
//- Pop the bottom element off the stack

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef IDLList_H
#define IDLList_H
#ifndef Foam_IDLList_H
#define Foam_IDLList_H
#include "ILList.H"
#include "DLListBase.H"

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef ISLList_H
#define ISLList_H
#ifndef Foam_ISLList_H
#define Foam_ISLList_H
#include "ILList.H"
#include "SLListBase.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,8 +34,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef LIFOStack_H
#define LIFOStack_H
#ifndef Foam_LIFOStack_H
#define Foam_LIFOStack_H
#include "SLList.H"
@ -63,28 +63,28 @@ public:
// Member Functions
//- Return a copy of the top element
T top() const
//- Const reference to the top element
const T& top() const
{
return this->first();
}
//- Return a copy of the bottom element
T bottom() const
//- Const reference to the bottom element
const T& bottom() const
{
return this->last();
}
//- Push an element onto the front of the stack
void push(const T& element)
void push(const T& elem)
{
this->insert(element);
this->prepend(elem);
}
//- Move an element onto the front of the stack
void push(T&& element)
void push(T&& elem)
{
this->insert(std::move(element));
this->prepend(std::move(elem));
}
//- Pop the top element off the stack

View File

@ -31,12 +31,11 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef SLList_H
#define SLList_H
#ifndef Foam_SLList_H
#define Foam_SLList_H
#include "SLListBase.H"
#include "LList.H"
#include "SLListFwd.H"
#endif

View File

@ -31,14 +31,14 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef SLListFwd_H
#define SLListFwd_H
#ifndef Foam_SLListFwd_H
#define Foam_SLListFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
// Forward Declarations
class SLListBase;
template<class LListBase, class T> class LList;

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef SLPtrList_H
#define SLPtrList_H
#ifndef Foam_SLPtrList_H
#define Foam_SLPtrList_H
#include "SLListBase.H"
#include "LPtrList.H"

View File

@ -31,14 +31,14 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef SLPtrListFwd_H
#define SLPtrListFwd_H
#ifndef Foam_SLPtrListFwd_H
#define Foam_SLPtrListFwd_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
// Forward Declarations
class SLListBase;
template<class LListBase, class T> class LPtrList;

View File

@ -31,8 +31,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef UIDLList_H
#define UIDLList_H
#ifndef Foam_UIDLList_H
#define Foam_UIDLList_H
#include "UILList.H"
#include "DLListBase.H"

View File

@ -652,12 +652,9 @@ void Foam::List<T>::operator=(SLList<T>&& list)
reAlloc(len);
T* iter = this->begin();
while (len--)
for (T* iter = this->begin(); len--; ++iter)
{
*iter = std::move(list.removeHead());
++iter;
}
list.clear();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -102,8 +102,8 @@ Foam::dictionary::dictionary
if (e.keyword().isPattern())
{
patterns_.insert(&e);
regexps_.insert(autoPtr<regExp>::New(e.keyword()));
patterns_.prepend(&e);
regexps_.prepend(autoPtr<regExp>::New(e.keyword()));
}
}
}
@ -124,8 +124,8 @@ Foam::dictionary::dictionary
if (e.keyword().isPattern())
{
patterns_.insert(&e);
regexps_.insert(autoPtr<regExp>::New(e.keyword()));
patterns_.prepend(&e);
regexps_.prepend(autoPtr<regExp>::New(e.keyword()));
}
}
}
@ -670,8 +670,8 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
if (entryPtr->keyword().isPattern())
{
patterns_.insert(entryPtr);
regexps_.insert(autoPtr<regExp>::New(entryPtr->keyword()));
patterns_.prepend(entryPtr);
regexps_.prepend(autoPtr<regExp>::New(entryPtr->keyword()));
}
return entryPtr; // now an entry in the dictionary
@ -698,8 +698,8 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
if (entryPtr->keyword().isPattern())
{
patterns_.insert(entryPtr);
regexps_.insert(autoPtr<regExp>::New(entryPtr->keyword()));
patterns_.prepend(entryPtr);
regexps_.prepend(autoPtr<regExp>::New(entryPtr->keyword()));
}
return entryPtr; // now an entry in the dictionary

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,7 +36,7 @@ namespace
// Walk lists of patterns and regexps for an exact match
// or a regular expression match
template<class WcIterator, class ReIterator>
static bool findInPatterns
bool findInPatterns
(
const bool patternMatch,
const Foam::word& keyword,
@ -680,8 +680,8 @@ bool Foam::dictionary::changeKeyword
if (newKeyword.isPattern())
{
patterns_.insert(iter());
regexps_.insert(autoPtr<regExp>::New(newKeyword));
patterns_.prepend(iter());
regexps_.prepend(autoPtr<regExp>::New(newKeyword));
}
return true;

View File

@ -30,12 +30,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::namedDictionary::namedDictionary()
:
Tuple2<keyType, dictionary>()
{}
Foam::namedDictionary::namedDictionary(Istream& is)
{
is >> *this;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,8 +61,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef namedDictionary_H
#define namedDictionary_H
#ifndef Foam_namedDictionary_H
#define Foam_namedDictionary_H
#include "dictionary.H"
#include "Tuple2.H"
@ -74,6 +74,7 @@ namespace Foam
// Forward Declarations
class namedDictionary;
Istream& operator>>(Istream&, namedDictionary&);
Ostream& operator<<(Ostream&, const namedDictionary&);
@ -93,7 +94,7 @@ public:
using Tuple2<keyType, dictionary>::Tuple2;
//- Default construct
namedDictionary();
namedDictionary() = default;
//- Construct from Istream
explicit namedDictionary(Istream& is);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -176,6 +176,12 @@ void Foam::globalIndex::bin
}
void Foam::globalIndex::reset(const label localSize)
{
reset(localSize, Pstream::msgType(), UPstream::worldComm, true);
}
void Foam::globalIndex::reset
(
const label localSize,
@ -189,6 +195,8 @@ void Foam::globalIndex::reset
if (len)
{
// Seed with localSize, zero elsewhere (for non-parallel branch)
// NB: can consider UPstream::listGatherValues
labelList localSizes(len, Zero);
localSizes[Pstream::myProcNo(comm)] = localSize;
@ -202,6 +210,7 @@ void Foam::globalIndex::reset
}
else
{
// Nothing to do
offsets_.clear();
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,14 +35,14 @@ Description
label globalFacei = globalFaces.toGlobal(facei);
SourceFiles
globalIndexI.H
globalIndex.C
globalIndexI.H
globalIndexTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef globalIndex_H
#define globalIndex_H
#ifndef Foam_globalIndex_H
#define Foam_globalIndex_H
#include "Pstream.H"
#include "CompactListList.H"
@ -175,7 +175,7 @@ public:
//- Reset from local size.
// Does communication with default communicator and message tag.
inline void reset(const label localSize);
void reset(const label localSize);
//- Reset from local size.
// Does communication with given communicator and message tag,
@ -377,10 +377,10 @@ public:
// Other
// Gather
// Gather (helpers)
//- Collect data in processor order on master (== procIDs[0]).
// Offsets needed on master only.
// \note offsets needed on master only.
template<class ProcIDsContainer, class Type>
static void gather
(
@ -394,7 +394,7 @@ public:
);
//- Collect indirect data in processor order on master
// Offsets needed on master only.
// \note offsets needed on master only.
template<class Type, class Addr>
static void gather
(
@ -407,8 +407,21 @@ public:
const Pstream::commsTypes = Pstream::commsTypes::scheduled
);
//- Inplace collect in processor order on master (== procIDs[0]).
// \note offsets needed on master only.
template<class ProcIDsContainer, class Type>
static void gather
(
const labelUList& offsets,
const label comm, //!< communicator
const ProcIDsContainer& procIDs,
List<Type>& fld,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking
);
//- Collect data in processor order on master (== procIDs[0]).
// Offsets needed on master only.
// \note the globalIndex offsets needed on master only.
template<class ProcIDsContainer, class Type>
void gather
(
@ -424,45 +437,8 @@ public:
gather(offsets_, comm, procIDs, fld, allFld, tag, commsType);
}
//- Collect data in processor order on master.
// Does communication with default communicator and message tag.
template<class Type>
void gather
(
const UList<Type>& fld,
List<Type>& allFld,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Collect data indirectly in processor order on master.
// Does communication with default communicator and message tag.
template<class Type, class Addr>
void gather
(
const IndirectListBase<Type, Addr>& fld,
List<Type>& allFld,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::scheduled,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Inplace collect in processor order on master (== procIDs[0]).
//- Needs offsets only on master.
template<class ProcIDsContainer, class Type>
static void gather
(
const labelUList& offsets,
const label comm, //!< communicator
const ProcIDsContainer& procIDs,
List<Type>& fld,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking
);
//- Inplace collect in processor order on master (== procIDs[0]).
//- Needs offsets only on master.
// \note the globalIndex offsets needed on master only.
template<class ProcIDsContainer, class Type>
void gather
(
@ -477,11 +453,68 @@ public:
gather(offsets_, comm, procIDs, fld, tag, commsType);
}
//- Inplace collect data in processor order on master
// Does communication with default communicator and message tag.
// After the gather, the field is zero-sized on the slaves.
// Gather
//- Collect data in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
template<class Type>
void gather
(
const UList<Type>& sendData,
List<Type>& allData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Collect data indirectly in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
template<class Type, class Addr>
void gather
(
const IndirectListBase<Type, Addr>& sendData,
List<Type>& allData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::scheduled,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Collect data in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
//
// \return output (master), zero-sized on non-master
template<class Type, class OutputContainer = List<Type>>
OutputContainer gather
(
const UList<Type>& sendData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Collect data indirectly in processor order on master.
// Communication with default/specified communicator, message tag.
//
// \return output (master), zero-sized on non-master
template<class Type, class Addr, class OutputContainer = List<Type>>
OutputContainer gather
(
const IndirectListBase<Type, Addr>& sendData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::scheduled,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Inplace collect data in processor order on master
//- (in serial: a no-op).
// Communication with default/specified communicator, message tag.
// After the gather, the field is zero-sized on the slaves.
template<class Type>
void gatherInplace
(
List<Type>& fld,
const int tag = UPstream::msgType(),
@ -490,19 +523,27 @@ public:
) const;
//- Collect \em contiguous data using a MPI_Gatherv call
//- (in serial: performs a simple copy).
// Communication with default/specified communicator.
// \attention The nProcs for globalIndex and communicator
// must match!!
//
// The allData is output (master), zero-sized on non-master
template<class Type, class OutputContainer = List<Type>>
void mpiGather
(
const UList<Type>& sendData,
OutputContainer& allValues,
OutputContainer& allData,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Collect \em contiguous data using a MPI_Gatherv call
//- (in serial: performs a simple copy).
// Communication with default/specified communicator.
// \attention The nProcs for globalIndex and communicator
// must match!!
//
// \return output (master), zero-sized on non-master
template<class Type, class OutputContainer = List<Type>>
OutputContainer mpiGather
(
@ -510,33 +551,139 @@ public:
const label comm = UPstream::worldComm //!< communicator
) const;
//- Inplace collect \em contiguous data using a MPI_Gatherv call
//- (in serial: a no-op).
// Communication with default/specified communicator.
// \attention The nProcs for globalIndex and communicator
// must match!!
//
// After the gather, the field is zero-sized on non-master.
template<class Type>
void mpiGatherInplace
(
List<Type>& fld,
const label comm = UPstream::worldComm //!< communicator
) const;
//- Collect data in processor order on master.
// Does communication with default communicator and message tag.
// Gather Operations
//- Collect \em contiguous data using a MPI_Gatherv call
//- (in serial: performs a simple copy).
// Communication with default/specified communicator.
//
// The allData is output (master), zero-sized on non-master
template<class Type, class OutputContainer = List<Type>>
static void mpiGatherOp
(
const UList<Type>& sendData,
OutputContainer& allData,
const label comm = UPstream::worldComm //!< communicator
);
//- Collect \em contiguous data using a MPI_Gatherv call
//- (in serial: performs a simple copy).
// Communication with default/specified communicator.
//
// \return output (master), zero-sized on non-master
template<class Type, class OutputContainer = List<Type>>
static OutputContainer mpiGatherOp
(
const UList<Type>& sendData,
const label comm = UPstream::worldComm //!< communicator
);
//- Inplace collect \em contiguous data using a MPI_Gatherv call
//- (in serial: a no-op).
// Communication with default/specified communicator.
//
// After the gather, the field is zero-sized on non-master.
template<class Type>
static void mpiGatherInplaceOp
(
List<Type>& fld,
const label comm = UPstream::worldComm //!< communicator
);
//- Collect data in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
//
// The allFld is output (master), zero-sized on non-master
template<class Type>
static void gatherOp
(
const UList<Type>& fld,
List<Type>& allFld,
const UList<Type>& sendData,
List<Type>& allData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
);
//- Collect data in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
//
// The allFld is output (master), zero-sized on non-master
template<class Type, class Addr>
static void gatherOp
(
const IndirectListBase<Type, Addr>& sendData,
List<Type>& allData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
);
//- Collect and return data in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
//
// \return output (master), zero-sized on non-master
template<class Type, class OutputContainer = List<Type>>
static OutputContainer gatherOp
(
const UList<Type>& sendData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
);
//- Collect and return data in processor order on master
//- (in serial: performs a simple copy).
// Communication with default/specified communicator, message tag.
//
// \return output (master), zero-sized on non-master
template<class Type, class Addr, class OutputContainer = List<Type>>
static OutputContainer gatherOp
(
const IndirectListBase<Type, Addr>& sendData,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
);
//- Inplace collect data in processor order on master
// Does communication with default communicator and message tag.
//- (in serial: a no-op).
// Communication with default/specified communicator, message tag.
//
// After the gather, the field is zero-sized on the slaves.
template<class Type>
static void gatherOp
static void gatherInplaceOp
(
List<Type>& fld,
const int tag = UPstream::msgType(),
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking,
const label comm = UPstream::worldComm //!< communicator
);
// Scatter
//- Distribute data in processor order. Requires fld to be sized!
//- Distribute data in processor order.
// Requires fld to be correctly sized!
// Communication with default/specified communicator, message tag.
// \note offsets needed on master only.
template<class ProcIDsContainer, class Type>
static void scatter
(
@ -549,7 +696,10 @@ public:
const Pstream::commsTypes = Pstream::commsTypes::nonBlocking
);
//- Distribute data in processor order. Requires fld to be sized!
//- Distribute data in processor order.
// Requires fld to be correctly sized!
// Communication with default/specified communicator, message tag.
// \note the globalIndex offsets needed on master only.
template<class ProcIDsContainer, class Type>
void scatter
(
@ -565,8 +715,10 @@ public:
scatter(offsets_, comm, procIDs, allFld, fld, tag, commsType);
}
//- Distribute data in processor order. Requires fld to be sized!
// Does communication with default communicator and message tag.
//- Distribute data in processor order.
// Requires fld to be correctly sized!
// Communication with default/specified communicator, message tag.
// \note the globalIndex offsets needed on master only.
template<class Type>
void scatter
(
@ -582,6 +734,7 @@ public:
//- Get (potentially remote) data.
//- Elements required given as global indices
// Communication with default/specified communicator, message tag.
template<class Type, class CombineOp>
void get
(

View File

@ -154,12 +154,6 @@ inline Foam::label Foam::globalIndex::size() const
}
inline void Foam::globalIndex::reset(const label localSize)
{
reset(localSize, Pstream::msgType(), UPstream::worldComm, true);
}
inline Foam::label Foam::globalIndex::offset(const label proci) const
{
return offsets_[proci];

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,12 +68,10 @@ Foam::globalIndex::calcListOffsets
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ProcIDsContainer, class Type>
void Foam::globalIndex::gather
(
const labelUList& off,
const labelUList& off, // needed on master only
const label comm,
const ProcIDsContainer& procIDs,
const UList<Type>& fld,
@ -82,6 +80,8 @@ void Foam::globalIndex::gather
const Pstream::commsTypes commsType
)
{
// low-level: no parRun guard
if
(
!is_contiguous<Type>::value
@ -94,6 +94,8 @@ void Foam::globalIndex::gather
// Could also warn and change to scheduled etc...
}
const label startOfRequests = UPstream::nRequests();
if (Pstream::myProcNo(comm) == procIDs[0])
{
allFld.resize_nocopy(off.last());
@ -106,53 +108,12 @@ void Foam::globalIndex::gather
SubList<Type>(allFld, off[1]-off[0], off[0]) =
SubList<Type>(fld, off[1]-off[0]);
if
(
commsType == Pstream::commsTypes::scheduled
|| commsType == Pstream::commsTypes::blocking
)
for (label i = 1; i < procIDs.size(); ++i)
{
for (label i = 1; i < procIDs.size(); ++i)
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (is_contiguous<Type>::value)
{
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (is_contiguous<Type>::value)
{
IPstream::read
(
commsType,
procIDs[i],
procSlot.data_bytes(),
procSlot.size_bytes(),
tag,
comm
);
}
else
{
IPstream fromProc
(
commsType,
procIDs[i],
0,
tag,
comm
);
fromProc >> procSlot;
}
}
}
else
{
// nonBlocking && is_contiguous == true (already checked)
const label startOfRequests = Pstream::nRequests();
// Set up reads
for (label i = 1; i < procIDs.size(); ++i)
{
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
IPstream::read
(
commsType,
@ -163,51 +124,24 @@ void Foam::globalIndex::gather
comm
);
}
// Wait for all to finish
Pstream::waitRequests(startOfRequests);
}
}
else
{
if
(
commsType == Pstream::commsTypes::scheduled
|| commsType == Pstream::commsTypes::blocking
)
{
if (is_contiguous<Type>::value)
{
OPstream::write
(
commsType,
procIDs[0],
fld.cdata_bytes(),
fld.size_bytes(),
tag,
comm
);
}
else
{
OPstream toMaster
IPstream fromProc
(
commsType,
procIDs[0],
procIDs[i],
0,
tag,
comm
);
toMaster << fld;
fromProc >> procSlot;
}
}
else
}
else
{
if (is_contiguous<Type>::value)
{
// nonBlocking && is_contiguous == true (already checked)
const label startOfRequests = Pstream::nRequests();
// Set up write
OPstream::write
(
commsType,
@ -217,10 +151,25 @@ void Foam::globalIndex::gather
tag,
comm
);
// Wait for all to finish
Pstream::waitRequests(startOfRequests);
}
else
{
OPstream toMaster
(
commsType,
procIDs[0],
0,
tag,
comm
);
toMaster << fld;
}
}
if (commsType == Pstream::commsTypes::nonBlocking)
{
// Wait for all to finish
UPstream::waitRequests(startOfRequests);
}
}
@ -228,7 +177,7 @@ void Foam::globalIndex::gather
template<class Type, class Addr>
void Foam::globalIndex::gather
(
const labelUList& off,
const labelUList& off, // needed on master only
const label comm,
const UList<int>& procIDs,
const IndirectListBase<Type, Addr>& fld,
@ -237,6 +186,8 @@ void Foam::globalIndex::gather
const Pstream::commsTypes commsType
)
{
// low-level: no parRun guard
if (commsType == Pstream::commsTypes::nonBlocking)
{
WarningInFunction
@ -289,55 +240,10 @@ void Foam::globalIndex::gather
}
template<class Type>
void Foam::globalIndex::gather
(
const UList<Type>& fld,
List<Type>& allFld,
const int tag,
const Pstream::commsTypes commsType,
const label comm
) const
{
gather
(
comm,
UPstream::procID(comm),
fld,
allFld,
tag,
commsType
);
}
template<class Type, class Addr>
void Foam::globalIndex::gather
(
const IndirectListBase<Type, Addr>& fld,
List<Type>& allFld,
const int tag,
const Pstream::commsTypes commsType,
const label comm
) const
{
gather
(
offsets_,
comm,
UPstream::procID(comm),
fld,
allFld,
tag,
commsType
);
}
template<class ProcIDsContainer, class Type>
void Foam::globalIndex::gather
(
const labelUList& off,
const labelUList& off, // needed on master only
const label comm,
const ProcIDsContainer& procIDs,
List<Type>& fld,
@ -345,19 +251,123 @@ void Foam::globalIndex::gather
const Pstream::commsTypes commsType
)
{
List<Type> allFld;
// low-level: no parRun guard
gather(off, comm, procIDs, fld, allFld, tag, commsType);
List<Type> allData;
gather(off, comm, procIDs, fld, allData, tag, commsType);
if (Pstream::myProcNo(comm) == procIDs[0])
{
fld.transfer(allFld);
fld.transfer(allData);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::globalIndex::gather
(
const UList<Type>& sendData,
List<Type>& allData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
) const
{
if (UPstream::parRun())
{
gather
(
offsets_, // needed on master only
comm,
UPstream::procID(comm),
sendData,
allData,
tag,
commsType
);
if (!UPstream::master(comm))
{
allData.clear(); // safety: zero-size on non-master
}
}
else
{
// Serial: direct copy
allData = sendData;
}
}
template<class Type, class Addr>
void Foam::globalIndex::gather
(
const IndirectListBase<Type, Addr>& sendData,
List<Type>& allData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
) const
{
if (UPstream::parRun())
{
gather
(
offsets_, // needed on master only
comm,
UPstream::procID(comm),
sendData,
allData,
tag,
commsType
);
if (!UPstream::master(comm))
{
allData.clear(); // safety: zero-size on non-master
}
}
else
{
// Serial: direct copy
allData = List<Type>(sendData);
}
}
template<class Type, class OutputContainer>
OutputContainer Foam::globalIndex::gather
(
const UList<Type>& sendData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
) const
{
OutputContainer allData;
gather(sendData, allData, tag, commsType, comm);
return allData;
}
template<class Type, class Addr, class OutputContainer>
OutputContainer Foam::globalIndex::gather
(
const IndirectListBase<Type, Addr>& sendData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
) const
{
OutputContainer allData;
gather(sendData, allData, tag, commsType, comm);
return allData;
}
template<class Type>
void Foam::globalIndex::gatherInplace
(
List<Type>& fld,
const int tag,
@ -365,26 +375,30 @@ void Foam::globalIndex::gather
const label comm
) const
{
List<Type> allFld;
gather
(
comm,
UPstream::procID(comm),
fld,
allFld,
tag,
commsType
);
if (Pstream::master(comm))
if (UPstream::parRun())
{
fld.transfer(allFld);
}
else
{
fld.clear();
List<Type> allData;
gather
(
comm,
UPstream::procID(comm),
fld,
allData,
tag,
commsType
);
if (UPstream::master(comm))
{
fld.transfer(allData);
}
else
{
fld.clear(); // zero-size on non-master
}
}
// Serial: (no-op)
}
@ -392,10 +406,16 @@ template<class Type, class OutputContainer>
void Foam::globalIndex::mpiGather
(
const UList<Type>& sendData,
OutputContainer& allValues,
OutputContainer& allData,
const label comm
) const
{
if (!UPstream::parRun())
{
// Serial: direct copy
allData = sendData;
return;
}
if (!is_contiguous<Type>::value)
{
FatalErrorInFunction
@ -403,29 +423,25 @@ void Foam::globalIndex::mpiGather
<< abort(FatalError);
}
const label proci = Pstream::myProcNo(comm);
const globalIndex& globalAddr = *this;
// Must be the same as Pstream::nProcs(comm), at least on master!!
const label nproc = globalAddr.nProcs();
auto nSendBytes = sendData.size_bytes();
// Respect local size information so that we can request
// 0 entries to be sent on master
if (proci < nproc && !globalAddr.localSize(proci))
{
nSendBytes = 0;
}
List<int> recvSizes;
List<int> recvOffsets;
if (Pstream::master(comm))
if (UPstream::master(comm))
{
allValues.resize_nocopy(globalAddr.size());
const globalIndex& globalAddr = *this;
// Must be the same as Pstream::nProcs(comm), at least on master!!
const label nproc = globalAddr.nProcs();
// Allow request of 0 entries to be sent on master
if (!globalAddr.localSize(0))
{
nSendBytes = 0;
}
allData.resize_nocopy(globalAddr.size());
recvSizes.resize(nproc);
recvOffsets.resize(nproc+1);
@ -439,14 +455,14 @@ void Foam::globalIndex::mpiGather
}
else
{
allValues.clear();
allData.clear(); // safety: zero-size on non-master
}
UPstream::gather
(
sendData.cdata_bytes(),
nSendBytes,
allValues.data_bytes(),
allData.data_bytes(),
recvSizes,
recvOffsets,
comm
@ -461,41 +477,210 @@ OutputContainer Foam::globalIndex::mpiGather
const label comm
) const
{
OutputContainer allValues;
mpiGather<Type, OutputContainer>(sendData, allValues, comm);
return allValues;
OutputContainer allData;
mpiGather(sendData, allData, comm);
return allData;
}
template<class Type>
void Foam::globalIndex::mpiGatherInplace
(
List<Type>& fld,
const label comm
) const
{
if (UPstream::parRun())
{
List<Type> allData;
mpiGather(fld, allData, comm);
if (UPstream::master(comm))
{
fld.transfer(allData);
}
else
{
fld.clear(); // zero-size on non-master
}
}
// Serial: (no-op)
}
template<class Type, class OutputContainer>
void Foam::globalIndex::mpiGatherOp
(
const UList<Type>& sendData,
OutputContainer& allData,
const label comm
)
{
if (UPstream::parRun())
{
// Gather sizes - only needed on master
globalIndex
(
UPstream::listGatherValues(sendData.size(), comm),
accessType::SIZES
).mpiGather(sendData, allData, comm);
}
else
{
// Serial: direct copy
allData = sendData;
}
}
template<class Type, class OutputContainer>
OutputContainer Foam::globalIndex::mpiGatherOp
(
const UList<Type>& sendData,
const label comm
)
{
OutputContainer allData;
mpiGatherOp(sendData, allData, comm);
return allData;
}
template<class Type>
void Foam::globalIndex::mpiGatherInplaceOp
(
List<Type>& fld,
const label comm
)
{
if (UPstream::parRun())
{
List<Type> allData;
mpiGatherOp(fld, allData, comm);
if (UPstream::master(comm))
{
fld.transfer(allData);
}
else
{
fld.clear(); // zero-size on non-master
}
}
// Serial: (no-op)
}
template<class Type>
void Foam::globalIndex::gatherOp
(
const UList<Type>& fld,
List<Type>& allFld,
const UList<Type>& sendData,
List<Type>& allData,
const int tag,
const Pstream::commsTypes commsType
const Pstream::commsTypes commsType,
const label comm
)
{
globalIndex(fld.size()).gather(fld, allFld, tag, commsType);
if (UPstream::parRun())
{
// Gather sizes - only needed on master
globalIndex
(
UPstream::listGatherValues(sendData.size(), comm),
accessType::SIZES
).gather(sendData, allData, tag, commsType, comm);
}
else
{
// Serial: direct copy
allData = sendData;
}
}
template<class Type, class Addr>
void Foam::globalIndex::gatherOp
(
const IndirectListBase<Type, Addr>& sendData,
List<Type>& allData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
)
{
if (UPstream::parRun())
{
// Gather sizes - only needed on master
globalIndex
(
UPstream::listGatherValues(sendData.size(), comm),
accessType::SIZES
).gather(sendData, allData, tag, commsType, comm);
}
else
{
// Serial: direct copy
allData = List<Type>(sendData);
}
}
template<class Type, class OutputContainer>
OutputContainer Foam::globalIndex::gatherOp
(
const UList<Type>& sendData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
)
{
OutputContainer allData;
gatherOp(sendData, allData, tag, commsType, comm);
return allData;
}
template<class Type, class Addr, class OutputContainer>
OutputContainer Foam::globalIndex::gatherOp
(
const IndirectListBase<Type, Addr>& sendData,
const int tag,
const Pstream::commsTypes commsType,
const label comm
)
{
OutputContainer allData;
gatherOp(sendData, allData, tag, commsType, comm);
return allData;
}
template<class Type>
void Foam::globalIndex::gatherOp
void Foam::globalIndex::gatherInplaceOp
(
List<Type>& fld,
const int tag,
const Pstream::commsTypes commsType
const Pstream::commsTypes commsType,
const label comm
)
{
globalIndex(fld.size()).gather(fld, tag, commsType);
if (UPstream::parRun())
{
// Gather sizes - only needed on master
globalIndex
(
UPstream::listGatherValues(fld.size(), comm),
accessType::SIZES
).gather(fld, tag, commsType, comm);
}
// Serial: (no-op)
}
template<class ProcIDsContainer, class Type>
void Foam::globalIndex::scatter
(
const labelUList& off,
const labelUList& off, // needed on master only
const label comm,
const ProcIDsContainer& procIDs,
const UList<Type>& allFld,
@ -516,6 +701,8 @@ void Foam::globalIndex::scatter
// Could also warn and change to scheduled etc...
}
const label startOfRequests = UPstream::nRequests();
if (Pstream::myProcNo(comm) == procIDs[0])
{
const SubList<Type> localSlot(allFld, off[1]-off[0], off[0]);
@ -525,53 +712,12 @@ void Foam::globalIndex::scatter
fld.deepCopy(localSlot);
}
if
(
commsType == Pstream::commsTypes::scheduled
|| commsType == Pstream::commsTypes::blocking
)
for (label i = 1; i < procIDs.size(); ++i)
{
for (label i = 1; i < procIDs.size(); ++i)
const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (is_contiguous<Type>::value)
{
const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (is_contiguous<Type>::value)
{
OPstream::write
(
commsType,
procIDs[i],
procSlot.cdata_bytes(),
procSlot.size_bytes(),
tag,
comm
);
}
else
{
OPstream toProc
(
commsType,
procIDs[i],
0,
tag,
comm
);
toProc << procSlot;
}
}
}
else
{
// nonBlocking && is_contiguous == true (already checked)
const label startOfRequests = Pstream::nRequests();
// Set up writes
for (label i = 1; i < procIDs.size(); ++i)
{
const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
OPstream::write
(
commsType,
@ -582,51 +728,24 @@ void Foam::globalIndex::scatter
comm
);
}
// Wait for all to finish
Pstream::waitRequests(startOfRequests);
}
}
else
{
if
(
commsType == Pstream::commsTypes::scheduled
|| commsType == Pstream::commsTypes::blocking
)
{
if (is_contiguous<Type>::value)
{
IPstream::read
(
commsType,
procIDs[0],
fld.data_bytes(),
fld.size_bytes(),
tag,
comm
);
}
else
{
IPstream fromMaster
OPstream toProc
(
commsType,
procIDs[0],
procIDs[i],
0,
tag,
comm
);
fromMaster >> fld;
toProc << procSlot;
}
}
else
}
else
{
if (is_contiguous<Type>::value)
{
// nonBlocking && is_contiguous == true (already checked)
const label startOfRequests = Pstream::nRequests();
// Set up read
IPstream::read
(
commsType,
@ -636,10 +755,25 @@ void Foam::globalIndex::scatter
tag,
comm
);
// Wait for all to finish
Pstream::waitRequests(startOfRequests);
}
else
{
IPstream fromMaster
(
commsType,
procIDs[0],
0,
tag,
comm
);
fromMaster >> fld;
}
}
if (commsType == Pstream::commsTypes::nonBlocking)
{
// Wait for all to finish
UPstream::waitRequests(startOfRequests);
}
}
@ -654,16 +788,19 @@ void Foam::globalIndex::scatter
const label comm
) const
{
scatter
(
offsets_,
comm,
UPstream::procID(comm),
allFld,
fld,
tag,
commsType
);
// TBD: protection and special handling for serial?
{
scatter
(
offsets_, // needed on master only
comm,
UPstream::procID(comm),
allFld,
fld,
tag,
commsType
);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2019 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -236,14 +236,14 @@ Foam::labelList Foam::polyMeshTetDecomposition::findFaceBasePts
labelList tetBasePtIs(mesh.nFaces(), -1);
label nInternalFaces = mesh.nInternalFaces();
const label nInternalFaces = mesh.nInternalFaces();
for (label fI = 0; fI < nInternalFaces; ++fI)
{
tetBasePtIs[fI] = findSharedBasePoint(mesh, fI, tol, report);
}
pointField neighbourCellCentres(mesh.nFaces() - nInternalFaces);
pointField neighbourCellCentres(mesh.nBoundaryFaces());
for (label facei = nInternalFaces; facei < mesh.nFaces(); ++facei)
{
@ -257,8 +257,8 @@ Foam::labelList Foam::polyMeshTetDecomposition::findFaceBasePts
SubList<label> boundaryFaceTetBasePtIs
(
tetBasePtIs,
mesh.nFaces() - nInternalFaces,
nInternalFaces
mesh.nBoundaryFaces(),
mesh.nInternalFaces()
);
for

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -347,8 +347,10 @@ bool Foam::processorCyclicPolyPatch::order
{
UIPstream fromNeighbour(neighbProcNo(), pBufs);
fromNeighbour >> masterPts >> masterFaces;
SubList<face> fcs(masterFaces, masterFaces.size());
masterPtr.reset(new primitivePatch(fcs, masterPts));
masterPtr.reset
(
new primitivePatch(SubList<face>(masterFaces), masterPts)
);
}
const cyclicPolyPatch& cycPatch =

View File

@ -65,8 +65,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef regExpCxx_H
#define regExpCxx_H
#ifndef Foam_regExpCxx_H
#define Foam_regExpCxx_H
#include <regex>
#include <string>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,7 +40,8 @@ const Foam::wordRe Foam::wordRe::null;
Foam::wordRe::wordRe(const keyType& str)
:
word(str, false) // No stripping
word(str, false), // No stripping
regexPtr_(nullptr)
{
if (str.isPattern())
{
@ -50,6 +51,9 @@ Foam::wordRe::wordRe(const keyType& str)
Foam::wordRe::wordRe(Istream& is)
:
word(),
regexPtr_(nullptr)
{
is >> *this;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,8 +51,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef wordRe_H
#define wordRe_H
#ifndef Foam_wordRe_H
#define Foam_wordRe_H
#include "word.H"
#include "regExp.H"
@ -85,7 +85,7 @@ class wordRe
// Private Member Data
//- The regular expression
regExp re_;
std::unique_ptr<Foam::regExp> regexPtr_;
public:
@ -164,10 +164,10 @@ public:
// Access
//- The wordRe is treated as literal string, not as pattern.
//- The wordRe is a literal string, not a pattern.
inline bool isLiteral() const noexcept;
//- The wordRe is treated as a pattern, not as literal string.
//- The wordRe is a pattern, not a literal string.
inline bool isPattern() const noexcept;
@ -181,7 +181,7 @@ public:
// \return false if the token was the incorrect type
bool assign(const token& tok);
//- Compile as regular expression
//- Compile as regular expression (if possible)
inline bool compile();
//- Mark as literal string, remove any regular expression

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,7 +40,7 @@ inline bool Foam::wordRe::valid(const char c)
inline Foam::wordRe::wordRe()
:
word(),
re_()
regexPtr_(nullptr)
{}
@ -58,25 +58,28 @@ inline Foam::wordRe::wordRe(const wordRe& str)
inline Foam::wordRe::wordRe(wordRe&& str)
:
word(std::move(static_cast<word&>(str))),
re_(std::move(str.re_))
regexPtr_(str.regexPtr_.release())
{}
inline Foam::wordRe::wordRe(const word& str)
:
word(str)
word(str),
regexPtr_(nullptr)
{}
inline Foam::wordRe::wordRe(word&& str)
:
word(std::move(str))
word(std::move(str)),
regexPtr_(nullptr)
{}
inline Foam::wordRe::wordRe(const std::string& str, const compOption opt)
:
word(str, false) // No stripping
word(str, false), // No stripping
regexPtr_(nullptr)
{
if (opt != wordRe::LITERAL)
{
@ -87,7 +90,8 @@ inline Foam::wordRe::wordRe(const std::string& str, const compOption opt)
inline Foam::wordRe::wordRe(const char* str, const compOption opt)
:
word(str, false) // No stripping
word(str, false), // No stripping
regexPtr_(nullptr)
{
if (opt != wordRe::LITERAL)
{
@ -100,13 +104,13 @@ inline Foam::wordRe::wordRe(const char* str, const compOption opt)
inline bool Foam::wordRe::isLiteral() const noexcept
{
return !re_.exists();
return !bool(regexPtr_);
}
inline bool Foam::wordRe::isPattern() const noexcept
{
return re_.exists();
return bool(regexPtr_);
}
@ -131,25 +135,47 @@ inline bool Foam::wordRe::compile(const compOption opt)
if (comp)
{
return re_.set(*this, (opt & wordRe::ICASE));
if (!regexPtr_)
{
regexPtr_.reset(new Foam::regExp());
}
if (!regexPtr_->set(*this, (opt & wordRe::ICASE)))
{
// Compilation failed
regexPtr_.reset(nullptr);
}
return bool(regexPtr_);
}
}
// Fall-through behaviour - not a regex
re_.clear();
regexPtr_.reset(nullptr);
return false;
}
inline bool Foam::wordRe::compile()
{
return re_.set(*this);
if (!regexPtr_)
{
regexPtr_.reset(new Foam::regExp());
}
if (!regexPtr_->set(*this))
{
// Compilation failed
regexPtr_.reset(nullptr);
}
return bool(regexPtr_);
}
inline void Foam::wordRe::uncompile()
{
re_.clear();
regexPtr_.reset(nullptr);
}
@ -160,22 +186,22 @@ inline void Foam::wordRe::uncompile(bool adjust)
{
string::stripInvalid<word>(*this);
}
re_.clear();
regexPtr_.reset(nullptr);
}
inline void Foam::wordRe::clear()
{
word::clear();
re_.clear();
regexPtr_.reset(nullptr);
}
inline bool Foam::wordRe::match(const std::string& text, bool literal) const
{
if (!literal && re_.exists())
if (!literal && regexPtr_)
{
return re_.match(text); // Match as regex
return regexPtr_->match(text); // Match as regex
}
return !compare(text); // Compare as literal
@ -191,6 +217,7 @@ inline void Foam::wordRe::set(const std::string& str, const compOption opt)
inline void Foam::wordRe::set(const char* str, const compOption opt)
{
// No nullptr protection here
assign(str);
compile(opt);
}
@ -204,7 +231,7 @@ inline void Foam::wordRe::swap(wordRe& str)
}
word::swap(static_cast<word&>(str));
re_.swap(str.re_);
regexPtr_.swap(str.regexPtr_);
}
@ -230,7 +257,7 @@ inline void Foam::wordRe::operator=(const wordRe& str)
}
else
{
re_.clear();
regexPtr_.reset(nullptr);
}
}
@ -238,7 +265,7 @@ inline void Foam::wordRe::operator=(const wordRe& str)
inline void Foam::wordRe::operator=(const word& str)
{
assign(str);
re_.clear();
regexPtr_.reset(nullptr);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -727,8 +728,8 @@ void Foam::polyDualMesh::calcDual
SubList<face>
(
mesh.faces(),
mesh.nFaces() - nIntFaces,
nIntFaces
mesh.nBoundaryFaces(),
mesh.nInternalFaces()
),
mesh.points()
);
@ -781,7 +782,7 @@ void Foam::polyDualMesh::calcDual
pointField dualPoints
(
mesh.nCells() // cell centres
+ mesh.nFaces() - nIntFaces // boundary face centres
+ mesh.nBoundaryFaces() // boundary face centres
+ featureEdges.size() // additional boundary edges
+ featurePoints.size() // additional boundary points
);
@ -803,7 +804,7 @@ void Foam::polyDualMesh::calcDual
// Boundary faces centres
const pointField& faceCentres = mesh.faceCentres();
boundaryFacePoint_.setSize(mesh.nFaces() - nIntFaces);
boundaryFacePoint_.setSize(mesh.nBoundaryFaces());
for (label facei = nIntFaces; facei < mesh.nFaces(); facei++)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,7 +65,7 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells
unrefineableCell = protectedCell_;
// Get neighbouring cell level
labelList neiLevel(nFaces()-nInternalFaces());
labelList neiLevel(nBoundaryFaces());
for (label facei = nInternalFaces(); facei < nFaces(); ++facei)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1894,9 +1894,11 @@ Foam::label Foam::boundaryMesh::getNPoints
const label nFaces
) const
{
SubList<face> patchFaces(mesh(), nFaces, startFacei);
primitivePatch patch(patchFaces, mesh().points());
primitivePatch patch
(
SubList<face>(mesh(), nFaces, startFacei),
mesh().points()
);
return patch.nPoints();
}
@ -1912,9 +1914,11 @@ void Foam::boundaryMesh::triangulateLocal
labelList& localToGlobal
) const
{
SubList<face> patchFaces(mesh(), nFaces, startFacei);
primitivePatch patch(patchFaces, mesh().points());
primitivePatch patch
(
SubList<face>(mesh(), nFaces, startFacei),
mesh().points()
);
// Map from local to mesh().points() addressing
localToGlobal = patch.meshPoints();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1889,7 +1889,7 @@ bool Foam::hexRef8::matchHexShape
primitivePatch bigFace
(
SubList<face>(fourFaces, fourFaces.size()),
SubList<face>(fourFaces),
mesh_.points()
);
const labelListList& edgeLoops = bigFace.edgeLoops();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -281,9 +281,7 @@ Foam::Ostream& Foam::OBJstream::write
const bool lines
)
{
SubList<face> allFcs(faces, faces.size());
primitivePatch pp(allFcs, points);
primitivePatch pp(SubList<face>(faces), points);
const pointField& localPoints = pp.localPoints();
const faceList& localFaces = pp.localFaces();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -385,7 +385,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
labelList cellAddr(mesh_.nCells(), -1);
const labelList& cellIDs = mesh_.cellZones()[cellZonei];
labelUIndList(cellAddr, cellIDs) = identity(cellIDs.size());
labelList nbrFaceCellAddr(mesh_.nFaces() - nInternalFaces, -1);
labelList nbrFaceCellAddr(mesh_.nBoundaryFaces(), -1);
forAll(pbm, patchi)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -141,7 +141,7 @@ void Foam::fv::rotorDiskSource::setFaceArea(vector& axis, const bool correct)
// Calculate cell addressing for selected cells
labelList cellAddr(mesh_.nCells(), -1);
labelUIndList(cellAddr, cells_) = identity(cells_.size());
labelList nbrFaceCellAddr(mesh_.nFaces() - nInternalFaces, -1);
labelList nbrFaceCellAddr(mesh_.nBoundaryFaces(), -1);
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];

View File

@ -539,8 +539,8 @@ Foam::labelList Foam::meshRefinement::nearestIntersection
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
labelList neiLevel(mesh_.nBoundaryFaces());
pointField neiCc(mesh_.nBoundaryFaces());
calcNeighbourData(neiLevel, neiCc);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019,2022 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -193,7 +193,7 @@ void Foam::meshRefinement::markOutsideFaces
}
{
const label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
const label nBnd = mesh_.nBoundaryFaces();
labelList neiRefineCell(nBnd);
syncTools::swapBoundaryCellList(mesh_, refineCell, neiRefineCell);
@ -948,8 +948,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::removeGapCells
)
{
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
labelList neiLevel(mesh_.nBoundaryFaces());
pointField neiCc(mesh_.nBoundaryFaces());
calcNeighbourData(neiLevel, neiCc);
labelList refineCell(mesh_.nCells(), -1);

View File

@ -2092,8 +2092,8 @@ Foam::labelList Foam::meshRefinement::refineCandidates
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
labelList neiLevel(mesh_.nBoundaryFaces());
pointField neiCc(mesh_.nBoundaryFaces());
calcNeighbourData(neiLevel, neiCc);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +85,7 @@ void Foam::advancingFrontAMI::distributePatches
faceList subFaces(UIndirectList<face>(pp, sendElems));
primitivePatch subPatch
(
SubList<face>(subFaces, subFaces.size()),
SubList<face>(subFaces),
pp.points()
);
@ -115,7 +115,7 @@ void Foam::advancingFrontAMI::distributePatches
faceList subFaces(UIndirectList<face>(pp, sendElems));
primitivePatch subPatch
(
SubList<face>(subFaces, subFaces.size()),
SubList<face>(subFaces),
pp.points()
);

View File

@ -1151,10 +1151,7 @@ void Foam::mappedPatchBase::calcAMI() const
pointField dummyPoints;
const primitivePatch dummyPatch
(
SubList<face>
(
dummyFaces
),
SubList<face>(dummyFaces),
dummyPoints
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -114,7 +114,7 @@ void Foam::cellToFace::combine
// Get coupled cell status
boolList neiInSet(mesh_.nFaces()-nInt, false);
boolList neiInSet(mesh_.nBoundaryFaces(), false);
for (const polyPatch& pp : patches)
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -152,11 +152,7 @@ bool Foam::mergedSurf::merge
PatchTools::gatherAndMerge
(
mergeDim,
primitivePatch
(
SubList<face>(unmergedFaces, unmergedFaces.size()),
unmergedPoints
),
primitivePatch(SubList<face>(unmergedFaces), unmergedPoints),
points_,
faces_,
pointsMap_