DSMCParcel.H 8.64 KB
Newer Older
Henry's avatar
Henry committed
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
Henry's avatar
Henry committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
25
    Foam::DSMCParcel
Henry's avatar
Henry committed
26
27
28
29
30

Description
    DSMC parcel class

SourceFiles
31
32
33
    DSMCParcelI.H
    DSMCParcel.C
    DSMCParcelIO.C
Henry's avatar
Henry committed
34
35
36

\*---------------------------------------------------------------------------*/

37
38
#ifndef DSMCParcel_H
#define DSMCParcel_H
Henry's avatar
Henry committed
39
40
41
42
43

#include "particle.H"
#include "IOstream.H"
#include "autoPtr.H"
#include "contiguous.H"
44
#include "DSMCCloud.H"
Henry's avatar
Henry committed
45
46
47
48
49
50
51

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

template<class ParcelType>
52
class DSMCParcel;
Henry's avatar
Henry committed
53
54
55
56
57
58
59

// Forward declaration of friend functions

template<class ParcelType>
Ostream& operator<<
(
    Ostream&,
60
    const DSMCParcel<ParcelType>&
Henry's avatar
Henry committed
61
62
63
);

/*---------------------------------------------------------------------------*\
64
                         Class DSMCParcel Declaration
Henry's avatar
Henry committed
65
66
67
\*---------------------------------------------------------------------------*/

template<class ParcelType>
68
class DSMCParcel
Henry's avatar
Henry committed
69
70
71
:
    public ParcelType
{
72
73
74
75
76
77
    // Private member data

        //- Size in bytes of the fields
        static const std::size_t sizeofFields_;


Henry's avatar
Henry committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
public:

    //- Class to hold DSMC particle constant properties
    class constantProperties
    {
        // Private data

            //- Particle mass [kg] (constant)
            scalar mass_;

            //- Particle hard sphere diameter [m] (constant)
            scalar d_;

            //- Internal degrees of freedom
92
            direction internalDegreesOfFreedom_;
Henry's avatar
Henry committed
93
94
95
96
97
98
99

            //- Viscosity index
            scalar omega_;


    public:

100
        // Constructors
Henry's avatar
Henry committed
101
102
103
104
105
106
107
108
109
110
111

            //- Null constructor, allows List of constantProperties to be
            //  created before the contents is initialised
            inline constantProperties();

            //- Constructor from dictionary
            inline constantProperties(const dictionary& dict);


        // Member functions

112
            //- Return const access to the particle mass [kg]
Henry's avatar
Henry committed
113
114
            inline scalar mass() const;

115
            //- Return const access to the hard sphere diameter [m]
Henry's avatar
Henry committed
116
117
118
119
120
121
            inline scalar d() const;

            //- Return the reference total collision cross section
            inline scalar sigmaT() const;

            //- Return the internalDegreesOfFreedom
122
            inline direction internalDegreesOfFreedom() const;
Henry's avatar
Henry committed
123
124
125
126
127
128
129
130
131
132

            //- Return the viscosity index
            inline scalar omega() const;

    };


    //- Class used to pass kinematic tracking data to the trackToFace function
    class trackingData
    :
133
        public particle::TrackingData<DSMCCloud<DSMCParcel<ParcelType> > >
Henry's avatar
Henry committed
134
135
136
137
138
139
    {
    public:

        // Constructors

            //- Construct from components
140
            trackingData(DSMCCloud<DSMCParcel<ParcelType> >& cloud)
Henry's avatar
Henry committed
141
            :
142
                particle::TrackingData<DSMCCloud<DSMCParcel<ParcelType> > >
Henry's avatar
Henry committed
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
                (
                    cloud
                )
            {}
    };


protected:

    // Protected member data

        // Parcel properties

            //- Velocity of Parcel [m/s]
            vector U_;

            //- Internal energy of the Parcel, covering all non-translational
160
            //  degrees of freedom [J]
Henry's avatar
Henry committed
161
162
163
164
165
166
167
168
169
            scalar Ei_;

            //- Parcel type id
            label typeId_;


public:

    //- Runtime type information
170
    TypeName("DSMCParcel");
Henry's avatar
Henry committed
171
172
173
174
175
176
177

    friend class Cloud<ParcelType>;


    // Constructors

        //- Construct from components
178
        inline DSMCParcel
Henry's avatar
Henry committed
179
180
181
182
183
184
185
186
187
188
189
190
        (
            const polyMesh& mesh,
            const vector& position,
            const vector& U,
            const scalar Ei,
            const label cellI,
            const label tetFaceI,
            const label tetPtI,
            const label typeId
        );

        //- Construct from Istream
191
        DSMCParcel
Henry's avatar
Henry committed
192
193
194
195
196
197
198
199
200
        (
            const polyMesh& mesh,
            Istream& is,
            bool readFields = true
        );

        //- Construct and return a clone
        virtual autoPtr<particle> clone() const
        {
201
            return autoPtr<particle>(new DSMCParcel<ParcelType>(*this));
Henry's avatar
Henry committed
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
        }

        //- Factory class to read-construct particles used for
        //  parallel transfer
        class iNew
        {
            const polyMesh& mesh_;

        public:

            iNew(const polyMesh& mesh)
            :
                mesh_(mesh)
            {}

217
            autoPtr<DSMCParcel<ParcelType> > operator()(Istream& is) const
Henry's avatar
Henry committed
218
            {
219
                return autoPtr<DSMCParcel<ParcelType> >
Henry's avatar
Henry committed
220
                (
221
                    new DSMCParcel<ParcelType>(mesh_, is, true)
Henry's avatar
Henry committed
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
                );
            }
        };


    // Member Functions

        // Access

            //- Return type id
            inline label typeId() const;

            //- Return const access to velocity
            inline const vector& U() const;

            //- Return const access to internal energy
            inline scalar Ei() const;

240

Henry's avatar
Henry committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
        // Edit

            //- Return access to velocity
            inline vector& U();

            //- Return access to internal energy
            inline scalar& Ei();


        // Main calculation loop

            // Tracking

                //- Move the parcel
                template<class TrackData>
                bool move(TrackData& td, const scalar trackTime);


        // Patch interactions

            //- Overridable function to handle the particle hitting a patch
            //  Executed before other patch-hitting functions
            template<class TrackData>
            bool hitPatch
            (
                const polyPatch&,
                TrackData& td,
                const label patchI,
                const scalar trackFraction,
                const tetIndices& tetIs
            );

            //- Overridable function to handle the particle hitting a
            //  processorPatch
            template<class TrackData>
            void hitProcessorPatch
            (
                const processorPolyPatch&,
                TrackData& td
            );

            //- Overridable function to handle the particle hitting a wallPatch
            template<class TrackData>
            void hitWallPatch
            (
                const wallPolyPatch&,
                TrackData& td,
                const tetIndices&
            );

            //- Overridable function to handle the particle hitting a polyPatch
            template<class TrackData>
            void hitPatch
            (
                const polyPatch&,
                TrackData& td
            );

            //- Transform the physical properties of the particle
            //  according to the given transformation tensor
            virtual void transformProperties(const tensor& T);

            //- Transform the physical properties of the particle
            //  according to the given separation vector
            virtual void transformProperties(const vector& separation);


        // I-O

310
            static void readFields(Cloud<DSMCParcel<ParcelType> >& c);
Henry's avatar
Henry committed
311

312
            static void writeFields(const Cloud<DSMCParcel<ParcelType> >& c);
Henry's avatar
Henry committed
313
314
315
316
317
318
319


    // Ostream Operator

        friend Ostream& operator<< <ParcelType>
        (
            Ostream&,
320
            const DSMCParcel<ParcelType>&
Henry's avatar
Henry committed
321
322
323
324
325
326
327
328
329
330
        );
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

331
#include "DSMCParcelI.H"
Henry's avatar
Henry committed
332
333
334
335

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifdef NoRepository
336
    #include "DSMCParcel.C"
Henry's avatar
Henry committed
337
338
339
340
341
342
343
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //