processorColour.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2022 M. Janssens
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::processorColour
28 
29 Description
30  Colouring processors such that no neighbours have the same colour
31 
32 SourceFiles
33  processorColour.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_processorColour_H
38 #define Foam_processorColour_H
39 
40 #include "MeshObject.H"
41 #include "lduMesh.H"
42 #include "lduInterfacePtrsList.H"
43 #include "primitiveFields.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 class lduMatrix;
51 
52 /*---------------------------------------------------------------------------*\
53  Class processorColour Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class processorColour
57 :
58  public MeshObject<lduMesh, MoveableMeshObject, processorColour>,
59  public labelList
60 {
61 protected:
62 
63  // Protected data
64 
65  //- Max number of colours
66  label nColours_;
67 
68 
69  // Protected Member Fucntions
70 
71  static void walkFront
72  (
73  const lduMesh& mesh,
76  );
77 
78 
79 private:
80 
81  //- No copy construct
82  processorColour(const processorColour&) = delete;
83 
84  //- No copy assignment
85  void operator=(const processorColour&) = delete;
86 
87 
88 public:
89 
90  //- Runtime type information
91  TypeName("processorColour");
92 
93 
94  // Constructors
95 
96  //- Construct given mesh
98 
99 
100  // Selectors
101 
102  //- Should use the MeshObject provided one but that needs a
103  // mesh.name() ...
104  static const processorColour& New(const lduMesh& mesh);
105 
106 
107  //- Destructor
108  virtual ~processorColour() = default;
109 
110 
111  // Member Functions
112 
113  // Access
114 
115  label nColours() const
116  {
117  return nColours_;
118  }
119 
120  label myColour() const
121  {
122  return operator[](Pstream::myProcNo());
123  }
124 
126  //- Calculate processor colouring from processor connectivity. Sets
127  //- colour per processor such that no neighbouring processors have the
128  //- same colour. Returns number of colours used.
129  static label colour(const lduMesh& mesh, labelList& procColour);
131  //- Calculate (locally) per cell colour according to walking from
132  //- global patches. Returns number of colours used.
133  //- Note: asssumes all non-processor interfaces are global.
134  static label cellColour
135  (
136  const lduMesh& mesh,
138  labelList& patchToColour
139  );
140 
141  virtual bool movePoints()
142  {
143  return true;
144  }
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
156 // ************************************************************************* //
label nColours_
Max number of colours.
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...
virtual ~processorColour()=default
Destructor.
T & front()
Access first element of the list, position [0].
Definition: UListI.H:237
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:53
static void walkFront(const lduMesh &mesh, DynamicList< label > &front, labelList &cellColour)
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1074
virtual bool movePoints()
T & operator[](const label i)
Return element of UList.
Definition: UListI.H:361
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
const lduMesh & mesh() const noexcept
Reference to the mesh.
Definition: MeshObject.H:157
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...
Specialisations of Field<T> for scalar, vector and tensor.
Colouring processors such that no neighbours have the same colour.
TypeName("processorColour")
Runtime type information.
Namespace for OpenFOAM.