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 | Copyright (C) 2011-2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "manualRenumber.H"
28 #include "IFstream.H"
29 #include "labelIOList.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(manualRenumber, 0);
36 
38  (
39  renumberMethod,
40  manualRenumber,
41  dictionary
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 Foam::manualRenumber::manualRenumber(const dictionary& renumberDict)
49 :
50  renumberMethod(renumberDict),
51  dataFile_
52  (
53  renumberDict.subDict(typeName+"Coeffs").lookup("dataFile")
54  )
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 
61 (
62  const polyMesh& mesh,
63  const pointField& points
64 ) const
65 {
66  labelIOList newToOld
67  (
68  IOobject
69  (
70  dataFile_,
71  mesh.facesInstance(),
72  mesh,
75  false
76  )
77  );
78 
79  // check if the final renumbering is OK
80 
81  if (newToOld.size() != points.size())
82  {
84  (
85  "manualRenumber::renumber(const pointField&, const scalarField&)"
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  label origCellI = newToOld[i];
100 
101  if (origCellI < 0 || origCellI >= points.size())
102  {
104  (
105  "manualRenumber::renumber(const pointField&"
106  ", const scalarField&)"
107  ) << "Renumbering is not one-to-one. Index "
108  << i << " maps onto original cell " << origCellI
109  << ".\n" << "Manual renumbering data read from file "
110  << dataFile_ << "." << endl
111  << exit(FatalError);
112  }
113 
114  if (oldToNew[origCellI] == -1)
115  {
116  oldToNew[origCellI] = i;
117  }
118  else
119  {
121  (
122  "manualRenumber::renumber(const pointField&"
123  ", const scalarField&)"
124  ) << "Renumbering is not one-to-one. Both index "
125  << oldToNew[origCellI]
126  << " and " << i << " map onto " << origCellI
127  << ".\n" << "Manual renumbering data read from file "
128  << dataFile_ << "." << endl
129  << exit(FatalError);
130  }
131  }
132 
133  return newToOld;
134 }
135 
136 
137 // ************************************************************************* //
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
stressControl lookup("compactNormalStress") >> compactNormalStress
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
Macros for easy insertion into run-time selection tables.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:824
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
error FatalError
Abstract base class for renumbering.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)