surfaceToPoint.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::surfaceToPoint
29 
30 Description
31  A \c topoSetPointSource to select points based on
32  relation to a surface given by an external file.
33 
34  \c surfaceToPoint can select based on:
35  - distance to surface
36  - inside/outside status to surface
37  (Uses normal of nearest surface triangle so requires valid surface
38  topology.)
39 
40  Operands:
41  \table
42  Operand | Type | Location
43  input | triSurface | $FOAM_CASE/constant/triSurface/<file>
44  output | pointSet | $FOAM_CASE/constant/polyMesh/sets/<set>
45  \endtable
46 
47 Usage
48  Minimal example by using \c system/topoSetDict.actions:
49  \verbatim
50  {
51  // Mandatory (inherited) entries
52  name <name>;
53  type pointSet;
54  action <action>;
55 
56  // Mandatory entries
57  source surfaceToPoint;
58  file <surfaceFileName>;
59  includeInside false;
60  includeOutside true;
61  nearDistance 0.5;
62 
63  // Optional entries
64  fileType stl;
65  scale 2.0;
66  }
67  \endverbatim
68 
69  where the entries mean:
70  \table
71  Property | Description | Type | Req'd | Dflt
72  name | Name of pointSet | word | yes | -
73  type | Type name: pointSet | word | yes | -
74  action | Action applied on points - see below | word | yes | -
75  source | Source name: surfaceToPoint | word | yes | -
76  file | The surface "filename" | word | yes | -
77  fileType | The format of the surface file | word | no | ""
78  nearDistance | Near distance to the surface | scalar | yes | -
79  includeInside | Flag to include inside cells | bool | yes | -
80  includeOutside | Flag to include outside cells | bool | yes | -
81  scale | Surface scaling factor | scalar | no | -1
82  \endtable
83 
84  Options for the \c action entry:
85  \verbatim
86  new | Create a new pointSet from selected points
87  add | Add selected points into this pointSet
88  subtract | Remove selected points from this pointSet
89  \endverbatim
90 
91 See also
92  - Foam::topoSetSource
93  - Foam::topoSetPointSource
94 
95 SourceFiles
96  surfaceToPoint.C
97 
98 \*---------------------------------------------------------------------------*/
99 
100 #ifndef surfaceToPoint_H
101 #define surfaceToPoint_H
102 
103 #include "topoSetPointSource.H"
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 
110 /*---------------------------------------------------------------------------*\
111  Class surfaceToPoint Declaration
112 \*---------------------------------------------------------------------------*/
113 
114 class surfaceToPoint
115 :
116  public topoSetPointSource
117 {
118  // Private Data
119 
120  //- Add usage string
121  static addToUsageTable usage_;
122 
123  //- Name of surface file
124  const fileName surfName_;
125 
126  //- Surface file type (optional)
127  const word surfType_;
128 
129  //- Surface scaling factor (optional)
130  const scalar scale_;
131 
132  //- If > 0 : include points with distance to surface less than nearDist.
133  const scalar nearDist_;
134 
135  //- Include all points on opposite sign of normal on nearest surface.
136  const bool includeInside_;
137 
138  //- Include all points on this sign of normal on nearest surface.
139  const bool includeOutside_;
140 
141 
142  // Private Member Functions
143 
144  //- Depending on surface add to or delete from pointSet.
145  void combine(topoSet& set, const bool add) const;
146 
147  //- Check settings at construction time.
148  void checkSettings() const;
149 
150 
151 public:
152 
153  //- Runtime type information
154  TypeName("surfaceToPoint");
155 
156 
157  // Constructors
158 
159  //- Construct from components
161  (
162  const polyMesh& mesh,
163  const fileName& surfName,
164  const scalar nearDist,
165  const bool includeInside,
166  const bool includeOutside
167  );
168 
169  //- Construct from dictionary
170  surfaceToPoint(const polyMesh& mesh, const dictionary& dict);
171 
172  //- Construct from Istream
173  surfaceToPoint(const polyMesh& mesh, Istream& is);
174 
175 
176  //- Destructor
177  virtual ~surfaceToPoint() = default;
178 
179 
180  // Member Functions
181 
182  virtual void applyToSet
183  (
184  const topoSetSource::setAction action,
185  topoSet& set
186  ) const;
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #endif
197 
198 // ************************************************************************* //
Foam::surfaceToPoint::~surfaceToPoint
virtual ~surfaceToPoint()=default
Destructor.
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::combine
Definition: FaceCellWave.C:57
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::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::surfaceToPoint::TypeName
TypeName("surfaceToPoint")
Runtime type information.
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
Foam::surfaceToPoint
A topoSetPointSource to select points based on relation to a surface given by an external file.
Definition: surfaceToPoint.H:191
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::surfaceToPoint::surfaceToPoint
surfaceToPoint(const polyMesh &mesh, const fileName &surfName, const scalar nearDist, const bool includeInside, const bool includeOutside)
Construct from components.
Definition: surfaceToPoint.C:130
topoSetPointSource.H
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342
Foam::surfaceToPoint::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: surfaceToPoint.C:189