FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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