cellToPoint.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 "cellToPoint.H"
27 #include "polyMesh.H"
28 #include "cellSet.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(cellToPoint, 0);
36  addToRunTimeSelectionTable(topoSetSource, cellToPoint, word);
37 
38  template<>
39  const char* Foam::NamedEnum
40  <
42  1
43  >::names[] =
44  {
45  "all"
46  };
47 }
48 
49 
51  Foam::cellToPoint::cellActionNames_;
52 
53 
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 
56 void Foam::cellToPoint::combine(topoSet& set, const bool add) const
57 {
58  // Load the set
59  cellSet loadedSet(mesh_, setName_);
60 
61  // Add all point from cells in loadedSet
62  forAllConstIter(cellSet, loadedSet, iter)
63  {
64  const label celli = iter.key();
65  const labelList& cFaces = mesh_.cells()[celli];
66 
67  forAll(cFaces, cFacei)
68  {
69  const face& f = mesh_.faces()[cFaces[cFacei]];
70 
71  forAll(f, fp)
72  {
73  addOrDelete(set, f[fp], add);
74  }
75  }
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 
83 (
84  const polyMesh& mesh,
85  const word& setName,
86  const cellAction option
87 )
88 :
89  topoSetSource(mesh),
90  setName_(setName),
91  option_(option)
92 {}
93 
94 
96 (
97  const polyMesh& mesh,
98  const dictionary& dict
99 )
100 :
101  topoSetSource(mesh),
102  setName_(dict.lookup("set")),
103  option_(cellActionNames_.read(dict.lookup("option")))
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
108 
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 (
117  const topoSetSource::setAction action,
118  topoSet& set
119 ) const
120 {
121  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
122  {
123  Info<< " Adding from " << setName_ << " ..." << endl;
124 
125  combine(set, true);
126  }
127  else if (action == topoSetSource::DELETE)
128  {
129  Info<< " Removing from " << setName_ << " ..." << endl;
130 
131  combine(set, false);
132  }
133 }
134 
135 
136 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: cellToPoint.C:116
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
cellAction
Enumeration defining the valid options.
Definition: cellToPoint.H:56
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:51
Macros for easy insertion into run-time selection tables.
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
A class for handling words, derived from string.
Definition: word.H:59
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual ~cellToPoint()
Destructor.
Definition: cellToPoint.C:109
defineTypeNameAndDebug(combustionModel, 0)
labelList f(nPoints)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
A collection of cell labels.
Definition: cellSet.H:48
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
cellToPoint(const polyMesh &mesh, const word &setName, const cellAction option)
Construct from components.
Definition: cellToPoint.C:83
Namespace for OpenFOAM.
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
Definition: patchToPatch.C:77
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864