OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

sampledSet.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::sampledSet
00027 
00028 Description
00029     Holds list of sampling points which is filled at construction time.
00030     Various implementations of this base class to e.g. get sampling points
00031     at uniform distance along a line (uniformSet) or directly specified
00032     (cloudSet)
00033 
00034     Each 'sampledSet' has a name and a specifier of how the axis should be
00035     write (x/y/z component or all 3 components)
00036 
00037 SourceFiles
00038     sampledSet.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef sampledSet_H
00043 #define sampledSet_H
00044 
00045 #include "pointField.H"
00046 #include "word.H"
00047 #include "labelList.H"
00048 #include "typeInfo.H"
00049 #include "runTimeSelectionTables.H"
00050 #include "autoPtr.H"
00051 #include "coordSet.H"
00052 
00053 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00054 
00055 namespace Foam
00056 {
00057 
00058 // Forward declaration of classes
00059 class polyMesh;
00060 class meshSearch;
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class sampledSet Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class sampledSet
00067 :
00068     public coordSet
00069 {
00070     // Private data
00071 
00072         //- Reference to mesh
00073         const polyMesh& mesh_;
00074 
00075         //- Reference to mesh searching class
00076         meshSearch& searchEngine_;
00077 
00078 
00079 protected:
00080 
00081         //- Segment numbers
00082         labelList segments_;
00083 
00084         //- Parameter along sample curve. Uniquely identifies position
00085         //  along sampling. Used for combining parallel results.
00086         scalarList curveDist_;
00087 
00088         //- Cell numbers
00089         labelList cells_;
00090 
00091         //- Face numbers (-1 if not known)
00092         labelList faces_;
00093 
00094 
00095     // Protected Member Functions
00096 
00097         //- Returns cell next to boundary face
00098         label getBoundaryCell(const label) const;
00099 
00100         //- Returns cell using face and containing sample
00101         label getCell
00102         (
00103             const label faceI,
00104             const point& sample
00105         ) const;
00106 
00107         //- Calculates inproduct of face normal and vector sample-face centre
00108         //  <0 if sample inside.
00109         scalar calcSign(const label faceI, const point& sample) const;
00110 
00111         //- Returns face label (or -1) of face which is close to sample
00112         label findNearFace
00113         (
00114             const label cellI,
00115             const point& sample,
00116             const scalar smallDist
00117         ) const;
00118 
00119         //- Moves sample in direction of -n to it is 'inside' of faceI
00120         point pushIn
00121         (
00122             const point& sample,
00123             const label faceI
00124         ) const;
00125 
00126         //- Calculates start of tracking given samplePt and first boundary
00127         //  intersection
00128         //  (bPoint, bFaceI) (bFaceI == -1 if no boundary intersection)
00129         //  Returns true if trackPt is valid sampling point. Sets trackPt,
00130         //  trackFaceI, trackCellI (-1 if no tracking point found)
00131         bool getTrackingPoint
00132         (
00133             const vector& offset,
00134             const point& samplePt,
00135             const point& bPoint,
00136             const label bFaceI,
00137 
00138             point& trackPt,
00139             label& trackCellI,
00140             label& trackFaceI
00141         ) const;
00142 
00143         //- Sets sample data
00144         void setSamples
00145         (
00146             const List<point>& samplingPts,
00147             const labelList& samplingCells,
00148             const labelList& samplingFaces,
00149             const labelList& samplingSegments,
00150             const scalarList& samplingCurveDist
00151         );
00152 
00153 
00154 public:
00155 
00156     //- Runtime type information
00157     TypeName("sampledSet");
00158 
00159 
00160     // Declare run-time constructor selection table
00161 
00162         declareRunTimeSelectionTable
00163         (
00164             autoPtr,
00165             sampledSet,
00166             word,
00167             (
00168                 const word& name,
00169                 const polyMesh& mesh,
00170                 meshSearch& searchEngine,
00171                 const dictionary& dict
00172             ),
00173             (name, mesh, searchEngine, dict)
00174         );
00175 
00176 
00177         //- Class used for the read-construction of
00178         //  PtrLists of sampledSet
00179         class iNew
00180         {
00181             const polyMesh& mesh_;
00182             meshSearch& searchEngine_;
00183 
00184         public:
00185 
00186             iNew(const polyMesh& mesh, meshSearch& searchEngine)
00187             :
00188                 mesh_(mesh),
00189                 searchEngine_(searchEngine)
00190             {}
00191 
00192             autoPtr<sampledSet> operator()(Istream& is) const
00193             {
00194                 word name(is);
00195                 dictionary dict(is);
00196                 return sampledSet::New(name, mesh_, searchEngine_, dict);
00197             }
00198         };
00199 
00200 
00201     // Static data
00202 
00203         //- Tolerance when comparing points. Usually relative to difference
00204         //  between start_ and end_
00205         const static scalar tol;
00206 
00207 
00208     // Constructors
00209 
00210         //- Construct from components
00211         sampledSet
00212         (
00213             const word& name,
00214             const polyMesh& mesh,
00215             meshSearch& searchEngine,
00216             const word& axis
00217         );
00218 
00219         //- Construct from dictionary
00220         sampledSet
00221         (
00222             const word& name,
00223             const polyMesh& mesh,
00224             meshSearch& searchEngine,
00225             const dictionary& dict
00226         );
00227 
00228         //- Clone
00229         autoPtr<sampledSet> clone() const
00230         {
00231             notImplemented("autoPtr<sampledSet> clone() const");
00232             return autoPtr<sampledSet>(NULL);
00233         }
00234 
00235 
00236     // Selectors
00237 
00238         //- Return a reference to the selected sampledSet
00239         static autoPtr<sampledSet> New
00240         (
00241             const word& name,
00242             const polyMesh& mesh,
00243             meshSearch& searchEngine,
00244             const dictionary& dict
00245         );
00246 
00247 
00248     // Destructor
00249 
00250         virtual ~sampledSet();
00251 
00252 
00253     // Member Functions
00254 
00255         const polyMesh& mesh() const
00256         {
00257             return mesh_;
00258         }
00259 
00260         meshSearch& searchEngine() const
00261         {
00262             return searchEngine_;
00263         }
00264 
00265         const labelList& segments() const
00266         {
00267             return segments_;
00268         }
00269 
00270         const scalarList& curveDist() const
00271         {
00272             return curveDist_;
00273         }
00274 
00275         const labelList& cells() const
00276         {
00277             return cells_;
00278         }
00279 
00280         const labelList& faces() const
00281         {
00282             return faces_;
00283         }
00284 
00285         //- Given all sampling points (on all processors) return reference point
00286         virtual point getRefPoint(const List<point>&) const = 0;
00287 
00288         //- Output for debugging
00289         Ostream& write(Ostream&) const;
00290 };
00291 
00292 
00293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00294 
00295 } // End namespace Foam
00296 
00297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00298 
00299 #endif
00300 
00301 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd