43template<
class ConnectionListListType>
46 const ConnectionListListType& cellCellAddressing
51 const label nOldCells(cellCellAddressing.size());
54 bitSet unvisited(nOldCells,
true);
75 label cellInOrder = 0;
83 for (
const label celli : unvisited)
85 const label nbrCount = cellCellAddressing[celli].size();
87 if (minCount > nbrCount)
102 queuedCells.append(currCelli);
109 while (!queuedCells.empty())
112 currCelli = queuedCells.first();
113 queuedCells.pop_front();
115 if (unvisited.test(currCelli))
118 unvisited.unset(currCelli);
121 newOrder[cellInOrder] = currCelli;
131 const auto& neighbours = cellCellAddressing[currCelli];
133 for (
const label nbr : neighbours)
135 const label nbrCount = cellCellAddressing[nbr].size();
137 if (unvisited.test(nbr))
152 for (
const label nbrIdx : nbrOrder)
154 queuedCells.append(nbrCells[nbrIdx]);
176 const label nOldCells =
max(0, (offsets.
size()-1));
180 for (label celli = 0; celli < nOldCells; ++celli)
182 const label beg = offsets[celli];
183 const label end = offsets[celli+1];
185 for (label idx = beg; idx < end; ++idx)
188 ++numNbrs[cellCells[idx]];
194 bitSet unvisited(nOldCells,
true);
216 label cellInOrder = 0;
221 label currCelli = -1;
224 for (
const label celli : unvisited)
226 const label nbrCount = numNbrs[celli];
228 if (minCount > nbrCount)
243 queuedCells.
append(currCelli);
255 while (!queuedCells.
empty())
258 currCelli = queuedCells.
first();
261 if (unvisited.test(currCelli))
264 unvisited.unset(currCelli);
267 newOrder[cellInOrder] = currCelli;
276 const label beg = offsets[currCelli];
277 const label end = offsets[currCelli+1];
279 for (label idx = beg; idx < end; ++idx)
281 const label nbr = cellCells[idx];
282 const label nbrCount = numNbrs[nbr];
284 if (unvisited.test(nbr))
299 for (
const label nbrIdx : nbrOrder)
301 queuedCells.
append(nbrCells[nbrIdx]);
320 return cuthill_mckee_algorithm(cellCellAddressing);
329 return cuthill_mckee_algorithm(cellCellAddressing);
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
The bandCompression function renumbers the addressing such that the band of the matrix is reduced....
A simple list of objects of type <T> that is intended to be used as a circular buffer (eg,...
void pop_front(label n=1)
Shrink by moving the front of the buffer 1 or more times.
T & first()
Access the first element (front). Requires !empty().
bool empty() const noexcept
Empty or exhausted buffer.
void append(const T &val)
Copy append an element to the end of the buffer.
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void resize_nocopy(const label len)
void append(const T &val)
Copy append an element to the end of this list.
void size(const label n)
Older name for setAddressableSize.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.