lumpedPointController.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) 2019-2020 OpenCFD Ltd.
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 "lumpedPointController.H"
29 #include "dictionary.H"
30 #include "labelField.H"
31 #include "Map.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 :
37  pointLabels_()
38 {}
39 
40 
42 (
43  const labelUList& pointLabels
44 )
45 :
46  pointLabels_(pointLabels)
47 {}
48 
49 
51 (
53 )
54 :
55  pointLabels_(std::move(pointLabels))
56 {}
57 
58 
60 (
61  const dictionary& dict
62 )
63 :
64  pointLabels_(dict.get<labelList>("pointLabels"))
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
71 (
72  const label nPoints,
73  const Map<label>& originalIds
74 )
75 {
76  if (originalIds.size())
77  {
78  for (label& pointi : pointLabels_)
79  {
80  pointi = originalIds[pointi];
81  }
82  }
83 
84  if (min(pointLabels_) < 0 || max(pointLabels_) >= nPoints)
85  {
87  << "Point id out-of-range: " << flatOutput(pointLabels_) << nl
88  << exit(FatalError);
89  }
90 }
91 
92 
93 // ************************************************************************* //
Foam::lumpedPointController::remapPointLabels
void remapPointLabels(const label nPoints, const Map< label > &originalIds)
Check point mapping (the count) or remap the point labels.
Definition: lumpedPointController.C:71
Foam::lumpedPointController::lumpedPointController
lumpedPointController() noexcept
Default construct.
Definition: lumpedPointController.C:35
Foam::Map< label >
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Map.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dict
dictionary dict
Definition: searchingEngine.H:14
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:123
Foam::flatOutput
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:216
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< label >
Foam::UList< label >
dictionary.H
lumpedPointController.H
pointLabels
labelList pointLabels(nPoints, -1)
labelField.H