1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Holds list of sampling points which is filled at construction time.
30 Various implementations of this base class to e.g. get sampling points
31 at uniform distance along a line (uniformSet) or directly specified
34 Each 'sampledSet' has a name and a specifier of how the axis should be
35 write (x/y/z component or all 3 components)
40 \*---------------------------------------------------------------------------*/
45 #include "pointField.H"
47 #include "labelList.H"
49 #include "runTimeSelectionTables.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 // Forward declaration of classes
62 /*---------------------------------------------------------------------------*\
63 Class sampledSet Declaration
64 \*---------------------------------------------------------------------------*/
73 const polyMesh& mesh_;
75 //- Reference to mesh searching class
76 meshSearch& searchEngine_;
84 //- Parameter along sample curve. Uniquely identifies position
85 // along sampling. Used for combining parallel results.
86 scalarList curveDist_;
91 //- Face numbers (-1 if not known)
95 // Protected Member Functions
97 //- Returns cell next to boundary face
98 label getBoundaryCell(const label) const;
100 //- Returns cell using face and containing sample
107 //- Calculates inproduct of face normal and vector sample-face centre
108 // <0 if sample inside.
109 scalar calcSign(const label faceI, const point& sample) const;
111 //- Returns face label (or -1) of face which is close to sample
116 const scalar smallDist
119 //- Moves sample in direction of -n to it is 'inside' of faceI
126 //- Calculates start of tracking given samplePt and first boundary
128 // (bPoint, bFaceI) (bFaceI == -1 if no boundary intersection)
129 // Returns true if trackPt is valid sampling point. Sets trackPt,
130 // trackFaceI, trackCellI (-1 if no tracking point found)
131 bool getTrackingPoint
133 const vector& offset,
134 const point& samplePt,
146 const List<point>& samplingPts,
147 const labelList& samplingCells,
148 const labelList& samplingFaces,
149 const labelList& samplingSegments,
150 const scalarList& samplingCurveDist
156 //- Runtime type information
157 TypeName("sampledSet");
160 // Declare run-time constructor selection table
162 declareRunTimeSelectionTable
169 const polyMesh& mesh,
170 meshSearch& searchEngine,
171 const dictionary& dict
173 (name, mesh, searchEngine, dict)
177 //- Class used for the read-construction of
178 // PtrLists of sampledSet
181 const polyMesh& mesh_;
182 meshSearch& searchEngine_;
186 iNew(const polyMesh& mesh, meshSearch& searchEngine)
189 searchEngine_(searchEngine)
192 autoPtr<sampledSet> operator()(Istream& is) const
196 return sampledSet::New(name, mesh_, searchEngine_, dict);
203 //- Tolerance when comparing points. Usually relative to difference
204 // between start_ and end_
205 const static scalar tol;
210 //- Construct from components
214 const polyMesh& mesh,
215 meshSearch& searchEngine,
219 //- Construct from dictionary
223 const polyMesh& mesh,
224 meshSearch& searchEngine,
225 const dictionary& dict
229 autoPtr<sampledSet> clone() const
231 notImplemented("autoPtr<sampledSet> clone() const");
232 return autoPtr<sampledSet>(NULL);
238 //- Return a reference to the selected sampledSet
239 static autoPtr<sampledSet> New
242 const polyMesh& mesh,
243 meshSearch& searchEngine,
244 const dictionary& dict
250 virtual ~sampledSet();
255 const polyMesh& mesh() const
260 meshSearch& searchEngine() const
262 return searchEngine_;
265 const labelList& segments() const
270 const scalarList& curveDist() const
275 const labelList& cells() const
280 const labelList& faces() const
285 //- Given all sampling points (on all processors) return reference point
286 virtual point getRefPoint(const List<point>&) const = 0;
288 //- Output for debugging
289 Ostream& write(Ostream&) const;
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 } // End namespace Foam
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 // ************************************************************************* //