renumberMethod.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-2015 OpenFOAM Foundation
9  Copyright (C) 2019-2023 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 "renumberMethod.H"
30 #include "globalMeshData.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
38 }
39 
40 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
41 
43 (
44  const dictionary& dict
45 )
46 {
47  const word methodType(dict.get<word>("method"));
48 
49  //Info<< "Selecting renumberMethod " << methodType << endl;
50 
51  auto* ctorPtr = dictionaryConstructorTable(methodType);
52 
53  if (!ctorPtr)
54  {
56  (
57  dict,
58  "renumberMethod",
59  methodType,
60  *dictionaryConstructorTablePtr_
61  ) << exit(FatalIOError);
62  }
63 
64  return autoPtr<renumberMethod>(ctorPtr(dict));
65 }
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
71 (
72  const polyMesh& mesh,
73  const pointField& points
74 ) const
75 {
76  CompactListList<label> cellCells;
78  (
79  mesh,
80  identity(mesh.nCells()),
81  mesh.nCells(),
82  false, // local only
83  cellCells
84  );
85 
86  return renumber(cellCells, points);
87 }
88 
89 
91 (
92  const CompactListList<label>& cellCells,
93  const pointField& points
94 ) const
95 {
96  return renumber(cellCells.unpack(), points);
97 }
98 
99 
101 (
102  const labelList& cellCells,
103  const labelList& offsets,
104  const pointField& cc
105 ) const
106 {
108  return labelList();
109 }
110 
111 
113 (
114  const polyMesh& mesh,
115  const labelList& fineToCoarse,
116  const pointField& coarsePoints
117 ) const
118 {
119  CompactListList<label> coarseCellCells;
121  (
122  mesh,
123  fineToCoarse,
124  coarsePoints.size(),
125  false, // local only
126  coarseCellCells
127  );
128 
129  // Renumber based on agglomerated points
130  labelList coarseDistribution
131  (
132  renumber(coarseCellCells, coarsePoints)
133  );
134 
135  // From coarse back to fine for original mesh
136  return labelList(coarseDistribution, fineToCoarse);
137 }
138 
139 
140 // ************************************************************************* //
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited (ie. from ordered back to original cell label)...
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells)
Determine (local or global) cellCells from mesh agglomeration.
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
Abstract base class for renumbering.
dynamicFvMesh & mesh
const pointField & points
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Definition: labelLists.C:44
List< SubListType > unpack() const
Return non-compact list of lists.
A class for handling words, derived from Foam::string.
Definition: word.H:63
A packed storage of objects of type <T> using an offset table for access.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
label nCells() const noexcept
Number of mesh cells.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
List< label > labelList
A List of labels.
Definition: List.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...