drippingInjection.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "drippingInjection.H"
28 #include "fvMesh.H"
29 #include "Time.H"
30 #include "mathematicalConstants.H"
31 #include "Random.H"
32 #include "volFields.H"
33 #include "kinematicSingleLayer.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace regionModels
40 {
41 namespace surfaceFilmModels
42 {
43 
44 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45 
46 defineTypeNameAndDebug(drippingInjection, 0);
47 addToRunTimeSelectionTable(injectionModel, drippingInjection, dictionary);
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 drippingInjection::drippingInjection
52 (
53  surfaceFilmModel& owner,
54  const dictionary& dict
55 )
56 :
57  injectionModel(type(), owner, dict),
58  deltaStable_(readScalar(coeffDict_.lookup("deltaStable"))),
59  particlesPerParcel_(readScalar(coeffDict_.lookup("particlesPerParcel"))),
60  rndGen_(label(0), -1),
61  parcelDistribution_
62  (
64  (
65  coeffDict_.subDict("parcelDistribution"),
66  rndGen_
67  )
68  ),
69  diameter_(owner.regionMesh().nCells(), -1.0)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74 
76 {}
77 
78 
79 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
80 
82 (
83  scalarField& availableMass,
84  scalarField& massToInject,
85  scalarField& diameterToInject
86 )
87 {
88  const kinematicSingleLayer& film =
89  refCast<const kinematicSingleLayer>(this->owner());
90 
91  const scalar pi = constant::mathematical::pi;
92 
93  // calculate available dripping mass
94  tmp<volScalarField> tgNorm(film.gNorm());
95  const scalarField& gNorm = tgNorm();
96  const scalarField& magSf = film.magSf();
97 
98  const scalarField& delta = film.delta();
99  const scalarField& rho = film.rho();
100 
101  scalarField massDrip(film.regionMesh().nCells(), 0.0);
102 
103  forAll(gNorm, i)
104  {
105  if (gNorm[i] > SMALL)
106  {
107  const scalar ddelta = max(0.0, delta[i] - deltaStable_);
108  massDrip[i] +=
109  min(availableMass[i], max(0.0, ddelta*rho[i]*magSf[i]));
110  }
111  }
112 
113 
114  // Collect the data to be transferred
115  forAll(massDrip, celli)
116  {
117  if (massDrip[celli] > 0)
118  {
119  // set new particle diameter if not already set
120  if (diameter_[celli] < 0)
121  {
122  diameter_[celli] = parcelDistribution_->sample();
123  }
124 
125  scalar& diam = diameter_[celli];
126  scalar rhoc = rho[celli];
127  scalar minMass = particlesPerParcel_*rhoc*pi/6*pow3(diam);
128 
129  if (massDrip[celli] > minMass)
130  {
131  // All drip mass can be injected
132  massToInject[celli] += massDrip[celli];
133  availableMass[celli] -= massDrip[celli];
134 
135  // Set particle diameter
136  diameterToInject[celli] = diam;
137 
138  // Retrieve new particle diameter sample
139  diam = parcelDistribution_->sample();
140 
141  addToInjectedMass(massDrip[celli]);
142  }
143  else
144  {
145  // Particle mass below minimum threshold - cannot be injected
146  massToInject[celli] = 0.0;
147  diameterToInject[celli] = 0.0;
148  }
149  }
150  else
151  {
152  massToInject[celli] = 0.0;
153  diameterToInject[celli] = 0.0;
154  }
155  }
156 
158 }
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace surfaceFilmModels
164 } // End namespace regionModels
165 } // End namespace Foam
166 
167 // ************************************************************************* //
scalar delta
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const autoPtr< distributionModels::distributionModel > parcelDistribution_
Parcel size PDF model.
virtual const volScalarField & rho() const
Return the film density [kg/m3].
Macros for easy insertion into run-time selection tables.
label nCells() const
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
scalar deltaStable_
Stable film thickness - drips only formed if thickness.
static autoPtr< distributionModel > New(const dictionary &dict, cachedRandom &rndGen)
Selector.
addToRunTimeSelectionTable(surfaceFilmModel, kinematicSingleLayer, mesh)
scalar particlesPerParcel_
Number of particles per parcel.
const volScalarField & delta() const
Return const access to the film thickness / [m].
tmp< volScalarField > gNorm() const
Return the gravity normal-to-patch component contribution.
scalarList diameter_
Diameters of particles to inject into the dripping.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
void addToInjectedMass(const scalar dMass)
Add to injected mass.
Base class for film injection models, handling mass transfer from the film.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedScalar pow3(const dimensionedScalar &ds)
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:461
const surfaceFilmModel & owner() const
Return const access to the owner surface film model.
A class for managing temporary objects.
Definition: PtrList.H:54
defineTypeNameAndDebug(kinematicSingleLayer, 0)
Namespace for OpenFOAM.