liquidFilmFoam.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) 2016-2017 Wikki 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 Application
27  liquidFilmFoam
28 
29 Group
30  grpFiniteAreaSolvers
31 
32 Description
33  Transient solver for incompressible, laminar flow of Newtonian fluids in
34  liquid film formulation.
35 
36 Author
37  Zeljko Tukovic, FMENA
38  Hrvoje Jasak, Wikki Ltd.
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #include "fvCFD.H"
43 #include "faCFD.H"
44 #include "loopControl.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
50  argList::addNote
51  (
52  "Transient solver for incompressible, laminar flow"
53  " of Newtonian fluids in liquid film formulation."
54  );
55 
56  #include "setRootCaseLists.H"
57  #include "createTime.H"
58  #include "createMesh.H"
59  #include "createFaMesh.H"
60  #include "readGravitationalAcceleration.H"
61  #include "readTransportProperties.H"
62  #include "createFaFields.H"
63  #include "createFvFields.H"
64  #include "createTimeControls.H"
65 
66  Info<< "\nStarting time loop\n" << endl;
67 
68  while (runTime.run())
69  {
70  #include "readSolutionControls.H"
71  #include "readTimeControls.H"
72  #include "surfaceCourantNo.H"
73  #include "capillaryCourantNo.H"
74  #include "setDeltaT.H"
75 
76  ++runTime;
77 
78  Info<< "Time = " << runTime.timeName() << nl << endl;
79 
80  while (iters.loop())
81  {
82  phi2s = fac::interpolate(h)*phis;
83 
84  #include "calcFrictionFactor.H"
85 
86  faVectorMatrix UsEqn
87  (
88  fam::ddt(h, Us)
89  + fam::div(phi2s, Us)
90  + fam::Sp(0.0125*frictionFactor*mag(Us), Us)
91  ==
92  Gs*h
93  - fam::Sp(Sd, Us)
94  );
95 
96  UsEqn.relax();
97  solve(UsEqn == - fac::grad(ps*h)/rhol + ps*fac::grad(h)/rhol);
98 
99  areaScalarField UsA(UsEqn.A());
100 
101  Us = UsEqn.H()/UsA;
102  Us.correctBoundaryConditions();
103 
104  phis =
105  (fac::interpolate(Us) & aMesh.Le())
106  - fac::interpolate(1.0/(rhol*UsA))*fac::lnGrad(ps*h)*aMesh.magLe()
107  + fac::interpolate(ps/(rhol*UsA))*fac::lnGrad(h)*aMesh.magLe();
108 
109  faScalarMatrix hEqn
110  (
111  fam::ddt(h)
112  + fam::div(phis, h)
113  ==
114  Sm
115  - fam::Sp
116  (
117  Sd/(h + dimensionedScalar("small", dimLength, SMALL)),
118  h
119  )
120  );
121 
122  hEqn.relax();
123  hEqn.solve();
124 
125  phi2s = hEqn.flux();
126 
127  // Bound h
128  h.primitiveFieldRef() = max
129  (
130  max
131  (
132  h.primitiveField(),
133  fac::average(max(h, h0))().primitiveField()
134  *pos(h0.value() - h.primitiveField())
135  ),
136  h0.value()
137  );
138 
139  ps = rhol*Gn*h - sigma*fac::laplacian(h);
140  ps.correctBoundaryConditions();
141 
142  Us -= (1.0/(rhol*UsA))*fac::grad(ps*h)
143  - (ps/(rhol*UsA))*fac::grad(h);
144  Us.correctBoundaryConditions();
145  }
146 
147  if (runTime.writeTime())
148  {
149  vsm.mapToVolume(h, H.boundaryFieldRef());
150  vsm.mapToVolume(Us, U.boundaryFieldRef());
151 
152  runTime.write();
153  }
154 
155  runTime.printExecutionTime(Info);
156  }
157 
158  Info<< "End\n" << endl;
159 
160  return 0;
161 }
162 
163 
164 // ************************************************************************* //
const volSurfaceMapping vsm(aMesh)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
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:49
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:43
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
Definition: facAverage.C:40
Read the control parameters used by setDeltaT.
Calculates and outputs the mean and maximum Courant Numbers for the Finite Area method.
faMatrix< vector > faVectorMatrix
Definition: faMatrices.H:47
tmp< GeometricField< Type, faPatchField, areaMesh > > ddt(const dimensioned< Type > dt, const faMesh &mesh)
Definition: facDdt.C:40
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
CEqn solve()
dimensionedScalar pos(const dimensionedScalar &ds)
volScalarField H(IOobject("H", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimensionedScalar(dimLength, Zero))
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:40
Us
tmp< GeometricField< Type, faePatchField, edgeMesh > > lnGrad(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLnGrad.C:40
const dimensionedScalar h
Planck constant.
faMatrix< scalar > faScalarMatrix
Definition: faMatrices.H:46
Required Variables.
U
Definition: pEqn.H:72
dimensionedScalar rhol("rhol", dimDensity, transportProperties)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
edgeScalarField phis(IOobject("phis", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), linearEdgeInterpolate(Us) &aMesh.Le())
loopControl iters(runTime, aMesh.solutionDict(), "solution")
messageStream Info
Information stream (stdout output on master, null elsewhere)
faMesh aMesh(mesh)
scalar h0
Read the control parameters used by setDeltaT.
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:49
zeroField Sp
Definition: alphaSuSp.H:2
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:80