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 -------------------------------------------------------------------------------
11 License
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 
35 namespace Foam
36 {
37 namespace 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 // ************************************************************************* //
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
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
faceZoneSelection(const word &name, const fvMesh &mesh, const dictionary &dict)
Construct from dictionary.
defineTypeNameAndDebug(combustionModel, 0)
virtual void select(const label, labelList &, boolList &) const =0
virtual ~faceZoneSelection()
Destructor.
List< label > labelList
A List of labels.
Definition: List.H:62
virtual void select(const label zoneID, labelList &, boolList &) const
Apply this selector.
List< bool > boolList
A List of bools.
Definition: List.H:60
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)