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  // Private Typedefs
62 
63  typedef MeshObject
64  <
65  lduMesh,
69 
70 
71  // Private Member Functions
72 
73  //- No copy construct
74  processorColour(const processorColour&) = delete;
75 
76  //- No copy assignment
77  void operator=(const processorColour&) = delete;
78 
79 
80 protected:
81 
82  // Protected data
83 
84  //- Max number of colours
85  label nColours_;
86 
87 
88  // Protected Member Fucntions
89 
90  static void walkFront
91  (
92  const lduMesh& mesh,
95  );
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("processorColour");
101 
102 
103  // Constructors
104 
105  //- Construct given mesh
106  explicit processorColour(const lduMesh& mesh);
107 
108 
109  // Selectors
110 
111  //- Should use the MeshObject provided one but that needs a
112  // mesh.name() ...
113  static const processorColour& New(const lduMesh& mesh);
114 
115 
116  //- Destructor
117  virtual ~processorColour() = default;
118 
119 
120  // Member Functions
121 
122  // Access
123 
124  label nColours() const
125  {
126  return nColours_;
127  }
128 
129  label myColour() const
130  {
131  return operator[](Pstream::myProcNo());
132  }
133 
135  //- Calculate processor colouring from processor connectivity. Sets
136  //- colour per processor such that no neighbouring processors have the
137  //- same colour. Returns number of colours used.
138  static label colour(const lduMesh& mesh, labelList& procColour);
140  //- Calculate (locally) per cell colour according to walking from
141  //- global patches. Returns number of colours used.
142  //- Note: asssumes all non-processor interfaces are global.
143  static label cellColour
144  (
145  const lduMesh& mesh,
147  labelList& patchToColour
148  );
149 
150  virtual bool movePoints()
151  {
152  return true;
153  }
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
165 // ************************************************************************* //
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.
MoveableMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:328
T & front()
Access first element of the list, position [0].
Definition: UListI.H:232
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:53
static int myProcNo(label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
Definition: UPstream.H:1799
static void walkFront(const lduMesh &mesh, DynamicList< label > &front, labelList &cellColour)
virtual bool movePoints()
Update for mesh motion.
T & operator[](const label i)
Return element of UList.
Definition: UListI.H:356
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
const lduMesh & mesh() const noexcept
Reference to the mesh.
Definition: MeshObject.H:257
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.