surfaceToCell.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 | Copyright (C) 2011-2015 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
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.
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  (
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.
127  (
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,
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
205 
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 // ************************************************************************* //
Foam::surfaceToCell::querySurfPtr_
const triSurfaceSearch * querySurfPtr_
Search engine on surface.
Definition: surfaceToCell.H:101
Foam::surfaceToCell::checkSettings
void checkSettings() const
Check values at construction time.
Definition: surfaceToCell.C:323
Foam::topoSetSource::sourceType
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:70
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::surfaceToCell::nearDist_
const scalar nearDist_
If > 0 : include cells with distance from cellCentre to surface.
Definition: surfaceToCell.H:91
Foam::surfaceToCell::IOwnPtrs_
const bool IOwnPtrs_
Whether I allocated above surface ptrs or whether they are.
Definition: surfaceToCell.H:105
Foam::surfaceToCell::getNearest
static label getNearest(const triSurfaceSearch &querySurf, const label pointI, const point &pt, const vector &searchSpan, Map< label > &cache)
Find index of nearest triangle to point. Returns triangle or -1 if.
Definition: surfaceToCell.C:67
Foam::topoSetSource::addToUsageTable
Class with constructor to add usage string to table.
Definition: topoSetSource.H:100
Foam::surfaceToCell::combine
void combine(topoSet &set, const bool add) const
Depending on surface add to or delete from cellSet.
Definition: surfaceToCell.C:149
Foam::Map< label >
Foam::surfaceToCell::TypeName
TypeName("surfaceToCell")
Runtime type information.
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
Foam::surfaceToCell::includeCut_
const bool includeCut_
Include cut cells.
Definition: surfaceToCell.H:77
Foam::surfaceToCell::surfPtr_
const triSurface * surfPtr_
triSurface to search on. On pointer since can be external.
Definition: surfaceToCell.H:98
Foam::topoSetSource::mesh
const polyMesh & mesh() const
Definition: topoSetSource.H:274
Foam::triSurfaceSearch
Helper class to search on triSurface.
Definition: triSurfaceSearch.H:55
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::surfaceToCell::differingPointNormals
bool differingPointNormals(const triSurfaceSearch &querySurf, const vector &span, const label cellI, const label cellTriI, Map< label > &pointToNearest) const
Return true if surface normal of nearest points to vertices on.
Definition: surfaceToCell.C:98
Map.H
Foam::surfaceToCell::curvature_
const scalar curvature_
If > -1 : include cells with normals at nearest surface points.
Definition: surfaceToCell.H:95
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.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::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
Foam::surfaceToCell
A topoSetSource to select cells based on relation to surface.
Definition: surfaceToCell.H:60
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::surfaceToCell::includeInside_
const bool includeInside_
Include inside cells.
Definition: surfaceToCell.H:80
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::topoSetSource::CELLSETSOURCE
@ CELLSETSOURCE
Definition: topoSetSource.H:72
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
Foam::surfaceToCell::usage_
static addToUsageTable usage_
Add usage string.
Definition: surfaceToCell.H:68
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::topoSetSource
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
Foam::surfaceToCell::useSurfaceOrientation_
const bool useSurfaceOrientation_
Determine inside/outside purely using geometric test.
Definition: surfaceToCell.H:87
Foam::surfaceToCell::surfName_
const fileName surfName_
Name of surface file.
Definition: surfaceToCell.H:71
Foam::surfaceToCell::setType
virtual sourceType setType() const
Definition: surfaceToCell.H:205
Foam::surfaceToCell::includeOutside_
const bool includeOutside_
Include outside cells.
Definition: surfaceToCell.H:83
Foam::Vector< scalar >
Foam::surfaceToCell::surfaceToCell
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.
Definition: surfaceToCell.C:359
topoSetSource.H
Foam::surfaceToCell::outsidePoints_
const pointField outsidePoints_
Points which are outside.
Definition: surfaceToCell.H:74
Foam::surfaceToCell::querySurf
const triSurfaceSearch & querySurf() const
Definition: surfaceToCell.H:141
Foam::surfaceToCell::~surfaceToCell
virtual ~surfaceToCell()
Destructor.
Definition: surfaceToCell.C:471
Foam::surfaceToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: surfaceToCell.C:484