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"
30 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace regionModels
37 {
38 namespace areaSurfaceFilmModels
39 {
40 
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const word& modelType,
51  const fvMesh& mesh,
52  const dictionary& dict
53 )
54 :
55  liquidFilmModel(modelType, mesh, dict)
56 {}
57 
58 
59 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
60 
62 {
66 
67  // Update mass exchange sources
69 
70  // gas pressure map from primary region
71  ppf_ = pg();
72 }
73 
74 
76 {
78 
80 
81  const areaVectorField gs(g_ - ns*(ns & g_));
82 
84 
85  for (int oCorr=1; oCorr<=nOuterCorr_; ++oCorr)
86  {
88 
89  faVectorMatrix UsEqn
90  (
91  fam::ddt(h_, Uf_)
92  + fam::div(phi2s_, Uf_)
93  ==
94  gs*h_
95  + turbulence_->Su(Uf_)
98  + USp_
99  );
100 
101  UsEqn.relax();
102 
103  faOptions().constrain(UsEqn);
104 
105  if (momentumPredictor_)
106  {
107  solve(UsEqn == -fac::grad(pf_*h_)/rho_ + pf_*fac::grad(h_)/rho_);
108  }
109 
110  for (int corr=1; corr<=nCorr_; ++corr)
111  {
112  areaScalarField UsA(UsEqn.A());
113 
114  Uf_ = UsEqn.H()/UsA;
116  faOptions().correct(Uf_);
117 
118  phif_ =
120  - fac::interpolate(1.0/(rho_*UsA))
122  + fac::interpolate(pf_/(rho_*UsA))
124 
125  for (int nFilm=1; nFilm<=nFilmCorr_; ++nFilm)
126  {
127  faScalarMatrix hEqn
128  (
129  fam::ddt(h_)
130  + fam::div(phif_, h_)
131  ==
133  + rhoSp_
134  );
135 
136  hEqn.relax();
137  faOptions().constrain(hEqn);
138  hEqn.solve();
139  faOptions().correct(h_);
140 
141  if (nFilm == nFilmCorr_)
142  {
143  phi2s_ = hEqn.flux();
144  }
145  }
146 
147  // Bound h_
148  h_ = max(h_, h0_);
149 
152  pf_.relax();
153 
154  Uf_ -= (1.0/(rho_*UsA))*fac::grad(pf_*h_)
155  - (pf_/(rho_*UsA))*fac::grad(h_);
157  faOptions().correct(Uf_);
158  }
159  }
160 
161  Info<< "Film h min/max = " << gMinMax(h_) << nl
162  << "Film mag(U) min/max = " << gMinMaxMag(Uf_) << endl;
163 }
164 
165 
167 {
168  // Reset sources
170 
171  // Correct thermo
173 
174  // Correct turbulence
175  turbulence_->correct();
176 }
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace areaSurfaceFilmModels
181 } // End namespace regionModels
182 } // End namespace Foam
183 
184 // ************************************************************************* //
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
autoPtr< filmTurbulenceModel > turbulence_
Turbulence model.
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
Definition: faMatrix.C:489
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 film thickness.
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:1099
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/s^2].
dynamicFvMesh & mesh
addToRunTimeSelectionTable(liquidFilmBase, kinematicThinFilm, dictionary)
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInFunction
Report an information message using Foam::Info.
const edgeVectorField & Le() const
Return edge length vectors.
Definition: faMesh.C:1088
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.
Foam::fa::options & faOptions() noexcept
Return faOptions.
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
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 inner correctors.
const areaVectorField & faceAreaNormals() const
Return face area normals.
Definition: faMesh.C:1183
Namespace for OpenFOAM.
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:51
const dimensionSet dimVelocity
Switch momentumPredictor_
Flag to enable momentum predictor.