ReactingParcel.H 14 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
OpenFOAM bot's avatar
OpenFOAM bot committed
6 7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2017 OpenFOAM Foundation
9
    Copyright (C) 2016-2020 OpenCFD Ltd.
10 11 12 13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14 15 16 17
    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.
18 19 20 21 22 23 24

    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
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26 27 28 29

Class
    Foam::ReactingParcel

30 31 32
Group
    grpLagrangianIntermediateParcels

33
Description
34 35
    Reacting parcel class with one/two-way coupling with the continuous
    phase.
36 37

SourceFiles
38
    ReactingParcelI.H
39
    ReactingParcel.C
40
    ReactingParcelIO.C
41 42 43 44 45 46

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

#ifndef ReactingParcel_H
#define ReactingParcel_H

andy's avatar
andy committed
47 48
#include "particle.H"
#include "SLGThermo.H"
49
#include "demandDrivenEntry.H"
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

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

namespace Foam
{

template<class ParcelType>
class ReactingParcel;

template<class ParcelType>
Ostream& operator<<
(
    Ostream&,
    const ReactingParcel<ParcelType>&
);

66

67 68 69 70 71 72 73
/*---------------------------------------------------------------------------*\
                        Class ReactingParcel Declaration
\*---------------------------------------------------------------------------*/

template<class ParcelType>
class ReactingParcel
:
andy's avatar
andy committed
74
    public ParcelType
75
{
76
public:
77

78 79
    //- Size in bytes of the fields
    static const std::size_t sizeofFields;
80

81

82
    //- Class to hold reacting parcel constant properties
83 84
    class constantProperties
    :
andy's avatar
andy committed
85
        public ParcelType::constantProperties
86 87 88
    {
        // Private data

89
            //- Minimum pressure [Pa]
90
            demandDrivenEntry<scalar> pMin_;
91

92
            //- Constant volume flag - e.g. during mass transfer
93
            demandDrivenEntry<bool> constantVolume_;
94

95 96 97

    public:

98 99 100 101 102 103 104 105
        // Constructors

            //- Null constructor
            constantProperties();

            //- Copy constructor
            constantProperties(const constantProperties& cp);

106 107
            //- Construct from dictionary
            constantProperties(const dictionary& parentDict);
108

109

110 111
        // Access

112 113 114
            //- Return const access to the minimum pressure
            inline scalar pMin() const;

115
            //- Return const access to the constant volume flag
116
            inline bool constantVolume() const;
andy's avatar
andy committed
117
    };
118 119


120
    class trackingData
121
    :
122
        public ParcelType::trackingData
123
    {
andy's avatar
andy committed
124
    private:
125 126 127

        // Private data

andy's avatar
andy committed
128
            // Interpolators for continuous phase fields
129

andy's avatar
andy committed
130
                //- Interpolator for continuous phase pressure field
131
                autoPtr<interpolation<scalar>> pInterp_;
132 133


134 135 136 137 138 139
            // Cached continuous phase properties

                //- Pressure [Pa]
                scalar pc_;


andy's avatar
andy committed
140
    public:
141

142
        typedef typename ParcelType::trackingData::trackPart trackPart;
143

144 145
        // Constructors

146
            //- Construct from components
147 148
            template<class TrackCloudType>
            inline trackingData
149
            (
150 151
                const TrackCloudType& cloud,
                trackPart part = ParcelType::trackingData::tpLinearTrack
152 153 154 155 156
            );


        // Member functions

andy's avatar
andy committed
157 158
            //- Return const access to the interpolator for continuous phase
            //  pressure field
159
            inline const interpolation<scalar>& pInterp() const;
160 161 162 163 164 165

            //- Return the continuous phase pressure
            inline scalar pc() const;

            //- Access the continuous phase pressure
            inline scalar& pc();
166 167 168
    };


169 170 171 172 173 174
protected:

    // Protected data

        // Parcel properties

175
            //- Initial mass [kg]
176 177 178
            scalar mass0_;

            //- Mass fractions of mixture []
179
            scalarField Y_;
180 181


182
    // Protected Member Functions
183

184
        //- Calculate Phase change
185
        template<class TrackCloudType>
186
        void calcPhaseChange
187
        (
188 189
            TrackCloudType& cloud,
            trackingData& td,
190
            const scalar dt,           // timestep
191
            const scalar Re,           // Reynolds number
andy's avatar
andy committed
192
            const scalar Pr,           // Prandtl number
193 194
            const scalar Ts,           // Surface temperature
            const scalar nus,          // Surface kinematic viscosity
195 196
            const scalar d,            // diameter
            const scalar T,            // temperature
197
            const scalar mass,         // mass
198 199 200
            const label idPhase,       // id of phase involved in phase change
            const scalar YPhase,       // total mass fraction
            const scalarField& YComponents, // component mass fractions
201 202 203
            scalarField& dMassPC,      // mass transfer - local to parcel
            scalar& Sh,                // explicit parcel enthalpy source
            scalar& N,                 // flux of species emitted from parcel
204 205
            scalar& NCpW,              // sum of N*Cp*W of emission species
            scalarField& Cs            // carrier conc. of emission species
206 207
        );

208
        //- Update mass fraction
209
        scalar updateMassFraction
210 211
        (
            const scalar mass0,
212
            const scalarField& dMass,
213
            scalarField& Y
214
        ) const;
215

216 217 218

public:

219 220 221 222 223
    // Static data members

        //- Runtime type information
        TypeName("ReactingParcel");

224 225 226 227 228 229 230 231
        //- String representation of properties
        AddToPropertyList
        (
            ParcelType,
            " mass0"
          + " nPhases(Y1..YN)"
        );

232

233 234
    // Constructors

235
        //- Construct from mesh, coordinates and topology
Andrew Heather's avatar
Andrew Heather committed
236 237 238
        //  Other properties initialised as null
        inline ReactingParcel
        (
andy's avatar
andy committed
239
            const polyMesh& mesh,
240
            const barycentric& coordinates,
241
            const label celli,
242
            const label tetFacei,
Henry Weller's avatar
Henry Weller committed
243
            const label tetPti
Andrew Heather's avatar
Andrew Heather committed
244 245
        );

246 247
        //- Construct from a position and a cell, searching for the rest of the
        //  required topology. Other properties are initialised as null.
248 249
        inline ReactingParcel
        (
andy's avatar
andy committed
250
            const polyMesh& mesh,
251
            const vector& position,
252 253 254 255 256 257 258 259
            const label celli
        );

        //- Construct from components
        inline ReactingParcel
        (
            const polyMesh& mesh,
            const barycentric& coordinates,
260
            const label celli,
261
            const label tetFacei,
Henry Weller's avatar
Henry Weller committed
262
            const label tetPti,
263 264
            const label typeId,
            const scalar nParticle0,
265
            const scalar d0,
graham's avatar
graham committed
266
            const scalar dTarget0,
267
            const vector& U0,
268
            const vector& f0,
269 270
            const vector& angularMomentum0,
            const vector& torque0,
271
            const scalarField& Y0,
272 273 274 275 276 277
            const constantProperties& constProps
        );

        //- Construct from Istream
        ReactingParcel
        (
andy's avatar
andy committed
278
            const polyMesh& mesh,
279
            Istream& is,
280 281
            bool readFields = true,
            bool newFormat = true
282 283
        );

284 285 286 287
        //- Construct as a copy
        ReactingParcel
        (
            const ReactingParcel& p,
andy's avatar
andy committed
288
            const polyMesh& mesh
289 290
        );

291 292 293
        //- Construct as a copy
        ReactingParcel(const ReactingParcel& p);

294
        //- Construct and return a (basic particle) clone
andy's avatar
andy committed
295
        virtual autoPtr<particle> clone() const
296
        {
andy's avatar
andy committed
297
            return autoPtr<particle>(new ReactingParcel<ParcelType>(*this));
298 299 300
        }

        //- Construct and return a (basic particle) clone
andy's avatar
andy committed
301
        virtual autoPtr<particle> clone(const polyMesh& mesh) const
302
        {
andy's avatar
andy committed
303
            return autoPtr<particle>
304
            (
andy's avatar
andy committed
305
                new ReactingParcel<ParcelType>(*this, mesh)
306
            );
307 308
        }

andy's avatar
andy committed
309 310 311 312 313 314 315 316 317 318 319 320 321
        //- Factory class to read-construct particles used for
        //  parallel transfer
        class iNew
        {
            const polyMesh& mesh_;

        public:

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

322
            autoPtr<ReactingParcel<ParcelType>> operator()(Istream& is) const
andy's avatar
andy committed
323
            {
324
                return autoPtr<ReactingParcel<ParcelType>>
andy's avatar
andy committed
325 326 327 328 329 330
                (
                    new ReactingParcel<ParcelType>(mesh_, is, true)
                );
            }
        };

331 332 333 334 335

    // Member Functions

        // Access

336
            //- Return const access to initial mass [kg]
337
            inline scalar mass0() const;
338

Henry's avatar
Henry committed
339
            //- Return const access to mass fractions of mixture []
340
            inline const scalarField& Y() const;
341

342 343 344 345 346 347 348 349 350 351 352 353
            //- Return const access to mass fractions of gases
            //  Note: for compatibilty only - returns Y()
            inline const scalarField& YGas() const;

            //- Return const access to mass fractions of liquids
            //  Note: for compatibilty only - returns Y()
            inline const scalarField& YLiquid() const;

            //- Return const access to mass fractions of solids
            //  Note: for compatibilty only - returns Y()
            inline const scalarField& YSolid() const;

354 355 356

        // Edit

357
            //- Return access to initial mass [kg]
358
            inline scalar& mass0();
359

Henry's avatar
Henry committed
360
            //- Return access to mass fractions of mixture []
361
            inline scalarField& Y();
362

363

364
        // Main calculation loop
365

366
            //- Set cell values
367
            template<class TrackCloudType>
368
            void setCellValues(TrackCloudType& cloud, trackingData& td);
369 370

            //- Correct cell values using latest transfer information
371
            template<class TrackCloudType>
372
            void cellValueSourceCorrection
373
            (
374 375
                TrackCloudType& cloud,
                trackingData& td,
376
                const scalar dt
377 378
            );

379
            //- Correct surface values due to emitted species
380
            template<class TrackCloudType>
381 382
            void correctSurfaceValues
            (
383 384
                TrackCloudType& cloud,
                trackingData& td,
385 386 387 388
                const scalar T,
                const scalarField& Cs,
                scalar& rhos,
                scalar& mus,
389 390
                scalar& Prs,
                scalar& kappas
391 392
            );

393
            //- Update parcel properties over the time interval
394
            template<class TrackCloudType>
395
            void calc
396
            (
397 398
                TrackCloudType& cloud,
                trackingData& td,
399
                const scalar dt
400
            );
401 402 403 404


        // I-O

405
            //- Read - composition supplied
andy's avatar
andy committed
406 407 408 409 410 411 412 413 414 415
            template<class CloudType, class CompositionType>
            static void readFields
            (
                CloudType& c,
                const CompositionType& compModel
            );

            //- Read - no composition
            template<class CloudType>
            static void readFields(CloudType& c);
416

417
            //- Write - composition supplied
andy's avatar
andy committed
418 419 420 421 422 423 424
            template<class CloudType, class CompositionType>
            static void writeFields
            (
                const CloudType& c,
                const CompositionType& compModel
            );

425
            //- Write - no composition
andy's avatar
andy committed
426 427
            template<class CloudType>
            static void writeFields(const CloudType& c);
428

429 430 431 432 433 434 435 436
            //- Write individual parcel properties to stream
            void writeProperties
            (
                Ostream& os,
                const wordRes& filters,
                const word& delim,
                const bool namesOnly = false
            ) const;
437

438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
            //- Read particle fields as objects from the obr registry
            //  - no composition
            template<class CloudType>
            static void readObjects
            (
                CloudType& c,
                const objectRegistry& obr
            );

            //- Read particle fields as objects from the obr registry
            template<class CloudType, class CompositionType>
            static void readObjects
            (
                CloudType& c,
                const CompositionType& compModel,
                const objectRegistry& obr
            );

456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
            //- Write particle fields as objects into the obr registry
            //  - no composition
            template<class CloudType>
            static void writeObjects
            (
                const CloudType& c,
                objectRegistry& obr
            );

            //- Write particle fields as objects into the obr registry
            template<class CloudType, class CompositionType>
            static void writeObjects
            (
                const CloudType& c,
                const CompositionType& compModel,
                objectRegistry& obr
            );

474

475 476 477 478 479 480 481
    // Ostream Operator

        friend Ostream& operator<< <ParcelType>
        (
            Ostream&,
            const ReactingParcel<ParcelType>&
        );
482 483 484 485 486 487 488 489 490 491
};


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

} // End namespace Foam

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

#include "ReactingParcelI.H"
andy's avatar
andy committed
492
#include "ReactingParcelTrackingDataI.H"
493 494 495 496 497 498 499 500 501 502 503 504

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

#ifdef NoRepository
    #include "ReactingParcel.C"
#endif

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

#endif

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