nearestToPoint.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9  Copyright (C) 2018-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::nearestToPoint
29 
30 Description
31  A \c topoSetPointSource to select points nearest to given points.
32 
33  Operands:
34  \table
35  Operand | Type | Location
36  output | pointSet | $FOAM_CASE/constant/polyMesh/sets/<set>
37  \endtable
38 
39 Usage
40  Minimal example by using \c system/topoSetDict.actions:
41  \verbatim
42  {
43  // Mandatory (inherited) entries
44  name <name>;
45  type pointSet;
46  action <action>;
47 
48  // Mandatory entries
49  source nearestToPoint;
50  points
51  (
52  (<p1x> <p1y> <p1z>)
53  (<p2x> <p2y> <p2z>)
54  ...
55  );
56  }
57  \endverbatim
58 
59  where the entries mean:
60  \table
61  Property | Description | Type | Req'd | Dflt
62  name | Name of pointSet | word | yes | -
63  type | Type name: pointSet | word | yes | -
64  action | Action applied on points - see below | word | yes | -
65  source | Source name: nearestToPoint | word | yes | -
66  points | List of selection points | vectorList | yes | -
67  \endtable
68 
69  Options for the \c action entry:
70  \verbatim
71  new | Create a new pointSet from selected points
72  add | Add selected points into this pointSet
73  subtract | Remove selected points from this pointSet
74  \endverbatim
75 
76 See also
77  - Foam::topoSetSource
78  - Foam::topoSetPointSource
79 
80 SourceFiles
81  nearestToPoint.C
82 
83 \*---------------------------------------------------------------------------*/
84 
85 #ifndef nearestToPoint_H
86 #define nearestToPoint_H
87 
88 #include "topoSetPointSource.H"
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 namespace Foam
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class nearestToPoint Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class nearestToPoint
100 :
101  public topoSetPointSource
102 {
103  // Private Data
104 
105  //- Add usage string
106  static addToUsageTable usage_;
107 
108  //- Points to select nearest to
109  pointField points_;
110 
111 
112  // Private Member Functions
113 
114  void combine(topoSet& set, const bool add) const;
115 
116 
117 public:
118 
119  //- Runtime type information
120  TypeName("nearestToPoint");
121 
122 
123  // Constructors
124 
125  //- Construct from components, copying points
126  nearestToPoint(const polyMesh& mesh, const pointField& points);
127 
128  //- Construct from components, moving points
129  nearestToPoint(const polyMesh& mesh, pointField&& points);
130 
131  //- Construct from dictionary
132  nearestToPoint(const polyMesh& mesh, const dictionary& dict);
133 
134  //- Construct from Istream
135  nearestToPoint(const polyMesh& mesh, Istream& is);
136 
137 
138  //- Destructor
139  virtual ~nearestToPoint() = default;
140 
141 
142  // Member Functions
143 
144  virtual void applyToSet
145  (
146  const topoSetSource::setAction action,
147  topoSet& set
148  ) const;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #endif
159 
160 // ************************************************************************* //
Foam::nearestToPoint::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: nearestToPoint.C:168
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::combine
Definition: FaceCellWave.C:57
Foam::nearestToPoint
A topoSetPointSource to select points nearest to given points.
Definition: nearestToPoint.H:142
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:100
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::nearestToPoint::TypeName
TypeName("nearestToPoint")
Runtime type information.
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::nearestToPoint::nearestToPoint
nearestToPoint(const polyMesh &mesh, const pointField &points)
Construct from components, copying points.
Definition: nearestToPoint.C:123
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
Foam::topoSetPointSource
The topoSetPointSource is a intermediate class for handling topoSet sources for selecting points.
Definition: topoSetPointSource.H:54
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
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:939
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::nearestToPoint::~nearestToPoint
virtual ~nearestToPoint()=default
Destructor.
topoSetPointSource.H
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342