CuthillMcKeeRenumber.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "CuthillMcKeeRenumber.H"
28 #include "bandCompression.H"
29 #include "decompositionMethod.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 
38  (
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 :
50  renumberMethod(renumberDict),
51  reverse_
52  (
53  renumberDict.optionalTypeDict(typeName)
54  .lookupOrDefault<Switch>("reverse", false)
55  )
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 
62 (
63  const polyMesh& mesh,
64  const pointField& points
65 ) const
66 {
67  CompactListList<label> cellCells;
69  (
70  mesh,
72  mesh.nCells(),
73  false, // local only
74  cellCells
75  );
76 
77  labelList orderedToOld = bandCompression(cellCells.list());
78 
79  if (reverse_)
80  {
81  reverse(orderedToOld);
82  }
83 
84  return orderedToOld;
85 }
86 
87 
89 (
90  const labelList& cellCells,
91  const labelList& offsets,
92  const pointField& cc
93 ) const
94 {
95  labelList orderedToOld = bandCompression(cellCells, offsets);
96 
97  if (reverse_)
98  {
99  reverse(orderedToOld);
100  }
101 
102  return orderedToOld;
103 }
104 
105 
107 (
108  const labelListList& cellCells,
109  const pointField& points
110 ) const
111 {
112  labelList orderedToOld = bandCompression(cellCells);
113 
114  if (reverse_)
115  {
116  reverse(orderedToOld);
117  }
118 
119  return orderedToOld;
120 }
121 
122 
123 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
The bandCompression function renumbers the addressing such that the band of the matrix is reduced....
Cuthill-McKee renumbering.
CuthillMcKeeRenumber(const dictionary &renumberDict)
Construct given the renumber dictionary.
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
List< Container > list() const
Convert to List<Container>
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool global, CompactListList< label > &cellCells)
Helper: determine (local or global) cellCells from mesh.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
label nCells() const
Abstract base class for renumbering.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const pointField & points
Namespace for OpenFOAM.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
labelList bandCompression(const labelListList &addressing)
Renumbers the addressing to reduce the band of the matrix.
void reverse(UList< T > &, const label n)
Definition: UListI.H:334
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)