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 
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 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
labelList pointLabels(nPoints, -1)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
label size() const noexcept
The number of elements in table.
Definition: HashTable.H:342
label nPoints
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
const direction noexcept
Definition: Scalar.H:258
lumpedPointController() noexcept
Default construct.
void remapPointLabels(const label nPoints, const Map< label > &originalIds)
Check point mapping (the count) or remap the point labels.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225