boxToFace.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-2012 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"
28 
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 defineTypeNameAndDebug(boxToFace, 0);
37 
38 addToRunTimeSelectionTable(topoSetSource, boxToFace, word);
39 
40 addToRunTimeSelectionTable(topoSetSource, boxToFace, istream);
41 
42 }
43 
44 
46 (
47  boxToFace::typeName,
48  "\n Usage: boxToFace ((minx miny minz) (maxx maxy maxz))\n\n"
49  " Select all face with faceCentre within bounding box\n\n"
50 );
51 
52 
53 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
54 
55 void Foam::boxToFace::combine(topoSet& set, const bool add) const
56 {
57  const pointField& ctrs = mesh_.faceCentres();
58 
59  forAll(ctrs, faceI)
60  {
61  forAll(bbs_, i)
62  {
63  if (bbs_[i].contains(ctrs[faceI]))
64  {
65  addOrDelete(set, faceI, add);
66  break;
67  }
68  }
69  }
70 }
71 
72 
73 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 
75 // Construct from components
77 (
78  const polyMesh& mesh,
79  const treeBoundBoxList& bbs
80 )
81 :
83  bbs_(bbs)
84 {}
85 
86 
87 // Construct from dictionary
89 (
90  const polyMesh& mesh,
91  const dictionary& dict
92 )
93 :
95  bbs_
96  (
97  dict.found("box")
99  : dict.lookup("boxes")
100  )
101 {}
102 
103 
104 // Construct from Istream
106 (
107  const polyMesh& mesh,
108  Istream& is
109 )
110 :
112  bbs_(1, treeBoundBox(checkIs(is)))
113 {}
114 
115 
116 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
117 
119 {}
120 
121 
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 
125 (
126  const topoSetSource::setAction action,
127  topoSet& set
128 ) const
129 {
130  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
131  {
132  Info<< " Adding faces with centre within boxes " << bbs_ << endl;
133 
134  combine(set, true);
135  }
136  else if (action == topoSetSource::DELETE)
137  {
138  Info<< " Removing faces with centre within boxes " << bbs_ << endl;
139 
140  combine(set, false);
141  }
142 }
143 
144 
145 // ************************************************************************* //
Foam::topoSetSource::ADD
@ ADD
Definition: topoSetSource.H:87
Foam::boxToFace::combine
void combine(topoSet &set, const bool add) const
Definition: boxToFace.C:55
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::boxToFace::bbs_
treeBoundBoxList bbs_
Bounding box.
Definition: boxToFace.H:60
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::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
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::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
Foam::boxToFace::~boxToFace
virtual ~boxToFace()
Destructor.
Definition: boxToFace.C:118
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
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::boxToFace::usage_
static addToUsageTable usage_
Add usage string.
Definition: boxToFace.H:57
Foam::topoSetSource::DELETE
@ DELETE
Definition: topoSetSource.H:88
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
boxToFace.H
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::boxToFace::boxToFace
boxToFace(const polyMesh &mesh, const treeBoundBoxList &bbs)
Construct from components.
Definition: boxToFace.C:77
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::topoSetSource
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
Foam::boxToFace::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: boxToFace.C:125
Foam::List< treeBoundBox >
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:130
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