labelToCell.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 "labelToCell.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(labelToCell, 0);
35  addToRunTimeSelectionTable(topoSetSource, labelToCell, word);
36  addToRunTimeSelectionTable(topoSetSource, labelToCell, istream);
37 }
38 
39 
40 Foam::topoSetSource::addToUsageTable Foam::labelToCell::usage_
41 (
42  labelToCell::typeName,
43  "\n Usage: labelToCell (i0 i1 .. in)\n\n"
44  " Select cells by cellLabel\n\n"
45 );
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 void Foam::labelToCell::combine(topoSet& set, const bool add) const
51 {
52  forAll(labels_, labelI)
53  {
54  addOrDelete(set, labels_[labelI], add);
55  }
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 (
63  const polyMesh& mesh,
64  const labelList& labels
65 )
66 :
67  topoSetSource(mesh),
68  labels_(labels)
69 {}
70 
71 
73 (
74  const polyMesh& mesh,
75  const dictionary& dict
76 )
77 :
78  topoSetSource(mesh),
79  labels_(dict.lookup("value"))
80 {}
81 
82 
84 (
85  const polyMesh& mesh,
86  Istream& is
87 )
88 :
89  topoSetSource(mesh),
90  labels_(checkIs(is))
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 (
104  const topoSetSource::setAction action,
105  topoSet& set
106 ) const
107 {
108  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
109  {
110  Info<< " Adding cells mentioned in dictionary" << " ..." << endl;
111 
112  combine(set, true);
113  }
114  else if (action == topoSetSource::DELETE)
115  {
116  Info<< " Removing cells mentioned in dictionary" << " ..." << endl;
117 
118  combine(set, false);
119  }
120 }
121 
122 
123 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:251
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
static const labelSphericalTensor labelI(1)
Identity labelTensor.
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
labelToCell(const polyMesh &mesh, const labelList &labels)
Construct from components.
Definition: labelToCell.C:62
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)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
Class with constructor to add usage string to table.
virtual ~labelToCell()
Destructor.
Definition: labelToCell.C:96
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: labelToCell.C:103
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:812