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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "manualRenumber.H"
30 #include "IFstream.H"
31 #include "labelIOList.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(manualRenumber, 0);
38 
40  (
41  renumberMethod,
42  manualRenumber,
43  dictionary
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 Foam::manualRenumber::manualRenumber(const dictionary& renumberDict)
51 :
52  renumberMethod(renumberDict),
53  dataFile_
54  (
55  renumberDict.optionalSubDict(typeName+"Coeffs").lookup("dataFile")
56  )
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 
63 (
64  const polyMesh& mesh,
65  const pointField& points
66 ) const
67 {
68  labelIOList newToOld
69  (
70  IOobject
71  (
72  dataFile_,
74  mesh,
77  false
78  )
79  );
80 
81  // Check if the final renumbering is OK
82  if (newToOld.size() != points.size())
83  {
85  << "Size of renumber list does not correspond "
86  << "to the number of points. Size: "
87  << newToOld.size() << " Number of points: "
88  << points.size()
89  << ".\n" << "Manual renumbering data read from file "
90  << dataFile_ << "." << endl
91  << exit(FatalError);
92  }
93 
94  // Invert to see if one to one
95  labelList oldToNew(points.size(), -1);
96  forAll(newToOld, i)
97  {
98  const label origCelli = newToOld[i];
99 
100  if (origCelli < 0 || origCelli >= points.size())
101  {
103  << "Renumbering is not one-to-one. Index "
104  << i << " maps onto original cell " << origCelli
105  << ".\n" << "Manual renumbering data read from file "
106  << dataFile_ << "." << endl
107  << exit(FatalError);
108  }
109 
110  if (oldToNew[origCelli] == -1)
111  {
112  oldToNew[origCelli] = i;
113  }
114  else
115  {
117  << "Renumbering is not one-to-one. Both index "
118  << oldToNew[origCelli]
119  << " and " << i << " map onto " << origCelli
120  << ".\n" << "Manual renumbering data read from file "
121  << dataFile_ << "." << endl
122  << exit(FatalError);
123  }
124  }
125 
126  return std::move(newToOld);
127 }
128 
129 
130 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::manualRenumber::renumber
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
Definition: manualRenumber.H:86
manualRenumber.H
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:821
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::label
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:62
Foam::Field< vector >
IFstream.H
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:63
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::renumberMethod
Abstract base class for renumbering.
Definition: renumberMethod.H:50
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::List< label >
labelIOList.H
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::IOList< label >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::IOobject::MUST_READ
Definition: IOobject.H:120