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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "CuthillMcKeeRenumber.H"
30 #include "bandCompression.H"
31 #include "decompositionMethod.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(CuthillMcKeeRenumber, 0);
38 
40  (
41  renumberMethod,
42  CuthillMcKeeRenumber,
43  dictionary
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 Foam::CuthillMcKeeRenumber::CuthillMcKeeRenumber(const dictionary& renumberDict)
51 :
52  renumberMethod(renumberDict),
53  reverse_
54  (
55  renumberDict.optionalSubDict
56  (
57  typeName + "Coeffs"
58  ).lookupOrDefault("reverse", false)
59  )
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
66 (
67  const polyMesh& mesh,
68  const pointField& points
69 ) const
70 {
71  CompactListList<label> cellCells;
73  (
74  mesh,
75  identity(mesh.nCells()),
76  mesh.nCells(),
77  false, // local only
78  cellCells
79  );
80 
81  labelList orderedToOld = bandCompression(cellCells());
82 
83  if (reverse_)
84  {
85  reverse(orderedToOld);
86  }
87 
88  return orderedToOld;
89 }
90 
91 
93 (
94  const labelList& cellCells,
95  const labelList& offsets,
96  const pointField& cc
97 ) const
98 {
99  labelList orderedToOld = bandCompression(cellCells, offsets);
100 
101  if (reverse_)
102  {
103  reverse(orderedToOld);
104  }
105 
106  return orderedToOld;
107 }
108 
109 
111 (
112  const labelListList& cellCells,
113  const pointField& points
114 ) const
115 {
116  labelList orderedToOld = bandCompression(cellCells);
117 
118  if (reverse_)
119  {
120  reverse(orderedToOld);
121  }
122 
123  return orderedToOld;
124 }
125 
126 
127 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::reverse
void reverse(UList< T > &list, const label n)
Definition: UListI.H:396
Foam::decompositionMethod::calcCellCells
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.
Definition: decompositionMethod.C:517
Foam::bandCompression
labelList bandCompression(const labelListList &addressing)
Renumbers the addressing to reduce the band of the matrix.
Definition: bandCompression.C:44
Foam::CompactListList
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
Definition: polyTopoChange.H:94
Foam::CuthillMcKeeRenumber::renumber
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
Definition: CuthillMcKeeRenumber.H:88
decompositionMethod.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::Field< vector >
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
bandCompression.H
The bandCompression function renumbers the addressing such that the band of the matrix is reduced....
Foam::renumberMethod
Abstract base class for renumbering.
Definition: renumberMethod.H:50
Foam::List< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
CuthillMcKeeRenumber.H