66 if (isA<processorLduInterface>(
patches[patchi]))
73 procToProcs.resize_nocopy(
n);
79 const auto* ppPtr = isA<processorLduInterface>(
patches[patchi]);
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);
167 <<
" processors with in total " <<
nColours <<
" colours" <<
endl;
177 DynamicList<label>& front,
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++)
211 if (cellColour[nbr] == -1)
213 cellColour[nbr] = colouri;
214 newFront.append(nbr);
219 const label fStart = losortStartAddrPtr[celli];
220 const label fEnd = losortStartAddrPtr[celli + 1];
222 for (label i=fStart; i<fEnd; i++)
224 label facei = losortAddrPtr[i];
231 if (cellColour[nbr] == -1)
233 cellColour[nbr] = colouri;
234 newFront.append(nbr);
241 if (newFront.empty())
246 front.transfer(newFront);
265 const label nCells = addr.
size();
269 cellColour.resize_nocopy(nCells);
276 DynamicList<label> front;
282 && !isA<processorLduInterface>(
patches[inti])
287 if (patchToColour[inti] == -1)
289 patchToColour[inti] = colouri++;
295 const label cell = fc[face];
296 if (cellColour[cell] != patchToColour[inti])
298 cellColour[cell] = patchToColour[inti];
307 walkFront(
mesh, front, cellColour);
311 for (
auto& colour : cellColour)
321 Info<< typeName <<
" : coloured " << nCells
322 <<
" cells with in total " << colouri <<
" colours" <<
endl;
331 Foam::processorColour::processorColour(
const lduMesh&
mesh)
333 MeshObject_type(
mesh)
335 nColours_ = colour(
mesh, *
this);
344 mesh.
thisDb().objectRegistry::template getObjectPtr<processorColour>
346 processorColour::typeName
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch with only those pointing to interfaces being set...
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...
void append(const T &val)
Append an element at the end of the list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
T & front()
Access first element of the list, position [0].
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
bool store()
Register object with its registry and transfer ownership to the registry.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
static int & msgType() noexcept
Message tag of standard messages.
static void walkFront(const lduMesh &mesh, DynamicList< label > &front, labelList &cellColour)
virtual label comm() const =0
Return communicator used for parallel communication.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
#define forAll(list, i)
Loop across all elements in list.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
const lduMesh & mesh() const noexcept
Reference to the mesh.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
label size() const noexcept
The number of entries in the list.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
iterator begin() noexcept
Return an iterator to begin traversing the UList.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
static const processorColour & New(const lduMesh &mesh)
Should use the MeshObject provided one but that needs a.
static label colour(const lduMesh &mesh, labelList &procColour)
Calculate processor colouring from processor connectivity. Sets colour per processor such that no nei...
Define the processor-processor connection table by walking a list of patches and detecting the proces...
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Colouring processors such that no neighbours have the same colour.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.