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 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 "decompositionMethod.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(CuthillMcKeeRenumber, 0);
39 
41  (
42  renumberMethod,
43  CuthillMcKeeRenumber,
44  dictionary
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 Foam::CuthillMcKeeRenumber::CuthillMcKeeRenumber(const dictionary& renumberDict)
52 :
53  renumberMethod(renumberDict),
54  reverse_
55  (
56  renumberDict.optionalSubDict
57  (
58  typeName + "Coeffs"
59  ).getOrDefault("reverse", false)
60  )
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 
67 (
68  const polyMesh& mesh,
69  const pointField& points
70 ) const
71 {
72  CompactListList<label> cellCells;
74  (
75  mesh,
76  identity(mesh.nCells()),
77  mesh.nCells(),
78  false, // local only
79  cellCells
80  );
81 
82  labelList orderedToOld = bandCompression(cellCells());
83 
84  if (reverse_)
85  {
86  reverse(orderedToOld);
87  }
88 
89  return orderedToOld;
90 }
91 
92 
94 (
95  const labelList& cellCells,
96  const labelList& offsets,
97  const pointField& cc
98 ) const
99 {
100  labelList orderedToOld = bandCompression(cellCells, offsets);
101 
102  if (reverse_)
103  {
104  reverse(orderedToOld);
105  }
106 
107  return orderedToOld;
108 }
109 
110 
112 (
113  const labelListList& cellCells,
114  const pointField& points
115 ) const
116 {
117  labelList orderedToOld = bandCompression(cellCells);
118 
119  if (reverse_)
120  {
121  reverse(orderedToOld);
122  }
123 
124  return orderedToOld;
125 }
126 
127 
128 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::reverse
void reverse(UList< T > &list, const label n)
Definition: UListI.H:449
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:468
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: CompactListList.H:63
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 noexcept
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:123
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