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-2023 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 #include "globalMeshData.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(CuthillMcKeeRenumber, 0);
39 
41  (
42  renumberMethod,
43  CuthillMcKeeRenumber,
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 Foam::CuthillMcKeeRenumber::CuthillMcKeeRenumber(const dictionary& dict)
52 :
54  reverse_
55  (
56  dict.optionalSubDict(typeName + "Coeffs")
57  .getOrDefault("reverse", false)
58  )
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
65 (
66  const polyMesh& mesh,
67  const pointField& points
68 ) const
69 {
70  CompactListList<label> cellCells;
72  (
73  mesh,
74  identity(mesh.nCells()),
75  mesh.nCells(),
76  false, // local only
77  cellCells
78  );
79 
80  labelList orderedToOld = meshTools::bandCompression(cellCells);
81 
82  if (reverse_)
83  {
84  reverse(orderedToOld);
85  }
86 
87  return orderedToOld;
88 }
89 
90 
92 (
93  const labelList& cellCells,
94  const labelList& offsets,
95  const pointField& cc
96 ) const
97 {
98  labelList orderedToOld = meshTools::bandCompression(cellCells, offsets);
99 
100  if (reverse_)
101  {
102  reverse(orderedToOld);
103  }
104 
105  return orderedToOld;
106 }
107 
108 
110 (
111  const CompactListList<label>& cellCells,
112  const pointField& cc
113 ) const
114 {
115  labelList orderedToOld = meshTools::bandCompression(cellCells);
116 
117  if (reverse_)
118  {
119  reverse(orderedToOld);
120  }
121 
122  return orderedToOld;
123 }
124 
125 
127 (
128  const labelListList& cellCells,
129  const pointField& points
130 ) const
131 {
132  labelList orderedToOld = meshTools::bandCompression(cellCells);
133 
134  if (reverse_)
135  {
136  reverse(orderedToOld);
137  }
138 
139  return orderedToOld;
140 }
141 
142 
143 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells)
Determine (local or global) cellCells from mesh agglomeration.
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
Macros for easy insertion into run-time selection tables.
Abstract base class for renumbering.
The bandCompression function renumbers the addressing such that the band of the matrix is reduced...
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
const pointField & points
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Definition: labelLists.C:44
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited (ie. from ordered back to original cell label)...
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
Definition: UListI.H:520
A packed storage of objects of type <T> using an offset table for access.
defineTypeNameAndDebug(combustionModel, 0)
label nCells() const noexcept
Number of mesh cells.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
List< label > labelList
A List of labels.
Definition: List.H:62
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
labelList bandCompression(const CompactListList< label > &addressing)
Renumber (mesh) addressing to reduce the band of the matrix, using the Cuthill-McKee algorithm...