All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
surfaceToCell.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 Class
25  Foam::surfaceToCell
26 
27 Description
28  A topoSetSource to select cells based on relation to surface.
29 
30  Selects:
31  - all cells inside/outside/cut by surface
32  - all cells inside/outside surface ('useSurfaceOrientation', requires closed
33  surface)
34  - cells with centre nearer than XXX to surface
35  - cells with centre nearer than XXX to surface \b and with normal
36  at nearest point to centre and cell-corners differing by
37  more than YYY (i.e., point of high curvature)
38 
39 SourceFiles
40  surfaceToCell.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef surfaceToCell_H
45 #define surfaceToCell_H
46 
47 #include "topoSetSource.H"
48 #include "Map.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 class triSurfaceSearch;
55 class triSurface;
56 
57 /*---------------------------------------------------------------------------*\
58  Class surfaceToCell Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class surfaceToCell
62 :
63  public topoSetSource
64 {
65 
66  // Private Data
67 
68  //- Add usage string
69  static addToUsageTable usage_;
70 
71  //- Name of surface file
72  const fileName surfName_;
73 
74  //- Points which are outside
75  const pointField outsidePoints_;
76 
77  //- Include cut cells
78  const bool includeCut_;
79 
80  //- Include inside cells
81  const bool includeInside_;
82 
83  //- Include outside cells
84  const bool includeOutside_;
85 
86  //- Determine inside/outside purely using geometric test
87  // (does not allow includeCut)
88  const bool useSurfaceOrientation_;
89 
90  //- If > 0 : include cells with distance from cellCentre to surface
91  // less than nearDist.
92  const scalar nearDist_;
93 
94  //- If > -1 : include cells with normals at nearest surface points
95  // varying more than curvature_.
96  const scalar curvature_;
97 
98  //- triSurface to search on. On pointer since can be external.
99  const triSurface* surfPtr_;
100 
101  //- Search engine on surface.
102  const triSurfaceSearch* querySurfPtr_;
103 
104  //- Whether I allocated above surface ptrs or whether they are
105  // external.
106  const bool IOwnPtrs_;
107 
108 
109  // Private Member Functions
110 
111  //- Find index of nearest triangle to point. Returns triangle or -1 if
112  // not found within search span.
113  // Cache result under pointi.
114  static label getNearest
115  (
116  const triSurfaceSearch& querySurf,
117  const label pointi,
118  const point& pt,
119  const vector& searchSpan,
120  Map<label>& cache
121  );
122 
123  //- Return true if surface normal of nearest points to vertices on
124  // cell differ from that on cell centre. Points cached in
125  // pointToNearest.
126  bool differingPointNormals
127  (
128  const triSurfaceSearch& querySurf,
129  const vector& span,
130  const label celli,
131  const label cellTriI,
132  Map<label>& pointToNearest
133  ) const;
134 
135 
136  //- Depending on surface add to or delete from cellSet.
137  void combine(topoSet& set, const bool add) const;
138 
139  //- Check values at construction time.
140  void checkSettings() const;
141 
142  const triSurfaceSearch& querySurf() const
143  {
144  return *querySurfPtr_;
145  }
146 
147 
148 public:
149 
150  //- Runtime type information
151  TypeName("surfaceToCell");
152 
153  // Constructors
154 
155  //- Construct from components
157  (
158  const polyMesh& mesh,
159  const fileName& surfName,
160  const pointField& outsidePoints,
161  const bool includeCut,
162  const bool includeInside,
163  const bool includeOutside,
164  const bool useSurfaceOrientation,
165  const scalar nearDist,
166  const scalar curvature
167  );
168 
169  //- Construct from components (supplied surface, surfaceSearch)
171  (
172  const polyMesh& mesh,
173  const fileName& surfName,
174  const triSurface& surf,
175  const triSurfaceSearch& querySurf,
176  const pointField& outsidePoints,
177  const bool includeCut,
178  const bool includeInside,
179  const bool includeOutside,
180  const bool useSurfaceOrientation,
181  const scalar nearDist,
182  const scalar curvature
183  );
184 
185  //- Construct from dictionary
187  (
188  const polyMesh& mesh,
189  const dictionary& dict
190  );
191 
192  //- Construct from Istream
194  (
195  const polyMesh& mesh,
196  Istream&
197  );
198 
199 
200  //- Destructor
201  virtual ~surfaceToCell();
202 
203 
204  // Member Functions
206  virtual sourceType setType() const
207  {
208  return CELLSETSOURCE;
209  }
210 
211  virtual void applyToSet
212  (
213  const topoSetSource::setAction action,
214  topoSet&
215  ) const;
216 
217 };
218 
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace Foam
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
virtual sourceType setType() const
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
virtual ~surfaceToCell()
Destructor.
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
const polyMesh & mesh() const
Helper class to search on triSurface.
TypeName("surfaceToCell")
Runtime type information.
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
surfaceToCell(const polyMesh &mesh, const fileName &surfName, const pointField &outsidePoints, const bool includeCut, const bool includeInside, const bool includeOutside, const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature)
Construct from components.
A topoSetSource to select cells based on relation to surface.
Definition: surfaceToCell.H:60
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:70
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Triangulated surface description with patch information.
Definition: triSurface.H:66
Namespace for OpenFOAM.