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-2022 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 "IFstream.H"
32#include "labelIOList.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
39
41 (
45 );
46}
47
48
49// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50
52:
54 dataFile_
55 (
56 dict.optionalSubDict(typeName+"Coeffs").get<fileName>("dataFile")
57 )
58{}
59
60
61// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62
64(
65 const polyMesh& mesh,
66 const pointField& points
67) const
68{
69 labelIOList newToOld
70 (
72 (
73 dataFile_,
75 mesh,
78 false
79 )
80 );
81
82 // Check if the final renumbering is OK
83 if (newToOld.size() != points.size())
84 {
86 << "Size of renumber list does not correspond "
87 << "to the number of points. Size: "
88 << newToOld.size() << " Number of points: "
89 << points.size()
90 << ".\n" << "Manual renumbering data read from file "
91 << dataFile_ << "." << endl
92 << exit(FatalError);
93 }
94
95 // Invert to see if one to one
96 labelList oldToNew(points.size(), -1);
97 forAll(newToOld, i)
98 {
99 const label origCelli = newToOld[i];
100
101 if (origCelli < 0 || origCelli >= points.size())
102 {
104 << "Renumbering is not one-to-one. Index "
105 << i << " maps onto original cell " << origCelli
106 << ".\n" << "Manual renumbering data read from file "
107 << dataFile_ << "." << endl
108 << exit(FatalError);
109 }
110
111 if (oldToNew[origCelli] == -1)
112 {
113 oldToNew[origCelli] = i;
114 }
115 else
116 {
118 << "Renumbering is not one-to-one. Both index "
119 << oldToNew[origCelli]
120 << " and " << i << " map onto " << origCelli
121 << ".\n" << "Manual renumbering data read from file "
122 << dataFile_ << "." << endl
123 << exit(FatalError);
124 }
125 }
126
127 return std::move(newToOld);
128}
129
130
131// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Renumber given a ordered-to-original cell association in a file.
virtual labelList renumber(const pointField &) const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:866
Abstract base class for renumbering.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const pointField & points
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333