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-------------------------------------------------------------------------------
10License
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(
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// ************************************************************************* //
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
void remapPointLabels(const label nPoints, const Map< label > &originalIds)
Check point mapping (the count) or remap the point labels.
lumpedPointController() noexcept
Default construct.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
label nPoints
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList pointLabels(nPoints, -1)
dictionary dict