mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-indirect-lists' into 'develop'
Feature indirect lists See merge request Development/OpenFOAM-plus!253
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2010-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2010-2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011 OpenFOAM Foundation
|
| Copyright (C) 2011 OpenFOAM Foundation
|
||||||
@ -27,19 +27,21 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IndirectList.H"
|
#include "argList.H"
|
||||||
#include "IOstreams.H"
|
|
||||||
#include "Fstream.H"
|
#include "Fstream.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
|
#include "IndirectList.H"
|
||||||
#include "labelIndList.H"
|
#include "labelIndList.H"
|
||||||
#include "argList.H"
|
#include "SortList.H"
|
||||||
|
#include "Random.H"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
template<class ListType>
|
template<class ListType>
|
||||||
void printInfo(const ListType& lst)
|
void printInfo(const ListType& lst)
|
||||||
{
|
{
|
||||||
Info<< "full: " << flatOutput(lst.completeList()) << nl
|
Info<< "full: " << flatOutput(lst.values()) << nl
|
||||||
<< "addr: " << flatOutput(lst.addressing()) << nl
|
<< "addr: " << flatOutput(lst.addressing()) << nl
|
||||||
<< "list: " << flatOutput(lst) << nl
|
<< "list: " << flatOutput(lst) << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -103,7 +105,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
inplaceReverseList(addresses);
|
inplaceReverseList(addresses);
|
||||||
|
|
||||||
idl1.resetAddressing(std::move(addresses));
|
idl1.addressing() = std::move(addresses);
|
||||||
|
|
||||||
printInfo(idl1);
|
printInfo(idl1);
|
||||||
|
|
||||||
@ -114,10 +116,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
printInfo(uidl1);
|
printInfo(uidl1);
|
||||||
|
|
||||||
idl1.resetAddressing(List<label>());
|
idl1.addressing().clear();
|
||||||
// idl2.resetAddressing(List<label>());
|
// idl2.addressing().clear();
|
||||||
|
|
||||||
Info<<"after resetAddressing:" << nl << endl;
|
Info<<"after reset addressing:" << nl << endl;
|
||||||
|
|
||||||
printInfo(uidl1);
|
printInfo(uidl1);
|
||||||
printInfo(idl1);
|
printInfo(idl1);
|
||||||
@ -140,7 +142,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Pout<< "full: " << flatOutput(idl3.completeList()) << nl
|
Pout<< "full: " << flatOutput(idl3.values()) << nl
|
||||||
<< "send: " << flatOutput(idl3) << endl;
|
<< "send: " << flatOutput(idl3) << endl;
|
||||||
|
|
||||||
for
|
for
|
||||||
@ -173,6 +175,61 @@ int main(int argc, char *argv[])
|
|||||||
Pstream::scatter(barrier);
|
Pstream::scatter(barrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SortList
|
||||||
|
{
|
||||||
|
List<scalar> list1(20);
|
||||||
|
|
||||||
|
Random rnd(1234);
|
||||||
|
|
||||||
|
for (scalar& val : list1)
|
||||||
|
{
|
||||||
|
val = 100 * rnd.sample01<scalar>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pick out 1/2 the values and make the negative
|
||||||
|
for (label i=0; i < list1.size()/2; ++i)
|
||||||
|
{
|
||||||
|
label pos = rnd.position(0, list1.size()-1);
|
||||||
|
list1[pos] = -list1[pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << "Random list: " << flatOutput(list1) << nl;
|
||||||
|
|
||||||
|
SortList<scalar> sorter1(list1);
|
||||||
|
|
||||||
|
Info<< nl << "Sort indices: " << flatOutput(sorter1.indices()) << nl;
|
||||||
|
|
||||||
|
Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl;
|
||||||
|
|
||||||
|
sorter1.reverse();
|
||||||
|
|
||||||
|
Info<< nl << "Again indices: " << flatOutput(sorter1.indices()) << nl;
|
||||||
|
|
||||||
|
sorter1.reverseSort();
|
||||||
|
|
||||||
|
Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl;
|
||||||
|
|
||||||
|
Info<< nl << "Sorted : " << flatOutput(sorter1) << nl;
|
||||||
|
|
||||||
|
sorter1.sort(std::greater<scalar>());
|
||||||
|
|
||||||
|
SortList<scalar> sorter2(list1, std::greater<scalar>());
|
||||||
|
|
||||||
|
sorter2.reverse();
|
||||||
|
|
||||||
|
Info<< "sorted: ";
|
||||||
|
for (const auto& val : sorter2)
|
||||||
|
{
|
||||||
|
Info<< ' ' << val;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
|
||||||
|
|
||||||
|
sorter2.sort([](scalar a, scalar b) { return mag(a) < mag(b); });
|
||||||
|
|
||||||
|
Info<< nl << "Mag sorted: " << flatOutput(sorter2) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -29,6 +29,9 @@ Description
|
|||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "sliceRange.H"
|
#include "sliceRange.H"
|
||||||
|
#include "SliceList.H"
|
||||||
|
#include "IndirectList.H"
|
||||||
|
#include "Random.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -128,9 +131,60 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sliced lists
|
||||||
|
{
|
||||||
|
List<scalar> list1(100);
|
||||||
|
|
||||||
|
Random rnd(1234);
|
||||||
|
|
||||||
|
for (scalar& val : list1)
|
||||||
|
{
|
||||||
|
val = 100 * rnd.sample01<scalar>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << "Random list: " << flatOutput(list1) << nl;
|
||||||
|
|
||||||
|
SliceList<scalar> slice1(list1, sliceRange(0, 15, 3));
|
||||||
|
|
||||||
|
Info<< nl << "slicing with: " << slice1.addressing() << nl;
|
||||||
|
|
||||||
|
Info<< nl << "Sliced list: " << flatOutput(slice1) << nl;
|
||||||
|
|
||||||
|
for (scalar& val : slice1)
|
||||||
|
{
|
||||||
|
val = -val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Changed list via slice:
|
||||||
|
Info<< nl << "Changed via slice: " << flatOutput(list1) << nl;
|
||||||
|
|
||||||
|
// Some indirect list
|
||||||
|
|
||||||
|
IndirectList<scalar> indlist
|
||||||
|
(
|
||||||
|
list1,
|
||||||
|
identity(slice1.size(), list1.size()-slice1.size())
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< nl << "Indirect slice: " << flatOutput(indlist) << nl;
|
||||||
|
|
||||||
|
indlist = 1000;
|
||||||
|
Info<< nl << "zeroed slice: " << flatOutput(indlist) << nl;
|
||||||
|
|
||||||
|
slice1 = indlist;
|
||||||
|
|
||||||
|
Info<< nl << "self-copy: " << flatOutput(list1) << nl;
|
||||||
|
|
||||||
|
slice1 = 100000;
|
||||||
|
|
||||||
|
Info<< nl << "set values: " << flatOutput(slice1) << nl
|
||||||
|
<< " = " << flatOutput(list1) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011 OpenFOAM Foundation
|
| Copyright (C) 2011 OpenFOAM Foundation
|
||||||
@ -67,6 +67,10 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "reverse ..." << nl;
|
Info<< "reverse ..." << nl;
|
||||||
printInfo(list1r);
|
printInfo(list1r);
|
||||||
|
|
||||||
|
list1r.partialSort(list1r.size()/2);
|
||||||
|
Info<< "partial sorted ..." << nl;
|
||||||
|
printInfo(list1r);
|
||||||
|
|
||||||
SortableList<label> list2(orig);
|
SortableList<label> list2(orig);
|
||||||
Info<< "unsorted: " << orig << nl;
|
Info<< "unsorted: " << orig << nl;
|
||||||
printInfo(list2);
|
printInfo(list2);
|
||||||
|
|||||||
@ -47,10 +47,11 @@ Foam::PackedList<Width>::PackedList
|
|||||||
|
|
||||||
|
|
||||||
template<unsigned Width>
|
template<unsigned Width>
|
||||||
|
template<class Addr>
|
||||||
Foam::PackedList<Width>::PackedList
|
Foam::PackedList<Width>::PackedList
|
||||||
(
|
(
|
||||||
const PackedList<Width>& list,
|
const PackedList<Width>& list,
|
||||||
const labelUIndList& addr
|
const IndirectListBase<label, Addr>& addr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
PackedList<Width>(addr.size())
|
PackedList<Width>(addr.size())
|
||||||
|
|||||||
@ -93,7 +93,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "BitOps.H"
|
#include "BitOps.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "UIndirectList.H"
|
#include "IndirectListBase.H"
|
||||||
#include "InfoProxy.H"
|
#include "InfoProxy.H"
|
||||||
#include "PackedListCore.H"
|
#include "PackedListCore.H"
|
||||||
|
|
||||||
@ -252,7 +252,12 @@ public:
|
|||||||
PackedList(const PackedList<Width>& list, const labelUList& addr);
|
PackedList(const PackedList<Width>& list, const labelUList& addr);
|
||||||
|
|
||||||
//- Copy construct a subset
|
//- Copy construct a subset
|
||||||
PackedList(const PackedList<Width>& list, const labelUIndList& addr);
|
template<class Addr>
|
||||||
|
PackedList
|
||||||
|
(
|
||||||
|
const PackedList<Width>& list,
|
||||||
|
const IndirectListBase<label, Addr>& addr
|
||||||
|
);
|
||||||
|
|
||||||
//- Copy construct a subset range
|
//- Copy construct a subset range
|
||||||
PackedList(const PackedList<Width>& list, const labelRange& range);
|
PackedList(const PackedList<Width>& list, const labelRange& range);
|
||||||
@ -260,8 +265,9 @@ public:
|
|||||||
//- Construct from a list of values
|
//- Construct from a list of values
|
||||||
inline explicit PackedList(const labelUList& values);
|
inline explicit PackedList(const labelUList& values);
|
||||||
|
|
||||||
//- Construct from a list of values
|
//- Construct from a indirect list of values
|
||||||
inline explicit PackedList(const labelUIndList& values);
|
template<class Addr>
|
||||||
|
inline explicit PackedList(const IndirectListBase<label, Addr>& values);
|
||||||
|
|
||||||
//- Clone
|
//- Clone
|
||||||
inline autoPtr<PackedList<Width>> clone() const;
|
inline autoPtr<PackedList<Width>> clone() const;
|
||||||
|
|||||||
@ -242,7 +242,11 @@ inline Foam::PackedList<Width>::PackedList(const labelUList& values)
|
|||||||
|
|
||||||
|
|
||||||
template<unsigned Width>
|
template<unsigned Width>
|
||||||
inline Foam::PackedList<Width>::PackedList(const labelUIndList& values)
|
template<class Addr>
|
||||||
|
inline Foam::PackedList<Width>::PackedList
|
||||||
|
(
|
||||||
|
const IndirectListBase<label, Addr>& values
|
||||||
|
)
|
||||||
:
|
:
|
||||||
blocks_(num_blocks(values.size()), 0u),
|
blocks_(num_blocks(values.size()), 0u),
|
||||||
size_(values.size())
|
size_(values.size())
|
||||||
|
|||||||
@ -306,19 +306,6 @@ Foam::bitSet::bitSet(const bitSet& bitset, const labelUList& addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::bitSet::bitSet(const bitSet& bitset, const labelUIndList& addr)
|
|
||||||
:
|
|
||||||
bitSet(addr.size())
|
|
||||||
{
|
|
||||||
const label len = addr.size();
|
|
||||||
|
|
||||||
for (label i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
set(i, bitset.get(addr[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::bitSet::bitSet(const bitSet& bitset, const labelRange& range)
|
Foam::bitSet::bitSet(const bitSet& bitset, const labelRange& range)
|
||||||
:
|
:
|
||||||
bitSet(range.size())
|
bitSet(range.size())
|
||||||
|
|||||||
@ -157,7 +157,12 @@ public:
|
|||||||
bitSet(const bitSet& bitset, const labelUList& addr);
|
bitSet(const bitSet& bitset, const labelUList& addr);
|
||||||
|
|
||||||
//- Copy construct a subset
|
//- Copy construct a subset
|
||||||
bitSet(const bitSet& bitset, const labelUIndList& addr);
|
template<class Addr>
|
||||||
|
bitSet
|
||||||
|
(
|
||||||
|
const bitSet& bitset,
|
||||||
|
const IndirectListBase<label, Addr>& addr
|
||||||
|
);
|
||||||
|
|
||||||
//- Copy construct a subset range
|
//- Copy construct a subset range
|
||||||
bitSet(const bitSet& bitset, const labelRange& range);
|
bitSet(const bitSet& bitset, const labelRange& range);
|
||||||
@ -171,7 +176,12 @@ public:
|
|||||||
|
|
||||||
//- Construct with given size with all bits set to 0,
|
//- Construct with given size with all bits set to 0,
|
||||||
//- subsequently add specified locations as 1.
|
//- subsequently add specified locations as 1.
|
||||||
inline bitSet(const label n, const labelUIndList& locations);
|
template<class Addr>
|
||||||
|
bitSet
|
||||||
|
(
|
||||||
|
const label n,
|
||||||
|
const IndirectListBase<label, Addr>& locations
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct with given size with all bits set to 0,
|
//- Construct with given size with all bits set to 0,
|
||||||
//- subsequently add specified locations as 1.
|
//- subsequently add specified locations as 1.
|
||||||
@ -188,7 +198,8 @@ public:
|
|||||||
|
|
||||||
//- Construct with automatic sizing (filled with 0),
|
//- Construct with automatic sizing (filled with 0),
|
||||||
//- and populate with specified locations as 1.
|
//- and populate with specified locations as 1.
|
||||||
inline explicit bitSet(const labelUIndList& locations);
|
template<class Addr>
|
||||||
|
inline explicit bitSet(const IndirectListBase<label, Addr>& locations);
|
||||||
|
|
||||||
//- Construct with automatic sizing (filled with 0),
|
//- Construct with automatic sizing (filled with 0),
|
||||||
//- and populate with specified locations as 1.
|
//- and populate with specified locations as 1.
|
||||||
@ -382,7 +393,8 @@ public:
|
|||||||
// Does auto-vivify for non-existent entries.
|
// Does auto-vivify for non-existent entries.
|
||||||
//
|
//
|
||||||
// \return number of locations changed
|
// \return number of locations changed
|
||||||
inline label set(const labelUIndList& locations);
|
template<class Addr>
|
||||||
|
inline label set(const IndirectListBase<label, Addr>& locations);
|
||||||
|
|
||||||
//- Set the listed locations to true.
|
//- Set the listed locations to true.
|
||||||
// Does auto-vivify for non-existent entries.
|
// Does auto-vivify for non-existent entries.
|
||||||
@ -406,7 +418,8 @@ public:
|
|||||||
//- Unset the listed locations, never auto-vivifies.
|
//- Unset the listed locations, never auto-vivifies.
|
||||||
//
|
//
|
||||||
// \return number of locations changed
|
// \return number of locations changed
|
||||||
inline label unset(const labelUIndList& locations);
|
template<class Addr>
|
||||||
|
inline label unset(const IndirectListBase<label, Addr>& locations);
|
||||||
|
|
||||||
//- Unset the listed locations, never auto-vivifies.
|
//- Unset the listed locations, never auto-vivifies.
|
||||||
//
|
//
|
||||||
|
|||||||
@ -120,7 +120,12 @@ inline Foam::bitSet::bitSet(const label n, const labelUList& locations)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::bitSet::bitSet(const label n, const labelUIndList& locations)
|
template<class Addr>
|
||||||
|
inline Foam::bitSet::bitSet
|
||||||
|
(
|
||||||
|
const label n,
|
||||||
|
const IndirectListBase<label, Addr>& locations
|
||||||
|
)
|
||||||
:
|
:
|
||||||
bitSet(n)
|
bitSet(n)
|
||||||
{
|
{
|
||||||
@ -148,7 +153,11 @@ inline Foam::bitSet::bitSet(const labelUList& locations)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::bitSet::bitSet(const labelUIndList& locations)
|
template<class Addr>
|
||||||
|
inline Foam::bitSet::bitSet
|
||||||
|
(
|
||||||
|
const IndirectListBase<label, Addr>& locations
|
||||||
|
)
|
||||||
:
|
:
|
||||||
bitSet()
|
bitSet()
|
||||||
{
|
{
|
||||||
@ -537,7 +546,11 @@ inline Foam::label Foam::bitSet::set(const labelUList& locations)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::bitSet::set(const labelUIndList& locations)
|
template<class Addr>
|
||||||
|
inline Foam::label Foam::bitSet::set
|
||||||
|
(
|
||||||
|
const IndirectListBase<label, Addr>& locations
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return setMany(locations.begin(), locations.end());
|
return setMany(locations.begin(), locations.end());
|
||||||
}
|
}
|
||||||
@ -549,7 +562,11 @@ inline Foam::label Foam::bitSet::unset(const labelUList& locations)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::bitSet::unset(const labelUIndList& locations)
|
template<class Addr>
|
||||||
|
inline Foam::label Foam::bitSet::unset
|
||||||
|
(
|
||||||
|
const IndirectListBase<label, Addr>& locations
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return unset(locations.begin(), locations.end());
|
return unset(locations.begin(), locations.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -48,6 +48,25 @@ Foam::bitSet::bitSet(const FixedList<label, N>& locations)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Addr>
|
||||||
|
Foam::bitSet::bitSet
|
||||||
|
(
|
||||||
|
const bitSet& bitset,
|
||||||
|
const IndirectListBase<label, Addr>& addr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
bitSet(addr.size())
|
||||||
|
{
|
||||||
|
const label len = addr.size();
|
||||||
|
|
||||||
|
for (label i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
set(i, bitset.get(addr[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class InputIter>
|
template<class InputIter>
|
||||||
|
|||||||
@ -84,7 +84,8 @@ Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& list)
|
|||||||
|
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
Foam::HashSet<Key, Hash>::HashSet(const UIndirectList<Key>& list)
|
template<class Addr>
|
||||||
|
Foam::HashSet<Key, Hash>::HashSet(const IndirectListBase<Key, Addr>& list)
|
||||||
:
|
:
|
||||||
parent_type(2*list.size())
|
parent_type(2*list.size())
|
||||||
{
|
{
|
||||||
@ -177,9 +178,10 @@ inline Foam::label Foam::HashSet<Key, Hash>::insert
|
|||||||
|
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
|
template<class Addr>
|
||||||
inline Foam::label Foam::HashSet<Key, Hash>::insert
|
inline Foam::label Foam::HashSet<Key, Hash>::insert
|
||||||
(
|
(
|
||||||
const UIndirectList<Key>& list
|
const IndirectListBase<Key, Addr>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return insert(list.begin(), list.end());
|
return insert(list.begin(), list.end());
|
||||||
@ -230,9 +232,10 @@ inline Foam::label Foam::HashSet<Key, Hash>::unset
|
|||||||
|
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
|
template<class Addr>
|
||||||
inline Foam::label Foam::HashSet<Key, Hash>::unset
|
inline Foam::label Foam::HashSet<Key, Hash>::unset
|
||||||
(
|
(
|
||||||
const UIndirectList<Key>& list
|
const IndirectListBase<Key, Addr>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return unset(list.begin(), list.end());
|
return unset(list.begin(), list.end());
|
||||||
|
|||||||
@ -65,7 +65,7 @@ Description
|
|||||||
#define HashSet_H
|
#define HashSet_H
|
||||||
|
|
||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
#include "UIndirectList.H"
|
#include "IndirectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -143,7 +143,8 @@ public:
|
|||||||
explicit HashSet(const UList<Key>& list);
|
explicit HashSet(const UList<Key>& list);
|
||||||
|
|
||||||
//- Construct from an indirect list
|
//- Construct from an indirect list
|
||||||
explicit HashSet(const UIndirectList<Key>& list);
|
template<class Addr>
|
||||||
|
explicit HashSet(const IndirectListBase<Key, Addr>& list);
|
||||||
|
|
||||||
//- Construct from an initializer list of Key
|
//- Construct from an initializer list of Key
|
||||||
HashSet(std::initializer_list<Key> list);
|
HashSet(std::initializer_list<Key> list);
|
||||||
@ -222,7 +223,8 @@ public:
|
|||||||
|
|
||||||
//- Insert keys from the list of Key
|
//- Insert keys from the list of Key
|
||||||
// \return The number of new elements inserted
|
// \return The number of new elements inserted
|
||||||
inline label insert(const UIndirectList<Key>& list);
|
template<class Addr>
|
||||||
|
inline label insert(const IndirectListBase<Key, Addr>& list);
|
||||||
|
|
||||||
//- Same as insert (no value to overwrite)
|
//- Same as insert (no value to overwrite)
|
||||||
template<class InputIter>
|
template<class InputIter>
|
||||||
@ -251,7 +253,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Same as insert (no value to overwrite)
|
//- Same as insert (no value to overwrite)
|
||||||
inline label set(const UIndirectList<Key>& list)
|
template<class Addr>
|
||||||
|
inline label set(const IndirectListBase<Key, Addr>& list)
|
||||||
{
|
{
|
||||||
return insert(list);
|
return insert(list);
|
||||||
}
|
}
|
||||||
@ -284,7 +287,8 @@ public:
|
|||||||
|
|
||||||
//- Unset the listed keys - same as erase
|
//- Unset the listed keys - same as erase
|
||||||
// \return The number of items removed
|
// \return The number of items removed
|
||||||
inline label unset(const UIndirectList<Key>& list);
|
template<class Addr>
|
||||||
|
inline label unset(const IndirectListBase<Key, Addr>& list);
|
||||||
|
|
||||||
|
|
||||||
// STL iterators
|
// STL iterators
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2010-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -30,8 +30,7 @@ Description
|
|||||||
A List with indirect addressing.
|
A List with indirect addressing.
|
||||||
|
|
||||||
See also
|
See also
|
||||||
Foam::UIndirectList for a version without any allocation for the
|
Foam::UIndirectList for a version without any addressing allocation.
|
||||||
addressing.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
IndirectListI.H
|
IndirectListI.H
|
||||||
@ -41,6 +40,7 @@ SourceFiles
|
|||||||
#ifndef IndirectList_H
|
#ifndef IndirectList_H
|
||||||
#define IndirectList_H
|
#define IndirectList_H
|
||||||
|
|
||||||
|
#include "IndirectListAddressing.H"
|
||||||
#include "UIndirectList.H"
|
#include "UIndirectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -48,53 +48,6 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class IndirectListAddressing Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
//- A helper class for storing addresses.
|
|
||||||
class IndirectListAddressing
|
|
||||||
{
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- Storage for the list addressing
|
|
||||||
List<label> addressing_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
IndirectListAddressing(const IndirectListAddressing&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const IndirectListAddressing&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Copy construct from addressing array
|
|
||||||
inline explicit IndirectListAddressing(const labelUList& addr);
|
|
||||||
|
|
||||||
//- Move construct from addressing array
|
|
||||||
inline explicit IndirectListAddressing(List<label>&& addr);
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
//- Return the list addressing
|
|
||||||
inline const List<label>& addressing() const;
|
|
||||||
|
|
||||||
//- Copy reset addressing
|
|
||||||
inline void resetAddressing(const labelUList& addr);
|
|
||||||
|
|
||||||
//- Move reset addressing
|
|
||||||
inline void resetAddressing(List<label>&& addr);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class IndirectList Declaration
|
Class IndirectList Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -102,43 +55,30 @@ protected:
|
|||||||
template<class T>
|
template<class T>
|
||||||
class IndirectList
|
class IndirectList
|
||||||
:
|
:
|
||||||
private IndirectListAddressing,
|
private IndirectListAddressing<labelList>,
|
||||||
public UIndirectList<T>
|
public UIndirectList<T>
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const IndirectList<T>&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment from UIndirectList
|
|
||||||
void operator=(const UIndirectList<T>&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Copy construct addressing, shallow copy values list reference.
|
//- Copy construct addressing, shallow copy values list reference
|
||||||
inline IndirectList(const UList<T>& values, const labelUList& addr);
|
inline IndirectList(const UList<T>& values, const labelUList& addr);
|
||||||
|
|
||||||
//- Move construct addressing, shallow copy values list reference.
|
//- Move construct addressing, shallow copy values list reference
|
||||||
inline IndirectList(const UList<T>& values, List<label>&& addr);
|
inline IndirectList(const UList<T>& values, labelList&& addr);
|
||||||
|
|
||||||
//- Copy construct addressing, shallow copy values list reference.
|
//- Copy construct addressing, shallow copy values list reference
|
||||||
inline IndirectList(const IndirectList<T>& list);
|
inline IndirectList(const IndirectList<T>& list);
|
||||||
|
|
||||||
//- Copy construct addressing, shallow copy values list reference
|
//- Copy construct addressing, shallow copy values list reference
|
||||||
//- from UIndirectList
|
|
||||||
inline explicit IndirectList(const UIndirectList<T>& list);
|
inline explicit IndirectList(const UIndirectList<T>& list);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the list addressing
|
//- The list addressing
|
||||||
using UIndirectList<T>::addressing;
|
using IndirectListAddressing::addressing;
|
||||||
|
|
||||||
//- Reset the list addressing
|
|
||||||
using IndirectListAddressing::resetAddressing;
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
@ -146,6 +86,11 @@ public:
|
|||||||
//- Assignment operator
|
//- Assignment operator
|
||||||
using UIndirectList<T>::operator=;
|
using UIndirectList<T>::operator=;
|
||||||
|
|
||||||
|
//- Deep copy values, Fatal if list sizes are not identical
|
||||||
|
void operator=(const IndirectList<T>& rhs)
|
||||||
|
{
|
||||||
|
this->copyList(rhs);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2010, 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -27,24 +27,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::IndirectListAddressing::IndirectListAddressing
|
|
||||||
(
|
|
||||||
const labelUList& addr
|
|
||||||
)
|
|
||||||
:
|
|
||||||
addressing_(addr)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::IndirectListAddressing::IndirectListAddressing
|
|
||||||
(
|
|
||||||
List<label>&& addr
|
|
||||||
)
|
|
||||||
:
|
|
||||||
addressing_(std::move(addr))
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::IndirectList<T>::IndirectList
|
inline Foam::IndirectList<T>::IndirectList
|
||||||
(
|
(
|
||||||
@ -52,11 +34,11 @@ inline Foam::IndirectList<T>::IndirectList
|
|||||||
const labelUList& addr
|
const labelUList& addr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
IndirectListAddressing(addr),
|
IndirectListAddressing<labelList>(addr),
|
||||||
UIndirectList<T>
|
UIndirectList<T>
|
||||||
(
|
(
|
||||||
values,
|
values,
|
||||||
IndirectListAddressing::addressing()
|
IndirectListAddressing<labelList>::addressing()
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -65,73 +47,42 @@ template<class T>
|
|||||||
inline Foam::IndirectList<T>::IndirectList
|
inline Foam::IndirectList<T>::IndirectList
|
||||||
(
|
(
|
||||||
const UList<T>& values,
|
const UList<T>& values,
|
||||||
List<label>&& addr
|
labelList&& addr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
IndirectListAddressing(std::move(addr)),
|
IndirectListAddressing<labelList>(std::move(addr)),
|
||||||
UIndirectList<T>
|
UIndirectList<T>
|
||||||
(
|
(
|
||||||
values,
|
values,
|
||||||
IndirectListAddressing::addressing()
|
IndirectListAddressing<labelList>::addressing()
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::IndirectList<T>::IndirectList
|
inline Foam::IndirectList<T>::IndirectList(const IndirectList<T>& list)
|
||||||
(
|
|
||||||
const IndirectList<T>& list
|
|
||||||
)
|
|
||||||
:
|
:
|
||||||
IndirectListAddressing(list.addressing()), // Copy addressing
|
// Copy addressing
|
||||||
|
IndirectListAddressing<labelList>(list.addressing()),
|
||||||
UIndirectList<T>
|
UIndirectList<T>
|
||||||
(
|
(
|
||||||
list.completeList(),
|
list.values(),
|
||||||
IndirectListAddressing::addressing()
|
IndirectListAddressing<labelList>::addressing()
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::IndirectList<T>::IndirectList
|
inline Foam::IndirectList<T>::IndirectList(const UIndirectList<T>& list)
|
||||||
(
|
|
||||||
const UIndirectList<T>& list
|
|
||||||
)
|
|
||||||
:
|
:
|
||||||
IndirectListAddressing(list.addressing()), // Copy addressing
|
// Copy addressing
|
||||||
|
IndirectListAddressing<labelList>(list.addressing()),
|
||||||
UIndirectList<T>
|
UIndirectList<T>
|
||||||
(
|
(
|
||||||
list.completeList(),
|
list.values(),
|
||||||
IndirectListAddressing::addressing()
|
IndirectListAddressing<labelList>::addressing()
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
inline const Foam::List<Foam::label>&
|
|
||||||
Foam::IndirectListAddressing::addressing() const
|
|
||||||
{
|
|
||||||
return addressing_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::IndirectListAddressing::resetAddressing
|
|
||||||
(
|
|
||||||
const labelUList& addr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
addressing_ = addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::IndirectListAddressing::resetAddressing
|
|
||||||
(
|
|
||||||
List<label>&& addr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
addressing_.transfer(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::IndirectListAddressing
|
||||||
|
|
||||||
|
Description
|
||||||
|
A class for storing list addressing (labels, slices etc) which are
|
||||||
|
normally to used by IndirectList. A private inheritance is often used
|
||||||
|
by any inheriting classes.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
IndirectListAddressing.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef IndirectListAddressing_H
|
||||||
|
#define IndirectListAddressing_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class IndirectListAddressing Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Addr>
|
||||||
|
class IndirectListAddressing
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Storage for addressing
|
||||||
|
Addr storedAddr_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Copy construct from addressing information
|
||||||
|
IndirectListAddressing(const Addr& addr)
|
||||||
|
:
|
||||||
|
storedAddr_(addr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Move construct from addressing information
|
||||||
|
IndirectListAddressing(Addr&& addr)
|
||||||
|
:
|
||||||
|
storedAddr_(std::move(addr))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Const access to the addressing
|
||||||
|
const Addr& addressing() const
|
||||||
|
{
|
||||||
|
return storedAddr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Non-const access to the addressing
|
||||||
|
Addr& addressing()
|
||||||
|
{
|
||||||
|
return storedAddr_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,23 +25,22 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline Foam::label Foam::UIndirectList<T>::find
|
Foam::label Foam::IndirectListBase<T, Addr>::find
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
const label start
|
const label start
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (start >= 0)
|
const label len = addr_.size();
|
||||||
|
|
||||||
|
if (start >= 0 && len)
|
||||||
{
|
{
|
||||||
List_CONST_ACCESS(T, values_, vals);
|
List_CONST_ACCESS(T, values_, vals);
|
||||||
List_CONST_ACCESS(label, addressing_, addr);
|
|
||||||
|
|
||||||
const label len = addressing_.size();
|
|
||||||
|
|
||||||
for (label i = start; i < len; ++i)
|
for (label i = start; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (vals[addr[i]] == val)
|
if (vals[addr_[i]] == val)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -52,29 +51,21 @@ inline Foam::label Foam::UIndirectList<T>::find
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline Foam::label Foam::UIndirectList<T>::rfind
|
Foam::label Foam::IndirectListBase<T, Addr>::rfind
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
const label pos
|
const label pos
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
List_CONST_ACCESS(T, values_, vals);
|
List_CONST_ACCESS(T, values_, vals);
|
||||||
List_CONST_ACCESS(label, addressing_, addr);
|
|
||||||
|
|
||||||
for
|
const label len1 = (addr_.size()-1);
|
||||||
(
|
|
||||||
label i =
|
// pos == -1 has same meaning as std::string::npos - search from end
|
||||||
(
|
for (label i = ((pos >= 0 && pos < len1) ? pos : len1); i >= 0; --i)
|
||||||
pos < 0
|
|
||||||
? (addressing_.size()-1)
|
|
||||||
: min(pos, (addressing_.size()-1))
|
|
||||||
);
|
|
||||||
i >= 0;
|
|
||||||
--i
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (vals[addr[i]] == val)
|
if (vals[addr_[i]] == val)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -24,24 +24,23 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::UIndirectList
|
Foam::IndirectListBase
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A List with indirect addressing.
|
Base for lists with indirect addressing, templated on the list contents
|
||||||
|
type and the addressing type. Storage for both values and addressing
|
||||||
Like IndirectList but does not store addressing.
|
is held outside of the class.
|
||||||
|
|
||||||
Note the const_cast of the list values. This is so we can use it both
|
|
||||||
on const and non-const lists. Alternative would be to have a const_
|
|
||||||
variant etc.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
UIndirectListI.H
|
IndirectListBase.H
|
||||||
|
IndirectListBase.C
|
||||||
|
IndirectListBaseI.H
|
||||||
|
IndirectListBaseIO.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef UIndirectList_H
|
#ifndef IndirectListBase_H
|
||||||
#define UIndirectList_H
|
#define IndirectListBase_H
|
||||||
|
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
|
|
||||||
@ -50,28 +49,34 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
|
||||||
template<class T> class UIndirectList;
|
|
||||||
|
|
||||||
// Common list types
|
|
||||||
typedef UIndirectList<bool> boolUIndList; //!< UIndirectList of bools
|
|
||||||
typedef UIndirectList<label> labelUIndList; //!< UIndirectList of labels
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class UIndirectList Declaration
|
Class IndirectListBase Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
class UIndirectList
|
class IndirectListBase
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
|
//- The list values
|
||||||
UList<T>& values_;
|
UList<T>& values_;
|
||||||
const labelUList& addressing_;
|
|
||||||
|
//- Reference to the addressing for the list values
|
||||||
|
const Addr& addr_;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Copy values The number of elements in the list
|
||||||
|
template<class ListType>
|
||||||
|
inline void copyList(const ListType& rhs);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// STL type definitions
|
// Type definitions (STL)
|
||||||
|
|
||||||
//- Type of values the list contains.
|
//- Type of values the list contains.
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
@ -100,43 +105,79 @@ public:
|
|||||||
//- Forward iterator with const access
|
//- Forward iterator with const access
|
||||||
class const_iterator;
|
class const_iterator;
|
||||||
|
|
||||||
|
//- The addressing type (non-stl definition)
|
||||||
|
typedef Addr addressing_type;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Copy construct from the values list and the addressing array
|
//- No null construct
|
||||||
inline UIndirectList(const UList<T>& values, const labelUList& addr);
|
IndirectListBase() = delete;
|
||||||
|
|
||||||
|
//- Store references to the values list and the addressing array
|
||||||
|
inline IndirectListBase(const UList<T>& values, const Addr& addr);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return the number of elements in the list
|
//- The number of elements in the list
|
||||||
inline label size() const;
|
inline label size() const
|
||||||
|
{
|
||||||
|
return addr_.size();
|
||||||
|
}
|
||||||
|
|
||||||
//- Return true if the list is empty (ie, size() is zero).
|
//- True if the list is empty (ie, size() is zero).
|
||||||
inline bool empty() const;
|
inline bool empty() const
|
||||||
|
{
|
||||||
|
return addr_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
//- True if all entries have identical values, and list is non-empty
|
//- True if all entries have identical values, and list is non-empty
|
||||||
inline bool uniform() const;
|
inline bool uniform() const;
|
||||||
|
|
||||||
//- Return the first element of the list.
|
//- The first element of the list.
|
||||||
inline T& first();
|
inline T& first()
|
||||||
|
{
|
||||||
|
return values_[addr_.first()];
|
||||||
|
}
|
||||||
|
|
||||||
//- Return first element of the list.
|
//- The first element of the list.
|
||||||
inline const T& first() const;
|
inline const T& first() const
|
||||||
|
{
|
||||||
|
return values_[addr_.first()];
|
||||||
|
}
|
||||||
|
|
||||||
//- Return the last element of the list.
|
//- The last element of the list.
|
||||||
inline T& last();
|
inline T& last()
|
||||||
|
{
|
||||||
|
return values_[addr_.last()];
|
||||||
|
}
|
||||||
|
|
||||||
//- Return the last element of the list.
|
//- The last element of the list.
|
||||||
inline const T& last() const;
|
inline const T& last() const
|
||||||
|
{
|
||||||
|
return values_[addr_.last()];
|
||||||
|
}
|
||||||
|
|
||||||
//- Return the complete list of values
|
//- The list of values (without addressing)
|
||||||
inline const UList<T>& completeList() const;
|
inline const UList<T>& values() const
|
||||||
|
{
|
||||||
|
return values_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Return the list addressing
|
//- The list of values (without addressing)
|
||||||
inline const List<label>& addressing() const;
|
inline UList<T>& values()
|
||||||
|
{
|
||||||
|
return values_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The addressing used for the list
|
||||||
|
inline const Addr& addressing() const
|
||||||
|
{
|
||||||
|
return addr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
@ -162,26 +203,39 @@ public:
|
|||||||
//- Return the addressed elements as a List
|
//- Return the addressed elements as a List
|
||||||
inline List<T> operator()() const;
|
inline List<T> operator()() const;
|
||||||
|
|
||||||
//- Return non-const access to an element
|
//- Non-const access to an element in the list
|
||||||
inline T& operator[](const label i);
|
inline T& operator[](const label i);
|
||||||
|
|
||||||
//- Return const access to an element
|
//- Const access to an element in the list
|
||||||
inline const T& operator[](const label i) const;
|
inline const T& operator[](const label i) const;
|
||||||
|
|
||||||
//- Copy assignment from a list of the addressed elements
|
//- Assign all addressed elements to the given value
|
||||||
inline void operator=(const UList<T>& rhs);
|
|
||||||
|
|
||||||
//- Copy assignment from a indirect list of the addressed elements
|
|
||||||
inline void operator=(const UIndirectList<T>& rhs);
|
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
|
||||||
inline void operator=(const T& val);
|
inline void operator=(const T& val);
|
||||||
|
|
||||||
//- An iterator for an indirect list
|
//- Assignment of all entries to zero
|
||||||
|
inline void operator=(const zero);
|
||||||
|
|
||||||
|
//- Deep copy values from a list of the addressed elements
|
||||||
|
// Fatal if list sizes are not identical
|
||||||
|
inline void operator=(const UList<T>& rhs);
|
||||||
|
|
||||||
|
//- Deep copy values from a list of the addressed elements
|
||||||
|
// Fatal if list sizes are not identical
|
||||||
|
inline void operator=(const IndirectListBase<T, Addr>& rhs);
|
||||||
|
|
||||||
|
//- Deep copy values from a list of the addressed elements
|
||||||
|
// Fatal if list sizes are not identical
|
||||||
|
template<class AnyAddr>
|
||||||
|
inline void operator=(const IndirectListBase<T, AnyAddr>& rhs);
|
||||||
|
|
||||||
|
|
||||||
|
// Iterators
|
||||||
|
|
||||||
|
//- A non-const iterator for an indirect list
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
typename UList<T>::pointer data_;
|
typename UList<T>::pointer data_;
|
||||||
labelUList::const_iterator base_;
|
typename addressing_type::const_iterator iter_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -194,32 +248,32 @@ public:
|
|||||||
iterator
|
iterator
|
||||||
(
|
(
|
||||||
UList<T>& list,
|
UList<T>& list,
|
||||||
labelUList::const_iterator baseIter
|
typename addressing_type::const_iterator baseIter
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
data_(list.begin()),
|
data_(list.begin()),
|
||||||
base_(baseIter)
|
iter_(baseIter)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
reference operator*() const
|
reference operator*() const
|
||||||
{
|
{
|
||||||
return data_[*base_];
|
return data_[*iter_];
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator& operator++()
|
iterator& operator++()
|
||||||
{
|
{
|
||||||
++base_;
|
++iter_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(iterator& rhs) const
|
bool operator==(iterator& rhs) const
|
||||||
{
|
{
|
||||||
return base_ == rhs.base_;
|
return iter_ == rhs.iter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(iterator& rhs) const
|
bool operator!=(iterator& rhs) const
|
||||||
{
|
{
|
||||||
return (base_ != rhs.base_);
|
return (iter_ != rhs.iter_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,7 +282,7 @@ public:
|
|||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
typename UList<T>::const_pointer data_;
|
typename UList<T>::const_pointer data_;
|
||||||
labelUList::const_iterator base_;
|
typename addressing_type::const_iterator iter_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -241,63 +295,63 @@ public:
|
|||||||
const_iterator
|
const_iterator
|
||||||
(
|
(
|
||||||
const UList<T>& list,
|
const UList<T>& list,
|
||||||
labelUList::const_iterator baseIter
|
typename addressing_type::const_iterator baseIter
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
data_(list.begin()),
|
data_(list.begin()),
|
||||||
base_(baseIter)
|
iter_(baseIter)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
reference operator*() const
|
reference operator*() const
|
||||||
{
|
{
|
||||||
return data_[*base_];
|
return data_[*iter_];
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator& operator++()
|
const_iterator& operator++()
|
||||||
{
|
{
|
||||||
++base_;
|
++iter_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const_iterator& rhs) const
|
bool operator==(const_iterator& rhs) const
|
||||||
{
|
{
|
||||||
return base_ == rhs.base_;
|
return iter_ == rhs.iter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const_iterator& rhs) const
|
bool operator!=(const_iterator& rhs) const
|
||||||
{
|
{
|
||||||
return base_ != rhs.base_;
|
return iter_ != rhs.iter_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// iterator (non-const)
|
// Iterator (non-const)
|
||||||
|
|
||||||
//- Return an iterator at begin of list
|
//- Return an iterator at begin of list
|
||||||
inline iterator begin()
|
inline iterator begin()
|
||||||
{
|
{
|
||||||
return iterator(values_, addressing_.cbegin());
|
return iterator(values_, addr_.cbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return an iterator at end of list
|
//- Return an iterator at end of list
|
||||||
inline iterator end()
|
inline iterator end()
|
||||||
{
|
{
|
||||||
return iterator(values_, addressing_.cend());
|
return iterator(values_, addr_.cend());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// iterator (const)
|
// Iterator (const)
|
||||||
|
|
||||||
//- Return a const_iterator at begin of list
|
//- Return a const_iterator at begin of list
|
||||||
inline const_iterator cbegin() const
|
inline const_iterator cbegin() const
|
||||||
{
|
{
|
||||||
return const_iterator(values_, addressing_.cbegin());
|
return const_iterator(values_, addr_.cbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return a const_iterator at end of list
|
//- Return a const_iterator at end of list
|
||||||
inline const_iterator cend() const
|
inline const_iterator cend() const
|
||||||
{
|
{
|
||||||
return const_iterator(values_, addressing_.cend());
|
return const_iterator(values_, addr_.cend());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return a const_iterator at end of list
|
//- Return a const_iterator at end of list
|
||||||
@ -325,8 +379,8 @@ public:
|
|||||||
|
|
||||||
//- Write List to Ostream, as per UList::writeList() with default length.
|
//- Write List to Ostream, as per UList::writeList() with default length.
|
||||||
// The default short-length is given by Detail::ListPolicy::short_length
|
// The default short-length is given by Detail::ListPolicy::short_length
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
Ostream& operator<<(Ostream& os, const UIndirectList<T>& list)
|
Ostream& operator<<(Ostream& os, const IndirectListBase<T, Addr>& list)
|
||||||
{
|
{
|
||||||
return list.writeList(os, Detail::ListPolicy::short_length<T>::value);
|
return list.writeList(os, Detail::ListPolicy::short_length<T>::value);
|
||||||
}
|
}
|
||||||
@ -338,11 +392,11 @@ Ostream& operator<<(Ostream& os, const UIndirectList<T>& list)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "UIndirectListI.H"
|
#include "IndirectListBaseI.H"
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "UIndirectList.C"
|
#include "IndirectListBase.C"
|
||||||
#include "UIndirectListIO.C"
|
#include "IndirectListBaseIO.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -25,40 +25,48 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T, class Addr>
|
||||||
|
template<class ListType>
|
||||||
|
inline void Foam::IndirectListBase<T, Addr>::copyList(const ListType& rhs)
|
||||||
|
{
|
||||||
|
const label len = addr_.size();
|
||||||
|
|
||||||
|
if (len != rhs.size())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Addressing and list of addressed elements "
|
||||||
|
"have different sizes: " << len << " " << rhs.size()
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or std::copy(rhs.cbegin(), rhs.cend(), this->begin());
|
||||||
|
for (label i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
values_[addr_[i]] = rhs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline Foam::UIndirectList<T>::UIndirectList
|
inline Foam::IndirectListBase<T, Addr>::IndirectListBase
|
||||||
(
|
(
|
||||||
const UList<T>& values,
|
const UList<T>& values,
|
||||||
const labelUList& addr
|
const Addr& addr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
values_(const_cast<UList<T>&>(values)),
|
values_(const_cast<UList<T>&>(values)),
|
||||||
addressing_(addr)
|
addr_(addr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline Foam::label Foam::UIndirectList<T>::size() const
|
inline bool Foam::IndirectListBase<T, Addr>::uniform() const
|
||||||
{
|
|
||||||
return addressing_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::UIndirectList<T>::empty() const
|
|
||||||
{
|
|
||||||
return addressing_.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::UIndirectList<T>::uniform() const
|
|
||||||
{
|
{
|
||||||
const label len = this->size();
|
const label len = this->size();
|
||||||
|
|
||||||
@ -81,50 +89,8 @@ inline bool Foam::UIndirectList<T>::uniform() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline T& Foam::UIndirectList<T>::first()
|
inline bool Foam::IndirectListBase<T, Addr>::found
|
||||||
{
|
|
||||||
return values_[addressing_.first()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::UIndirectList<T>::first() const
|
|
||||||
{
|
|
||||||
return values_[addressing_.first()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T& Foam::UIndirectList<T>::last()
|
|
||||||
{
|
|
||||||
return values_[addressing_.last()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::UIndirectList<T>::last() const
|
|
||||||
{
|
|
||||||
return values_[addressing_.last()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const Foam::UList<T>& Foam::UIndirectList<T>::completeList() const
|
|
||||||
{
|
|
||||||
return values_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const Foam::List<Foam::label>& Foam::UIndirectList<T>::addressing() const
|
|
||||||
{
|
|
||||||
return addressing_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::UIndirectList<T>::found
|
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
const label pos
|
const label pos
|
||||||
@ -136,82 +102,90 @@ inline bool Foam::UIndirectList<T>::found
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline Foam::List<T> Foam::UIndirectList<T>::operator()() const
|
inline Foam::List<T>
|
||||||
|
Foam::IndirectListBase<T, Addr>::operator()() const
|
||||||
{
|
{
|
||||||
List<T> result(size());
|
const label len = addr_.size();
|
||||||
|
|
||||||
forAll(*this, i)
|
List<T> result(len);
|
||||||
|
|
||||||
|
// Or std::copy(this->cbegin(), this->cend(), result.begin());
|
||||||
|
for (label i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
result[i] = operator[](i);
|
result[i] = values_[addr_[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline T& Foam::UIndirectList<T>::operator[](const label i)
|
inline T& Foam::IndirectListBase<T, Addr>::operator[](const label i)
|
||||||
{
|
{
|
||||||
return values_[addressing_[i]];
|
return values_[addr_[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline const T& Foam::UIndirectList<T>::operator[](const label i) const
|
inline const T&
|
||||||
|
Foam::IndirectListBase<T, Addr>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
return values_[addressing_[i]];
|
return values_[addr_[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
inline void Foam::UIndirectList<T>::operator=(const UList<T>& rhs)
|
inline void Foam::IndirectListBase<T, Addr>::operator=(const T& val)
|
||||||
{
|
{
|
||||||
const label len = addressing_.size();
|
// Or std::fill(this->begin(), this->end(), val);
|
||||||
|
for (const label idx : addr_)
|
||||||
if (len != rhs.size())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Addressing and list of addressed elements "
|
|
||||||
"have different sizes: " << len << " " << rhs.size()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (label i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
values_[addressing_[i]] = rhs[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline void Foam::UIndirectList<T>::operator=(const UIndirectList<T>& rhs)
|
|
||||||
{
|
|
||||||
const label len = addressing_.size();
|
|
||||||
|
|
||||||
if (len != rhs.size())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Addressing and list of addressed elements "
|
|
||||||
"have different sizes: " << len << " " << rhs.size()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (label i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
values_[addressing_[i]] = rhs[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline void Foam::UIndirectList<T>::operator=(const T& val)
|
|
||||||
{
|
|
||||||
for (const label idx : addressing_)
|
|
||||||
{
|
{
|
||||||
values_[idx] = val;
|
values_[idx] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Addr>
|
||||||
|
inline void Foam::IndirectListBase<T, Addr>::operator=(const zero)
|
||||||
|
{
|
||||||
|
// Or std::fill(this->begin(), this->end(), Zero);
|
||||||
|
for (const label idx : addr_)
|
||||||
|
{
|
||||||
|
values_[idx] = Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Addr>
|
||||||
|
inline void Foam::IndirectListBase<T, Addr>::operator=
|
||||||
|
(
|
||||||
|
const UList<T>& rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this->copyList(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Addr>
|
||||||
|
inline void Foam::IndirectListBase<T, Addr>::operator=
|
||||||
|
(
|
||||||
|
const IndirectListBase<T, Addr>& rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this->copyList(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Addr>
|
||||||
|
template<class AnyAddr>
|
||||||
|
inline void Foam::IndirectListBase<T, Addr>::operator=
|
||||||
|
(
|
||||||
|
const IndirectListBase<T, AnyAddr>& rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this->copyList(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -25,21 +25,21 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "UIndirectList.H"
|
#include "IndirectListBase.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "token.H"
|
#include "token.H"
|
||||||
#include "contiguous.H"
|
#include "contiguous.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T, class Addr>
|
||||||
Foam::Ostream& Foam::UIndirectList<T>::writeList
|
Foam::Ostream& Foam::IndirectListBase<T, Addr>::writeList
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label shortLen
|
const label shortLen
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const UIndirectList<T>& list = *this;
|
const IndirectListBase<T, Addr>& list = *this;
|
||||||
|
|
||||||
const label len = list.size();
|
const label len = list.size();
|
||||||
|
|
||||||
95
src/OpenFOAM/containers/IndirectLists/SliceList/SliceList.H
Normal file
95
src/OpenFOAM/containers/IndirectLists/SliceList/SliceList.H
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::SliceList
|
||||||
|
|
||||||
|
Description
|
||||||
|
A List with indirect slice addressing.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
SliceList.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef SliceList_H
|
||||||
|
#define SliceList_H
|
||||||
|
|
||||||
|
#include "IndirectListAddressing.H"
|
||||||
|
#include "IndirectListBase.H"
|
||||||
|
#include "sliceRange.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class SliceList Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class SliceList
|
||||||
|
:
|
||||||
|
private IndirectListAddressing<sliceRange>,
|
||||||
|
public IndirectListBase<T, sliceRange>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Copy construct from values list and slicing
|
||||||
|
SliceList(const UList<T>& values, const sliceRange& addr)
|
||||||
|
:
|
||||||
|
IndirectListAddressing<sliceRange>(addr),
|
||||||
|
IndirectListBase<T, sliceRange>
|
||||||
|
(
|
||||||
|
values,
|
||||||
|
IndirectListAddressing<sliceRange>::addressing()
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- The list addressing
|
||||||
|
using IndirectListAddressing::addressing;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Use standard assignment operations
|
||||||
|
using IndirectListBase<T, sliceRange>::operator=;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
118
src/OpenFOAM/containers/IndirectLists/SortList/SortList.H
Normal file
118
src/OpenFOAM/containers/IndirectLists/SortList/SortList.H
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::SortList
|
||||||
|
|
||||||
|
Description
|
||||||
|
An indirect list with addressing based on sorting.
|
||||||
|
The list is sorted upon construction or when explicitly requested.
|
||||||
|
|
||||||
|
Uses the std::stable_sort() algorithm.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
SortListI.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef SortList_H
|
||||||
|
#define SortList_H
|
||||||
|
|
||||||
|
#include "IndirectList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class SortList Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class SortList
|
||||||
|
:
|
||||||
|
public IndirectList<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Shallow copy values list reference, sort immediately
|
||||||
|
inline explicit SortList(const UList<T>& values);
|
||||||
|
|
||||||
|
//- Shallow copy values list reference,
|
||||||
|
//- sort with given \b value comparator.
|
||||||
|
// \note The comparator is not stored in the class.
|
||||||
|
template<class Compare>
|
||||||
|
inline SortList(const UList<T>& values, const Compare& comp);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the list of sorted indices. Updated every sort
|
||||||
|
// Same as addressing()
|
||||||
|
inline const labelUList& indices() const;
|
||||||
|
|
||||||
|
//- Return the list of indices. Updated every sort
|
||||||
|
// Same as addressing()
|
||||||
|
inline labelList& indices();
|
||||||
|
|
||||||
|
//- Reverse the indices
|
||||||
|
inline void reverse();
|
||||||
|
|
||||||
|
//- Reset list indices to identity
|
||||||
|
inline void reset();
|
||||||
|
|
||||||
|
//- Sort the list using the given \b value comparator
|
||||||
|
template<class Compare>
|
||||||
|
inline void sort(const Compare& comp);
|
||||||
|
|
||||||
|
//- Forward (stable) sort the list.
|
||||||
|
//- Functionally identical to sort with std::less\<T\>()
|
||||||
|
inline void sort();
|
||||||
|
|
||||||
|
//- Reverse (stable) sort the list
|
||||||
|
inline void reverseSort();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Assignment operators
|
||||||
|
using IndirectList<T>::operator=;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "SortListI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
149
src/OpenFOAM/containers/IndirectLists/SortList/SortListI.H
Normal file
149
src/OpenFOAM/containers/IndirectLists/SortList/SortListI.H
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "ListOps.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::SortList<T>::SortList(const UList<T>& values)
|
||||||
|
:
|
||||||
|
IndirectList<T>(values, identity(values.size()))
|
||||||
|
{
|
||||||
|
sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
template<class Compare>
|
||||||
|
inline Foam::SortList<T>::SortList(const UList<T>& values, const Compare& comp)
|
||||||
|
:
|
||||||
|
IndirectList<T>(values, identity(values.size()))
|
||||||
|
{
|
||||||
|
sort<Compare>(comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline const Foam::labelUList& Foam::SortList<T>::indices() const
|
||||||
|
{
|
||||||
|
return this->addressing();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::labelList& Foam::SortList<T>::indices()
|
||||||
|
{
|
||||||
|
return this->addressing();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::SortList<T>::reverse()
|
||||||
|
{
|
||||||
|
Foam::reverse(this->indices());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::SortList<T>::reset()
|
||||||
|
{
|
||||||
|
const label len = this->values().size();
|
||||||
|
|
||||||
|
labelList& addr = this->indices();
|
||||||
|
addr.resize(len);
|
||||||
|
ListOps::identity(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
template<class Compare>
|
||||||
|
inline void Foam::SortList<T>::sort(const Compare& comp)
|
||||||
|
{
|
||||||
|
UList<T>& vals = this->values();
|
||||||
|
labelList& addr = this->indices();
|
||||||
|
|
||||||
|
if (addr.size() != vals.size())
|
||||||
|
{
|
||||||
|
addr.resize(vals.size());
|
||||||
|
ListOps::identity(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stable_sort
|
||||||
|
(
|
||||||
|
addr.begin(),
|
||||||
|
addr.end(),
|
||||||
|
[&](label a, label b) -> bool { return comp(vals[a], vals[b]); }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::SortList<T>::sort()
|
||||||
|
{
|
||||||
|
UList<T>& vals = this->values();
|
||||||
|
labelList& addr = this->indices();
|
||||||
|
|
||||||
|
if (addr.size() != vals.size())
|
||||||
|
{
|
||||||
|
addr.resize(vals.size());
|
||||||
|
ListOps::identity(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forward sort of indices
|
||||||
|
std::stable_sort
|
||||||
|
(
|
||||||
|
addr.begin(),
|
||||||
|
addr.end(),
|
||||||
|
[&](label a, label b) -> bool { return vals[a] < vals[b]; }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::SortList<T>::reverseSort()
|
||||||
|
{
|
||||||
|
UList<T>& vals = this->values();
|
||||||
|
labelList& addr = this->indices();
|
||||||
|
|
||||||
|
if (addr.size() != vals.size())
|
||||||
|
{
|
||||||
|
addr.resize(vals.size());
|
||||||
|
ListOps::identity(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse sort of indices
|
||||||
|
std::stable_sort
|
||||||
|
(
|
||||||
|
addr.begin(),
|
||||||
|
addr.end(),
|
||||||
|
[&](label a, label b) -> bool { return vals[b] < vals[a]; }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,109 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::UIndirectList
|
||||||
|
|
||||||
|
Description
|
||||||
|
A List with indirect addressing.
|
||||||
|
|
||||||
|
Like IndirectList but does not store addressing.
|
||||||
|
|
||||||
|
Note the const_cast of the list values. This is so we can use it both
|
||||||
|
on const and non-const lists. Alternative would be to have a const_
|
||||||
|
variant etc.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
UIndirectListI.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef UIndirectList_H
|
||||||
|
#define UIndirectList_H
|
||||||
|
|
||||||
|
#include "List.H"
|
||||||
|
#include "IndirectListBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
template<class T> class UIndirectList;
|
||||||
|
|
||||||
|
// Common list types
|
||||||
|
typedef UIndirectList<bool> boolUIndList; //!< UIndirectList of bools
|
||||||
|
typedef UIndirectList<label> labelUIndList; //!< UIndirectList of labels
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class UIndirectList Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class UIndirectList
|
||||||
|
:
|
||||||
|
public IndirectListBase<T, labelUList>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Shallow copy values and addressing arrays
|
||||||
|
UIndirectList(const UList<T>& values, const labelUList& addr)
|
||||||
|
:
|
||||||
|
IndirectListBase<T, labelUList>(values, addr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Copy construct from UIndirectList with
|
||||||
|
//- shallow copy of values and addressing arrays
|
||||||
|
UIndirectList(const UIndirectList<T>& list)
|
||||||
|
:
|
||||||
|
UIndirectList<T>(list.values(), list.addressing())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Use standard assignment operations
|
||||||
|
using IndirectListBase<T, labelUList>::operator=;
|
||||||
|
|
||||||
|
//- Deep copy values, Fatal if list sizes are not identical
|
||||||
|
void operator=(const UIndirectList<T>& rhs)
|
||||||
|
{
|
||||||
|
this->copyList(rhs);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2016-2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -151,8 +151,9 @@ public:
|
|||||||
//- Construct from an initializer list. Size set to list size.
|
//- Construct from an initializer list. Size set to list size.
|
||||||
inline explicit DynamicList(std::initializer_list<T> lst);
|
inline explicit DynamicList(std::initializer_list<T> lst);
|
||||||
|
|
||||||
//- Construct from UIndirectList. Size set to UIndirectList size.
|
//- Construct from IndirectList. Size set to addressing size.
|
||||||
inline explicit DynamicList(const UIndirectList<T>& lst);
|
template<class Addr>
|
||||||
|
inline explicit DynamicList(const IndirectListBase<T, Addr>& lst);
|
||||||
|
|
||||||
//- Move construct.
|
//- Move construct.
|
||||||
inline DynamicList(DynamicList<T, SizeMin>&& lst);
|
inline DynamicList(DynamicList<T, SizeMin>&& lst);
|
||||||
@ -259,9 +260,10 @@ public:
|
|||||||
inline DynamicList<T, SizeMin>&
|
inline DynamicList<T, SizeMin>&
|
||||||
append(std::initializer_list<T> lst);
|
append(std::initializer_list<T> lst);
|
||||||
|
|
||||||
//- Append a UIndirectList at the end of this list
|
//- Append a IndirectList at the end of this list
|
||||||
|
template<class Addr>
|
||||||
inline DynamicList<T, SizeMin>&
|
inline DynamicList<T, SizeMin>&
|
||||||
append(const UIndirectList<T>& lst);
|
append(const IndirectListBase<T, Addr>& lst);
|
||||||
|
|
||||||
//- Move append list
|
//- Move append list
|
||||||
inline DynamicList<T, SizeMin>& append(List<T>&& lst);
|
inline DynamicList<T, SizeMin>& append(List<T>&& lst);
|
||||||
@ -338,8 +340,9 @@ public:
|
|||||||
//- Assignment from initializer list
|
//- Assignment from initializer list
|
||||||
inline void operator=(std::initializer_list<T> lst);
|
inline void operator=(std::initializer_list<T> lst);
|
||||||
|
|
||||||
//- Assignment to UIndirectList
|
//- Assignment from IndirectList
|
||||||
inline void operator=(const UIndirectList<T>& lst);
|
template<class Addr>
|
||||||
|
inline void operator=(const IndirectListBase<T, Addr>& lst);
|
||||||
|
|
||||||
//- Move assignment
|
//- Move assignment
|
||||||
inline void operator=(List<T>&& lst);
|
inline void operator=(List<T>&& lst);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2016-2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -169,9 +169,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
|
template<class Addr>
|
||||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||||
(
|
(
|
||||||
const UIndirectList<T>& lst
|
const IndirectListBase<T, Addr>& lst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
List<T>(lst),
|
List<T>(lst),
|
||||||
@ -555,10 +556,11 @@ Foam::DynamicList<T, SizeMin>::append
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
|
template<class Addr>
|
||||||
inline Foam::DynamicList<T, SizeMin>&
|
inline Foam::DynamicList<T, SizeMin>&
|
||||||
Foam::DynamicList<T, SizeMin>::append
|
Foam::DynamicList<T, SizeMin>::append
|
||||||
(
|
(
|
||||||
const UIndirectList<T>& lst
|
const IndirectListBase<T, Addr>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label idx = List<T>::size();
|
label idx = List<T>::size();
|
||||||
@ -827,9 +829,10 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
|
template<class Addr>
|
||||||
inline void Foam::DynamicList<T, SizeMin>::operator=
|
inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||||
(
|
(
|
||||||
const UIndirectList<T>& lst
|
const IndirectListBase<T, Addr>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assignDynList(lst);
|
assignDynList(lst);
|
||||||
|
|||||||
@ -30,8 +30,6 @@ License
|
|||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "PtrList.H"
|
#include "PtrList.H"
|
||||||
#include "SLList.H"
|
#include "SLList.H"
|
||||||
#include "IndirectList.H"
|
|
||||||
#include "UIndirectList.H"
|
|
||||||
#include "contiguous.H"
|
#include "contiguous.H"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -330,7 +328,8 @@ Foam::List<T>::List(const SLList<T>& list)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::List<T>::List(const UIndirectList<T>& list)
|
template<class Addr>
|
||||||
|
Foam::List<T>::List(const IndirectListBase<T, Addr>& list)
|
||||||
:
|
:
|
||||||
UList<T>(nullptr, list.size())
|
UList<T>(nullptr, list.size())
|
||||||
{
|
{
|
||||||
@ -511,7 +510,8 @@ void Foam::List<T>::operator=(const SLList<T>& list)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void Foam::List<T>::operator=(const UIndirectList<T>& list)
|
template<class Addr>
|
||||||
|
void Foam::List<T>::operator=(const IndirectListBase<T, Addr>& list)
|
||||||
{
|
{
|
||||||
const label len = list.size();
|
const label len = list.size();
|
||||||
|
|
||||||
|
|||||||
@ -65,8 +65,7 @@ template<class T, int SizeMin> class DynamicList;
|
|||||||
|
|
||||||
template<class T> class PtrList;
|
template<class T> class PtrList;
|
||||||
template<class T> class SortableList;
|
template<class T> class SortableList;
|
||||||
template<class T> class IndirectList;
|
template<class T, class Addr> class IndirectListBase;
|
||||||
template<class T> class UIndirectList;
|
|
||||||
|
|
||||||
template<class T> Istream& operator>>(Istream& is, List<T>& list);
|
template<class T> Istream& operator>>(Istream& is, List<T>& list);
|
||||||
|
|
||||||
@ -169,8 +168,9 @@ public:
|
|||||||
//- Construct as copy of SLList<T>
|
//- Construct as copy of SLList<T>
|
||||||
explicit List(const SLList<T>& list);
|
explicit List(const SLList<T>& list);
|
||||||
|
|
||||||
//- Construct as copy of UIndirectList<T>
|
//- Construct as copy of IndirectList contents
|
||||||
explicit List(const UIndirectList<T>& list);
|
template<class Addr>
|
||||||
|
explicit List(const IndirectListBase<T, Addr>& list);
|
||||||
|
|
||||||
//- Construct from an initializer list
|
//- Construct from an initializer list
|
||||||
List(std::initializer_list<T> list);
|
List(std::initializer_list<T> list);
|
||||||
@ -234,8 +234,9 @@ public:
|
|||||||
//- Append a List to the end of this list
|
//- Append a List to the end of this list
|
||||||
inline void append(const UList<T>& list);
|
inline void append(const UList<T>& list);
|
||||||
|
|
||||||
//- Append a UIndirectList at the end of this list
|
//- Append IndirectList contents at the end of this list
|
||||||
inline void append(const UIndirectList<T>& list);
|
template<class Addr>
|
||||||
|
inline void append(const IndirectListBase<T, Addr>& list);
|
||||||
|
|
||||||
//- Transfer the contents of the argument List into this list
|
//- Transfer the contents of the argument List into this list
|
||||||
//- and annul the argument list
|
//- and annul the argument list
|
||||||
@ -266,8 +267,9 @@ public:
|
|||||||
//- Assignment to SLList operator. Takes linear time
|
//- Assignment to SLList operator. Takes linear time
|
||||||
void operator=(const SLList<T>& list);
|
void operator=(const SLList<T>& list);
|
||||||
|
|
||||||
//- Assignment to UIndirectList operator. Takes linear time
|
//- Assignment from IndirectList. Takes linear time
|
||||||
void operator=(const UIndirectList<T>& list);
|
template<class Addr>
|
||||||
|
void operator=(const IndirectListBase<T, Addr>& list);
|
||||||
|
|
||||||
//- Assignment to an initializer list
|
//- Assignment to an initializer list
|
||||||
void operator=(std::initializer_list<T> list);
|
void operator=(std::initializer_list<T> list);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -208,7 +208,8 @@ inline void Foam::List<T>::append(const UList<T>& list)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Foam::List<T>::append(const UIndirectList<T>& list)
|
template<class Addr>
|
||||||
|
inline void Foam::List<T>::append(const IndirectListBase<T, Addr>& list)
|
||||||
{
|
{
|
||||||
label idx = this->size();
|
label idx = this->size();
|
||||||
const label n = list.size();
|
const label n = list.size();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -75,7 +75,7 @@ inline Foam::SortableList<T>::SortableList(SortableList<T>&& lst)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::SortableList<T>::SortableList(const UList<T>& values)
|
inline Foam::SortableList<T>::SortableList(const UList<T>& values)
|
||||||
:
|
:
|
||||||
List<T>(values)
|
List<T>(values)
|
||||||
{
|
{
|
||||||
@ -84,7 +84,7 @@ Foam::SortableList<T>::SortableList(const UList<T>& values)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::SortableList<T>::SortableList(List<T>&& values)
|
inline Foam::SortableList<T>::SortableList(List<T>&& values)
|
||||||
:
|
:
|
||||||
List<T>(std::move(values))
|
List<T>(std::move(values))
|
||||||
{
|
{
|
||||||
@ -107,7 +107,7 @@ inline Foam::SortableList<T>::SortableList
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::SortableList<T>::SortableList(std::initializer_list<T> values)
|
inline Foam::SortableList<T>::SortableList(std::initializer_list<T> values)
|
||||||
:
|
:
|
||||||
List<T>(values)
|
List<T>(values)
|
||||||
{
|
{
|
||||||
@ -136,10 +136,10 @@ Foam::List<T>& Foam::SortableList<T>::shrink()
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::SortableList<T>::sort()
|
void Foam::SortableList<T>::sort()
|
||||||
{
|
{
|
||||||
Foam::sortedOrder(*this, indices_);
|
Foam::sortedOrder(*this, indices_, typename UList<T>::less(*this));
|
||||||
|
|
||||||
List<T> lst(*this, indices_); // Copy with indices for mapping
|
List<T> list(*this, indices_); // Copy with indices for mapping
|
||||||
List<T>::transfer(lst);
|
List<T>::transfer(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,8 +148,48 @@ void Foam::SortableList<T>::reverseSort()
|
|||||||
{
|
{
|
||||||
Foam::sortedOrder(*this, indices_, typename UList<T>::greater(*this));
|
Foam::sortedOrder(*this, indices_, typename UList<T>::greater(*this));
|
||||||
|
|
||||||
List<T> lst(*this, indices_); // Copy with indices for mapping
|
List<T> list(*this, indices_); // Copy with indices for mapping
|
||||||
List<T>::transfer(lst);
|
List<T>::transfer(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::SortableList<T>::partialSort(label n, label start)
|
||||||
|
{
|
||||||
|
indices_.resize(this->size());
|
||||||
|
ListOps::identity(indices_);
|
||||||
|
|
||||||
|
// Forward partial sort of indices
|
||||||
|
std::partial_sort
|
||||||
|
(
|
||||||
|
indices_.begin() + start,
|
||||||
|
indices_.begin() + start + n,
|
||||||
|
indices_.end(),
|
||||||
|
typename UList<T>::less(*this)
|
||||||
|
);
|
||||||
|
|
||||||
|
List<T> list(*this, indices_); // Copy with indices for mapping
|
||||||
|
List<T>::transfer(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::SortableList<T>::partialReverseSort(label n, label start)
|
||||||
|
{
|
||||||
|
indices_.resize(this->size());
|
||||||
|
ListOps::identity(indices_);
|
||||||
|
|
||||||
|
// Reverse partial sort of indices
|
||||||
|
std::partial_sort
|
||||||
|
(
|
||||||
|
indices_.begin() + start,
|
||||||
|
indices_.begin() + start + n,
|
||||||
|
indices_.end(),
|
||||||
|
typename UList<T>::greater(*this)
|
||||||
|
);
|
||||||
|
|
||||||
|
List<T> list(*this, indices_); // Copy with indices for mapping
|
||||||
|
List<T>::transfer(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -30,7 +30,7 @@ Description
|
|||||||
A list that is sorted upon construction or when explicitly requested
|
A list that is sorted upon construction or when explicitly requested
|
||||||
with the sort() method.
|
with the sort() method.
|
||||||
|
|
||||||
Uses the Foam::stableSort() algorithm.
|
Uses the std::stable_sort() algorithm.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
SortableList.C
|
SortableList.C
|
||||||
@ -88,10 +88,10 @@ public:
|
|||||||
inline SortableList(SortableList<T>&& lst);
|
inline SortableList(SortableList<T>&& lst);
|
||||||
|
|
||||||
//- Copy construct from UList, sorting immediately
|
//- Copy construct from UList, sorting immediately
|
||||||
explicit SortableList(const UList<T>& values);
|
explicit inline SortableList(const UList<T>& values);
|
||||||
|
|
||||||
//- Move construct from List, sorting immediately
|
//- Move construct from List, sorting immediately
|
||||||
SortableList(List<T>&& values);
|
inline SortableList(List<T>&& values);
|
||||||
|
|
||||||
//- Construct given begin/end iterators.
|
//- Construct given begin/end iterators.
|
||||||
// Uses std::distance to determine the size.
|
// Uses std::distance to determine the size.
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
inline SortableList(InputIterator begIter, InputIterator endIter);
|
inline SortableList(InputIterator begIter, InputIterator endIter);
|
||||||
|
|
||||||
//- Construct from an initializer list, sorting immediately
|
//- Construct from an initializer list, sorting immediately
|
||||||
SortableList(std::initializer_list<T> values);
|
inline SortableList(std::initializer_list<T> values);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -122,13 +122,20 @@ public:
|
|||||||
//- Clear the indices and return a reference to the underlying List
|
//- Clear the indices and return a reference to the underlying List
|
||||||
List<T>& shrink();
|
List<T>& shrink();
|
||||||
|
|
||||||
//- (stable) sort the list (if changed after construction time).
|
//- Forward (stable) sort the list (if changed after construction).
|
||||||
// Resizes the indices as required
|
// Resizes the indices as required
|
||||||
void sort();
|
void sort();
|
||||||
|
|
||||||
//- Reverse (stable) sort the list
|
//- Reverse (stable) sort the list
|
||||||
|
// Resizes the indices as required
|
||||||
void reverseSort();
|
void reverseSort();
|
||||||
|
|
||||||
|
//- Forward partial sort the list until the middle point
|
||||||
|
void partialSort(label n, label start=0);
|
||||||
|
|
||||||
|
//- Reverse partial sort the list until the middle point
|
||||||
|
void partialReverseSort(label n, label start=0);
|
||||||
|
|
||||||
//- Swap content with another SortableList in constant time
|
//- Swap content with another SortableList in constant time
|
||||||
inline void swap(SortableList<T>& lst);
|
inline void swap(SortableList<T>& lst);
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -48,29 +48,6 @@ Foam::labelRange Foam::UList<T>::validateRange(const labelRange& range) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
Foam::labelRange Foam::UList<T>::validateRange
|
|
||||||
(
|
|
||||||
std::initializer_list<label> start_size
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (start_size.size() != 2)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "range specified with " << start_size.size()
|
|
||||||
<< " elements instead of 2"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto iter = start_size.begin();
|
|
||||||
|
|
||||||
const label beg = *(iter++);
|
|
||||||
const label len = *iter;
|
|
||||||
|
|
||||||
return this->validateRange(labelRange(beg, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -176,31 +153,6 @@ const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
Foam::UList<T> Foam::UList<T>::operator[]
|
|
||||||
(
|
|
||||||
std::initializer_list<label> start_size
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const labelRange slice = validateRange(start_size);
|
|
||||||
|
|
||||||
return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
const Foam::UList<T> Foam::UList<T>::operator[]
|
|
||||||
(
|
|
||||||
std::initializer_list<label> start_size
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
// Restricted range
|
|
||||||
const labelRange slice = validateRange(start_size);
|
|
||||||
|
|
||||||
return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void Foam::UList<T>::operator=(const T& val)
|
void Foam::UList<T>::operator=(const T& val)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -123,12 +123,6 @@ protected:
|
|||||||
//- always addresses a valid section of the list.
|
//- always addresses a valid section of the list.
|
||||||
labelRange validateRange(const labelRange& range) const;
|
labelRange validateRange(const labelRange& range) const;
|
||||||
|
|
||||||
//- Return a validated (start,size) subset range, which means that it
|
|
||||||
//- always addresses a valid section of the list.
|
|
||||||
labelRange validateRange
|
|
||||||
(
|
|
||||||
std::initializer_list<label> start_size_pair
|
|
||||||
) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -361,19 +355,6 @@ public:
|
|||||||
// result always addresses a valid section of the list.
|
// result always addresses a valid section of the list.
|
||||||
const UList<T> operator[](const labelRange& range) const;
|
const UList<T> operator[](const labelRange& range) const;
|
||||||
|
|
||||||
//- Return (start,size) subset from UList with non-const access.
|
|
||||||
// The range is subsetted with the list size itself to ensure that the
|
|
||||||
// result always addresses a valid section of the list.
|
|
||||||
UList<T> operator[](std::initializer_list<label> start_size);
|
|
||||||
|
|
||||||
//- Return (start,size) subset from UList with const access.
|
|
||||||
// The range is subsetted with the list size itself to ensure that the
|
|
||||||
// result always addresses a valid section of the list.
|
|
||||||
const UList<T> operator[]
|
|
||||||
(
|
|
||||||
std::initializer_list<label> start_size
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Allow cast to a const List<T>&
|
//- Allow cast to a const List<T>&
|
||||||
inline operator const Foam::List<T>&() const;
|
inline operator const Foam::List<T>&() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2009-2011, 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2009-2011, 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -124,8 +124,9 @@ public:
|
|||||||
// Also constructs from DynamicField with different sizing parameters.
|
// Also constructs from DynamicField with different sizing parameters.
|
||||||
inline explicit DynamicField(const UList<T>& list);
|
inline explicit DynamicField(const UList<T>& list);
|
||||||
|
|
||||||
//- Copy construct from UIndirectList
|
//- Copy construct from IndirectList
|
||||||
inline explicit DynamicField(const UIndirectList<T>& list);
|
template<class Addr>
|
||||||
|
inline explicit DynamicField(const IndirectListBase<T, Addr>& list);
|
||||||
|
|
||||||
//- Move construct from List contents
|
//- Move construct from List contents
|
||||||
inline explicit DynamicField(List<T>&& content);
|
inline explicit DynamicField(List<T>&& content);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2009-2010, 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2009-2010, 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -132,9 +132,10 @@ inline Foam::DynamicField<T, SizeMin>::DynamicField
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
|
template<class Addr>
|
||||||
inline Foam::DynamicField<T, SizeMin>::DynamicField
|
inline Foam::DynamicField<T, SizeMin>::DynamicField
|
||||||
(
|
(
|
||||||
const UIndirectList<T>& list
|
const IndirectListBase<T, Addr>& list
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Field<T>(list),
|
Field<T>(list),
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010, 2015-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2010, 2015-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -120,8 +120,9 @@ public:
|
|||||||
//- Copy construct from UList\<Type\>
|
//- Copy construct from UList\<Type\>
|
||||||
inline explicit Field(const UList<Type>& list);
|
inline explicit Field(const UList<Type>& list);
|
||||||
|
|
||||||
//- Copy construct from UIndirectList\<Type\>
|
//- Copy construct from IndirectList
|
||||||
inline explicit Field(const UIndirectList<Type>& list);
|
template<class Addr>
|
||||||
|
inline explicit Field(const IndirectListBase<Type, Addr>& list);
|
||||||
|
|
||||||
//- Move construct from Field
|
//- Move construct from Field
|
||||||
inline Field(Field<Type>&& fld);
|
inline Field(Field<Type>&& fld);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -68,7 +68,8 @@ inline Foam::Field<Type>::Field(const UList<Type>& list)
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline Foam::Field<Type>::Field(const UIndirectList<Type>& list)
|
template<class Addr>
|
||||||
|
inline Foam::Field<Type>::Field(const IndirectListBase<Type, Addr>& list)
|
||||||
:
|
:
|
||||||
List<Type>(list)
|
List<Type>(list)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@ -555,7 +555,7 @@ void Foam::ccm::reader::readCells
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ccmLookupOrder.resetAddressing(std::move(addr));
|
ccmLookupOrder.addressing() = std::move(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -84,7 +84,7 @@ bool Foam::vtk::writeCellSetFaces
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use these faces
|
// Use these faces
|
||||||
faces.resetAddressing(cellFaces.sortedToc());
|
faces.addressing() = cellFaces.sortedToc();
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -50,7 +50,7 @@ bool Foam::vtk::writeFaceSet
|
|||||||
FaceListType& faces = pp;
|
FaceListType& faces = pp;
|
||||||
|
|
||||||
// Use the faces from faceSet
|
// Use the faces from faceSet
|
||||||
faces.resetAddressing(set.sortedToc());
|
faces.addressing() = set.sortedToc();
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user