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-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 "faceToPoint.H"
27 #include "polyMesh.H"
28 #include "faceSet.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
37 
38  template<>
39  const char* Foam::NamedEnum
40  <
42  1
43  >::names[] =
44  {
45  "all"
46  };
47 }
48 
49 
51  Foam::faceToPoint::faceActionNames_;
52 
53 
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 
56 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
57 {
58  // Load the set
59  faceSet loadedSet(mesh_, setName_);
60 
61  // Add all points from faces in loadedSet
62  forAllConstIter(faceSet, loadedSet, iter)
63  {
64  const face& f = mesh_.faces()[iter.key()];
65 
66  forAll(f, fp)
67  {
68  addOrDelete(set, f[fp], add);
69  }
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
75 
77 (
78  const polyMesh& mesh,
79  const word& setName,
80  const faceAction option
81 )
82 :
83  topoSetSource(mesh),
84  setName_(setName),
85  option_(option)
86 {}
87 
88 
90 (
91  const polyMesh& mesh,
92  const dictionary& dict
93 )
94 :
95  topoSetSource(mesh),
96  setName_(dict.lookup("set")),
97  option_(faceActionNames_.read(dict.lookup("option")))
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
102 
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 (
111  const topoSetSource::setAction action,
112  topoSet& set
113 ) const
114 {
115  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
116  {
117  Info<< " Adding points from face in faceSet " << setName_
118  << " ..." << endl;
119 
120  combine(set, true);
121  }
122  else if (action == topoSetSource::DELETE)
123  {
124  Info<< " Removing points from face in faceSet " << setName_
125  << " ..." << endl;
126 
127  combine(set, false);
128  }
129 }
130 
131 
132 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Macros for easy insertion into run-time selection tables.
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:54
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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:110
virtual ~faceToPoint()
Destructor.
Definition: faceToPoint.C:103
faceToPoint(const polyMesh &mesh, const word &setName, const faceAction option)
Construct from components.
Definition: faceToPoint.C:77
faceAction
Enumeration defining the valid options.
Definition: faceToPoint.H:57
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1373
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
const polyMesh & mesh_
Definition: topoSetSource.H:99
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
Namespace for OpenFOAM.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
defineTypeNameAndDebug(combustionModel, 0)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
Definition: patchToPatch.C:78
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
labelList f(nPoints)
dictionary dict