faceZoneSelection.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "faceZoneSelection.H"
31#include "fvMesh.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
37namespace faceSelections
38{
39 defineTypeNameAndDebug(faceZoneSelection, 0);
40 addToRunTimeSelectionTable(faceSelection, faceZoneSelection, dictionary);
41}
42}
43
44// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45
47(
48 const word& name,
49 const fvMesh& mesh,
50 const dictionary& dict
51)
52:
53 faceSelection(name, mesh, dict),
54 zoneName_(dict_.get<word>("zoneName"))
55{}
56
57
58// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59
61{}
62
63
64// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65
67(
68 const label zoneID,
69 labelList& faceToZoneID,
70 boolList& faceToFlip
71) const
72{
73 label readID = mesh_.faceZones().findZoneID(zoneName_);
74
75 if (readID == -1)
76 {
78 << "Cannot find faceZone " << zoneName_ << nl << "Valid zones are "
79 << mesh_.faceZones().names()
80 << exit(FatalError);
81 }
82
83 const faceZone& fZone = mesh_.faceZones()[readID];
84
85 forAll(fZone, i)
86 {
87 label facei = fZone[i];
88
89 if (faceToZoneID[facei] == -1)
90 {
91 faceToZoneID[facei] = zoneID;
92 faceToFlip[facei] = fZone.flipMap()[i];
93 }
94 else if (faceToZoneID[facei] != zoneID)
95 {
97 << "Face " << facei << " already in faceZone "
98 << faceToZoneID[facei]
99 << exit(FatalError);
100 }
101 }
102
103 faceSelection::select(zoneID, faceToZoneID, faceToFlip);
104}
105
106
107// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
virtual void select(const label, labelList &, boolList &) const =0
virtual void select(const label zoneID, labelList &, boolList &) const
Apply this selector.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const labelIOList & zoneID
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
List< bool > boolList
A List of bools.
Definition: List.H:64
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
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
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333