faceToPoint.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 "faceToPoint.H"
27 #include "polyMesh.H"
28 #include "faceSet.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
37 }
38 
41 {
42  "all"
43 };
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
49 {
50  // Load the set
51  faceSet loadedSet(mesh_, setName_);
52 
53  // Add all points from faces in loadedSet
54  forAllConstIter(faceSet, loadedSet, iter)
55  {
56  const face& f = mesh_.faces()[iter.key()];
57 
58  forAll(f, fp)
59  {
60  addOrDelete(set, f[fp], add);
61  }
62  }
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 
69 (
70  const polyMesh& mesh,
71  const word& setName,
72  const faceAction option
73 )
74 :
76  setName_(setName),
77  option_(option)
78 {}
79 
80 
82 (
83  const polyMesh& mesh,
84  const dictionary& dict
85 )
86 :
88  setName_(dict.lookup("set")),
89  option_(faceActionNames_.read(dict.lookup("option")))
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 (
103  const topoSetSource::setAction action,
104  topoSet& set
105 ) const
106 {
107  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
108  {
109  Info<< " Adding points from face in faceSet " << setName_
110  << " ..." << endl;
111 
112  combine(set, true);
113  }
114  else if (action == topoSetSource::DELETE)
115  {
116  Info<< " Removing points from face in faceSet " << setName_
117  << " ..." << endl;
118 
119  combine(set, false);
120  }
121 }
122 
123 
124 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:476
Macros for easy insertion into run-time selection tables.
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:55
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A topoSetSource to select points based on usage in faces.
Definition: faceToPoint.H:52
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: faceToPoint.C:102
virtual ~faceToPoint()
Destructor.
Definition: faceToPoint.C:95
faceToPoint(const polyMesh &mesh, const word &setName, const faceAction option)
Construct from components.
Definition: faceToPoint.C:69
static const NamedEnum< faceAction, 1 > faceActionNames_
Names of the valid options.
Definition: faceToPoint.H:64
faceAction
Enumeration defining the valid options.
Definition: faceToPoint.H:59
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1344
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:87
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:83
const polyMesh & mesh_
Definition: topoSetSource.H:99
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
defineTypeNameAndDebug(combustionModel, 0)
void add(LagrangianPatchField< typename typeOfSum< Type1, Type2 >::type > &f, const LagrangianPatchField< Type1 > &f1, const LagrangianPatchField< Type2 > &f2)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
Definition: patchToPatch.C:78
labelList f(nPoints)
dictionary dict