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 | Copyright (C) 2012-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "faceZoneSelection.H"
28 #include "fvMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace faceSelections
35 {
36  defineTypeNameAndDebug(faceZoneSelection, 0);
37  addToRunTimeSelectionTable(faceSelection, faceZoneSelection, dictionary);
38 }
39 }
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const word& name,
46  const fvMesh& mesh,
47  const dictionary& dict
48 )
49 :
50  faceSelection(name, mesh, dict),
51  zoneName_(dict_.lookup("zoneName"))
52 {}
53 
54 
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
64 (
65  const label zoneID,
66  labelList& faceToZoneID,
67  boolList& faceToFlip
68 ) const
69 {
70  label readID = mesh_.faceZones().findZoneID(zoneName_);
71 
72  if (readID == -1)
73  {
75  << "Cannot find faceZone " << zoneName_ << nl << "Valid zones are "
76  << mesh_.faceZones().names()
77  << exit(FatalError);
78  }
79 
80  const faceZone& fZone = mesh_.faceZones()[readID];
81 
82  forAll(fZone, i)
83  {
84  label facei = fZone[i];
85 
86  if (faceToZoneID[facei] == -1)
87  {
88  faceToZoneID[facei] = zoneID;
89  faceToFlip[facei] = fZone.flipMap()[i];
90  }
91  else if (faceToZoneID[facei] != zoneID)
92  {
94  << "Face " << facei << " already in faceZone "
95  << faceToZoneID[facei]
96  << exit(FatalError);
97  }
98  }
99 
100  faceSelection::select(zoneID, faceToZoneID, faceToFlip);
101 }
102 
103 
104 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const fvMesh & mesh_
Reference to mesh.
Definition: faceSelection.H:67
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual void select(const label zoneID, labelList &, boolList &) const
Apply this selector.
Macros for easy insertion into run-time selection tables.
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
label findZoneID(const word &zoneName) const
Find zone index given a name.
Definition: ZoneMesh.C:341
stressControl lookup("compactNormalStress") >> compactNormalStress
dynamicFvMesh & mesh
wordList names() const
Return a list of zone names.
Definition: ZoneMesh.C:256
List< label > labelList
A List of labels.
Definition: labelList.H:56
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:262
faceZoneSelection(const word &name, const fvMesh &mesh, const dictionary &dict)
Construct from dictionary.
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
virtual void select(const label, labelList &, boolList &) const =0
virtual ~faceZoneSelection()
Destructor.
const faceZoneMesh & faceZones() const
Return face zone mesh.
Definition: polyMesh.H:463
Namespace for OpenFOAM.