BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / streamLine / streamLineParticle.H
blobd01353c46f7312f5565619731c1ce8467e5ebd9c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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
19     for more details.
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/>.
24 Class
25     Foam::streamLineParticle
27 Description
28     Particle class that samples fields as it passes through. Used in streamline
29     calculation.
31 SourceFiles
32     streamLineParticle.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef streamLineParticle_H
37 #define streamLineParticle_H
39 #include "particle.H"
40 #include "autoPtr.H"
41 #include "interpolationCellPoint.H"
42 #include "vectorList.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 class streamLineParticleCloud;
51 /*---------------------------------------------------------------------------*\
52                      Class streamLineParticle Declaration
53 \*---------------------------------------------------------------------------*/
55 class streamLineParticle
57     public particle
60 public:
62     //- Class used to pass tracking data to the trackToFace function
63     class trackingData
64     :
65         public particle::TrackingData<Cloud<streamLineParticle> >
66     {
68     public:
71         const PtrList<interpolationCellPoint<scalar> >& vsInterp_;
72         const PtrList<interpolationCellPoint<vector> >& vvInterp_;
73         const label UIndex_;
74         const bool trackForward_;
75         const label nSubCycle_;
77         DynamicList<vectorList>& allPositions_;
78         List<DynamicList<scalarList> >& allScalars_;
79         List<DynamicList<vectorList> >& allVectors_;
82         // Constructors
84             trackingData
85             (
86                 Cloud<streamLineParticle>& cloud,
87                 const PtrList<interpolationCellPoint<scalar> >& vsInterp,
88                 const PtrList<interpolationCellPoint<vector> >& vvInterp,
89                 const label UIndex,
90                 const bool trackForward,
91                 const label nSubCycle,
92                 DynamicList<List<point> >& allPositions,
93                 List<DynamicList<scalarList> >& allScalars,
94                 List<DynamicList<vectorList> >& allVectors
95             )
96             :
97                 particle::TrackingData<Cloud<streamLineParticle> >(cloud),
98                 vsInterp_(vsInterp),
99                 vvInterp_(vvInterp),
100                 UIndex_(UIndex),
101                 trackForward_(trackForward),
102                 nSubCycle_(nSubCycle),
103                 allPositions_(allPositions),
104                 allScalars_(allScalars),
105                 allVectors_(allVectors)
106             {}
107     };
110 private:
112     // Private data
114         //- Lifetime of particle. Particle dies when reaches 0.
115         label lifeTime_;
117         //- sampled positions
118         DynamicList<point> sampledPositions_;
120         //- sampled scalars
121         List<DynamicList<scalar> > sampledScalars_;
123         //- sampled vectors
124         List<DynamicList<vector> > sampledVectors_;
127     // Private Member Functions
129         //- Estimate dt to cross from current face to next one in nSubCycle
130         //  steps.
131         scalar calcSubCycleDeltaT
132         (
133             trackingData& td,
134             const scalar dt,
135             const vector& U
136         ) const;
138         //- Interpolate all quantities; return interpolated velocity.
139         vector interpolateFields
140         (
141             const trackingData&,
142             const point&,
143             const label cellI
144         );
147 public:
149     // Constructors
151         //- Construct from components
152         streamLineParticle
153         (
154             const polyMesh& c,
155             const vector& position,
156             const label cellI,
157             const label lifeTime
158         );
160         //- Construct from Istream
161         streamLineParticle
162         (
163             const polyMesh& c,
164             Istream& is,
165             bool readFields = true
166         );
168         //- Construct copy
169         streamLineParticle(const streamLineParticle& p);
171         //- Construct and return a clone
172         autoPtr<particle> clone() const
173         {
174             return autoPtr<particle>(new streamLineParticle(*this));
175         }
177         //- Factory class to read-construct particles used for
178         //  parallel transfer
179         class iNew
180         {
181             const polyMesh& mesh_;
183         public:
185             iNew(const polyMesh& mesh)
186             :
187                 mesh_(mesh)
188             {}
190             autoPtr<streamLineParticle> operator()(Istream& is) const
191             {
192                 return autoPtr<streamLineParticle>
193                 (
194                     new streamLineParticle(mesh_, is, true)
195                 );
196             }
197         };
200     // Member Functions
202         // Tracking
204             //- Track all particles to their end point
205             bool move(trackingData&, const scalar trackTime);
208             //- Overridable function to handle the particle hitting a patch
209             //  Executed before other patch-hitting functions
210             bool hitPatch
211             (
212                 const polyPatch&,
213                 trackingData& td,
214                 const label patchI,
215                 const scalar trackFraction,
216                 const tetIndices& tetIs
217             );
219             //- Overridable function to handle the particle hitting a wedge
220             void hitWedgePatch
221             (
222                 const wedgePolyPatch&,
223                 trackingData& td
224             );
226             //- Overridable function to handle the particle hitting a
227             //  symmetryPlane
228             void hitSymmetryPatch
229             (
230                 const symmetryPolyPatch&,
231                 trackingData& td
232             );
234             //- Overridable function to handle the particle hitting a cyclic
235             void hitCyclicPatch
236             (
237                 const cyclicPolyPatch&,
238                 trackingData& td
239             );
241             //- Overridable function to handle the particle hitting a
242             //- processorPatch
243             void hitProcessorPatch
244             (
245                 const processorPolyPatch&,
246                 trackingData& td
247             );
249             //- Overridable function to handle the particle hitting a wallPatch
250             void hitWallPatch
251             (
252                 const wallPolyPatch&,
253                 trackingData& td,
254                 const tetIndices&
255             );
257             //- Overridable function to handle the particle hitting a polyPatch
258             void hitPatch
259             (
260                 const polyPatch&,
261                 trackingData& td
262             );
265         // I-O
267             //- Read
268             static void readFields(Cloud<streamLineParticle>&);
270             //- Write
271             static void writeFields(const Cloud<streamLineParticle>&);
274     // Ostream Operator
276         friend Ostream& operator<<(Ostream&, const streamLineParticle&);
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 } // End namespace Foam
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 #endif
288 // ************************************************************************* //