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-2025 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 
39 Foam::topoSetSource::actionNames_
40 {
41  "clear",
42  "new",
43  "invert",
44  "add",
45  "delete",
46  "subset",
47  "list",
48  "remove"
49 };
50 
51 const Foam::string Foam::topoSetSource::illegalSource_
52 (
53  "Illegal topoSetSource name"
54 );
55 
56 
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
61 (
62  const word& topoSetSourceType,
63  const polyMesh& mesh,
64  const dictionary& dict
65 )
66 {
67  wordConstructorTable::iterator cstrIter =
68  wordConstructorTablePtr_->find(topoSetSourceType);
69 
70  if (cstrIter == wordConstructorTablePtr_->end())
71  {
73  << "Unknown topoSetSource type " << topoSetSourceType
74  << endl << endl
75  << "Valid topoSetSource types : " << endl
76  << wordConstructorTablePtr_->sortedToc()
77  << exit(FatalError);
78  }
79 
80  return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
81 }
82 
83 
84 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
85 
87 (
88  topoSet& set,
89  const label celli,
90  const bool add
91 ) const
92 {
93  if (add)
94  {
95  set.insert(celli);
96  }
97  else
98  {
99  set.erase(celli);
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
107 :
108  mesh_(mesh)
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
113 
115 {}
116 
117 
118 // ************************************************************************* //
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:55
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 class for handling character strings derived from std::string.
Definition: string.H:79
void addOrDelete(topoSet &set, const label celli, const bool) const
Add (if bool) celli to set or delete celli from set.
virtual ~topoSetSource()
Destructor.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
topoSetSource(const polyMesh &mesh)
Construct from components.
const polyMesh & mesh() const
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
void add(GeometricField< typename typeOfSum< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
defineRunTimeSelectionTable(fvConstraint, dictionary)
error FatalError
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
dictionary dict