faceSelection.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 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 "faceSelection.H"
27 #include "fvMesh.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(faceSelection, 0);
34  defineRunTimeSelectionTable(faceSelection, dictionary);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const word& name,
43  const fvMesh& mesh,
44  const dictionary& dict
45 )
46 :
47  name_(name),
48  mesh_(mesh),
49  dict_(dict),
50  flip_(dict.lookupOrDefault("flip", false))
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55 
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 
63 (
64  const word& name,
65  const fvMesh& mesh,
66  const dictionary& dict
67 )
68 {
69  const word sampleType(dict.lookup("type"));
70 
71  dictionaryConstructorTable::iterator cstrIter =
72  dictionaryConstructorTablePtr_->find(sampleType);
73 
74  if (cstrIter == dictionaryConstructorTablePtr_->end())
75  {
77  << "Unknown faceSelection type "
78  << sampleType << nl << nl
79  << "Valid faceSelection types : " << endl
80  << dictionaryConstructorTablePtr_->sortedToc()
81  << exit(FatalError);
82  }
83 
84  return autoPtr<faceSelection>(cstrIter()(name, mesh, dict));
85 }
86 
87 
89 (
90  const label zoneID,
91  labelList& faceToZoneID,
92  boolList& faceToFlip
93 ) const
94 {
95  if (flip_)
96  {
97  forAll(faceToZoneID, facei)
98  {
99  if (faceToZoneID[facei] == zoneID)
100  {
101  faceToFlip[facei] = !faceToFlip[facei];
102  }
103  }
104  }
105 }
106 
107 
108 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
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 ~faceSelection()
Destructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
dynamicFvMesh & mesh
faceSelection(const word &name, const fvMesh &mesh, const dictionary &dict)
Construct from dictionary.
List< label > labelList
A List of labels.
Definition: labelList.H:56
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static autoPtr< faceSelection > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected faceSelection.
virtual void select(const label, labelList &, boolList &) const =0
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Namespace for OpenFOAM.