ENH: cleanup of ListOps, ListListOps. Adjustments to List, PackedList.

- relocated ListAppendEqOp and ListUniqueEqOp to ListOps::appendEqOp
  and ListOps::UniqueEqOp, respectively for better code isolation and
  documentation of purpose.

- relocated setValues to ListOps::setValue() with many more
  alternative selectors possible

- relocated createWithValues to ListOps::createWithValue
  for better code isolation. The default initialization value is itself
  now a default parameter, which allow for less typing.

  Negative indices in the locations to set are now silently ignored,
  which makes it possible to use an oldToNew mapping that includes
  negative indices.

- additional ListOps::createWithValue taking a single position to set,
  available both in copy assign and move assign versions.
  Since a negative index is ignored, it is possible to combine with
  the output of List::find() etc.

STYLE: changes for PackedList

- code simplication in the PackedList iterators, including dropping
  the unused operator() on iterators, which is not available in plain
  list versions either.

- improved sizing for PackedBoolList creation from a labelUList.

ENH: additional List constructors, for handling single element list.

- can assist in reducing constructor ambiguity, but can also helps
  memory optimization when creating a single element list.
  For example,

    labelListList labels(one(), identity(mesh.nFaces()));
This commit is contained in:
Mark Olesen
2018-03-01 14:12:51 +01:00
parent ffd7b00ad5
commit 15f7260884
31 changed files with 1017 additions and 484 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -97,11 +97,14 @@ void printMyString(const UList<string>& lst)
int main(int argc, char *argv[])
{
argList::noParallel();
argList::noFunctionObjects();
argList::addOption("reList", "reList");
argList::addOption("wordList", "wordList");
argList::addOption("stringList", "stringList");
argList::addOption("float", "xx");
argList::addBoolOption("transform", "Test List::createList functionality");
argList::addBoolOption("create", "Test ListOps::create functionality");
argList::addBoolOption("ListList", "Test list of list functionality");
argList::addBoolOption("flag");
#include "setRootCase.H"
@ -332,11 +335,11 @@ int main(int argc, char *argv[])
List<scalar> sident(range.begin(), range.end());
Info<<"range-list (scalar)=" << sident << nl;
// Sub-ranges also work
List<scalar> sident2(range(3), range(10));
Info<<"range-list (scalar)=" << sident2 << nl;
// // Sub-ranges also work
// List<scalar> sident2(range.at(3), range.at(10));
// Info<<"subrange-list (scalar)=" << sident2 << nl;
// VERY BAD IDEA: List<scalar> sident3(range(10), range(3));
// VERY BAD IDEA: List<scalar> sident3(range.at(10), range.at(3));
// This doesn't work, and don't know what it should do anyhow
// List<vector> vident(range.begin(), range.end());
@ -362,15 +365,15 @@ int main(int argc, char *argv[])
Info<<"-flag:" << args["flag"] << endl;
}
if (args.found("transform"))
if (args.found("create"))
{
Info<< nl << "Test List::createList functionality" << nl;
Info<< nl << "Test ListOps::create functionality" << nl;
const auto labels = identity(15);
Info<< "labels: " << flatOutput(labels) << endl;
{
auto scalars = List<scalar>::createList
auto scalars = ListOps::create<scalar>
(
labels,
[](const label& val){ return scalar(1.5*val); }
@ -379,7 +382,7 @@ int main(int argc, char *argv[])
}
{
auto vectors = List<vector>::createList
auto vectors = ListOps::create<vector>
(
labels,
[](const label& val){ return vector(1.2*val, -1.2*val, 0); }
@ -388,7 +391,7 @@ int main(int argc, char *argv[])
}
{
auto longs = List<long>::createList
auto longs = ListOps::create<long>
(
labels,
[](const label& val){ return val; }
@ -396,7 +399,7 @@ int main(int argc, char *argv[])
Info<< "longs: " << flatOutput(longs) << endl;
}
{
auto negs = List<label>::createList
auto negs = ListOps::create<label>
(
labels,
std::negate<label>()
@ -405,7 +408,7 @@ int main(int argc, char *argv[])
}
{
auto scalars = List<scalar>::createList
auto scalars = ListOps::create<scalar>
(
labelRange::null.cbegin(),
labelRange::identity(15).cend(),
@ -417,9 +420,9 @@ int main(int argc, char *argv[])
#if WM_LABEL_SIZE == 32
{
List<int64_t> input(10);
std::iota(input.begin(), input.end(), 0);
std::iota(input.begin(), input.end(), 50);
auto output = List<label>::createList
auto output = ListOps::create<label>
(
input,
toLabel<int64_t>()
@ -429,9 +432,9 @@ int main(int argc, char *argv[])
#elif WM_LABEL_SIZE == 64
{
List<int32_t> input(10);
std::iota(input.begin(), input.end(), 0);
std::iota(input.begin(), input.end(), 50);
auto output = List<label>::createList
auto output = ListOps::create<label>
(
input,
toLabel<int32_t>()
@ -439,6 +442,157 @@ int main(int argc, char *argv[])
Info<< "label (from int32): " << flatOutput(output) << endl;
}
#endif
labelHashSet locations{ -15, 5, 10, 15, 25, 35 };
Info<< nl << "Test for createWithValue with locations :"
<< flatOutput(locations.sortedToc()) << nl;
{
auto output = ListOps::createWithValue<label>
(
30,
locations.toc(), // Any order
100,
-1 // default value
);
Info<< "with labelUList: " << flatOutput(output)
<< " selector: " << flatOutput(locations.sortedToc()) << nl;
}
{
auto output = ListOps::createWithValue<label>
(
30,
locations,
100,
-1 // default value
);
Info<< "with labelHashSet: " << flatOutput(output)
<< " selector: " << flatOutput(locations) << nl;
}
{
PackedBoolList select(locations.toc());
auto output = ListOps::createWithValue<label>
(
30,
select,
100,
-1 // default value
);
Info<< "with PackedBoolList: " << flatOutput(output)
<< " selector: " << flatOutput(select.used()) << nl;
}
{
// Fairly really inconvenient way to set true/false
labelList toc(locations.sortedToc());
List<bool> select = ListOps::createWithValue<bool>
(
toc.last() + 1,
toc,
true,
false // default value
);
auto output = ListOps::createWithValue<label>
(
30,
select,
100,
-1 // default value
);
Info<< "with boolList: " << flatOutput(output)
<< " selector: " << flatOutput(select) << nl;
}
// Repeat with a shorter selector
locations = { -15, 5, 10 };
{
auto output = ListOps::createWithValue<label>
(
30,
locations,
100,
-1 // default value
);
Info<< "with labelHashSet: " << flatOutput(output)
<< " selector: " << flatOutput(locations) << nl;
}
{
PackedBoolList select(locations.toc());
auto output = ListOps::createWithValue<label>
(
30,
select,
100,
-1 // default value
);
Info<< "with PackedBoolList: " << flatOutput(output)
<< " selector: " << flatOutput(select.used()) << nl;
}
{
// Fairly really inconvenient way to set true/false
labelList toc(locations.sortedToc());
List<bool> select = ListOps::createWithValue<bool>
(
toc.last() + 1,
toc,
true,
false // default value
);
auto output = ListOps::createWithValue<label>
(
30,
select,
100,
-1 // default value
);
Info<< "with boolList: " << flatOutput(output)
<< " selector: " << flatOutput(select) << nl;
}
}
if (args.found("ListList"))
{
{
labelListList listlist(5, identity(5));
Info<<"list-list with length/val:" << listlist << nl;
}
{
labelListList listlist(one(), identity(5));
Info<<"list-list 1/val:" << listlist << nl;
}
{
labelList content = identity(5);
labelListList listlist(one(), content);
Info<<"list-list 1/copy val:" << listlist
<<" - from " << content << nl;
}
{
labelList content = identity(5);
labelListList listlist(one(), std::move(content));
Info<<"list-list 1/move val:" << listlist
<<" - from " << content << nl;
}
{
labelListList listlist(one(), Zero);
Info<<"list-list 1/move val:" << listlist
<< nl;
}
}
if (args.readIfPresent<scalar>("float", xxx))

View File

@ -251,13 +251,13 @@ int main(int argc, char *argv[])
Info<< "begin():";
iter.printInfo(Info) << "\n";
Info<< "iterator:" << iter() << "\n";
iter() = 5;
Info<< "iterator:" << *iter << "\n";
*iter = 5;
iter.printInfo(Info);
list1.printInfo(Info, true);
iter = list1[31];
Info<< "iterator:" << iter() << "\n";
Info<< "iterator:" << *iter << "\n";
iter.printInfo(Info);

View File

@ -229,7 +229,7 @@ int main(int argc, char *argv[])
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAllIter(PackedBoolList, packed, it)
forAllIters(packed, it)
{
sum += it;
}
@ -244,9 +244,9 @@ int main(int argc, char *argv[])
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAllConstIter(PackedBoolList, packed, cit)
forAllConstIters(packed, cit)
{
sum += cit();
sum += *cit;
}
}
std::cout
@ -370,9 +370,9 @@ int main(int argc, char *argv[])
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
forAllIter(PackedBoolList, packed, it)
forAllIters(packed, it)
{
it() = 1;
*it = 1;
}
}
Info<< "Writing packed using iterator:" << timer.cpuTimeIncrement()

View File

@ -29,9 +29,12 @@ Description
#include "uLabel.H"
#include "boolList.H"
#include "DynamicList.H"
#include "IOstreams.H"
#include "PackedBoolList.H"
#include "ITstream.H"
#include "StringStream.H"
#include "FlatOutput.H"
using namespace Foam;
@ -135,8 +138,9 @@ int main(int argc, char *argv[])
PackedBoolList list4
(
IStringStream
ITstream
(
"input",
"(1 n 1 n 1 n 1 1 off 0 0 f f 0 y yes y true y false on t)"
)()
);
@ -199,6 +203,18 @@ int main(int argc, char *argv[])
list4.writeEntry("PackedBoolList", Info);
// Construct from labelUList, labelUIndList
{
DynamicList<label> indices({10, 50, 300});
Info<< "set: " << flatOutput(indices) << endl;
PackedBoolList bools1(indices);
Info<< "used: " << bools1.size() << " "
<< flatOutput(bools1.used()) << endl;
}
return 0;
}

View File

@ -1007,7 +1007,7 @@ Foam::label Foam::checkGeometry
globalFaces().gather
(
UPstream::worldComm,
labelList::createList
ListOps::create<label>
(
UPstream::procID(UPstream::worldComm),
toLabel<int>() // int -> label
@ -1061,7 +1061,7 @@ Foam::label Foam::checkGeometry
globalFaces().gather
(
UPstream::worldComm,
labelList::createList
ListOps::create<label>
(
UPstream::procID(UPstream::worldComm),
toLabel<int>() // int -> label

View File

@ -84,7 +84,7 @@ void writeWeights
globalFaces().gather
(
UPstream::worldComm,
labelList::createList
ListOps::create<label>
(
UPstream::procID(UPstream::worldComm),
toLabel<int>() // int -> label

View File

@ -81,7 +81,7 @@ void Foam::parLagrangianRedistributor::findClouds
}
// Synchronise cloud names
Pstream::combineGather(cloudNames, ListUniqueEqOp<word>());
Pstream::combineGather(cloudNames, ListOps::uniqueEqOp<word>());
Pstream::combineScatter(cloudNames);
objectNames.setSize(cloudNames.size());
@ -117,10 +117,10 @@ void Foam::parLagrangianRedistributor::findClouds
}
// Synchronise objectNames
forAll(objectNames, cloudI)
forAll(objectNames, i)
{
Pstream::combineGather(objectNames[cloudI], ListUniqueEqOp<word>());
Pstream::combineScatter(objectNames[cloudI]);
Pstream::combineGather(objectNames[i], ListOps::uniqueEqOp<word>());
Pstream::combineScatter(objectNames[i]);
}
}

View File

@ -44,7 +44,7 @@ Foam::wordList Foam::parLagrangianRedistributor::filterObjects
// Parallel synchronise
wordList fieldNames(objects.names(fieldClassName));
Pstream::combineGather(fieldNames, ListUniqueEqOp<word>());
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::combineScatter(fieldNames);
if (!selectedFields.empty())

View File

@ -2357,7 +2357,7 @@ int main(int argc, char *argv[])
bool nfs = true;
{
List<fileName> roots(1, args.rootPath());
combineReduce(roots, ListUniqueEqOp<fileName>());
combineReduce(roots, ListOps::uniqueEqOp<fileName>());
nfs = (roots.size() == 1);
}

View File

@ -35,65 +35,6 @@ License
#include <utility>
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>
template<class T2, class UnaryOperation>
Foam::List<T> Foam::List<T>::createList
(
const UList<T2>& input,
const UnaryOperation& op
)
{
const label len = input.size();
List<T> output(len);
if (len)
{
List_ACCESS(T, output, out);
List_CONST_ACCESS(T2, input, in);
for (label i = 0; i < len; ++i)
{
out[i] = op(in[i]);
}
}
return output;
}
template<class T>
template<class InputIterator, class UnaryOperation>
Foam::List<T> Foam::List<T>::createList
(
InputIterator begIter,
InputIterator endIter,
const UnaryOperation& op
)
{
const label len = std::distance(begIter, endIter);
List<T> output(len);
if (len)
{
List_ACCESS(T, output, out);
InputIterator iter = begIter;
for (label i = 0; i < len; ++i)
{
out[i] = op(*iter);
++iter;
}
}
return output;
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T>
@ -162,6 +103,33 @@ Foam::List<T>::List(const label len, const zero)
}
template<class T>
Foam::List<T>::List(const one, const T& val)
:
UList<T>(new T[1], 1)
{
this->v_[0] = val;
}
template<class T>
Foam::List<T>::List(const one, T&& val)
:
UList<T>(new T[1], 1)
{
this->v_[0] = std::move(val);
}
template<class T>
Foam::List<T>::List(const one, const zero)
:
UList<T>(new T[1], 1)
{
this->v_[0] = Zero;
}
template<class T>
Foam::List<T>::List(const UList<T>& a)
:

View File

@ -42,6 +42,7 @@ SourceFiles
#include "UList.H"
#include "autoPtr.H"
#include "one.H"
#include "Xfer.H"
#include "SLListFwd.H"
@ -112,49 +113,11 @@ public:
//- Return a null List
inline static const List<T>& null();
//- Create from a list of a dissimilar type.
// Eg, convert a list of ints to floats, vectors etc.
// For example,
// \code
// auto vectors = List<vector>::createList
// (
// ints,
// [](const int& val){ return vector(1.5*val, 0, 0); }
// );
//
// auto neg = labelList::createList
// (
// ints,
// std::negate<label>()
// );
// auto labels = labelList::createList
// (
// ints,
// toLabel<int>()
// );
// \endcode
template<class T2, class UnaryOperation>
static List<T> createList
(
const UList<T2>& input,
const UnaryOperation& op
);
//- Create from an iterator range (uses std::distance for the size).
// The unary operation can be used to convert to other types.
template<class InputIterator, class UnaryOperation>
static List<T> createList
(
InputIterator begIter,
InputIterator endIter,
const UnaryOperation& op
);
// Constructors
//- Null constructor
inline List();
inline constexpr List() noexcept;
//- Construct with given size
explicit List(const label len);
@ -165,6 +128,15 @@ public:
//- Construct with given size initializing all elements to zero
List(const label len, const zero);
//- Construct with length=1, copying the value as the only content
List(const one, const T& val);
//- Construct with length=1, moving the value as the only content
List(const one, T&& val);
//- Construct with length=1, initializing content to zero
List(const one, const zero);
//- Copy construct from list
List(const List<T>& a);

View File

@ -88,7 +88,7 @@ inline Foam::List<T>::List
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
inline Foam::List<T>::List()
inline constexpr Foam::List<T>::List() noexcept
{}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,93 +23,109 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
template<class T, class AccessOp>
Foam::labelList Foam::ListListOps::subSizes
(
const UList<T>& lists,
AccessOp aop
)
{
labelList output(lists.size());
auto out = output.begin();
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class AccessType, class T, class AccessOp>
AccessType ListListOps::combine(const List<T>& lst, AccessOp aop)
{
label sum = 0;
forAll(lst, lstI)
for (const T& sub : lists)
{
sum += aop(lst[lstI]).size();
*out = aop(sub).size();
++out;
}
AccessType result(sum);
label globalElemI = 0;
forAll(lst, lstI)
{
const T& sub = lst[lstI];
forAll(aop(sub), elemI)
{
result[globalElemI++] = aop(sub)[elemI];
}
}
return result;
return output;
}
template<class T, class AccessOp>
labelList ListListOps::subSizes(const List<T>& lst, AccessOp aop)
Foam::label Foam::ListListOps::sumSizes
(
const UList<T>& lists,
AccessOp aop
)
{
labelList sizes(lst.size());
label len = 0;
forAll(lst, lstI)
for (const T& sub : lists)
{
sizes[lstI] = aop(lst[lstI]).size();
len += aop(sub).size();
}
return sizes;
return len;
}
template<class AccessType, class T, class AccessOp>
AccessType Foam::ListListOps::combine
(
const UList<T>& lists,
AccessOp aop
)
{
label len = 0;
for (const T& sub : lists)
{
len += aop(sub).size();
}
AccessType output(len);
auto out = output.begin();
for (const T& sub : lists)
{
for (const auto& item : aop(sub))
{
*out = item;
++out;
}
}
return output;
}
template<class AccessType, class T, class AccessOp, class OffsetOp>
AccessType ListListOps::combineOffset
AccessType Foam::ListListOps::combineOffset
(
const List<T>& lst,
const labelList& sizes,
const UList<T>& lists,
const labelUList& offsets,
AccessOp aop,
OffsetOp oop
)
{
label sum = 0;
label len = 0;
forAll(lst, lstI)
for (const T& sub : lists)
{
sum += aop(lst[lstI]).size();
len += aop(sub).size();
}
AccessType result(sum);
label globalElemI = 0;
AccessType output(len);
auto out = output.begin();
auto off = offsets.begin();
label offset = 0;
forAll(lst, lstI)
for (const T& sub : lists)
{
const T& sub = lst[lstI];
forAll(aop(sub), elemI)
for (const auto& item : aop(sub))
{
result[globalElemI++] = oop(aop(sub)[elemI], offset);
*out = oop(item, offset);
++out;
}
offset += sizes[lstI];
offset += *off;
++off;
}
return result;
return output;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -93,12 +93,10 @@ SourceFiles
namespace Foam
{
// Dummy access operator for ListListOps::combine()
//- Dummy access operator for ListListOps::combine()
template<class T>
class accessOp
struct accessOp
{
public:
const T& operator()(const T& x) const
{
return x;
@ -106,54 +104,57 @@ public:
};
// Offset operator for ListListOps::combineOffset()
//- Offset operator for ListListOps::combineOffset()
template<class T>
class offsetOp
struct offsetOp
{
public:
T operator()(const T& x, const label offset) const
{
return x + offset;
}
};
/*---------------------------------------------------------------------------*\
Class ListListOps Declaration
Namespace ListListOps Declaration
\*---------------------------------------------------------------------------*/
namespace ListListOps
{
//- Combines sublists into one big list
template<class AccessType, class T, class AccessOp>
AccessType combine(const List<T>&, AccessOp aop = accessOp<T>());
//- Gets sizes of sublists
//- Return the sizes of the sub-lists
template<class T, class AccessOp>
labelList subSizes(const List<T>&, AccessOp aop = accessOp<T>());
labelList subSizes(const UList<T>& lists, AccessOp aop = accessOp<T>());
//- The total size of all sub-lists
template<class T, class AccessOp>
label sumSizes(const UList<T>& lists, AccessOp aop = accessOp<T>());
//- Combines sub-lists into a single list
template<class AccessType, class T, class AccessOp>
AccessType combine(const UList<T>& lists, AccessOp aop = accessOp<T>());
//- Like combine but also offsets sublists based on passed sizes
template<class AccessType, class T, class AccessOp, class OffsetOp>
AccessType combineOffset
(
const List<T>&,
const labelList& sizes,
const UList<T>& lists,
const labelUList& offsets,
AccessOp aop,
OffsetOp oop = offsetOp<T>()
);
};
} // End namespace ListListOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ListListOps.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -27,6 +27,12 @@ InNamspace
Description
Various functions to operate on Lists.
Namespace
Foam::ListOps
Description
Various utility functions to work on Lists.
SourceFiles
ListOps.C
ListOpsTemplates.C
@ -38,6 +44,8 @@ SourceFiles
#include "FlatOutput.H"
#include "labelList.H"
#include "HashSet.H"
#include "PackedBoolList.H"
#include "ops.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -260,25 +268,6 @@ labelList findIndices
label start=0
);
//- Opposite of findIndices: set values at indices to given value
template<class ListType>
void setValues
(
ListType& input,
const labelUList& indices,
typename ListType::const_reference val
);
//- Opposite of findIndices: set values at indices to given value
template<class ListType>
ListType createWithValues
(
const label len,
typename ListType::const_reference initValue,
const labelUList& indices,
typename ListType::const_reference setValue
);
//- Find index of max element (and larger than given element).
// return -1 if not found. Linear search.
template<class ListType>
@ -325,24 +314,6 @@ label findLower
);
//- Helper class for list to append y onto the end of x
template<class T>
class ListAppendEqOp
{
public:
void operator()(List<T>& x, const List<T>& y) const;
};
//- Helper class for list to append unique elements of y onto the end of x
template<class T>
class ListUniqueEqOp
{
public:
void operator()(List<T>& x, const List<T>& y) const;
};
//- Reverse a list. First element becomes last element etc.
template<class ListType>
ListType reverseList(const ListType& input);
@ -364,6 +335,271 @@ template<template<typename> class ListType, class DataType>
void inplaceRotateList(ListType<DataType>& list, label n);
/*---------------------------------------------------------------------------*\
Namespace ListOps Declaration
\*---------------------------------------------------------------------------*/
namespace ListOps
{
//- List helper to append y elements onto the end of x
template<class T>
struct appendEqOp
{
void operator()(List<T>& x, const List<T>& y) const;
};
//- List helper to append y unique elements onto the end of x
template<class T>
struct uniqueEqOp
{
void operator()(List<T>& x, const List<T>& y) const;
};
//- Set various locations of the list with a specified value.
//
// \param list the list to modify
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
template<class T>
void setValue
(
UList<T>& list,
const labelUList& locations,
const T& val
);
//- Set various locations of the list with a specified value.
//
// \param list the list to modify
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
template<class T>
void setValue
(
UList<T>& list,
const labelHashSet& locations,
const T& val
);
//- Set various locations of the list with a specified value.
//
// \param list the list to modify
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
template<class T>
void setValue
(
UList<T>& list,
const UList<bool>& locations,
const T& val
);
//- Set various locations of the list with a specified value.
//
// \param list the list to modify
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
template<class T>
void setValue
(
UList<T>& list,
const PackedBoolList& locations,
const T& val
);
//- Create a List from a List of a dissimilar type, using the entire list.
// For example, convert a list of ints to floats, vectors etc.
//
// \param input the list input values.
// \param op the unary conversion operator, which can be used to convert
// to other types.
//
// \code
// auto neg = ListOps::create<label>
// (
// ints,
// std::negate<label>()
// );
//
// auto labels = ListOps::create<label>
// (
// ints,
// toLabel<int>()
// );
//
// auto vectors = ListOps::create<vector>
// (
// ints,
// [](const int& val){ return vector(1.5*val, 0, 0); }
// );
//
// \endcode
template<class T, class T2, class UnaryOperation>
List<T> create
(
const UList<T2>& input,
const UnaryOperation& op
);
//- Create a List from an iterator range [first,last) of a dissimilar type.
// Uses std::distance for the size.
//
// \param first the begin of the iterator range
// \param last the end of the iterator range
// \param op the unary conversion operator, which can be used to convert
// to other types.
template<class T, class InputIterator, class UnaryOperation>
List<T> create
(
InputIterator first,
InputIterator last,
const UnaryOperation& op
);
//- Create a List filled with default values and various locations with
//- another specified value.
//
// \param len the length of the list
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
// \param deflt the initialization default value
template<class T>
List<T> createWithValue
(
const label len,
const labelUList& locations,
const T& val,
const T& deflt = T()
);
//- Create a List filled with default values and various locations with
//- another specified value.
//
// \param len the length of the list
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
// \param deflt the initialization default value
template<class T>
List<T> createWithValue
(
const label len,
const labelHashSet& locations,
const T& val,
const T& deflt = T()
);
//- Create a List filled with default values and various locations with
//- another specified value.
//
// \param len the length of the list
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
// \param deflt the initialization default value
template<class T>
List<T> createWithValue
(
const label len,
const UList<bool>& locations,
const T& val,
const T& deflt = T()
);
//- Create a List filled with default values and various locations with
//- another specified value.
//
// \param len the length of the list
// \param locations where to apply the specified value
// An out-of-range index is silently ignored.
// \param val the value to set at the specified locations
// \param deflt the initialization default value
template<class T>
List<T> createWithValue
(
const label len,
const PackedBoolList& locations,
const T& val,
const T& deflt = T()
);
//- Create a List filled with default values and one specified value,
//- which is copy assigned at the specified index
//
// \param len the length of the list
// \param index where to apply the specified value.
// An out-of-range index is silently ignored.
// \param val the value to copy assign at the specified index
// \param deflt the initialization default value
template<class T>
List<T> createWithValue
(
const label len,
const label index,
const T& val,
const T& deflt = T()
);
//- Create a List filled with default values and one specified value,
//- which is move assigned at the specified index
//
// \param len the length of the list
// \param index where to apply the specified value.
// An out-of-range index is silently ignored.
// \param val the value to move assign at the specified index
// \param deflt the initialization default value
//
// For example,
// \code
// // Gather all unique points on master
//
// List<pointField> gatheredPoints(Pstream::nProcs());
// gatheredPoints[Pstream::myProcNo()] = pointField
// (
// mesh.points(),
// uniqueMeshPoints
// );
// ...
//
// // Or else
// auto gatheredPoints = ListOps::createWithValue<pointField>
// (
// Pstream::nProcs(),
// Pstream::myProcNo(),
// pointField(mesh.points(), uniqueMeshPoints)
// );
// ...
//
// \endcode
template<class T>
List<T> createWithValue
(
const label len,
const label index,
T&& val,
const T& deflt = T()
);
} // End namespace ListOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -23,7 +23,9 @@ License
\*---------------------------------------------------------------------------*/
#include <utility>
#include "ListOps.H"
#include "ListLoopM.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -558,36 +560,6 @@ Foam::labelList Foam::findIndices
}
template<class ListType>
void Foam::setValues
(
ListType& input,
const labelUList& indices,
typename ListType::const_reference val
)
{
for (const label idx : indices)
{
input[idx] = val;
}
}
template<class ListType>
ListType Foam::createWithValues
(
const label len,
const typename ListType::const_reference initValue,
const labelUList& indices,
typename ListType::const_reference setValue
)
{
ListType list(len, initValue);
setValues(list, indices, setValue);
return list;
}
template<class ListType>
Foam::label Foam::findMax(const ListType& input, const label start)
{
@ -736,51 +708,6 @@ Foam::label Foam::findLower
}
template<class T>
void Foam::ListAppendEqOp<T>::operator()(List<T>& x, const List<T>& y) const
{
if (y.size())
{
label len = x.size();
if (len)
{
x.setSize(len + y.size());
for (const T& val : y)
{
x[len++] = val;
}
}
else
{
x = y;
}
}
}
template<class T>
void Foam::ListUniqueEqOp<T>::operator()(List<T>& x, const List<T>& y) const
{
if (y.size())
{
if (x.size())
{
for (const T& val : y)
{
if (!x.found(val))
{
x.append(val);
}
}
}
else
{
x = y;
}
}
}
template<class ListType>
ListType Foam::reverseList(const ListType& input)
{
@ -859,4 +786,309 @@ void Foam::inplaceRotateList(ListType<DataType>& input, label n)
}
// * * * * * * * * * * * * * * * * * ListOps * * * * * * * * * * * * * * * * //
template<class T>
void Foam::ListOps::appendEqOp<T>::operator()
(
List<T>& x,
const List<T>& y
) const
{
if (y.size())
{
label len = x.size();
if (len)
{
x.resize(len + y.size());
for (const T& val : y)
{
x[len++] = val;
}
}
else
{
x = y;
}
}
}
template<class T>
void Foam::ListOps::uniqueEqOp<T>::operator()
(
List<T>& x,
const List<T>& y
) const
{
if (y.size())
{
if (x.size())
{
for (const T& val : y)
{
if (!x.found(val))
{
x.append(val);
}
}
}
else
{
x = y;
}
}
}
template<class T>
void Foam::ListOps::setValue
(
UList<T>& list,
const labelUList& locations,
const T& val
)
{
const label len = list.size();
for (const label index : locations)
{
// Range-checked
if (index >= 0 && index < len)
{
list[index] = val;
}
}
}
template<class T>
void Foam::ListOps::setValue
(
UList<T>& list,
const labelHashSet& locations,
const T& val
)
{
const label len = list.size();
for (const label index : locations)
{
// Range-checked
if (index >= 0 && index < len)
{
list[index] = val;
}
}
}
template<class T>
void Foam::ListOps::setValue
(
UList<T>& list,
const UList<bool>& locations,
const T& val
)
{
const label len = list.size();
const label count = locations.size();
const label end = min(count, len);
// The efficiency is modest
for (label index = 0; index < end; ++index)
{
if (locations[index])
{
list[index] = val;
}
}
}
template<class T>
void Foam::ListOps::setValue
(
UList<T>& list,
const PackedBoolList& locations,
const T& val
)
{
// Need improvements in PackedBoolList for more efficiency
const label len = list.size();
const label count = locations.count();
for (label index = 0, used = 0; index < len && used < count; ++index)
{
if (locations[index])
{
list[index] = val;
++used;
}
}
}
template<class T, class T2, class UnaryOperation>
Foam::List<T> Foam::ListOps::create
(
const UList<T2>& input,
const UnaryOperation& op
)
{
const label len = input.size();
List<T> output(len);
if (len)
{
List_ACCESS(T, output, out);
List_CONST_ACCESS(T2, input, in);
for (label i = 0; i < len; ++i)
{
out[i] = op(in[i]);
}
}
return output;
}
template<class T, class InputIterator, class UnaryOperation>
Foam::List<T> Foam::ListOps::create
(
InputIterator first,
InputIterator last,
const UnaryOperation& op
)
{
const label len = std::distance(first, last);
List<T> output(len);
if (len)
{
List_ACCESS(T, output, out);
InputIterator in = first;
for (label i = 0; i < len; ++i)
{
out[i] = op(*in);
++in;
}
}
return output;
}
template<class T>
Foam::List<T> Foam::ListOps::createWithValue
(
const label len,
const labelUList& locations,
const T& val,
const T& deflt
)
{
List<T> list(len, deflt);
ListOps::setValue(list, locations, val);
return list;
}
template<class T>
Foam::List<T> Foam::ListOps::createWithValue
(
const label len,
const labelHashSet& locations,
const T& val,
const T& deflt
)
{
List<T> list(len, deflt);
ListOps::setValue(list, locations, val);
return list;
}
template<class T>
Foam::List<T> Foam::ListOps::createWithValue
(
const label len,
const UList<bool>& locations,
const T& val,
const T& deflt
)
{
List<T> list(len, deflt);
ListOps::setValue(list, locations, val);
return list;
}
template<class T>
Foam::List<T> Foam::ListOps::createWithValue
(
const label len,
const PackedBoolList& locations,
const T& val,
const T& deflt
)
{
List<T> list(len, deflt);
ListOps::setValue(list, locations, val);
return list;
}
template<class T>
Foam::List<T> Foam::ListOps::createWithValue
(
const label len,
const label index,
const T& val,
const T& deflt
)
{
List<T> list(len, deflt);
// Range-checked
if (index >= 0 && index < len)
{
list[index] = val;
}
return list;
}
template<class T>
Foam::List<T> Foam::ListOps::createWithValue
(
const label len,
const label index,
T&& val,
const T& deflt
)
{
List<T> list(len, deflt);
// Range-checked
if (index >= 0 && index < len)
{
list[index] = std::move(val);
}
return list;
}
// ************************************************************************* //

View File

@ -88,13 +88,13 @@ inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
inline Foam::PackedBoolList::PackedBoolList(const labelUList& indices)
:
PackedBoolList(indices.size(), indices)
PackedBoolList((indices.size() ? indices.last() : 0), indices)
{}
inline Foam::PackedBoolList::PackedBoolList(const labelUIndList& indices)
:
PackedBoolList(indices.size(), indices)
PackedBoolList((indices.size() ? indices.last() : 0), indices)
{}

View File

@ -384,7 +384,7 @@ public:
void writeEntry(const word& keyword, Ostream& os) const;
// Member operators
// Member Operators
//- Append a value at the end of the list
inline PackedList<nBits>& append(const unsigned int val);
@ -438,22 +438,32 @@ public:
label index_;
// Constructors
//- Construct null - an end iterator
inline iteratorBase();
//- Construct from base list and position index
inline iteratorBase(const PackedList* lst, const label i);
// Protected Member Functions
//- Limit index to the list size - avoid going past end()
// Eg, iter = iterator(list, Inf)
inline void bound();
//- Get value as unsigned, no range-checking
inline unsigned int get() const;
//- Set value, returning true if changed, no range-checking
inline bool set(unsigned int val);
//- Move backward through list
inline void prev();
// Constructors
//- Construct null
inline iteratorBase();
//- Construct from base list and position index
inline iteratorBase(const PackedList* lst, const label i);
//- Move forward through list
inline void next();
public:
@ -534,15 +544,9 @@ public:
//- Return value
inline unsigned int operator*() const;
//- Return value
inline unsigned int operator()() const;
//- Return iteratorBase for assigning values
inline iteratorBase& operator*();
//- Return iteratorBase for assigning values
inline iteratorBase& operator()();
inline iterator& operator++();
inline iterator operator++(int);
@ -595,9 +599,6 @@ public:
//- Return referenced value directly
inline unsigned int operator*() const;
//- Return referenced value directly
inline unsigned int operator()() const;
inline const_iterator& operator++();
inline const_iterator operator++(int);

View File

@ -294,8 +294,31 @@ inline Foam::PackedList<nBits>::iteratorBase::iteratorBase
template<unsigned nBits>
inline unsigned int
Foam::PackedList<nBits>::iteratorBase::get() const
inline void Foam::PackedList<nBits>::iteratorBase::bound()
{
if (list_ && index_ > list_->size_)
{
index_ = list_->size_;
}
}
template<unsigned nBits>
inline void Foam::PackedList<nBits>::iteratorBase::prev()
{
--index_;
}
template<unsigned nBits>
inline void Foam::PackedList<nBits>::iteratorBase::next()
{
++index_;
}
template<unsigned nBits>
inline unsigned int Foam::PackedList<nBits>::iteratorBase::get() const
{
const unsigned int seg = index_ / packing();
const unsigned int off = index_ % packing();
@ -306,8 +329,7 @@ Foam::PackedList<nBits>::iteratorBase::get() const
template<unsigned nBits>
inline bool
Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val)
inline bool Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val)
{
const unsigned int seg = index_ / packing();
const unsigned int off = index_ % packing();
@ -346,7 +368,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator==
const iteratorBase& iter
) const
{
return this->get() == iter.get();
return this->get() == iter.get(); // Compare values
}
@ -356,7 +378,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator!=
const iteratorBase& iter
) const
{
return this->get() != iter.get();
return this->get() != iter.get(); // Compare values
}
@ -366,8 +388,7 @@ inline void Foam::PackedList<nBits>::iteratorBase::operator=
const iteratorBase& iter
)
{
const unsigned int val = iter.get();
this->set(val);
this->set(iter.get()); // Set values
}
@ -423,12 +444,7 @@ inline Foam::PackedList<nBits>::iterator::iterator
:
iteratorBase(iter)
{
// Avoid going past end()
// eg, iter = iterator(list, Inf)
if (this->index_ > this->list_->size_)
{
this->index_ = this->list_->size_;
}
this->bound();
}
@ -440,12 +456,7 @@ inline Foam::PackedList<nBits>::const_iterator::const_iterator
:
iteratorBase(iter)
{
// Avoid going past end()
// eg, iter = iterator(list, Inf)
if (this->index_ > this->list_->size_)
{
this->index_ = this->list_->size_;
}
this->bound();
}
@ -487,7 +498,7 @@ inline bool Foam::PackedList<nBits>::iterator::operator==
const iteratorBase& iter
) const
{
return this->index_ == iter.index_;
return this->index_ == iter.index_; // Compare positions
}
@ -497,7 +508,7 @@ inline bool Foam::PackedList<nBits>::iterator::operator!=
const iteratorBase& iter
) const
{
return this->index_ != iter.index_;
return this->index_ != iter.index_; // Compare positions
}
@ -507,7 +518,7 @@ inline bool Foam::PackedList<nBits>::const_iterator::operator==
const iteratorBase& iter
) const
{
return this->index_ == iter.index_;
return this->index_ == iter.index_; // Compare positions
}
@ -517,7 +528,7 @@ inline bool Foam::PackedList<nBits>::const_iterator::operator!=
const iteratorBase& iter
) const
{
return this->index_ != iter.index_;
return this->index_ != iter.index_; // Compare positions
}
@ -530,12 +541,7 @@ inline void Foam::PackedList<nBits>::iterator::operator=
this->list_ = iter.list_;
this->index_ = iter.index_;
// Avoid going past end()
// eg, iter = iterator(list, Inf)
if (this->index_ > this->list_->size_)
{
this->index_ = this->list_->size_;
}
this->bound();
}
@ -548,14 +554,7 @@ inline void Foam::PackedList<nBits>::const_iterator::operator=
this->list_ = iter.list_;
this->index_ = iter.index_;
// Avoid going past end()
// eg, iter = iterator(list, Inf)
if (this->index_ > this->list_->size_)
{
this->index_ = this->list_->size_;
}
return *this;
this->bound();
}
@ -563,7 +562,7 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::iterator&
Foam::PackedList<nBits>::iterator::operator++()
{
++this->index_;
this->next();
return *this;
}
@ -572,7 +571,7 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::const_iterator&
Foam::PackedList<nBits>::const_iterator::operator++()
{
++this->index_;
this->next();
return *this;
}
@ -581,8 +580,8 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::iterator
Foam::PackedList<nBits>::iterator::operator++(int)
{
iterator old = *this;
++this->index_;
iterator old(*this);
this->next();
return old;
}
@ -591,8 +590,8 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::const_iterator
Foam::PackedList<nBits>::const_iterator::operator++(int)
{
const_iterator old = *this;
++this->index_;
const_iterator old(*this);
this->next();
return old;
}
@ -601,7 +600,7 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::iterator&
Foam::PackedList<nBits>::iterator::operator--()
{
--this->index_;
this->prev();
return *this;
}
@ -610,7 +609,7 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::const_iterator&
Foam::PackedList<nBits>::const_iterator::operator--()
{
--this->index_;
this->prev();
return *this;
}
@ -619,8 +618,8 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::iterator
Foam::PackedList<nBits>::iterator::operator--(int)
{
iterator old = *this;
--this->index_;
iterator old(*this);
this->prev();
return old;
}
@ -629,8 +628,8 @@ template<unsigned nBits>
inline typename Foam::PackedList<nBits>::const_iterator
Foam::PackedList<nBits>::const_iterator::operator--(int)
{
const_iterator old = *this;
--this->index_;
const_iterator old(*this);
this->prev();
return old;
}
@ -643,14 +642,6 @@ Foam::PackedList<nBits>::iterator::operator*()
}
template<unsigned nBits>
inline typename Foam::PackedList<nBits>::iteratorBase&
Foam::PackedList<nBits>::iterator::operator()()
{
return static_cast<iteratorBase&>(*this);
}
template<unsigned nBits>
inline unsigned int
Foam::PackedList<nBits>::const_iterator::operator*() const
@ -659,14 +650,6 @@ Foam::PackedList<nBits>::const_iterator::operator*() const
}
template<unsigned nBits>
inline unsigned int
Foam::PackedList<nBits>::const_iterator::operator()() const
{
return this->get();
}
template<unsigned nBits>
inline typename Foam::PackedList<nBits>::iterator
Foam::PackedList<nBits>::begin()
@ -785,7 +768,6 @@ inline void Foam::PackedList<nBits>::resize
}
}
// Mask off the (new) final partial segment
{
const unsigned int off = size_ % packing();
@ -913,7 +895,7 @@ inline void Foam::PackedList<nBits>::clearStorage()
template<unsigned nBits>
inline void Foam::PackedList<nBits>::shrink()
{
// Any uneed space allocated?
// Any unneeded space allocated?
const label len = packedLength();
if (len < StorageList::size())
{

View File

@ -213,10 +213,10 @@ public:
// Constructors
//- Null constructor
inline UList();
inline constexpr UList() noexcept;
//- Construct from components
inline UList(T* __restrict__ v, label size);
inline UList(T* __restrict__ v, label size) noexcept;
// Member Functions

View File

@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
inline Foam::UList<T>::UList()
inline constexpr Foam::UList<T>::UList() noexcept
:
size_(0),
v_(nullptr)
@ -38,7 +38,7 @@ inline Foam::UList<T>::UList()
template<class T>
inline Foam::UList<T>::UList(T* __restrict__ v, label size)
inline Foam::UList<T>::UList(T* __restrict__ v, label size) noexcept
:
size_(size),
v_(v)

View File

@ -288,7 +288,7 @@ inline bool operator==(const edge& a, const edge& b);
inline bool operator!=(const edge& a, const edge& b);
//- Hash specialization for hashing edges - a commutative hash value.
//- Hash specialization for hashing edges as a commutative hash value.
// Hash incrementally.
template<>
inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const
@ -310,7 +310,7 @@ inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const
}
//- Hash specialization for hashing edges - a commutative hash value.
//- Hash specialization for hashing edges as a commutative hash value.
// Hash incrementally.
template<>
inline unsigned Hash<edge>::operator()(const edge& e) const

View File

@ -394,13 +394,10 @@ public:
};
//- Hash specialization to offset faces in ListListOps::combineOffset
//- Specialization to offset faces, used in ListListOps::combineOffset
template<>
class offsetOp<face>
struct offsetOp<face>
{
public:
inline face operator()
(
const face& x,

View File

@ -128,13 +128,10 @@ template<>
inline bool contiguous<labelledTri>() {return true;}
//- Hash specialization to offset faces in ListListOps::combineOffset
//- Specialization to offset faces, used in ListListOps::combineOffset
template<>
class offsetOp<labelledTri>
struct offsetOp<labelledTri>
{
public:
inline labelledTri operator()
(
const labelledTri& x,

View File

@ -246,8 +246,8 @@ inline bool operator==(const triFace& a, const triFace& b);
inline bool operator!=(const triFace& a, const triFace& b);
//- Hash specialization for hashing triFace - a commutative hash value.
// Hash incrementally.
//- Hash specialization for triFace as a commutative hash value.
// Hashes incrementally.
template<>
inline unsigned Hash<triFace>::operator()(const triFace& t, unsigned seed) const
{
@ -262,7 +262,7 @@ inline unsigned Hash<triFace>::operator()(const triFace& t, unsigned seed) const
}
//- Hash specialization for hashing triFace - a commutative hash value.
//- Hash specialization for triFace as a commutative hash value.
template<>
inline unsigned Hash<triFace>::operator()(const triFace& t) const
{
@ -270,13 +270,10 @@ inline unsigned Hash<triFace>::operator()(const triFace& t) const
}
//- Hash specialization to offset faces in ListListOps::combineOffset
//- Specialization to offset faces, used in ListListOps::combineOffset
template<>
class offsetOp<triFace>
struct offsetOp<triFace>
{
public:
inline triFace operator()
(
const triFace& x,

View File

@ -205,13 +205,7 @@ void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst) const
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
nOldPoints(),
false,
lst,
true
)
ListOps::createWithValue<bool>(nOldPoints(), lst, true, false)
);
// Distribute
@ -227,13 +221,7 @@ void Foam::mapDistributePolyMesh::distributeFaceIndices(labelList& lst) const
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
nOldFaces(),
false,
lst,
true
)
ListOps::createWithValue<bool>(nOldFaces(), lst, true, false)
);
// Distribute
@ -249,13 +237,7 @@ void Foam::mapDistributePolyMesh::distributeCellIndices(labelList& lst) const
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
(
nOldCells(),
false,
lst,
true
)
ListOps::createWithValue<bool>(nOldCells(), lst, true, false)
);
// Distribute
@ -271,12 +253,12 @@ void Foam::mapDistributePolyMesh::distributePatchIndices(labelList& lst) const
// Construct boolList from selected elements
boolList isSelected
(
createWithValues<boolList>
ListOps::createWithValue<bool>
(
oldPatchStarts().size(), // nOldPatches
false,
oldPatchStarts().size(), // nOldPatches
lst,
true
true, // set value
false // default value
)
);

View File

@ -1413,12 +1413,12 @@ Foam::label Foam::snappyRefineDriver::shellRefine
// mark list to remove any refined faces
meshRefiner_.userFaceData()[0].first() = meshRefinement::REMOVE;
meshRefiner_.userFaceData()[0].second() = createWithValues<labelList>
meshRefiner_.userFaceData()[0].second() = ListOps::createWithValue<label>
(
mesh.nFaces(),
-1,
meshRefiner_.intersectedFaces(),
0
0, // set value
-1 // default value
);
// Determine the maximum refinement level over all volume refinement

View File

@ -1007,7 +1007,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
}
// Send data back to originating procs. Note that contributions
// from different processors get added (ListAppendEqOp)
// from different processors get added (ListOps::appendEqOp)
mapDistributeBase::distribute
(
@ -1019,7 +1019,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
map.subMap(),
false, // has flip
tgtAddress_,
ListAppendEqOp<label>(),
ListOps::appendEqOp<label>(),
flipOp(), // flip operation
labelList()
);
@ -1034,7 +1034,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
map.subMap(),
false,
tgtWeights_,
ListAppendEqOp<scalar>(),
ListOps::appendEqOp<scalar>(),
flipOp(),
scalarList()
);

View File

@ -1084,13 +1084,7 @@ Foam::triSurface Foam::distributedTriSurfaceMesh::subsetMesh
{
const boolList include
(
createWithValues<boolList>
(
s.size(),
false,
newToOldFaces,
true
)
ListOps::createWithValue<bool>(s.size(), newToOldFaces, true, false)
);
newToOldPoints.setSize(s.points().size());

View File

@ -1266,13 +1266,7 @@ Foam::triSurface Foam::isoSurface::subsetMesh
{
const boolList include
(
createWithValues<boolList>
(
s.size(),
false,
newToOldFaces,
true
)
ListOps::createWithValue<bool>(s.size(), newToOldFaces, true, false)
);
newToOldPoints.setSize(s.points().size());

View File

@ -1236,13 +1236,7 @@ Foam::triSurface Foam::isoSurfaceCell::subsetMesh
{
const boolList include
(
createWithValues<boolList>
(
s.size(),
false,
newToOldFaces,
true
)
ListOps::createWithValue<bool>(s.size(), newToOldFaces, true, false)
);
newToOldPoints.setSize(s.points().size());