interFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  interFoam
26 
27 Description
28  Solver for 2 incompressible, isothermal immiscible fluids using a VOF
29  (volume of fluid) phase-fraction based interface capturing approach,
30  with optional mesh motion and mesh topology changes including adaptive
31  re-meshing.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #include "fvCFD.H"
36 #include "dynamicFvMesh.H"
37 #include "CMULES.H"
38 #include "EulerDdtScheme.H"
39 #include "localEulerDdtScheme.H"
40 #include "CrankNicolsonDdtScheme.H"
41 #include "subCycle.H"
44 #include "pimpleControl.H"
45 #include "fvOptions.H"
46 #include "CorrectPhi.H"
47 #include "fvcSmooth.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 int main(int argc, char *argv[])
52 {
53  #include "postProcess.H"
54 
55  #include "setRootCaseLists.H"
56  #include "createTime.H"
57  #include "createDynamicFvMesh.H"
58  #include "initContinuityErrs.H"
59  #include "createDyMControls.H"
60  #include "createFields.H"
61  #include "createAlphaFluxes.H"
62  #include "initCorrectPhi.H"
63  #include "createUfIfPresent.H"
64 
65  turbulence->validate();
66 
67  if (!LTS)
68  {
69  #include "CourantNo.H"
70  #include "setInitialDeltaT.H"
71  }
72 
73  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74  Info<< "\nStarting time loop\n" << endl;
75 
76  while (pimple.run(runTime))
77  {
78  #include "readDyMControls.H"
79 
80  if (LTS)
81  {
82  #include "setRDeltaT.H"
83  }
84  else
85  {
86  #include "CourantNo.H"
87  #include "alphaCourantNo.H"
88  #include "setDeltaT.H"
89  }
90 
91  runTime++;
92 
93  Info<< "Time = " << runTime.timeName() << nl << endl;
94 
95  // --- Pressure-velocity PIMPLE corrector loop
96  while (pimple.loop())
97  {
98  if (pimple.firstPimpleIter() || moveMeshOuterCorrectors)
99  {
100  mesh.update();
101 
102  if (mesh.changing())
103  {
104  // Do not apply previous time-step mesh compression flux
105  // if the mesh topology changed
106  if (mesh.topoChanging())
107  {
108  talphaPhi1Corr0.clear();
109  }
110 
111  gh = (g & mesh.C()) - ghRef;
112  ghf = (g & mesh.Cf()) - ghRef;
113 
114  MRF.update();
115 
116  if (correctPhi)
117  {
118  // Calculate absolute flux
119  // from the mapped surface velocity
120  phi = mesh.Sf() & Uf();
121 
122  #include "correctPhi.H"
123 
124  // Make the flux relative to the mesh motion
126  }
127 
128  mixture.correct();
129 
130  if (checkMeshCourantNo)
131  {
132  #include "meshCourantNo.H"
133  }
134  }
135  }
136 
137  #include "alphaControls.H"
138  #include "alphaEqnSubCycle.H"
139 
140  mixture.correct();
141 
142  #include "UEqn.H"
143 
144  // --- Pressure corrector loop
145  while (pimple.correct())
146  {
147  #include "pEqn.H"
148  }
149 
150  if (pimple.turbCorr())
151  {
152  turbulence->correct();
153  }
154  }
155 
156  runTime.write();
157 
158  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
159  << " ClockTime = " << runTime.elapsedClockTime() << " s"
160  << nl << endl;
161  }
162 
163  Info<< "End\n" << endl;
164 
165  return 0;
166 }
167 
168 
169 // ************************************************************************* //
pimpleNoLoopControl & pimple
IOMRFZoneList & MRF
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
correctPhi
checkMeshCourantNo
phi
Definition: pEqn.H:104
dynamicFvMesh & mesh
autoPtr< surfaceVectorField > Uf
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(dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::momentumTransportModel > turbulence(compressible::momentumTransportModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
const surfaceScalarField & ghf
static const char nl
Definition: Ostream.H:260
bool LTS
Definition: createRDeltaT.H:1
moveMeshOuterCorrectors
Calculates and outputs the mean and maximum Courant Numbers.
U
Definition: pEqn.H:72
const volScalarField & gh
messageStream Info
phaseChangeTwoPhaseMixture & mixture
Definition: createFields.H:38
const dimensionedVector & g
Execute application functionObjects to post-process existing results.
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:75
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Creates and initialises the velocity field Uf if required.
tmp< surfaceScalarField > talphaPhi1Corr0