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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "drippingInjection.H"
30 #include "fvMesh.H"
31 #include "Time.H"
32 #include "mathematicalConstants.H"
33 #include "Random.H"
34 #include "volFields.H"
35 #include "kinematicSingleLayer.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace regionModels
42 {
43 namespace surfaceFilmModels
44 {
45 
46 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
47 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
53 drippingInjection::drippingInjection
54 (
56  const dictionary& dict
57 )
58 :
59  injectionModel(type(), film, dict),
60  deltaStable_(coeffDict_.get<scalar>("deltaStable")),
61  particlesPerParcel_(coeffDict_.get<scalar>("particlesPerParcel")),
62  rndGen_(),
63  parcelDistribution_
64  (
66  (
67  coeffDict_.subDict("parcelDistribution"),
68  rndGen_
69  )
70  ),
71  diameter_(film.regionMesh().nCells(), -1.0)
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
78 {}
79 
80 
81 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
82 
84 (
85  scalarField& availableMass,
86  scalarField& massToInject,
87  scalarField& diameterToInject
88 )
89 {
90  const kinematicSingleLayer& film =
91  refCast<const kinematicSingleLayer>(this->film());
92 
93  const scalar pi = constant::mathematical::pi;
94 
95  // calculate available dripping mass
96  tmp<volScalarField> tgNorm(film.gNorm());
97  const scalarField& gNorm = tgNorm();
98  const scalarField& magSf = film.magSf();
99 
100  const scalarField& delta = film.delta();
101  const scalarField& rho = film.rho();
102 
103  scalarField massDrip(film.regionMesh().nCells(), Zero);
104 
105  forAll(gNorm, i)
106  {
107  if (gNorm[i] > SMALL)
108  {
109  const scalar ddelta = max(0.0, delta[i] - deltaStable_);
110  massDrip[i] +=
111  min(availableMass[i], max(0.0, ddelta*rho[i]*magSf[i]));
112  }
113  }
114 
115 
116  // Collect the data to be transferred
117  forAll(massDrip, celli)
118  {
119  if (massDrip[celli] > 0)
120  {
121  // set new particle diameter if not already set
122  if (diameter_[celli] < 0)
123  {
124  diameter_[celli] = parcelDistribution_->sample();
125  }
126 
127  scalar& diam = diameter_[celli];
128  scalar rhoc = rho[celli];
129  scalar minMass = particlesPerParcel_*rhoc*pi/6*pow3(diam);
130 
131  if (massDrip[celli] > minMass)
132  {
133  // All drip mass can be injected
134  massToInject[celli] += massDrip[celli];
135  availableMass[celli] -= massDrip[celli];
136 
137  // Set particle diameter
138  diameterToInject[celli] = diam;
139 
140  // Retrieve new particle diameter sample
141  diam = parcelDistribution_->sample();
142 
143  addToInjectedMass(massDrip[celli]);
144  }
145  else
146  {
147  // Particle mass below minimum threshold - cannot be injected
148  massToInject[celli] = 0.0;
149  diameterToInject[celli] = 0.0;
150  }
151  }
152  else
153  {
154  massToInject[celli] = 0.0;
155  diameterToInject[celli] = 0.0;
156  }
157  }
158 
160 }
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace surfaceFilmModels
166 } // End namespace regionModels
167 } // End namespace Foam
168 
169 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
scalar delta
dictionary dict
Kinematic form of single-cell layer surface film model.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
virtual const volScalarField & rho() const =0
Return the film density [kg/m3].
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.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
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.
virtual const volScalarField & delta() const =0
Return the film thickness [m].
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:26
constexpr scalar pi(M_PI)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
void addToInjectedMass(const scalar dMass)
Add to injected mass.
Base class for film injection models, handling mass transfer from the film.
dimensionedScalar pow3(const dimensionedScalar &ds)
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
label nCells() const noexcept
Number of mesh cells.
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
A class for managing temporary objects.
Definition: HashPtrTable.H:50
defineTypeNameAndDebug(kinematicSingleLayer, 0)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127