compressibleInterDyMFoam.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 | Copyright (C) 2011-2015 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  compressibleInterDyMFoam
26 
27 Description
28  Solver for 2 compressible, non-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  The momentum and other fluid properties are of the "mixture" and a single
34  momentum equation is solved.
35 
36  Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #include "fvCFD.H"
41 #include "dynamicFvMesh.H"
42 #include "MULES.H"
43 #include "subCycle.H"
44 #include "interfaceProperties.H"
45 #include "twoPhaseMixture.H"
46 #include "twoPhaseMixtureThermo.H"
48 #include "pimpleControl.H"
49 #include "CorrectPhi.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 int main(int argc, char *argv[])
55 {
56  #include "setRootCase.H"
57  #include "createTime.H"
58  #include "createDynamicFvMesh.H"
59  #include "initContinuityErrs.H"
60 
61  pimpleControl pimple(mesh);
62 
63  #include "createFields.H"
64  #include "createUf.H"
65  #include "createControls.H"
66  #include "CourantNo.H"
67  #include "setInitialDeltaT.H"
68 
69  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70  Info<< "\nStarting time loop\n" << endl;
71 
72  while (runTime.run())
73  {
74  #include "readControls.H"
75 
76  {
77  // Store divU from the previous mesh so that it can be mapped
78  // and used in correctPhi to ensure the corrected phi has the
79  // same divergence
81 
82  #include "CourantNo.H"
83  #include "setDeltaT.H"
84 
85  runTime++;
86 
87  Info<< "Time = " << runTime.timeName() << nl << endl;
88 
89  scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
90 
91  // Do any mesh changes
92  mesh.update();
93 
94  if (mesh.changing())
95  {
96  Info<< "Execution time for mesh.update() = "
97  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
98  << " s" << endl;
99 
100  gh = (g & mesh.C()) - ghRef;
101  ghf = (g & mesh.Cf()) - ghRef;
102  }
103 
104  if (mesh.changing() && correctPhi)
105  {
106  // Calculate absolute flux from the mapped surface velocity
107  phi = mesh.Sf() & Uf;
108 
109  #include "correctPhi.H"
110 
111  // Make the fluxes relative to the mesh motion
113  }
114  }
115 
116  if (mesh.changing() && checkMeshCourantNo)
117  {
118  #include "meshCourantNo.H"
119  }
120 
121  turbulence->correct();
122 
123  // --- Pressure-velocity PIMPLE corrector loop
124  while (pimple.loop())
125  {
126  #include "alphaEqnsSubCycle.H"
127 
128  // correct interface on first PIMPLE corrector
129  if (pimple.corr() == 1)
130  {
131  interface.correct();
132  }
133 
135 
136  #include "UEqn.H"
137  #include "TEqn.H"
138 
139  // --- Pressure corrector loop
140  while (pimple.correct())
141  {
142  #include "pEqn.H"
143  }
144  }
145 
146  rho = alpha1*rho1 + alpha2*rho2;
147 
148  runTime.write();
149 
150  Info<< "ExecutionTime = "
151  << runTime.elapsedCpuTime()
152  << " s\n\n" << endl;
153  }
154 
155  Info<< "End\n" << endl;
156 
157  return 0;
158 }
159 
160 
161 // ************************************************************************* //
Calculates and outputs the mean and maximum Courant Numbers.
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:187
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
const dictionary & pimple
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
volScalarField divU(fvc::div(fvc::absolute(phi, U)))
int main(int argc, char *argv[])
Definition: postCalc.C:54
static const char nl
Definition: Ostream.H:260
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:74
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
interfaceProperties interface(alpha1, U, mixture())
rho2
Definition: pEqn.H:125
U
Definition: pEqn.H:82
volScalarField & alpha1
Definition: createFields.H:15
messageStream Info
const dimensionedVector & g
Uf
Definition: pEqn.H:78
checkMeshCourantNo
Definition: readControls.H:5
alpha2
Definition: alphaEqn.H:112
surfaceScalarField & phi
rhoEqn solve()
dynamicFvMesh & mesh
autoPtr< compressible::turbulenceModel > turbulence
Definition: createFields.H:23
Creates and initialises the velocity velocity field Uf.
const surfaceScalarField & ghf
const volScalarField & gh
rho1
Definition: pEqn.H:124
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
rhoPhi
Definition: rhoEqn.H:10
correctPhi
Definition: readControls.H:3
MULES: Multidimensional universal limiter for explicit solution.