cellToPoint.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 "cellToPoint.H"
27 #include "polyMesh.H"
28 #include "cellSet.H"
29 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(cellToPoint, 0);
37  addToRunTimeSelectionTable(topoSetSource, cellToPoint, word);
38  addToRunTimeSelectionTable(topoSetSource, cellToPoint, istream);
39 
40  template<>
41  const char* Foam::NamedEnum
42  <
44  1
45  >::names[] =
46  {
47  "all"
48  };
49 }
50 
51 
53 (
54  cellToPoint::typeName,
55  "\n Usage: cellToPoint <cellSet> all\n\n"
56  " Select all points of cells in the cellSet\n\n"
57 );
58 
61 
62 
63 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
64 
65 void Foam::cellToPoint::combine(topoSet& set, const bool add) const
66 {
67  // Load the set
68  cellSet loadedSet(mesh_, setName_);
69 
70  // Add all point from cells in loadedSet
71  forAllConstIter(cellSet, loadedSet, iter)
72  {
73  const label cellI = iter.key();
74  const labelList& cFaces = mesh_.cells()[cellI];
75 
76  forAll(cFaces, cFaceI)
77  {
78  const face& f = mesh_.faces()[cFaces[cFaceI]];
79 
80  forAll(f, fp)
81  {
82  addOrDelete(set, f[fp], add);
83  }
84  }
85  }
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90 
91 // Construct from components
93 (
94  const polyMesh& mesh,
95  const word& setName,
96  const cellAction option
97 )
98 :
100  setName_(setName),
101  option_(option)
102 {}
103 
104 
105 // Construct from dictionary
107 (
108  const polyMesh& mesh,
109  const dictionary& dict
110 )
111 :
113  setName_(dict.lookup("set")),
114  option_(cellActionNames_.read(dict.lookup("option")))
115 {}
116 
117 
118 // Construct from Istream
120 (
121  const polyMesh& mesh,
122  Istream& is
123 )
124 :
126  setName_(checkIs(is)),
127  option_(cellActionNames_.read(checkIs(is)))
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 
140 (
141  const topoSetSource::setAction action,
142  topoSet& set
143 ) const
144 {
145  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
146  {
147  Info<< " Adding from " << setName_ << " ..." << endl;
148 
149  combine(set, true);
150  }
151  else if (action == topoSetSource::DELETE)
152  {
153  Info<< " Removing from " << setName_ << " ..." << endl;
154 
155  combine(set, false);
156  }
157 }
158 
159 
160 // ************************************************************************* //
Foam::topoSetSource::ADD
@ ADD
Definition: topoSetSource.H:87
Foam::cellToPoint::combine
void combine(topoSet &set, const bool add) const
Depending on face to cell option add to or delete from cellSet.
Definition: cellToPoint.C:65
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::cellToPoint::cellActionNames_
static const NamedEnum< cellAction, 1 > cellActionNames_
Definition: cellToPoint.H:66
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::ListListOps::combine
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
Definition: ListListOps.C:34
Foam::topoSetSource::addToUsageTable
Class with constructor to add usage string to table.
Definition: topoSetSource.H:100
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:136
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
Foam::topoSetSource::NEW
@ NEW
Definition: topoSetSource.H:85
polyMesh.H
Foam::cellToPoint::usage_
static addToUsageTable usage_
Add usage string.
Definition: cellToPoint.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::Info
messageStream Info
Foam::cellToPoint::cellAction
cellAction
Enumeration defining the valid options.
Definition: cellToPoint.H:56
Foam::topoSetSource::DELETE
@ DELETE
Definition: topoSetSource.H:88
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:870
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::topoSetSource
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
Foam::cellSet
A collection of cell labels.
Definition: cellSet.H:48
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1004
Foam::cellToPoint::setName_
word setName_
Name of set to use.
Definition: cellToPoint.H:69
f
labelList f(nPoints)
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::cellToPoint::~cellToPoint
virtual ~cellToPoint()
Destructor.
Definition: cellToPoint.C:133
Foam::cellToPoint::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: cellToPoint.C:140
cellToPoint.H
Foam::cellToPoint::cellToPoint
cellToPoint(const polyMesh &mesh, const word &setName, const cellAction option)
Construct from components.
Definition: cellToPoint.C:93
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
cellSet.H
Foam::topoSetSource::mesh_
const polyMesh & mesh_
Definition: topoSetSource.H:126
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::topoSetSource::addOrDelete
void addOrDelete(topoSet &set, const label cellI, const bool) const
Add (if bool) cellI to set or delete cellI from set.
Definition: topoSetSource.C:140
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52