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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
faCFD.H
Foam::faVectorMatrix
faMatrix< vector > faVectorMatrix
Definition: faMatrices.H:53
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
h0
scalar h0
Definition: readInitialConditions.H:78
H
volScalarField H(IOobject("H", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimensionedScalar(dimLength, Zero))
Sp
zeroField Sp
Definition: alphaSuSp.H:2
Foam::fac::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:56
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
faScalarMatrix
Template specialisation for scalar faMatrix.
rhol
dimensionedScalar rhol("rhol", dimDensity, transportProperties)
Foam::fac::div
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
solve
CEqn solve()
vsm
volSurfaceMapping vsm(aMesh)
aMesh
faMesh aMesh(mesh)
setRootCaseLists.H
Foam::fac::average
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
Definition: facAverage.C:47
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
readSolutionControls.H
Foam::fac::lnGrad
tmp< GeometricField< Type, faePatchField, edgeMesh > > lnGrad(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLnGrad.C:47
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
calcFrictionFactor.H
iters
loopControl iters(runTime, aMesh.solutionDict(), "solution")
Foam::areaScalarField
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:53
capillaryCourantNo.H
U
U
Definition: pEqn.H:72
Foam::nl
constexpr char nl
Definition: Ostream.H:404
loopControl.H
createTimeControls.H
Read the control parameters used by setDeltaT.
readTimeControls.H
Read the control parameters used by setDeltaT.
Us
Us
Definition: createFaFields.H:51
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fac::ddt
tmp< GeometricField< Type, faPatchField, areaMesh > > ddt(const dimensioned< Type > dt, const faMesh &mesh)
Definition: facDdt.C:47
createMesh.H
Required Variables.
createTime.H
fvCFD.H
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Foam::fac::laplacian
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:47
Foam::fac::interpolate
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.
phis
edgeScalarField phis(IOobject("phis", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), linearEdgeInterpolate(Us) &aMesh.Le())
createFvFields.H
surfaceCourantNo.H
Calculates and outputs the mean and maximum Courant Numbers for the Finite Area method.
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177