topoSetSource.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) 2011-2021 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 "topoSetSource.H"
27 #include "polyMesh.H"
28 #include "topoSet.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
36 
37  template<>
38  const char* Foam::NamedEnum
39  <
41  8
42  >::names[] =
43  {
44  "clear",
45  "new",
46  "invert",
47  "add",
48  "delete",
49  "subset",
50  "list",
51  "remove"
52  };
53 }
54 
55 
57  Foam::topoSetSource::actionNames_;
58 
59 
60 const Foam::string Foam::topoSetSource::illegalSource_
61 (
62  "Illegal topoSetSource name"
63 );
64 
65 
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
70 (
71  const word& topoSetSourceType,
72  const polyMesh& mesh,
73  const dictionary& dict
74 )
75 {
76  wordConstructorTable::iterator cstrIter =
77  wordConstructorTablePtr_->find(topoSetSourceType);
78 
79  if (cstrIter == wordConstructorTablePtr_->end())
80  {
82  << "Unknown topoSetSource type " << topoSetSourceType
83  << endl << endl
84  << "Valid topoSetSource types : " << endl
85  << wordConstructorTablePtr_->sortedToc()
86  << exit(FatalError);
87  }
88 
89  return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
90 }
91 
92 
93 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
94 
96 (
97  topoSet& set,
98  const label celli,
99  const bool add
100 ) const
101 {
102  if (add)
103  {
104  set.insert(celli);
105  }
106  else
107  {
108  set.erase(celli);
109  }
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 
116 :
117  mesh_(mesh)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
122 
124 {}
125 
126 
127 // ************************************************************************* //
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:111
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
Definition: HashTable.C:371
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:54
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for handling character strings derived from std::string.
Definition: string.H:79
Base class of a source for a topoSet.
Definition: topoSetSource.H:64
void addOrDelete(topoSet &set, const label celli, const bool) const
Add (if bool) celli to set or delete celli from set.
Definition: topoSetSource.C:96
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:83
topoSetSource(const polyMesh &mesh)
Construct from components.
virtual ~topoSetSource()
Destructor.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
Definition: topoSetSource.C:70
const polyMesh & mesh() const
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:65
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
defineTypeNameAndDebug(combustionModel, 0)
error FatalError
dictionary dict