1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
29 #include "nearestToCell.H"
31 #include "meshSearch.H"
33 #include "addToRunTimeSelectionTable.H"
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(nearestToCell, 0);
42 addToRunTimeSelectionTable(topoSetSource, nearestToCell, word);
44 addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream);
49 Foam::topoSetSource::addToUsageTable Foam::nearestToCell::usage_
51 nearestToCell::typeName,
52 "\n Usage: nearestToCell (pt0 .. ptn)\n\n"
53 " Select the nearest cell for each of the points pt0 ..ptn\n\n"
57 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
59 void Foam::nearestToCell::combine(topoSet& set, const bool add) const
61 // Construct search engine withouth tet decomposition.
62 meshSearch queryMesh(mesh_, false);
64 forAll(points_, pointI)
66 addOrDelete(set, queryMesh.findNearestCell(points_[pointI]), add);
71 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73 // Construct from components
74 Foam::nearestToCell::nearestToCell
77 const pointField& points
85 // Construct from dictionary
86 Foam::nearestToCell::nearestToCell
89 const dictionary& dict
93 points_(dict.lookup("points"))
97 // Construct from Istream
98 Foam::nearestToCell::nearestToCell
100 const polyMesh& mesh,
109 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 Foam::nearestToCell::~nearestToCell()
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 void Foam::nearestToCell::applyToSet
119 const topoSetSource::setAction action,
123 if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
125 Info<< " Adding cells nearest to " << points_ << endl;
129 else if (action == topoSetSource::DELETE)
131 Info<< " Removing cells nearest to " << points_ << endl;
138 // ************************************************************************* //