boxToFace.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 "boxToFace.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(boxToFace, 0);
35  addToRunTimeSelectionTable(topoSetSource, boxToFace, word);
36  addToRunTimeSelectionTable(topoSetSource, boxToFace, istream);
37 }
38 
39 
40 Foam::topoSetSource::addToUsageTable Foam::boxToFace::usage_
41 (
42  boxToFace::typeName,
43  "\n Usage: boxToFace ((minx miny minz) (maxx maxy maxz))\n\n"
44  " Select all face with faceCentre within bounding box\n\n"
45 );
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 void Foam::boxToFace::combine(topoSet& set, const bool add) const
51 {
52  const pointField& ctrs = mesh_.faceCentres();
53 
54  forAll(ctrs, facei)
55  {
56  forAll(bbs_, i)
57  {
58  if (bbs_[i].contains(ctrs[facei]))
59  {
60  addOrDelete(set, facei, add);
61  break;
62  }
63  }
64  }
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
71 (
72  const polyMesh& mesh,
73  const treeBoundBoxList& bbs
74 )
75 :
76  topoSetSource(mesh),
77  bbs_(bbs)
78 {}
79 
80 
82 (
83  const polyMesh& mesh,
84  const dictionary& dict
85 )
86 :
87  topoSetSource(mesh),
88  bbs_
89  (
90  dict.found("box")
91  ? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
92  : dict.lookup("boxes")
93  )
94 {}
95 
96 
98 (
99  const polyMesh& mesh,
100  Istream& is
101 )
102 :
103  topoSetSource(mesh),
104  bbs_(1, treeBoundBox(checkIs(is)))
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 
111 {}
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
117 (
118  const topoSetSource::setAction action,
119  topoSet& set
120 ) const
121 {
122  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
123  {
124  Info<< " Adding faces with centre within boxes " << bbs_ << endl;
125 
126  combine(set, true);
127  }
128  else if (action == topoSetSource::DELETE)
129  {
130  Info<< " Removing faces with centre within boxes " << bbs_ << endl;
131 
132  combine(set, false);
133  }
134 }
135 
136 
137 // ************************************************************************* //
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:643
#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:156
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.
boxToFace(const polyMesh &mesh, const treeBoundBoxList &bbs)
Construct from components.
Definition: boxToFace.C:71
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
virtual ~boxToFace()
Destructor.
Definition: boxToFace.C:110
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.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: boxToFace.C:117
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844