CuthillMcKeeRenumber.C
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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2020-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "CuthillMcKeeRenumber.H"
31 #include "bandCompression.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeName(CuthillMcKeeRenumber);
38  defineTypeName(reverseCuthillMcKeeRenumber);
39 
41  (
42  renumberMethod,
43  CuthillMcKeeRenumber,
44  dictionary
45  );
46 
48  (
49  renumberMethod,
50  reverseCuthillMcKeeRenumber,
51  dictionary
52  );
53 
54  // Select under the name "RCM"
56  (
57  renumberMethod,
58  reverseCuthillMcKeeRenumber,
59  dictionary,
60  RCM
61  );
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
68 :
70  reverse_(reverse)
71 {}
72 
73 
75 :
77  reverse_
78  (
79  dict.optionalSubDict(typeName + "Coeffs")
80  .getOrDefault("reverse", false)
81  )
82 {}
83 
84 
86 (
87  const dictionary& dict,
88  const bool reverse
89 )
90 :
92  reverse_(reverse)
93 {}
94 
95 
97 :
98  CuthillMcKeeRenumber(true) // reverse = true
99 {}
100 
101 
103 (
104  const dictionary& dict
105 )
106 :
107  CuthillMcKeeRenumber(dict, true) // reverse = true
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 
114 (
115  const polyMesh& mesh
116 ) const
117 {
118  labelList orderedToOld = meshTools::bandCompression(mesh);
119 
120  if (reverse_)
121  {
122  Foam::reverse(orderedToOld);
123  }
124 
125  return orderedToOld;
126 }
127 
128 
130 (
131  const CompactListList<label>& cellCells
132 ) const
133 {
134  labelList orderedToOld = meshTools::bandCompression(cellCells);
135 
136  if (reverse_)
137  {
138  Foam::reverse(orderedToOld);
139  }
140 
141  return orderedToOld;
142 }
143 
144 
146 (
147  const labelListList& cellCells
148 ) const
149 {
150  labelList orderedToOld = meshTools::bandCompression(cellCells);
151 
152  if (reverse_)
153  {
154  Foam::reverse(orderedToOld);
155  }
156 
157  return orderedToOld;
158 }
159 
160 
161 // Foam::labelList Foam::CuthillMcKeeRenumber::renumber
162 // (
163 // const labelUList& cellCells,
164 // const labelUList& offsets
165 // ) const
166 // {
167 // labelList orderedToOld = meshTools::bandCompression(cellCells, offsets);
168 //
169 // if (reverse_)
170 // {
171 // Foam::reverse(orderedToOld);
172 // }
173 //
174 // return orderedToOld;
175 // }
176 
177 
178 // ************************************************************************* //
dictionary dict
reverseCuthillMcKeeRenumber()
Default construct.
CuthillMcKeeRenumber(const bool reverse=false)
Default construct, optionally with reverse.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
defineTypeName(manifoldCellsMeshObject)
Abstract base class for renumbering.
The bandCompression function renumbers the addressing such that the band of the matrix is reduced...
dynamicFvMesh & mesh
Cuthill-McKee renumbering (CM or RCM)
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
Definition: UListI.H:521
virtual labelList renumber(const polyMesh &mesh) const
Return the cell visit order (from ordered back to original cell id) using the mesh to determine the c...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
List< label > labelList
A List of labels.
Definition: List.H:62
labelList bandCompression(const polyMesh &mesh)
Renumber (mesh) addressing to reduce the band of the mesh connectivity, using the Cuthill-McKee algor...
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)