73 procToProcs.resize_nocopy(
n);
82 procToProcs[
n++] = ppPtr->neighbProcNo();
96 DynamicList<label>
front;
99 DynamicList<label> newFront;
105 for (
const label proci :
front)
107 if (procColour[proci] == -1)
109 const labelList& nbrs = procNeighbours[proci];
110 const UIndirectList<label> nbrColour(procColour, nbrs);
119 if (!nbrColour.found(colouri))
121 procColour[proci] = colouri;
122 for (label nbrProci : nbrs)
124 if (procColour[nbrProci] == -1)
126 newFront.append(nbrProci);
135 front = std::move(newFront);
177 DynamicList<label>& front,
183 const lduAddressing& addr =
mesh.lduAddr();
184 const label*
const __restrict__ uPtr = addr.upperAddr().begin();
185 const label*
const __restrict__ lPtr = addr.lowerAddr().begin();
186 const label*
const __restrict__ ownStartPtr = addr.ownerStartAddr().begin();
187 const label*
const __restrict__ losortStartAddrPtr =
188 addr.losortStartAddr().begin();
189 const label*
const __restrict__ losortAddrPtr = addr.losortAddr().begin();
191 DynamicList<label> newFront;
195 for (
const label celli : front)
197 const label colouri = cellColour[celli];
200 const label fStart = ownStartPtr[celli];
201 const label fEnd = ownStartPtr[celli + 1];
203 for (label facei=fStart; facei<fEnd; facei++)
205 const label nbr = uPtr[facei];
206 if (cellColour[nbr] == -1)
208 cellColour[nbr] = colouri;
209 newFront.append(nbr);
214 const label fStart = losortStartAddrPtr[celli];
215 const label fEnd = losortStartAddrPtr[celli + 1];
217 for (label i=fStart; i<fEnd; i++)
219 label facei = losortAddrPtr[i];
220 const label nbr = lPtr[facei];
221 if (cellColour[nbr] == -1)
223 cellColour[nbr] = colouri;
224 newFront.append(nbr);
230 if (newFront.empty())
235 front.transfer(newFront);
254 const label nCells = addr.
size();
258 cellColour.resize_nocopy(nCells);
276 if (patchToColour[inti] == -1)
278 patchToColour[inti] = colouri++;
285 if (cellColour[
cell] != patchToColour[inti])
287 cellColour[
cell] = patchToColour[inti];
296 walkFront(
mesh, front, cellColour);
300 for (
auto& colour : cellColour)
311 <<
" cells with in total " << colouri <<
" colours" <<
endl;
320Foam::processorColour::processorColour(
const lduMesh&
mesh)
322 MeshObject_type(
mesh)
333 mesh.thisDb().objectRegistry::template getObjectPtr<processorColour>
335 processorColour::typeName
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 append(const T &val)
Copy append an element to the end of this list.
bool found(const T &val, label pos=0) const
Same as contains().
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
const lduMesh & mesh() const noexcept
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
A List with indirect addressing. Like IndirectList but does not store addressing.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static int & msgType() noexcept
Message tag of standard messages.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
@ gatherList
gatherList [manual algorithm]
@ broadcast
broadcast [MPI]
label size() const noexcept
The number of entries in the list.
A cell is defined as a list of faces with extra functionality.
A face is a list of labels corresponding to mesh vertices.
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const labelUList & ownerStartAddr() const
Return owner start addressing.
const labelUList & losortStartAddr() const
Return losort start addressing.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
label size() const noexcept
Return number of equations.
const labelUList & losortAddr() const
Return losort addressing.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
Colouring processors such that no neighbours have the same colour.
static const processorColour & New(const lduMesh &mesh)
Should use the MeshObject provided one but that needs a.
label nColours_
Max number of colours.
static void walkFront(const lduMesh &mesh, DynamicList< label > &front, labelList &cellColour)
static label cellColour(const lduMesh &mesh, labelList &cellColour, labelList &patchToColour)
Calculate (locally) per cell colour according to walking from global patches. Returns number of colou...
static label colour(const lduMesh &mesh, labelList &procColour)
Calculate processor colouring from processor connectivity. Sets colour per processor such that no nei...
bool store()
Register object with its registry and transfer ownership to the registry.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
Namespace for handling debugging switches.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
messageStream Info
Information stream (stdout output on master, null elsewhere).
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Define the processor-processor connection table by walking a list of patches and detecting the proces...
#define forAll(list, i)
Loop across all elements in list.