interIsoFoam.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  Copyright (C) 2016 DHI
10  Copyright (C) 2017 OpenCFD Ltd.
11  Copyright (C) 2018 Johan Roenby
12  Copyright (C) 2019-2020 DLR
13  Copyright (C) 2020 OpenCFD Ltd.
14 -------------------------------------------------------------------------------
15 License
16  This file is part of OpenFOAM.
17 
18  OpenFOAM is free software: you can redistribute it and/or modify it
19  under the terms of the GNU General Public License as published by
20  the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
24  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26  for more details.
27 
28  You should have received a copy of the GNU General Public License
29  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
30 
31 Application
32  interIsoFoam
33 
34 Group
35  grpMultiphaseSolvers
36 
37 Description
38  Solver derived from interFoam for two incompressible, isothermal immiscible
39  fluids using the isoAdvector phase-fraction based interface capturing
40  approach, with optional mesh motion and mesh topology changes including
41  adaptive re-meshing.
42 
43  Reference:
44  \verbatim
45  Roenby, J., Bredmose, H. and Jasak, H. (2016).
46  A computational method for sharp interface advection
47  Royal Society Open Science, 3
48  doi 10.1098/rsos.160405
49  \endverbatim
50 
51  isoAdvector code supplied by Johan Roenby, STROMNING (2018)
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #include "fvCFD.H"
56 #include "dynamicFvMesh.H"
57 #include "isoAdvection.H"
58 #include "EulerDdtScheme.H"
59 #include "localEulerDdtScheme.H"
60 #include "CrankNicolsonDdtScheme.H"
61 #include "subCycle.H"
64 #include "pimpleControl.H"
65 #include "fvOptions.H"
66 #include "CorrectPhi.H"
67 #include "fvcSmooth.H"
68 #include "dynamicRefineFvMesh.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 int main(int argc, char *argv[])
73 {
74  argList::addNote
75  (
76  "Solver for two incompressible, isothermal immiscible fluids"
77  " using isoAdvector phase-fraction based interface capturing.\n"
78  "With optional mesh motion and mesh topology changes including"
79  " adaptive re-meshing.\n"
80  "The solver is derived from interFoam"
81  );
82 
83  #include "postProcess.H"
84 
85  #include "addCheckCaseOptions.H"
86  #include "setRootCaseLists.H"
87  #include "createTime.H"
88  #include "createDynamicFvMesh.H"
89  #include "initContinuityErrs.H"
90  #include "createDyMControls.H"
91  #include "createFields.H"
92  #include "initCorrectPhi.H"
93  #include "createUfIfPresent.H"
94 
95  #include "porousCourantNo.H"
96  #include "setInitialDeltaT.H"
97 
98  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99  Info<< "\nStarting time loop\n" << endl;
100 
101  while (runTime.run())
102  {
103  #include "readDyMControls.H"
104  #include "porousCourantNo.H"
105  #include "porousAlphaCourantNo.H"
106  #include "setDeltaT.H"
107 
108  ++runTime;
109 
110  Info<< "Time = " << runTime.timeName() << nl << endl;
111 
112  // --- Pressure-velocity PIMPLE corrector loop
113  while (pimple.loop())
114  {
115  if (pimple.firstIter() || moveMeshOuterCorrectors)
116  {
117  if (isA<dynamicRefineFvMesh>(mesh))
118  {
119  advector.surf().reconstruct();
120  }
121 
122  mesh.update();
123 
124  if (mesh.changing())
125  {
126  gh = (g & mesh.C()) - ghRef;
127  ghf = (g & mesh.Cf()) - ghRef;
128 
129  if (isA<dynamicRefineFvMesh>(mesh))
130  {
131  advector.surf().mapAlphaField();
132  alpha2 = 1.0 - alpha1;
133  alpha2.correctBoundaryConditions();
134  rho == alpha1*rho1 + alpha2*rho2;
135  rho.correctBoundaryConditions();
136  rho.oldTime() = rho;
137  alpha2.oldTime() = alpha2;
138  }
139 
140  MRF.update();
141 
142  if (correctPhi)
143  {
144  // Calculate absolute flux
145  // from the mapped surface velocity
146  phi = mesh.Sf() & Uf();
147 
148  #include "correctPhi.H"
149 
150  // Make the flux relative to the mesh motion
152 
153  mixture.correct();
154  }
155 
156  if (checkMeshCourantNo)
157  {
158  #include "meshCourantNo.H"
159  }
160  }
161  }
162 
163  #include "alphaControls.H"
164  #include "alphaEqnSubCycle.H"
165 
166  mixture.correct();
167 
168  if (pimple.frozenFlow())
169  {
170  continue;
171  }
172 
173  #include "UEqn.H"
174 
175  // --- Pressure corrector loop
176  while (pimple.correct())
177  {
178  #include "pEqn.H"
179  }
180 
181  if (pimple.turbCorr())
182  {
183  turbulence->correct();
184  }
185  }
186 
187  runTime.write();
188 
189  runTime.printExecutionTime(Info);
190  }
191 
192  Info<< "End\n" << endl;
193 
194  return 0;
195 }
196 
197 
198 // ************************************************************************* //
Calculates and outputs the mean and maximum Courant Numbers.
isoAdvection advector(alpha1, phi, U)
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
volScalarField & rho1
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\"<< endl;autoPtr< temperaturePhaseChangeTwoPhaseMixture > mixture
Definition: createFields.H:39
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
correctPhi
const volScalarField & alpha2
checkMeshCourantNo
const surfaceScalarField & ghf
dynamicFvMesh & mesh
IOMRFZoneList & MRF
Calculates and outputs the mean and maximum Courant Numbers.
autoPtr< surfaceVectorField > Uf
const uniformDimensionedVectorField & g
pimpleControl & pimple
Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar("pos", dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar("neg", dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
volScalarField & rho2
moveMeshOuterCorrectors
Calculates and outputs the mean and maximum Courant Numbers.
U
Definition: pEqn.H:72
const volScalarField & gh
messageStream Info
Information stream (stdout output on master, null elsewhere)
Execute application functionObjects to post-process existing results.
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:70
Required Classes.
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...
Creates and initialises the velocity field Uf if required.
const volScalarField & alpha1