drippingInjection.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 
52 (
54  const dictionary& dict
55 )
56 :
57  injectionModel(type(), film, dict),
58  deltaStable_(coeffDict_.lookup<scalar>("deltaStable")),
59  particlesPerParcel_(coeffDict_.lookup<scalar>("particlesPerParcel")),
60  rndGen_(label(0)),
61  parcelDistribution_
62  (
64  (
65  coeffDict_.subDict("parcelDistribution"),
66  rndGen_
67  )
68  ),
69  diameter_(film.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->film());
90 
91  const scalar pi = constant::mathematical::pi;
92 
93  // calculate available dripping mass
94  const scalarField gNorm(film.g() & film.nHat()());
95  const scalarField& magSf = film.magSf();
96 
97  const scalarField& delta = film.delta();
98  const scalarField& rho = film.rho();
99 
100  scalarField massDrip(film.regionMesh().nCells(), 0.0);
101 
102  forAll(gNorm, i)
103  {
104  if (gNorm[i] > small)
105  {
106  const scalar ddelta = max(0.0, delta[i] - deltaStable_);
107  massDrip[i] +=
108  min(availableMass[i], max(0.0, ddelta*rho[i]*magSf[i]));
109  }
110  }
111 
112 
113  // Collect the data to be transferred
114  forAll(massDrip, celli)
115  {
116  if (massDrip[celli] > 0)
117  {
118  // set new particle diameter if not already set
119  if (diameter_[celli] < 0)
120  {
121  diameter_[celli] = parcelDistribution_->sample();
122  }
123 
124  scalar& diam = diameter_[celli];
125  scalar rhoc = rho[celli];
126  scalar minMass = particlesPerParcel_*rhoc*pi/6*pow3(diam);
127 
128  if (massDrip[celli] > minMass)
129  {
130  // All drip mass can be injected
131  massToInject[celli] += massDrip[celli];
132  availableMass[celli] -= massDrip[celli];
133 
134  // Set particle diameter
135  diameterToInject[celli] = diam;
136 
137  // Retrieve new particle diameter sample
138  diam = parcelDistribution_->sample();
139 
140  addToInjectedMass(massDrip[celli]);
141  }
142  else
143  {
144  // Particle mass below minimum threshold - cannot be injected
145  massToInject[celli] = 0.0;
146  diameterToInject[celli] = 0.0;
147  }
148  }
149  else
150  {
151  massToInject[celli] = 0.0;
152  diameterToInject[celli] = 0.0;
153  }
154  }
155 
157 }
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace surfaceFilmModels
163 } // End namespace regionModels
164 } // End namespace Foam
165 
166 // ************************************************************************* //
scalar delta
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
Kinematic form of single-cell layer surface film model.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
label nCells() const
addToRunTimeSelectionTable(surfaceFilmRegionModel, kinematicSingleLayer, mesh)
Macros for easy insertion into run-time selection tables.
const surfaceFilmRegionModel & film() const
Return const access to the film surface film model.
scalar deltaStable_
Stable film thickness - drips only formed if thickness.
scalar particlesPerParcel_
Number of particles per parcel.
const autoPtr< distributionModel > parcelDistribution_
Parcel size PDF model.
scalarList diameter_
Diameters of particles to inject into the dripping.
const volVectorField & nHat() const
Return the patch normal vectors.
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
void addToInjectedMass(const scalar dMass)
Add to injected mass.
const dimensionedVector & g() const
Return the acceleration due to gravity.
Base class for film injection models, handling mass transfer from the film.
const volScalarField & delta() const
Return const access to the film thickness [m].
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
drippingInjection(surfaceFilmRegionModel &film, const dictionary &dict)
Construct from surface film model.
dimensionedScalar pow3(const dimensionedScalar &ds)
const volScalarField::Internal & magSf() const
Return the face area magnitudes [m^2].
static autoPtr< distributionModel > New(const dictionary &dict, Random &rndGen)
Selector.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
const volScalarField & rho() const
Return the film density [kg/m^3].
defineTypeNameAndDebug(kinematicSingleLayer, 0)
Namespace for OpenFOAM.