interMixingFoam.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-2019 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  interMixingFoam
26 
27 Description
28  Solver for 3 incompressible fluids, two of which are miscible, using a VOF
29  method to capture the interface, with optional mesh motion and mesh topology
30  changes including adaptive re-meshing.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #include "fvCFD.H"
35 #include "dynamicFvMesh.H"
36 #include "CMULES.H"
37 #include "localEulerDdtScheme.H"
38 #include "subCycle.H"
41 #include "pimpleControl.H"
42 #include "fvOptions.H"
43 #include "CorrectPhi.H"
44 #include "fvcSmooth.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
50  #include "postProcess.H"
51 
52  #include "setRootCaseLists.H"
53  #include "createTime.H"
54  #include "createDynamicFvMesh.H"
55  #include "initContinuityErrs.H"
56  #include "createDyMControls.H"
57  #include "createFields.H"
58  #include "initCorrectPhi.H"
59  #include "createUfIfPresent.H"
60 
61  turbulence->validate();
62 
63  if (!LTS)
64  {
65  #include "readTimeControls.H"
66  #include "CourantNo.H"
67  #include "setInitialDeltaT.H"
68  }
69 
70  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72  Info<< "\nStarting time loop\n" << endl;
73 
74  while (runTime.run())
75  {
76  #include "readDyMControls.H"
77 
78  if (LTS)
79  {
80  #include "setRDeltaT.H"
81  }
82  else
83  {
84  #include "CourantNo.H"
85  #include "alphaCourantNo.H"
86  #include "setDeltaT.H"
87  }
88 
89  runTime++;
90 
91  Info<< "Time = " << runTime.timeName() << nl << endl;
92 
93  // --- Pressure-velocity PIMPLE corrector loop
94  while (pimple.loop())
95  {
96  if (pimple.firstPimpleIter() || moveMeshOuterCorrectors)
97  {
98  mesh.update();
99 
100  if (mesh.changing())
101  {
102  gh = (g & mesh.C()) - ghRef;
103  ghf = (g & mesh.Cf()) - ghRef;
104 
105  MRF.update();
106 
107  if (correctPhi)
108  {
109  // Calculate absolute flux
110  // from the mapped surface velocity
111  phi = mesh.Sf() & Uf();
112 
113  #include "correctPhi.H"
114 
115  // Make the flux relative to the mesh motion
117 
118  mixture.correct();
119  }
120 
121  if (checkMeshCourantNo)
122  {
123  #include "meshCourantNo.H"
124  }
125  }
126  }
127 
128  #include "alphaControls.H"
129  #include "alphaEqnSubCycle.H"
130 
131  mixture.correct();
132 
133  #include "UEqn.H"
134 
135  // --- Pressure corrector loop
136  while (pimple.correct())
137  {
138  #include "pEqn.H"
139  }
140 
141  if (pimple.turbCorr())
142  {
143  turbulence->correct();
144  }
145  }
146 
147  #include "continuityErrs.H"
148 
149  runTime.write();
150 
151  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
152  << " ClockTime = " << runTime.elapsedClockTime() << " s"
153  << nl << endl;
154  }
155 
156  Info<< "End\n" << endl;
157 
158  return 0;
159 }
160 
161 
162 // ************************************************************************* //
pimpleNoLoopControl & pimple
surfaceScalarField & phi
IOMRFZoneList & MRF
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
Read the control parameters used by setDeltaT.
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::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
correctPhi
checkMeshCourantNo
dynamicFvMesh & mesh
autoPtr< surfaceVectorField > Uf
const surfaceScalarField & ghf
static const char nl
Definition: Ostream.H:265
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.