Loading...
Searching...
No Matches
manualRenumber.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-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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 "manualRenumber.H"
31#include "labelIOList.H"
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
38
40 (
44 );
45}
46
47
48// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49
58:
60 dataFile_
61 (
62 dict.optionalSubDict(typeName + "Coeffs").get<fileName>("dataFile")
63 )
64{}
65
66
67// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68
70(
71 const polyMesh& mesh
72) const
73{
74 const label nCells = mesh.nCells();
75
76 labelList newToOld
77 (
79 (
81 (
82 dataFile_,
83 mesh.facesInstance(),
84 mesh.thisDb(),
86 )
87 )
88 );
89
90 // Check if the final renumbering is OK
91 if (newToOld.size() != nCells)
92 {
94 << "Size of renumber list: "
95 << newToOld.size() << " != number of cells: " << nCells << nl
96 << "Renumbering data read from file " << dataFile_ << endl
97 << exit(FatalError);
98 }
99
100 // Invert to see if one to one
101 labelList oldToNew(nCells, -1);
102 forAll(newToOld, i)
103 {
104 const label origCelli = newToOld[i];
105
106 if (origCelli < 0 || origCelli >= nCells)
107 {
109 << "Renumbering range error. Index " << i
110 << " maps to cell " << origCelli << " from " << nCells << nl
111 << "Renumbering data read from file " << dataFile_ << endl
112 << exit(FatalError);
113 }
114
115 if (oldToNew[origCelli] == -1)
116 {
117 oldToNew[origCelli] = i;
118 }
119 else
120 {
122 << "Renumbering is not one-to-one. Index " << i << " and "
123 << oldToNew[origCelli] << " map onto " << origCelli << nl
124 << "Renumbering data read from file " << dataFile_ << endl
125 << exit(FatalError);
126 }
127 }
128
129 return newToOld;
130}
131
132
133// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static List< label > readContents(const IOobject &io)
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Renumber given a ordered-to-original cell association in a file.
manualRenumber(const fileName &file)
Construct with given data file.
virtual labelList renumber(const polyMesh &mesh) const
Return the cell visit order (from ordered back to original cell id) using the mesh for its IOobject a...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
Abstract base class for renumbering.
renumberMethod()
Default construct.
#define defineTypeName(Type)
Define the typeName.
Definition className.H:113
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299