All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
boxToPoint.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 "boxToPoint.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(boxToPoint, 0);
35  addToRunTimeSelectionTable(topoSetSource, boxToPoint, word);
36  addToRunTimeSelectionTable(topoSetSource, boxToPoint, istream);
37 }
38 
39 
40 Foam::topoSetSource::addToUsageTable Foam::boxToPoint::usage_
41 (
42  boxToPoint::typeName,
43  "\n Usage: boxToPoint ((minx miny minz) (maxx maxy maxz))\n\n"
44  " Select all points with coordinate within bounding box\n\n"
45 );
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 void Foam::boxToPoint::combine(topoSet& set, const bool add) const
51 {
52  const pointField& pts = mesh_.points();
53 
54  forAll(pts, pointi)
55  {
56  forAll(bbs_, i)
57  {
58  if (bbs_[i].contains(pts[pointi]))
59  {
60  addOrDelete(set, pointi, add);
61  }
62  }
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 (
71  const polyMesh& mesh,
72  const treeBoundBoxList& bbs
73 )
74 :
75  topoSetSource(mesh),
76  bbs_(bbs)
77 {}
78 
79 
81 (
82  const polyMesh& mesh,
83  const dictionary& dict
84 )
85 :
86  topoSetSource(mesh),
87  bbs_
88  (
89  dict.found("box")
90  ? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
91  : dict.lookup("boxes")
92  )
93 {}
94 
95 
97 (
98  const polyMesh& mesh,
99  Istream& is
100 )
101 :
102  topoSetSource(mesh),
103  bbs_(1, treeBoundBox(checkIs(is)))
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 points that are within boxes " << bbs_ << " ..."
124  << endl;
125 
126  combine(set, true);
127  }
128  else if (action == topoSetSource::DELETE)
129  {
130  Info<< " Removing points that are within boxes " << bbs_ << " ..."
131  << endl;
132 
133  combine(set, false);
134  }
135 }
136 
137 
138 // ************************************************************************* //
List< treeBoundBox > treeBoundBoxList
List of bounding boxes.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
boxToPoint(const polyMesh &mesh, const treeBoundBoxList &bb)
Construct from components.
Definition: boxToPoint.C:70
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
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: boxToPoint.C:116
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
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
stressControl lookup("compactNormalStress") >> compactNormalStress
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual ~boxToPoint()
Destructor.
Definition: boxToPoint.C:109
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.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
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