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 {
34  defineTypeNameAndDebug(topoSetSource, 0);
35  defineRunTimeSelectionTable(topoSetSource, word);
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 // ************************************************************************* //
dictionary dict
topoSetSource(const polyMesh &mesh)
Construct from components.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvMesh & mesh
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:51
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
A class for handling words, derived from string.
Definition: word.H:59
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
Definition: topoSetSource.C:70
virtual ~topoSetSource()
Destructor.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
A class for handling character strings derived from std::string.
Definition: string.H:76
Namespace for OpenFOAM.