nearestToCell.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 "nearestToCell.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 defineTypeNameAndDebug(nearestToCell, 0);
36 
37 addToRunTimeSelectionTable(topoSetSource, nearestToCell, word);
38 
39 addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream);
40 
41 }
42 
43 
45 (
46  nearestToCell::typeName,
47  "\n Usage: nearestToCell (pt0 .. ptn)\n\n"
48  " Select the nearest cell for each of the points pt0 ..ptn\n\n"
49 );
50 
51 
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
53 
54 void Foam::nearestToCell::combine(topoSet& set, const bool add) const
55 {
56  forAll(points_, pointI)
57  {
59  }
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
65 // Construct from components
67 (
68  const polyMesh& mesh,
69  const pointField& points
70 )
71 :
73  points_(points)
74 {}
75 
76 
77 // Construct from dictionary
79 (
80  const polyMesh& mesh,
81  const dictionary& dict
82 )
83 :
85  points_(dict.lookup("points"))
86 {}
87 
88 
89 // Construct from Istream
91 (
92  const polyMesh& mesh,
93  Istream& is
94 )
95 :
97  points_(checkIs(is))
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
102 
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 (
111  const topoSetSource::setAction action,
112  topoSet& set
113 ) const
114 {
115  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
116  {
117  Info<< " Adding cells nearest to " << points_ << endl;
118 
119  combine(set, true);
120  }
121  else if (action == topoSetSource::DELETE)
122  {
123  Info<< " Removing cells nearest to " << points_ << endl;
124 
125  combine(set, false);
126  }
127 }
128 
129 
130 // ************************************************************************* //
Foam::nearestToCell::nearestToCell
nearestToCell(const polyMesh &mesh, const pointField &points)
Construct from components.
Definition: nearestToCell.C:67
Foam::topoSetSource::ADD
@ ADD
Definition: topoSetSource.H:87
Foam::nearestToCell::usage_
static addToUsageTable usage_
Add usage string.
Definition: nearestToCell.H:56
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::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::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::nearestToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: nearestToCell.C:110
Foam::primitiveMesh::findNearestCell
label findNearestCell(const point &location) const
Find the cell with the nearest cell centre to location.
Definition: primitiveMeshFindCell.C:70
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::topoSetSource::DELETE
@ DELETE
Definition: topoSetSource.H:88
Foam::nearestToCell::~nearestToCell
virtual ~nearestToCell()
Destructor.
Definition: nearestToCell.C:103
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
points
const pointField & points
Definition: gmvOutputHeader.H:1
nearestToCell.H
Foam::nearestToCell::points_
pointField points_
Points to select nearest to.
Definition: nearestToCell.H:59
Foam::topoSetSource::mesh_
const polyMesh & mesh_
Definition: topoSetSource.H:126
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::nearestToCell::combine
void combine(topoSet &set, const bool add) const
Definition: nearestToCell.C:54
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