From 1cd47839acdbab37fd85407434c9cdfda801f057 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Fri, 23 Dec 2022 13:53:36 +0000 Subject: [PATCH 001/348] CONFIG: Reset version post-release --- etc/bashrc | 2 +- etc/cshrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index a935a16f93..02d084f060 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -55,7 +55,7 @@ # [WM_PROJECT_VERSION] - A human-readable version name # A development version is often named 'com' - as in www.openfoam.com -export WM_PROJECT_VERSION=v2212 +export WM_PROJECT_VERSION=com #------------------------------------------------------------------------------ # Configuration environment variables. diff --git a/etc/cshrc b/etc/cshrc index 7b4f4c3e2b..7f19beec7b 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -55,7 +55,7 @@ # [WM_PROJECT_VERSION] - A human-readable version name # A development version is often named 'com' - as in www.openfoam.com -setenv WM_PROJECT_VERSION v2212 +setenv WM_PROJECT_VERSION com #------------------------------------------------------------------------------ # Configuration environment variables. From d74572cae86d5227cc6401d16ce7cbbc253fafd8 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 28 Dec 2022 09:33:42 +0000 Subject: [PATCH 002/348] CONFIG: set API level to 2212 --- doc/Build.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/Build.md b/doc/Build.md index 6b3ad62356..490a3c6c94 100644 --- a/doc/Build.md +++ b/doc/Build.md @@ -1,23 +1,23 @@ ## Getting the code -Links to all code packs are available on https://dl.openfoam.com. For OpenFOAM-v2206: +Links to all code packs are available on https://dl.openfoam.com. For OpenFOAM-v2212: - https://dl.openfoam.com/source/latest/ -- Source: https://dl.openfoam.com/source/v2206/OpenFOAM-v2206.tgz -- ThirdParty: https://dl.openfoam.com/source/v2206/ThirdParty-v2206.tgz +- Source: https://dl.openfoam.com/source/v2212/OpenFOAM-v2212.tgz +- ThirdParty: https://dl.openfoam.com/source/v2212/ThirdParty-v2212.tgz ## OpenFOAM® Quick Build Guide Prior to building, ensure that the [system requirements][link openfoam-require] are satisfied (including any special [cross-compiling][wiki-cross-compile] considerations), and source the correct OpenFOAM environment. -For example, for the OpenFOAM-v2206 version: +For example, for the OpenFOAM-v2212 version: ``` -source /OpenFOAM-v2206/etc/bashrc +source /OpenFOAM-v2212/etc/bashrc ``` e.g. if installed under the `~/openfoam` directory ``` -source ~/openfoam/OpenFOAM-v2206/etc/bashrc +source ~/openfoam/OpenFOAM-v2212/etc/bashrc ``` From f08392010f2c58ceb6684d6fdcd2c7197b795800 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 11 Jan 2023 11:46:09 +0100 Subject: [PATCH 003/348] ENH: label version of neg0(). Add noexcept to sign/pos/neg etc. --- src/OpenFOAM/primitives/Scalar/Scalar.H | 16 +++++------ .../primitives/ints/label/labelSpecific.H | 28 +++++++++++++++---- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.H b/src/OpenFOAM/primitives/Scalar/Scalar.H index dc5361f9bb..7e0d0784b9 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.H +++ b/src/OpenFOAM/primitives/Scalar/Scalar.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -233,42 +233,42 @@ inline constexpr Scalar component(const Scalar val, const direction) noexcept //- Return 1 if s is greater_equal zero, or otherwise -1 -inline Scalar sign(const Scalar s) +inline Scalar sign(const Scalar s) noexcept { return (s >= 0)? 1: -1; } //- Return 1 if s is greater than zero, otherwise 1 -inline Scalar pos(const Scalar s) +inline Scalar pos(const Scalar s) noexcept { return (s > 0)? 1: 0; } //- Return 1 if s is greater_equal zero, or otherwise 0 -inline Scalar pos0(const Scalar s) +inline Scalar pos0(const Scalar s) noexcept { return (s >= 0)? 1: 0; } //- Return 1 if s is less than zero, or otherwise 0 -inline Scalar neg(const Scalar s) +inline Scalar neg(const Scalar s) noexcept { return (s < 0)? 1: 0; } //- Return 1 if s is less_equal zero, or otherwise 0 -inline Scalar neg0(const Scalar s) +inline Scalar neg0(const Scalar s) noexcept { return (s <= 0)? 1: 0; } //- Return the positive part of s, otherwise zero. Same as max(0, s). -inline Scalar posPart(const Scalar s) +inline Scalar posPart(const Scalar s) noexcept { return (s > 0)? s: 0; } @@ -276,7 +276,7 @@ inline Scalar posPart(const Scalar s) //- Return the negative part of s, otherwise zero. Same as min(0, s). // Does not change the sign -inline Scalar negPart(const Scalar s) +inline Scalar negPart(const Scalar s) noexcept { return (s < 0)? s: 0; } diff --git a/src/OpenFOAM/primitives/ints/label/labelSpecific.H b/src/OpenFOAM/primitives/ints/label/labelSpecific.H index 4f63951f6b..dc24d4c21e 100644 --- a/src/OpenFOAM/primitives/ints/label/labelSpecific.H +++ b/src/OpenFOAM/primitives/ints/label/labelSpecific.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,27 +39,44 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inline label sign(const label s) +//- Return 1 if s is greater_equal zero, or otherwise -1 +inline label sign(const label s) noexcept { return (s >= 0)? 1: -1; } -inline label pos0(const label s) + +//- Return 1 if s is greater_equal zero, or otherwise 0 +inline label pos0(const label s) noexcept { return (s >= 0)? 1: 0; } -inline label neg(const label s) + +//- Return 1 if s is less than zero, or otherwise 0 +inline label neg(const label s) noexcept { return (s < 0)? 1: 0; } -inline label posPart(const label s) + +//- Return 1 if s is less_equal zero, or otherwise 0 +inline label neg0(const label s) noexcept +{ + return (s <= 0)? 1: 0; +} + + +//- Return the positive part of s, otherwise zero. Same as max(0, s). +inline label posPart(const label s) noexcept { return (s > 0)? s: 0; } -inline label negPart(const label s) + +//- Return the negative part of s, otherwise zero. Same as min(0, s). +// Does not change the sign +inline label negPart(const label s) noexcept { return (s < 0)? s: 0; } From 33c9df77414fbcbacd10197fba2ff44cc79da773 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 11 Jan 2023 08:58:38 +0100 Subject: [PATCH 004/348] ENH: construct DynamicField, DynamicList from subset of elements STYLE: inline some size(), empty() members --- .../containers/Bits/PackedList/PackedList.H | 10 ++--- .../containers/Bits/PackedList/PackedListI.H | 14 ------- .../HashTables/HashTable/HashTable.H | 10 ++--- .../HashTables/HashTable/HashTableCore.H | 2 +- .../HashTables/HashTable/HashTableI.H | 21 ---------- .../BiIndirectList/BiIndirectList.H | 6 +-- .../IndirectLists/IndirectList/IndirectList.H | 2 +- .../IndirectListBase/IndirectListBase.H | 6 +-- .../IndirectLists/IndirectListsFwd.H | 4 +- .../linkTypes/DLListBase/DLListBase.H | 8 ++-- .../linkTypes/DLListBase/DLListBaseI.H | 12 ------ .../linkTypes/SLListBase/SLListBase.H | 8 ++-- .../linkTypes/SLListBase/SLListBaseI.H | 12 ------ .../Lists/DynamicList/DynamicList.H | 9 ++-- .../Lists/DynamicList/DynamicListI.H | 42 ++++++++++++------- src/OpenFOAM/containers/Lists/List/List.H | 2 +- src/OpenFOAM/containers/Lists/List/SubList.H | 2 +- src/OpenFOAM/containers/Lists/List/UList.H | 9 ++-- src/OpenFOAM/containers/Lists/List/UListI.H | 14 ------- .../PtrLists/PtrDynList/PtrDynListI.H | 8 ++-- .../containers/PtrLists/UPtrList/UPtrList.H | 6 +-- .../containers/PtrLists/UPtrList/UPtrListI.H | 8 ++-- .../fields/Fields/DynamicField/DynamicField.H | 26 +++++++----- .../Fields/DynamicField/DynamicFieldI.H | 33 ++++++++++----- src/OpenFOAM/fields/Fields/Field/Field.H | 12 ++++-- 25 files changed, 124 insertions(+), 162 deletions(-) diff --git a/src/OpenFOAM/containers/Bits/PackedList/PackedList.H b/src/OpenFOAM/containers/Bits/PackedList/PackedList.H index 14150bc832..872911dfe6 100644 --- a/src/OpenFOAM/containers/Bits/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Bits/PackedList/PackedList.H @@ -283,13 +283,13 @@ public: //- Check index is within valid range [0,size) inline void checkIndex(const label i) const; - //- Number of entries. - inline label size() const noexcept; - //- True if the list is empty (ie, size() is zero). - inline bool empty() const noexcept; + bool empty() const noexcept { return !size_; } - //- The number of elements that can be stored with reallocating + //- Number of entries. + label size() const noexcept { return size_; } + + //- Number of elements that can be stored without reallocating inline label capacity() const noexcept; //- True if all entries have identical values, and list is non-empty diff --git a/src/OpenFOAM/containers/Bits/PackedList/PackedListI.H b/src/OpenFOAM/containers/Bits/PackedList/PackedListI.H index d4db13d316..216ea59b7d 100644 --- a/src/OpenFOAM/containers/Bits/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Bits/PackedList/PackedListI.H @@ -373,20 +373,6 @@ inline void Foam::PackedList::checkIndex(const label i) const } -template -inline Foam::label Foam::PackedList::size() const noexcept -{ - return size_; -} - - -template -inline bool Foam::PackedList::empty() const noexcept -{ - return !size_; -} - - template inline Foam::label Foam::PackedList::capacity() const noexcept { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 2e4549e471..d46dd8eae6 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -257,14 +257,14 @@ public: // Access - //- The size of the underlying table - inline label capacity() const noexcept; + //- True if the hash table is empty + bool empty() const noexcept { return !size_; } //- The number of elements in table - inline label size() const noexcept; + label size() const noexcept { return size_; } - //- True if the hash table is empty - inline bool empty() const noexcept; + //- The size of the underlying table + label capacity() const noexcept { return capacity_; } //- Find and return a hashed entry. FatalError if it does not exist. inline T& at(const Key& key); diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H index aa5377ad19..b9af32082a 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H @@ -90,8 +90,8 @@ struct HashTableCore //- Construct begin/end pair for table inline const_iterator_pair(const TableType& tbl); - label size() const noexcept { return size_; } bool empty() const noexcept { return !size_; } + label size() const noexcept { return size_; } inline IteratorType begin() const; inline IteratorType cbegin() const; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index ab96a64b94..86fd95a488 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -41,27 +41,6 @@ Foam::HashTable::hashKeyIndex(const Key& key) const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline Foam::label Foam::HashTable::capacity() const noexcept -{ - return capacity_; -} - - -template -inline Foam::label Foam::HashTable::size() const noexcept -{ - return size_; -} - - -template -inline bool Foam::HashTable::empty() const noexcept -{ - return !size_; -} - - template inline T& Foam::HashTable::at(const Key& key) { diff --git a/src/OpenFOAM/containers/IndirectLists/BiIndirectList/BiIndirectList.H b/src/OpenFOAM/containers/IndirectLists/BiIndirectList/BiIndirectList.H index cf0331da8d..63d990c571 100644 --- a/src/OpenFOAM/containers/IndirectLists/BiIndirectList/BiIndirectList.H +++ b/src/OpenFOAM/containers/IndirectLists/BiIndirectList/BiIndirectList.H @@ -84,12 +84,12 @@ public: // Access - //- The number of elements in the list - label size() const noexcept { return addr_.size(); } - //- True if the list is empty (ie, size() is zero). bool empty() const noexcept { return addr_.empty(); } + //- The number of elements in the list + label size() const noexcept { return addr_.size(); } + //- The list of positive values (without addressing) const UList& posList() const noexcept { return posList_; } diff --git a/src/OpenFOAM/containers/IndirectLists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/IndirectLists/IndirectList/IndirectList.H index 5e802a6b57..38260ce2f6 100644 --- a/src/OpenFOAM/containers/IndirectLists/IndirectList/IndirectList.H +++ b/src/OpenFOAM/containers/IndirectLists/IndirectList/IndirectList.H @@ -53,8 +53,8 @@ SourceFiles #define Foam_IndirectList_H #include "List.H" -#include "IndirectListBase.H" #include "IndirectListAddressing.H" +#include "IndirectListBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/IndirectLists/IndirectListBase/IndirectListBase.H b/src/OpenFOAM/containers/IndirectLists/IndirectListBase/IndirectListBase.H index de5a183582..16b4d2c81a 100644 --- a/src/OpenFOAM/containers/IndirectLists/IndirectListBase/IndirectListBase.H +++ b/src/OpenFOAM/containers/IndirectLists/IndirectListBase/IndirectListBase.H @@ -122,12 +122,12 @@ public: // Access - //- The number of elements in the list - label size() const noexcept { return addr_.size(); } - //- True if the list is empty (ie, size() is zero). bool empty() const noexcept { return addr_.empty(); } + //- The number of elements in the list + label size() const noexcept { return addr_.size(); } + //- The list of values (without addressing) const UList& values() const noexcept { return values_; } diff --git a/src/OpenFOAM/containers/IndirectLists/IndirectListsFwd.H b/src/OpenFOAM/containers/IndirectLists/IndirectListsFwd.H index 5d09dcc3b6..6ef74db472 100644 --- a/src/OpenFOAM/containers/IndirectLists/IndirectListsFwd.H +++ b/src/OpenFOAM/containers/IndirectLists/IndirectListsFwd.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef IndirectListsFwd_H -#define IndirectListsFwd_H +#ifndef Foam_IndirectListsFwd_H +#define Foam_IndirectListsFwd_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 87b5925aab..d87622e9c1 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -150,11 +150,11 @@ public: // Member Functions - //- The number of elements in list - inline label size() const noexcept; - //- True if the list is empty - inline bool empty() const noexcept; + bool empty() const noexcept { return !size_; } + + //- The number of elements in list + label size() const noexcept { return size_; } //- Return first entry inline link* front(); diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index c3ec916324..76ebe1979a 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -99,18 +99,6 @@ Foam::DLListBase::crend() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::label Foam::DLListBase::size() const noexcept -{ - return size_; -} - - -inline bool Foam::DLListBase::empty() const noexcept -{ - return !size_; -} - - inline Foam::DLListBase::link* Foam::DLListBase::front() { diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index 841efa8211..b0c6abe7da 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -141,11 +141,11 @@ public: // Member Functions - //- The number of elements in list - inline label size() const noexcept; - //- True if the list is empty - inline bool empty() const noexcept; + bool empty() const noexcept { return !size_; } + + //- The number of elements in list + label size() const noexcept { return size_; } //- Return first entry inline link* front(); diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H index a3fc487667..4cd8d3cf5f 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H @@ -70,18 +70,6 @@ inline IteratorType Foam::SLListBase::iterator_last() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::label Foam::SLListBase::size() const noexcept -{ - return size_; -} - - -inline bool Foam::SLListBase::empty() const noexcept -{ - return !size_; -} - - inline Foam::SLListBase::link* Foam::SLListBase::front() { diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 38b203c18e..ab0a35039e 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,7 +89,7 @@ class DynamicList //- Copy assignment from another list template - inline void assignDynList(const ListType& list); + inline void doAssignDynList(const ListType& list); //- Alter the size of the underlying storage // The 'nocopy' option will not attempt to recover old content @@ -133,6 +133,9 @@ public: // Also constructs from DynamicList with different sizing parameters. inline explicit DynamicList(const UList& lst); + //- Copy construct subset of list + inline DynamicList(const UList& list, const labelUList& indices); + //- Construct from a FixedList template inline explicit DynamicList(const FixedList& lst); @@ -166,7 +169,7 @@ public: static constexpr label min_size() noexcept { return SizeMin; } //- Size of the underlying storage. - inline label capacity() const noexcept; + label capacity() const noexcept { return capacity_; } //- Number of contiguous bytes of the underlying storage. // \note Only meaningful for contiguous data diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index 2d2bc765b4..822bbc803a 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,7 @@ License template template -inline void Foam::DynamicList::assignDynList +inline void Foam::DynamicList::doAssignDynList ( const ListType& list ) @@ -210,6 +210,18 @@ inline Foam::DynamicList::DynamicList {} +template +inline Foam::DynamicList::DynamicList +( + const UList& list, + const labelUList& indices +) +: + List(list, indices), + capacity_(List::size()) +{} + + template template inline Foam::DynamicList::DynamicList @@ -283,13 +295,6 @@ inline Foam::DynamicList::DynamicList // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline Foam::label Foam::DynamicList::capacity() const noexcept -{ - return capacity_; -} - - template inline std::streamsize Foam::DynamicList::capacity_bytes() const noexcept @@ -791,7 +796,7 @@ inline void Foam::DynamicList::operator= const UList& lst ) { - assignDynList(lst); + doAssignDynList(lst); } @@ -802,7 +807,7 @@ inline void Foam::DynamicList::operator= const FixedList& lst ) { - assignDynList(lst); + doAssignDynList(lst); } @@ -817,7 +822,7 @@ inline void Foam::DynamicList::operator= return; // Self-assignment is a no-op } - assignDynList(lst); + doAssignDynList(lst); } @@ -837,7 +842,7 @@ inline void Foam::DynamicList::operator= return; // Self-assignment is a no-op } - assignDynList(list); + doAssignDynList(list); } @@ -847,7 +852,7 @@ inline void Foam::DynamicList::operator= std::initializer_list lst ) { - assignDynList(lst); + doAssignDynList(lst); } @@ -858,7 +863,14 @@ inline void Foam::DynamicList::operator= const IndirectListBase& lst ) { - assignDynList(lst); + // NOTE: Self-assignment needs special handling + /// if + /// ( + /// static_cast*>(this) + /// == static_cast*>(&list.values()) + /// ) + + doAssignDynList(lst); } diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index acd6a3e311..4539f2e815 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/src/OpenFOAM/containers/Lists/List/SubList.H b/src/OpenFOAM/containers/Lists/List/SubList.H index d393db4a89..addd12055d 100644 --- a/src/OpenFOAM/containers/Lists/List/SubList.H +++ b/src/OpenFOAM/containers/Lists/List/SubList.H @@ -159,7 +159,7 @@ public: #include "SubListI.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Implementations * * * * * * * * * * * * * * // template Foam::SubList diff --git a/src/OpenFOAM/containers/Lists/List/UList.H b/src/OpenFOAM/containers/Lists/List/UList.H index a2a7ed77c8..eecbb82904 100644 --- a/src/OpenFOAM/containers/Lists/List/UList.H +++ b/src/OpenFOAM/containers/Lists/List/UList.H @@ -74,6 +74,7 @@ template class List; template class SubList; template class UList; template class IndirectList; +template class UIndirectList; template class IndirectListBase; template Istream& operator>>(Istream&, UList&); @@ -448,11 +449,11 @@ public: // STL member functions - //- The number of elements in the UList - inline label size() const noexcept; + //- True if List is empty (ie, size() is zero) + bool empty() const noexcept { return !size_; } - //- True if the UList is empty (ie, size() is zero) - inline bool empty() const noexcept; + //- The number of elements in the List + label size() const noexcept { return size_; } //- The size of the largest possible UList static constexpr label max_size() noexcept { return labelMax; } diff --git a/src/OpenFOAM/containers/Lists/List/UListI.H b/src/OpenFOAM/containers/Lists/List/UListI.H index 4c91bbe336..053109c50e 100644 --- a/src/OpenFOAM/containers/Lists/List/UListI.H +++ b/src/OpenFOAM/containers/Lists/List/UListI.H @@ -416,20 +416,6 @@ inline void Foam::UList::setAddressableSize(const label n) noexcept } -template -inline Foam::label Foam::UList::size() const noexcept -{ - return size_; -} - - -template -inline bool Foam::UList::empty() const noexcept -{ - return !size_; -} - - template inline void Foam::UList::swap(UList& list) { diff --git a/src/OpenFOAM/containers/PtrLists/PtrDynList/PtrDynListI.H b/src/OpenFOAM/containers/PtrLists/PtrDynList/PtrDynListI.H index e635e2ea44..746b9c2b86 100644 --- a/src/OpenFOAM/containers/PtrLists/PtrDynList/PtrDynListI.H +++ b/src/OpenFOAM/containers/PtrLists/PtrDynList/PtrDynListI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,10 +42,10 @@ inline constexpr Foam::PtrDynList::PtrDynList() noexcept template inline Foam::PtrDynList::PtrDynList(const label len) : - PtrList(len), - capacity_(len) + PtrList(), + capacity_(0) { - PtrList::setAddressableSize(0); + reserve(len); } diff --git a/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H index 88bf25242c..b546ac0541 100644 --- a/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H +++ b/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H @@ -211,12 +211,12 @@ public: // Access - //- The number of elements in the list - inline label size() const noexcept; - //- True if the list is empty (ie, size() is zero) inline bool empty() const noexcept; + //- The number of elements in the list + inline label size() const noexcept; + //- Reference to the first element of the list inline T& front(); diff --git a/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H b/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H index 781b26cc0d..d0c29ba2c1 100644 --- a/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H +++ b/src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H @@ -103,16 +103,16 @@ inline Foam::UPtrList::UPtrList(UList& list) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline Foam::label Foam::UPtrList::size() const noexcept +inline bool Foam::UPtrList::empty() const noexcept { - return ptrs_.size(); + return ptrs_.empty(); } template -inline bool Foam::UPtrList::empty() const noexcept +inline Foam::label Foam::UPtrList::size() const noexcept { - return ptrs_.empty(); + return ptrs_.size(); } diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H index 8f10988ccf..3c62700783 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,7 +76,7 @@ class DynamicField //- Copy assignment from another list template - inline void assignDynList(const ListType& list); + inline void doAssignDynList(const ListType& list); //- Alter the size of the underlying storage // The 'nocopy' option will not attempt to recover old content @@ -178,21 +178,18 @@ public: // Member Functions - // Access + // Sizing //- Normal lower capacity limit - the SizeMin template parameter static constexpr label min_size() noexcept { return SizeMin; } //- Size of the underlying storage. - inline label capacity() const noexcept; + label capacity() const noexcept { return capacity_; } //- Number of contiguous bytes of the underlying storage. // \note Only meaningful for contiguous data inline std::streamsize capacity_bytes() const noexcept; - - // Sizing - //- Alter the size of the underlying storage. // The addressed size will be truncated if needed to fit, but will // remain otherwise untouched. @@ -305,10 +302,7 @@ public: inline Istream& readList(Istream& is); - // Member Operators - - //- Return non-const access to an element, resizing list if needed - inline T& operator()(const label i); + // Assignment //- Assign addressed entries to the given value inline void operator=(const T& val); @@ -322,6 +316,10 @@ public: //- Copy assignment inline void operator=(const DynamicField& list); + //- Copy assign from IndirectList + template + inline void operator=(const IndirectListBase& rhs); + //- Move assignment inline void operator=(List&& list); @@ -337,6 +335,12 @@ public: inline void operator=(DynamicField&& list); + // Member Operators + + //- Return non-const access to an element, resizing list if needed + inline T& operator()(const label i); + + // IOstream Operators //- Use the readList() method to read contents from Istream. diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H index e64fe817ee..d7b81fcd9e 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +30,7 @@ License template template -inline void Foam::DynamicField::assignDynList +inline void Foam::DynamicField::doAssignDynList ( const ListType& list ) @@ -323,13 +323,6 @@ Foam::DynamicField::clone() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline Foam::label Foam::DynamicField::capacity() const noexcept -{ - return capacity_; -} - - template inline std::streamsize Foam::DynamicField::capacity_bytes() const noexcept @@ -716,7 +709,7 @@ inline void Foam::DynamicField::operator= const UList& list ) { - assignDynList(list); + doAssignDynList(list); } @@ -731,7 +724,25 @@ inline void Foam::DynamicField::operator= return; // Self-assignment is a no-op } - assignDynList(list); + doAssignDynList(list); +} + + +template +template +inline void Foam::DynamicField::operator= +( + const IndirectListBase& list +) +{ + // NOTE: Self-assignment needs special handling + /// if + /// ( + /// static_cast*>(this) + /// == static_cast*>(&list.values()) + /// ) + + doAssignDynList(list); } diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index 7ab65e03f6..2cbdb712e1 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.H @@ -440,7 +440,7 @@ public: const SubField slice(const labelRange& range) const; - // Member Operators + // Assignment //- Copy assignment void operator=(const Field&); @@ -460,14 +460,18 @@ public: template inline void operator=(DynamicList&& rhs); - - //- Value assignment + //- Assign entries to the given value inline void operator=(const Type& val); + + //- Assign entries to zero inline void operator=(const Foam::zero); template void operator=(const VectorSpace&); + + // Member Operators + void operator+=(const UList&); void operator+=(const tmp>&); @@ -487,7 +491,7 @@ public: void operator/=(const scalar&); - // IOstream operators + // IOstream Operators friend Ostream& operator<< (Ostream&, const Field&); From 248e5ff86fed94b2f419eaa55d81f814fc0bb305 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 9 Jan 2023 20:19:10 +0100 Subject: [PATCH 005/348] ENH: simpler logic for doTransform() check - test pTraits rank first (compile-time) and then parallel() --- .../constraint/cyclic/cyclicPointPatchField.H | 6 +++--- .../constraint/processor/processorPointPatchField.H | 12 ++++++------ .../processorCyclic/processorCyclicPointPatchField.H | 12 ++++++------ .../constraint/cyclic/cyclicFaPatchField.H | 6 +++--- .../constraint/processor/processorFaPatchField.H | 6 +++--- .../constraint/cyclic/cyclicFvPatchField.H | 6 +++--- .../constraint/cyclicACMI/cyclicACMIFvPatchField.C | 2 +- .../constraint/cyclicACMI/cyclicACMIFvPatchField.H | 7 +++---- .../constraint/cyclicAMI/cyclicAMIFvPatchField.C | 2 +- .../constraint/cyclicAMI/cyclicAMIFvPatchField.H | 8 +++----- .../jumpCyclicAMI/jumpCyclicAMIFvPatchField.C | 2 +- .../constraint/processor/processorFvPatchField.H | 8 +++----- .../processorCyclic/processorCyclicFvPatchField.H | 6 +++--- .../cyclicACMIPointPatchField.H | 10 +++------- .../cyclicAMIPointPatchField.H | 10 +++------- 15 files changed, 45 insertions(+), 58 deletions(-) diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H index 6012a219d5..e3c19117c9 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicPointPatchField_H -#define cyclicPointPatchField_H +#ifndef Foam_cyclicPointPatchField_H +#define Foam_cyclicPointPatchField_H #include "coupledPointPatchField.H" #include "cyclicPointPatch.H" @@ -142,7 +142,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return !(cyclicPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !cyclicPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H index 4aeee50e46..6741795e03 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processor/processorPointPatchField.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorPointPatchField_H -#define processorPointPatchField_H +#ifndef Foam_processorPointPatchField_H +#define Foam_processorPointPatchField_H #include "coupledPointPatchField.H" #include "processorPointPatch.H" @@ -145,10 +145,10 @@ public: virtual bool doTransform() const { return - !( - procPatch_.procPolyPatch().parallel() - || pTraits::rank == 0 - ); + ( + pTraits::rank + && !procPatch_.procPolyPatch().parallel() + ); } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H index fc63899af6..25a8ec9f6b 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/processorCyclic/processorCyclicPointPatchField.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorCyclicPointPatchField_H -#define processorCyclicPointPatchField_H +#ifndef Foam_processorCyclicPointPatchField_H +#define Foam_processorCyclicPointPatchField_H #include "coupledPointPatchField.H" #include "processorCyclicPointPatch.H" @@ -149,10 +149,10 @@ public: virtual bool doTransform() const { return - !( - pTraits::rank == 0 - || procPatch_.procPolyPatch().parallel() - ); + ( + pTraits::rank + && !procPatch_.procPolyPatch().parallel() + ); } diff --git a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H index 63da81ed38..5b505bb37b 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.H @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicFaPatchField_H -#define cyclicFaPatchField_H +#ifndef Foam_cyclicFaPatchField_H +#define Foam_cyclicFaPatchField_H #include "coupledFaPatchField.H" #include "cyclicLduInterfaceField.H" @@ -205,7 +205,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return !(cyclicPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !cyclicPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H index 10d01e42a1..033bf6f5df 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.H @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorFaPatchField_H -#define processorFaPatchField_H +#ifndef Foam_processorFaPatchField_H +#define Foam_processorFaPatchField_H #include "coupledFaPatchField.H" #include "processorLduInterfaceField.H" @@ -254,7 +254,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return !(procPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !procPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H index 33abab3bc7..b2b3595ae5 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H @@ -53,8 +53,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicFvPatchField_H -#define cyclicFvPatchField_H +#ifndef Foam_cyclicFvPatchField_H +#define Foam_cyclicFvPatchField_H #include "coupledFvPatchField.H" #include "cyclicLduInterfaceField.H" @@ -220,7 +220,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return !(cyclicPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !cyclicPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index 9eb8e6169f..b796999044 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -183,7 +183,7 @@ Foam::cyclicACMIFvPatchField::patchNeighbourField() const if (doTransform()) { - tpnf.ref() = transform(forwardT(), tpnf()); + transform(tpnf.ref(), forwardT(), tpnf()); } return tpnf; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H index da1097b06c..a3664e5937 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -52,8 +52,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicACMIFvPatchField_H -#define cyclicACMIFvPatchField_H +#ifndef Foam_cyclicACMIFvPatchField_H +#define Foam_cyclicACMIFvPatchField_H #include "coupledFvPatchField.H" #include "cyclicACMILduInterfaceField.H" @@ -255,8 +255,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return - !(cyclicACMIPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !cyclicACMIPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index fb0b880cfc..61a7e49820 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -168,7 +168,7 @@ Foam::cyclicAMIFvPatchField::patchNeighbourField() const if (doTransform()) { - tpnf.ref() = transform(forwardT(), tpnf()); + transform(tpnf.ref(), forwardT(), tpnf()); } return tpnf; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H index 08ddce2aa7..44efff7915 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H @@ -57,9 +57,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicAMIFvPatchField_H -#define cyclicAMIFvPatchField_H - +#ifndef Foam_cyclicAMIFvPatchField_H +#define Foam_cyclicAMIFvPatchField_H #include "coupledFvPatchField.H" #include "cyclicAMILduInterfaceField.H" @@ -242,8 +241,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return - !(cyclicAMIPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !cyclicAMIPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C index f96eaa1468..dcd345fc87 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C @@ -120,7 +120,7 @@ Foam::jumpCyclicAMIFvPatchField::patchNeighbourField() const if (this->doTransform()) { - tpnf = transform(this->forwardT(), tpnf); + transform(tpnf.ref(), this->forwardT(), tpnf()); } tmp> tjf = jump(); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H index 029683e8bb..ffa43402c6 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H @@ -47,8 +47,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorFvPatchField_H -#define processorFvPatchField_H +#ifndef Foam_processorFvPatchField_H +#define Foam_processorFvPatchField_H #include "coupledFvPatchField.H" #include "processorLduInterfaceField.H" @@ -251,7 +251,6 @@ public: const scalarField& coeffs, const Pstream::commsTypes commsType ) const; - //- Processor coupled interface functions @@ -277,7 +276,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return !(procPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !procPatch_.parallel()); } //- Return face transformation tensor @@ -291,7 +290,6 @@ public: { return pTraits::rank; } - }; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H index b823d574d6..f8068ac40a 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H @@ -53,8 +53,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorCyclicFvPatchField_H -#define processorCyclicFvPatchField_H +#ifndef Foam_processorCyclicFvPatchField_H +#define Foam_processorCyclicFvPatchField_H #include "processorCyclicFvPatch.H" #include "processorFvPatchField.H" @@ -162,7 +162,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return !(procPatch_.parallel() || pTraits::rank == 0); + return (pTraits::rank && !procPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H index 861ff876a4..0c4017cd8d 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicACMIPointPatchField_H -#define cyclicACMIPointPatchField_H +#ifndef Foam_cyclicACMIPointPatchField_H +#define Foam_cyclicACMIPointPatchField_H #include "coupledPointPatchField.H" #include "cyclicACMIPointPatch.H" @@ -189,11 +189,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return - !( - cyclicACMIPatch_.parallel() - || pTraits::rank == 0 - ); + return (pTraits::rank && !cyclicACMIPatch_.parallel()); } //- Return face transformation tensor diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H index 87fbaf5a8e..d3237db8e5 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cyclicAMIPointPatchField_H -#define cyclicAMIPointPatchField_H +#ifndef Foam_cyclicAMIPointPatchField_H +#define Foam_cyclicAMIPointPatchField_H #include "coupledPointPatchField.H" #include "cyclicAMIPointPatch.H" @@ -189,11 +189,7 @@ public: //- Does the patch field perform the transformation virtual bool doTransform() const { - return - !( - cyclicAMIPatch_.parallel() - || pTraits::rank == 0 - ); + return (pTraits::rank && !cyclicAMIPatch_.parallel()); } //- Return face transformation tensor From 06f479fbd4100d4e07649b8ca5ea4ceb2bb534c0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 11 Jan 2023 19:01:31 +0100 Subject: [PATCH 006/348] ENH: improve handling of wait/finished requests - now simply a no-op for out-of-range values (instead of an error), which simplifies the calling code. Previously ========== if (request_ >= 0 && request_ < UPstream::nRequests()) { UPstream::waitRequest(request_); } Updated ======= UPstream::waitRequest(request_); - when 'recycling' freed request indices, ensure they are actually within the currently addressable range - MPI finalization now checks outstanding requests against MPI_REQUEST_NULL to verify that they have been waited or tested on. Previously simply checked against freed request indices ENH: consistent initialisation of send/receive bookkeeping --- src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H | 19 +- .../lduCalculatedProcessorField.C | 88 +++------ .../lduCalculatedProcessorField.H | 18 +- .../processorGAMGInterfaceField.C | 40 ++-- .../processorGAMGInterfaceField.H | 14 +- src/Pstream/dummy/Make/files | 1 + src/Pstream/dummy/UPstream.C | 24 +-- src/Pstream/dummy/UPstreamRequest.C | 43 ++++ src/Pstream/mpi/Make/files | 1 + src/Pstream/mpi/PstreamGlobals.C | 7 +- src/Pstream/mpi/PstreamGlobals.H | 41 ++-- src/Pstream/mpi/UPstream.C | 174 +--------------- src/Pstream/mpi/UPstreamRequest.C | 185 ++++++++++++++++++ .../calculatedProcessorFvPatchField.C | 121 ++++-------- .../calculatedProcessorFvPatchField.H | 19 +- .../processor/processorFvPatchField.C | 172 ++++++---------- .../processor/processorFvPatchField.H | 17 +- .../calculatedProcessorGAMGInterfaceField.C | 40 ++-- .../calculatedProcessorGAMGInterfaceField.H | 16 +- 19 files changed, 473 insertions(+), 567 deletions(-) create mode 100644 src/Pstream/dummy/UPstreamRequest.C create mode 100644 src/Pstream/mpi/UPstreamRequest.C diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H index a5111d019e..ea1b63a7fe 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -447,21 +447,26 @@ public: //- Number of outstanding requests static label nRequests() noexcept; - //- Truncate outstanding requests to given length + //- Truncate outstanding requests to given length, which is + //- expected to be in the range 0 to nRequests. + // A no-op for out-of-range values. static void resetRequests(const label n); //- Wait until all requests (from start onwards) have finished. - // A no-op if parRun() == false + // A no-op if parRun() == false, if there are no pending requests + // or if the start is out-of-range (0 to nRequests) static void waitRequests(const label start = 0); //- Wait until request i has finished. - // A no-op if parRun() == false - // or for placeholder (negative) request indices + // A no-op if parRun() == false, + // there are no pending requests, + // or if the index is out-of-range (0 to nRequests) static void waitRequest(const label i); //- Non-blocking comms: has request i finished? - // A no-op and returns true if parRun() == false - // or for placeholder (negative) request indices + // A no-op and returns true if parRun() == false, + // there are no pending requests, + // or if the index is out-of-range (0 to nRequests) static bool finishedRequest(const label i); static int allocateTag(const char* const msg = nullptr); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C index b72ad7e7b8..0212005b24 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,12 +37,8 @@ Foam::lduCalculatedProcessorField::lduCalculatedProcessorField : LduInterfaceField(interface), procInterface_(refCast(interface)), - sendBuf_(procInterface_.faceCells().size()), - receiveBuf_(procInterface_.faceCells().size()), - scalarSendBuf_(procInterface_.faceCells().size()), - scalarReceiveBuf_(procInterface_.faceCells().size()), - outstandingSendRequest_(-1), - outstandingRecvRequest_(-1) + sendRequest_(-1), + recvRequest_(-1) {} @@ -54,12 +50,8 @@ Foam::lduCalculatedProcessorField::lduCalculatedProcessorField : LduInterfaceField(refCast(ptf)), procInterface_(ptf.procInterface_), - sendBuf_(procInterface_.faceCells().size()), - receiveBuf_(procInterface_.faceCells().size()), - scalarSendBuf_(procInterface_.faceCells().size()), - scalarReceiveBuf_(procInterface_.faceCells().size()), - outstandingSendRequest_(-1), - outstandingRecvRequest_(-1) + sendRequest_(-1), + recvRequest_(-1) {} @@ -68,31 +60,11 @@ Foam::lduCalculatedProcessorField::lduCalculatedProcessorField template bool Foam::lduCalculatedProcessorField::ready() const { - if - ( - this->outstandingSendRequest_ >= 0 - && this->outstandingSendRequest_ < UPstream::nRequests() - ) - { - if (!UPstream::finishedRequest(this->outstandingSendRequest_)) - { - return false; - } - } - this->outstandingSendRequest_ = -1; + if (!UPstream::finishedRequest(this->sendRequest_)) return false; + this->sendRequest_ = -1; - if - ( - this->outstandingRecvRequest_ >= 0 - && this->outstandingRecvRequest_ < UPstream::nRequests() - ) - { - if (!UPstream::finishedRequest(this->outstandingRecvRequest_)) - { - return false; - } - } - this->outstandingRecvRequest_ = -1; + if (!UPstream::finishedRequest(this->recvRequest_)) return false; + this->recvRequest_ = -1; return true; } @@ -111,6 +83,13 @@ void Foam::lduCalculatedProcessorField::initInterfaceMatrixUpdate const Pstream::commsTypes commsType ) const { + if (!this->ready()) + { + FatalErrorInFunction + << "Outstanding request." + << abort(FatalError); + } + // Bypass patchInternalField since uses fvPatch addressing const labelList& fc = lduAddr.patchAddr(patchId); @@ -120,21 +99,12 @@ void Foam::lduCalculatedProcessorField::initInterfaceMatrixUpdate scalarSendBuf_[i] = psiInternal[fc[i]]; } - if (!this->ready()) - { - FatalErrorInFunction - << "On patch " - << " outstanding request." - << abort(FatalError); - } - - scalarReceiveBuf_.setSize(scalarSendBuf_.size()); - outstandingRecvRequest_ = UPstream::nRequests(); + recvRequest_ = UPstream::nRequests(); UIPstream::read ( - Pstream::commsTypes::nonBlocking, + UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), scalarReceiveBuf_.data_bytes(), scalarReceiveBuf_.size_bytes(), @@ -142,11 +112,10 @@ void Foam::lduCalculatedProcessorField::initInterfaceMatrixUpdate procInterface_.comm() ); - outstandingSendRequest_ = UPstream::nRequests(); - + sendRequest_ = UPstream::nRequests(); UOPstream::write ( - Pstream::commsTypes::nonBlocking, + UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), scalarSendBuf_.cdata_bytes(), scalarSendBuf_.size_bytes(), @@ -207,19 +176,12 @@ void Foam::lduCalculatedProcessorField::updateInterfaceMatrix return; } - if - ( - outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < UPstream::nRequests() - ) - { - UPstream::waitRequest(outstandingRecvRequest_); - } - // Recv finished so assume sending finished as well. - outstandingSendRequest_ = -1; - outstandingRecvRequest_ = -1; + // Treat send as finished when recv is done + UPstream::waitRequest(recvRequest_); + recvRequest_ = -1; + sendRequest_ = -1; - // Consume straight from scalarReceiveBuf_. Note use of our own + // Consume straight from receive buffer. Note use of our own // helper to avoid using fvPatch addressing addToInternalField(result, !add, coeffs, scalarReceiveBuf_); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H index 60c188626e..1bb956585a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,8 +42,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef lduCalculatedProcessorField_H -#define lduCalculatedProcessorField_H +#ifndef Foam_lduCalculatedProcessorField_H +#define Foam_lduCalculatedProcessorField_H #include "lduPrimitiveProcessorInterface.H" #include "processorLduInterfaceField.H" @@ -74,6 +74,12 @@ protected: // Sending and receiving + //- Current (non-blocking) send request + mutable label sendRequest_; + + //- Current (non-blocking) recv request + mutable label recvRequest_; + //- Send buffer mutable Field sendBuf_; @@ -86,12 +92,6 @@ protected: //- Scalar receive buffer mutable solveScalarField scalarReceiveBuf_; - //- Outstanding request - mutable label outstandingSendRequest_; - - //- Outstanding request - mutable label outstandingRecvRequest_; - // Protected Member Functions diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C index bcc476d840..9e75568ace 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,10 +61,11 @@ Foam::processorGAMGInterfaceField::processorGAMGInterfaceField GAMGInterfaceField(GAMGCp, fineInterface), procInterface_(refCast(GAMGCp)), doTransform_(false), - rank_(0) + rank_(0), + sendRequest_(-1), + recvRequest_(-1) { - const processorLduInterfaceField& p = - refCast(fineInterface); + const auto& p = refCast(fineInterface); doTransform_ = p.doTransform(); rank_ = p.rank(); @@ -81,7 +82,9 @@ Foam::processorGAMGInterfaceField::processorGAMGInterfaceField GAMGInterfaceField(GAMGCp, doTransform, rank), procInterface_(refCast(GAMGCp)), doTransform_(doTransform), - rank_(rank) + rank_(rank), + sendRequest_(-1), + recvRequest_(-1) {} @@ -109,10 +112,11 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate { // Fast path. scalarReceiveBuf_.setSize(scalarSendBuf_.size()); - outstandingRecvRequest_ = UPstream::nRequests(); + + recvRequest_ = UPstream::nRequests(); UIPstream::read ( - Pstream::commsTypes::nonBlocking, + UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), scalarReceiveBuf_.data_bytes(), scalarReceiveBuf_.size_bytes(), @@ -120,10 +124,10 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate comm() ); - outstandingSendRequest_ = UPstream::nRequests(); + sendRequest_ = UPstream::nRequests(); UOPstream::write ( - Pstream::commsTypes::nonBlocking, + UPstream::commsTypes::nonBlocking, procInterface_.neighbProcNo(), scalarSendBuf_.cdata_bytes(), scalarSendBuf_.size_bytes(), @@ -165,20 +169,12 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix && !Pstream::floatTransfer ) { - // Fast path. - if - ( - outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < UPstream::nRequests() - ) - { - UPstream::waitRequest(outstandingRecvRequest_); - } - // Recv finished so assume sending finished as well. - outstandingSendRequest_ = -1; - outstandingRecvRequest_ = -1; + // Fast path: consume straight from receive buffer - // Consume straight from scalarReceiveBuf_ + // Treat send as finished when recv is done + UPstream::waitRequest(recvRequest_); + recvRequest_ = -1; + sendRequest_ = -1; // Transform according to the transformation tensor transformCoupleField(scalarReceiveBuf_, cmpt); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H index c4f9457427..ee07b013d9 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef processorGAMGInterfaceField_H -#define processorGAMGInterfaceField_H +#ifndef Foam_processorGAMGInterfaceField_H +#define Foam_processorGAMGInterfaceField_H #include "GAMGInterfaceField.H" #include "processorGAMGInterface.H" @@ -70,11 +70,11 @@ class processorGAMGInterfaceField // Sending and receiving - //- Outstanding request - mutable label outstandingSendRequest_; + //- Current (non-blocking) send request + mutable label sendRequest_; - //- Outstanding request - mutable label outstandingRecvRequest_; + //- Current (non-blocking) recv request + mutable label recvRequest_; //- Scalar send buffer mutable solveScalarField scalarSendBuf_; diff --git a/src/Pstream/dummy/Make/files b/src/Pstream/dummy/Make/files index 7ba370e470..d5e68ac408 100644 --- a/src/Pstream/dummy/Make/files +++ b/src/Pstream/dummy/Make/files @@ -3,6 +3,7 @@ UPstreamAllToAll.C UPstreamBroadcast.C UPstreamGatherScatter.C UPstreamReduce.C +UPstreamRequest.C UIPstreamRead.C UOPstreamWrite.C diff --git a/src/Pstream/dummy/UPstream.C b/src/Pstream/dummy/UPstream.C index a586c1ef1a..db934c00e3 100644 --- a/src/Pstream/dummy/UPstream.C +++ b/src/Pstream/dummy/UPstream.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +26,7 @@ License \*---------------------------------------------------------------------------*/ -#include "Pstream.H" +#include "UPstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -87,28 +87,12 @@ void Foam::UPstream::freePstreamCommunicator(const label) {} -Foam::label Foam::UPstream::nRequests() noexcept -{ - return 0; -} +int Foam::UPstream::allocateTag(const char* const msg) { return 0; } -void Foam::UPstream::resetRequests(const label n) +void Foam::UPstream::freeTag(const int tag, const char* const msg) {} -void Foam::UPstream::waitRequests(const label start) -{} - - -void Foam::UPstream::waitRequest(const label i) -{} - - -bool Foam::UPstream::finishedRequest(const label i) -{ - return true; -} - // ************************************************************************* // diff --git a/src/Pstream/dummy/UPstreamRequest.C b/src/Pstream/dummy/UPstreamRequest.C new file mode 100644 index 0000000000..ab104e0b3e --- /dev/null +++ b/src/Pstream/dummy/UPstreamRequest.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 . + +\*---------------------------------------------------------------------------*/ + +#include "UPstream.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::label Foam::UPstream::nRequests() noexcept { return 0; } + +void Foam::UPstream::resetRequests(const label n) {} + +void Foam::UPstream::waitRequests(const label start) {} + +void Foam::UPstream::waitRequest(const label i) {} + +bool Foam::UPstream::finishedRequest(const label i) { return true; } + + +// ************************************************************************* // diff --git a/src/Pstream/mpi/Make/files b/src/Pstream/mpi/Make/files index 217347cc29..48a99bac40 100644 --- a/src/Pstream/mpi/Make/files +++ b/src/Pstream/mpi/Make/files @@ -4,6 +4,7 @@ UPstreamAllToAll.C UPstreamBroadcast.C UPstreamGatherScatter.C UPstreamReduce.C +UPstreamRequest.C UIPstreamRead.C UOPstreamWrite.C diff --git a/src/Pstream/mpi/PstreamGlobals.C b/src/Pstream/mpi/PstreamGlobals.C index f6b09aa4cd..2d6e65aa10 100644 --- a/src/Pstream/mpi/PstreamGlobals.C +++ b/src/Pstream/mpi/PstreamGlobals.C @@ -29,16 +29,15 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +Foam::DynamicList Foam::PstreamGlobals::MPICommunicators_; +Foam::DynamicList Foam::PstreamGlobals::MPIGroups_; + Foam::DynamicList Foam::PstreamGlobals::outstandingRequests_; Foam::DynamicList Foam::PstreamGlobals::freedRequests_; int Foam::PstreamGlobals::nTags_ = 0; - Foam::DynamicList Foam::PstreamGlobals::freedTags_; -Foam::DynamicList Foam::PstreamGlobals::MPICommunicators_; -Foam::DynamicList Foam::PstreamGlobals::MPIGroups_; - // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // diff --git a/src/Pstream/mpi/PstreamGlobals.H b/src/Pstream/mpi/PstreamGlobals.H index 33287c6c9a..859d0aa64b 100644 --- a/src/Pstream/mpi/PstreamGlobals.H +++ b/src/Pstream/mpi/PstreamGlobals.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,6 +49,13 @@ namespace Foam namespace PstreamGlobals { +// Current communicators, which may be allocated or predefined +// (eg, MPI_COMM_SELF, MPI_COMM_WORLD) +extern DynamicList MPICommunicators_; + +// Groups associated with the currrent communicators. +extern DynamicList MPIGroups_; + //- Outstanding non-blocking operations. extern DynamicList outstandingRequests_; extern DynamicList