kinematicThinFilm.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) 2020 OpenCFD Ltd.
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 "kinematicThinFilm.H"
31 #include "volFields.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace regionModels
38 {
39 namespace areaSurfaceFilmModels
40 {
41 
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& modelType,
52  const fvMesh& mesh,
53  const dictionary& dict
54 )
55 :
56  liquidFilmModel(modelType, mesh, dict)
57 {}
58 
59 
60 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
61 
63 {
67 
68  // Update mass exchange sources
70 
71  // gas pressure map from primary region
72  ppf_ = pg();
73 }
74 
75 
77 {
78  if (debug)
79  {
81  }
82 
84 
85  const areaVectorField gs(g_ - ns*(ns & g_));
86 
88 
89  for (int oCorr=1; oCorr<=nOuterCorr_; oCorr++)
90  {
92 
93  faVectorMatrix UsEqn
94  (
95  fam::ddt(h_, Uf_)
96  + fam::div(phi2s_, Uf_)
97  ==
98  gs*h_
99  + turbulence_->Su(Uf_)
100  + faOptions()(h_, Uf_, sqr(dimVelocity))
101  + forces_.correct(Uf_)
102  + USp_
103  );
104 
105  UsEqn.relax();
106 
107  faOptions().constrain(UsEqn);
108 
109  if (momentumPredictor_)
110  {
111  solve(UsEqn == - fac::grad(pf_*h_)/rho_ + pf_*fac::grad(h_)/rho_);
112  }
113 
114  for (int corr=1; corr<=nCorr_; corr++)
115  {
116  areaScalarField UsA(UsEqn.A());
117 
118  Uf_ = UsEqn.H()/UsA;
120  faOptions().correct(Uf_);
121 
122  phif_ =
124  - fac::interpolate(1.0/(rho_*UsA))
126  + fac::interpolate(pf_/(rho_*UsA))
128 
129  for (int nFilm=1; nFilm<=nFilmCorr_; nFilm++)
130  {
131  faScalarMatrix hEqn
132  (
133  fam::ddt(h_)
134  + fam::div(phif_, h_)
135  ==
137  + rhoSp_
138  );
139 
140  hEqn.relax();
141  faOptions().constrain(hEqn);
142  hEqn.solve();
143  faOptions().correct(h_);
144 
145  if (nFilm == nFilmCorr_)
146  {
147  phi2s_ = hEqn.flux();
148  }
149  }
150 
151  // Bound h_
152  h_ = max(h_, h0_);
153 
156  pf_.relax();
157 
158  Uf_ -= (1.0/(rho_*UsA))*fac::grad(pf_*h_)
159  - (pf_/(rho_*UsA))*fac::grad(h_);
161  faOptions().correct(Uf_);
162  }
163  }
164 
165  Info<< "Film h min/max = " << gMinMax(h_) << nl
166  << "Film mag(U) min/max = " << gMinMaxMag(Uf_) << endl;
167 }
168 
169 
171 {
172  // Reset sources
174 
175  // Correct thermo
177 
178  // Correct turbulence
179  turbulence_->correct();
180 }
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace areaSurfaceFilmModels
185 } // End namespace regionModels
186 } // End namespace Foam
187 
188 // ************************************************************************* //
dictionary dict
void constrain(faMatrix< Type > &eqn)
Apply constraints to equation.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Foam::fa::options & faOptions()
Return faOptions.
autoPtr< filmTurbulenceModel > turbulence_
Turbulence model.
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
Definition: faMatrix.C:499
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
dimensionedScalar h0_
Smallest numerical thickness.
Various UniformDimensionedField types.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
tmp< areaScalarField > pg() const
Map primary static pressure.
defineTypeNameAndDebug(kinematicThinFilm, 0)
label nFilmCorr_
Number of film thickness correctors.
const edgeScalarField & magLe() const
Return edge length magnitudes.
Definition: faMesh.C:880
Macros for easy insertion into run-time selection tables.
void correct(GeometricField< Type, faPatchField, areaMesh > &field)
Apply correction to field.
areaScalarField sigma_
Surface tension [m/s2].
dynamicFvMesh & mesh
addToRunTimeSelectionTable(liquidFilmBase, kinematicThinFilm, dictionary)
A class for handling words, derived from Foam::string.
Definition: word.H:63
const edgeVectorField & Le() const
Return edge length vectors.
Definition: faMesh.C:869
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:40
tmp< faVectorMatrix > correct(areaVectorField &U)
Return (net) force system.
Definition: forceList.C:75
kinematicThinFilm(const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components and dict.
const faMesh & regionMesh() const
Return the region mesh database.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &solverControls)
Solve returning the solution statistics given convergence tolerance.
forceList forces_
Transfer with the continuous phase.
tmp< faMatrix< Type > > ddt(const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famDdt.C:41
tmp< faMatrix< Type > > div(const edgeScalarField &flux, const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: famDiv.C:41
int debug
Static debugging option.
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
tmp< GeometricField< Type, faePatchField, edgeMesh > > lnGrad(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLnGrad.C:40
areaScalarField ppf_
Primary region pressure.
areaScalarField pnSp_
Normal pressure by particles.
void relax(const scalar alpha)
Relax field (for steady-state solution).
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A special matrix type and solver, designed for finite area solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: faMatricesFwd.H:37
Template specialisation for scalar faMatrix.
void correctBoundaryConditions()
Correct boundary field.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void storePrevIter() const
Store the field as the previous iteration value.
label nCorr_
Number of PISO-like correctors.
const areaVectorField & faceAreaNormals() const
Return face area normals.
Definition: faMesh.C:964
Namespace for OpenFOAM.
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:51
#define InfoInFunction
Report an information message using Foam::Info.
const dimensionSet dimVelocity