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