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-2018 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 {
35  defineTypeNameAndDebug(CuthillMcKeeRenumber, 0);
36 
38  (
39  renumberMethod,
40  CuthillMcKeeRenumber,
41  dictionary
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 :
50  renumberMethod(renumberDict),
51  reverse_
52  (
53  renumberDict.optionalSubDict
54  (
55  typeName + "Coeffs"
56  ).lookupOrDefault<Switch>("reverse", false)
57  )
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
64 (
65  const polyMesh& mesh,
66  const pointField& points
67 ) const
68 {
69  CompactListList<label> cellCells;
71  (
72  mesh,
73  identity(mesh.nCells()),
74  mesh.nCells(),
75  false, // local only
76  cellCells
77  );
78 
79  labelList orderedToOld = bandCompression(cellCells());
80 
81  if (reverse_)
82  {
83  reverse(orderedToOld);
84  }
85 
86  return orderedToOld;
87 }
88 
89 
91 (
92  const labelList& cellCells,
93  const labelList& offsets,
94  const pointField& cc
95 ) const
96 {
97  labelList orderedToOld = bandCompression(cellCells, offsets);
98 
99  if (reverse_)
100  {
101  reverse(orderedToOld);
102  }
103 
104  return orderedToOld;
105 }
106 
107 
109 (
110  const labelListList& cellCells,
111  const pointField& points
112 ) const
113 {
114  labelList orderedToOld = bandCompression(cellCells);
115 
116  if (reverse_)
117  {
118  reverse(orderedToOld);
119  }
120 
121  return orderedToOld;
122 }
123 
124 
125 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
CuthillMcKeeRenumber(const dictionary &renumberDict)
Construct given the renumber dictionary.
label nCells() const
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
Macros for easy insertion into run-time selection tables.
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.
Abstract base class for renumbering.
The bandCompression function renumbers the addressing such that the band of the matrix is reduced...
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
void reverse(UList< T > &, const label n)
Definition: UListI.H:322
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
labelList bandCompression(const labelListList &addressing)
Renumbers the addressing to reduce the band of the matrix.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.