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 | Copyright (C) 2011-2013 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 
48 Foam::CuthillMcKeeRenumber::CuthillMcKeeRenumber(const dictionary& renumberDict)
49 :
50  renumberMethod(renumberDict),
51  reverse_
52  (
53  renumberDict.found(typeName + "Coeffs")
54  ? Switch(renumberDict.subDict(typeName + "Coeffs").lookup("reverse"))
55  : Switch(false)
56  )
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 
63 (
64  const polyMesh& mesh,
65  const pointField& points
66 ) const
67 {
68  CompactListList<label> cellCells;
70  (
71  mesh,
72  identity(mesh.nCells()),
73  mesh.nCells(),
74  false, // local only
75  cellCells
76  );
77 
78  labelList orderedToOld = bandCompression(cellCells());
79 
80  if (reverse_)
81  {
82  reverse(orderedToOld);
83  }
84 
85  return orderedToOld;
86 }
87 
88 
90 (
91  const labelList& cellCells,
92  const labelList& offsets,
93  const pointField& cc
94 ) const
95 {
96  labelList orderedToOld = bandCompression(cellCells, offsets);
97 
98  if (reverse_)
99  {
100  reverse(orderedToOld);
101  }
102 
103  return orderedToOld;
104 }
105 
106 
108 (
109  const labelListList& cellCells,
110  const pointField& points
111 ) const
112 {
113  labelList orderedToOld = bandCompression(cellCells);
114 
115  if (reverse_)
116  {
117  reverse(orderedToOld);
118  }
119 
120  return orderedToOld;
121 }
122 
123 
124 // ************************************************************************* //
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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.
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.
label nCells() const
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...
stressControl lookup("compactNormalStress") >> compactNormalStress
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
bool found
Namespace for OpenFOAM.