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-2018 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 {
35  defineTypeNameAndDebug(faceToPoint, 0);
36  addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
37  addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
38 
39  template<>
40  const char* Foam::NamedEnum
41  <
43  1
44  >::names[] =
45  {
46  "all"
47  };
48 }
49 
50 
51 Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
52 (
53  faceToPoint::typeName,
54  "\n Usage: faceToPoint <faceSet> all\n\n"
55  " Select all points of faces in the faceSet\n\n"
56 );
57 
59  Foam::faceToPoint::faceActionNames_;
60 
61 
62 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
63 
64 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
65 {
66  // Load the set
67  faceSet loadedSet(mesh_, setName_);
68 
69  // Add all points from faces in loadedSet
70  forAllConstIter(faceSet, loadedSet, iter)
71  {
72  const face& f = mesh_.faces()[iter.key()];
73 
74  forAll(f, fp)
75  {
76  addOrDelete(set, f[fp], add);
77  }
78  }
79 }
80 
81 
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
83 
85 (
86  const polyMesh& mesh,
87  const word& setName,
88  const faceAction option
89 )
90 :
91  topoSetSource(mesh),
92  setName_(setName),
93  option_(option)
94 {}
95 
96 
98 (
99  const polyMesh& mesh,
100  const dictionary& dict
101 )
102 :
103  topoSetSource(mesh),
104  setName_(dict.lookup("set")),
105  option_(faceActionNames_.read(dict.lookup("option")))
106 {}
107 
108 
110 (
111  const polyMesh& mesh,
112  Istream& is
113 )
114 :
115  topoSetSource(mesh),
116  setName_(checkIs(is)),
117  option_(faceActionNames_.read(checkIs(is)))
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
122 
124 {}
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
130 (
131  const topoSetSource::setAction action,
132  topoSet& set
133 ) const
134 {
135  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
136  {
137  Info<< " Adding points from face in faceSet " << setName_
138  << " ..." << endl;
139 
140  combine(set, true);
141  }
142  else if (action == topoSetSource::DELETE)
143  {
144  Info<< " Removing points from face in faceSet " << setName_
145  << " ..." << endl;
146 
147  combine(set, false);
148  }
149 }
150 
151 
152 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
faceToPoint(const polyMesh &mesh, const word &setName, const faceAction option)
Construct from components.
Definition: faceToPoint.C:85
A list of face labels.
Definition: faceSet.H:48
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:51
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
Definition: ListListOps.C:34
Macros for easy insertion into run-time selection tables.
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
faceAction
Enumeration defining the valid options.
Definition: faceToPoint.H:56
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: faceToPoint.C:130
A class for handling words, derived from string.
Definition: word.H:59
virtual ~faceToPoint()
Destructor.
Definition: faceToPoint.C:123
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
labelList f(nPoints)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
Class with constructor to add usage string to table.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:583