FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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  - cells with centre nearer than XXX to surface
33  - cells with centre nearer than XXX to surface @b and with normal
34  at nearest point to centre and cell-corners differing by
35  more than YYY (i.e., point of high curvature)
36 
37 SourceFiles
38  surfaceToCell.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef surfaceToCell_H
43 #define surfaceToCell_H
44 
46 #include <OpenFOAM/Map.H>
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 class triSurfaceSearch;
53 class triSurface;
54 
55 /*---------------------------------------------------------------------------*\
56  Class surfaceToCell Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
61  public topoSetSource
62 {
63 
64  // Private data
65 
66  //- Add usage string
67  static addToUsageTable usage_;
68 
69  //- Name of surface file
70  fileName surfName_;
71 
72  //- Points which are outside
73  pointField outsidePoints_;
74 
75  //- Include cut cells
76  bool includeCut_;
77 
78  //- Include inside cells
79  bool includeInside_;
80 
81  //- Include outside cells
82  bool includeOutside_;
83 
84  //- if > 0 : include cells with distance from cellCentre to surface
85  // less than nearDist.
86  scalar nearDist_;
87 
88  //- if > -1 : include cells with normals at nearest surface points
89  // varying more than curvature_.
90  scalar curvature_;
91 
92  //- triSurface to search on. On pointer since can be external.
93  const triSurface* surfPtr_;
94 
95  //- search engine on surface.
96  const triSurfaceSearch* querySurfPtr_;
97 
98  //- whether I allocated above surface ptrs or whether they are
99  // external.
100  bool IOwnPtrs_;
101 
102 
103  // Private Member Functions
104 
105  //- Find index of nearest triangle to point. Returns triangle or -1 if
106  // not found within search span.
107  // Cache result under pointI.
108  static label getNearest
109  (
110  const triSurfaceSearch& querySurf,
111  const label pointI,
112  const point& pt,
113  const vector& searchSpan,
114  Map<label>& cache
115  );
116 
117  //- Return true if surface normal of nearest points to vertices on
118  // cell differ from that on cell centre. Points cached in
119  // pointToNearest.
120  bool differingPointNormals
121  (
122  const triSurfaceSearch& querySurf,
123  const vector& span,
124  const label cellI,
125  const label cellTriI,
126  Map<label>& pointToNearest
127  ) const;
128 
129 
130  //- Depending on surface add to or delete from cellSet.
131  void combine(topoSet& set, const bool add) const;
132 
133  //- Check values at construction time.
134  void checkSettings() const;
135 
136  const triSurfaceSearch& querySurf() const
137  {
138  return *querySurfPtr_;
139  }
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("surfaceToCell");
146 
147  // Constructors
148 
149  //- Construct from components
151  (
152  const polyMesh& mesh,
153  const fileName& surfName,
154  const pointField& outsidePoints,
155  const bool includeCut,
156  const bool includeInside,
157  const bool includeOutside,
158  const scalar nearDist,
159  const scalar curvature
160  );
161 
162  //- Construct from components (supplied surface, surfaceSearch)
164  (
165  const polyMesh& mesh,
166  const fileName& surfName,
167  const triSurface& surf,
168  const triSurfaceSearch& querySurf,
169  const pointField& outsidePoints,
170  const bool includeCut,
171  const bool includeInside,
172  const bool includeOutside,
173  const scalar nearDist,
174  const scalar curvature
175  );
176 
177  //- Construct from dictionary
179  (
180  const polyMesh& mesh,
181  const dictionary& dict
182  );
183 
184  //- Construct from Istream
186  (
187  const polyMesh& mesh,
188  Istream&
189  );
190 
191 
192  // Destructor
193 
194  virtual ~surfaceToCell();
195 
196 
197  // Member Functions
198 
199  virtual void applyToSet
200  (
201  const topoSetSource::setAction action,
202  topoSet&
203  ) const;
204 
205 };
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace Foam
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #endif
215 
216 // ************************ vim: set sw=4 sts=4 et: ************************ //