faceToPoint.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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"
29 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(faceToPoint, 0);
37  addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
38  addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
39 
40  template<>
41  const char* Foam::NamedEnum
42  <
44  1
45  >::names[] =
46  {
47  "all"
48  };
49 }
50 
51 
52 Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
53 (
54  faceToPoint::typeName,
55  "\n Usage: faceToPoint <faceSet> all\n\n"
56  " Select all points of faces in the faceSet\n\n"
57 );
58 
60  Foam::faceToPoint::faceActionNames_;
61 
62 
63 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
64 
65 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
66 {
67  // Load the set
68  faceSet loadedSet(mesh_, setName_);
69 
70  // Add all points from faces in loadedSet
71  forAllConstIter(faceSet, loadedSet, iter)
72  {
73  const face& f = mesh_.faces()[iter.key()];
74 
75  forAll(f, fp)
76  {
77  addOrDelete(set, f[fp], add);
78  }
79  }
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
84 
85 // Construct from components
87 (
88  const polyMesh& mesh,
89  const word& setName,
90  const faceAction option
91 )
92 :
93  topoSetSource(mesh),
94  setName_(setName),
95  option_(option)
96 {}
97 
98 
99 // Construct from dictionary
101 (
102  const polyMesh& mesh,
103  const dictionary& dict
104 )
105 :
106  topoSetSource(mesh),
107  setName_(dict.lookup("set")),
108  option_(faceActionNames_.read(dict.lookup("option")))
109 {}
110 
111 
112 // Construct from Istream
114 (
115  const polyMesh& mesh,
116  Istream& is
117 )
118 :
119  topoSetSource(mesh),
120  setName_(checkIs(is)),
121  option_(faceActionNames_.read(checkIs(is)))
122 {}
123 
124 
125 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
126 
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
132 
134 (
135  const topoSetSource::setAction action,
136  topoSet& set
137 ) const
138 {
139  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
140  {
141  Info<< " Adding points from face in faceSet " << setName_
142  << " ..." << endl;
143 
144  combine(set, true);
145  }
146  else if (action == topoSetSource::DELETE)
147  {
148  Info<< " Removing points from face in faceSet " << setName_
149  << " ..." << endl;
150 
151  combine(set, false);
152  }
153 }
154 
155 
156 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
faceToPoint(const polyMesh &mesh, const word &setName, const faceAction option)
Construct from components.
Definition: faceToPoint.C:87
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:137
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:253
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52
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:134
A class for handling words, derived from string.
Definition: word.H:59
virtual ~faceToPoint()
Destructor.
Definition: faceToPoint.C:127
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:576