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-2016 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"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 int main(int argc, char *argv[])
54 {
55  #include "postProcess.H"
56 
57  #include "setRootCase.H"
58  #include "createTime.H"
59  #include "createDynamicFvMesh.H"
60  #include "initContinuityErrs.H"
61  #include "createControl.H"
62  #include "createFields.H"
63  #include "createUf.H"
64  #include "createControls.H"
65  #include "CourantNo.H"
66  #include "setInitialDeltaT.H"
67 
68  volScalarField& p = mixture.p();
69  volScalarField& T = mixture.T();
70  const volScalarField& psi1 = mixture.thermo1().psi();
71  const volScalarField& psi2 = mixture.thermo2().psi();
72 
73  turbulence->validate();
74 
75  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76  Info<< "\nStarting time loop\n" << endl;
77 
78  while (runTime.run())
79  {
80  #include "readControls.H"
81 
82  {
83  // Store divU from the previous mesh so that it can be mapped
84  // and used in correctPhi to ensure the corrected phi has the
85  // same divergence
87 
88  #include "CourantNo.H"
89  #include "setDeltaT.H"
90 
91  runTime++;
92 
93  Info<< "Time = " << runTime.timeName() << nl << endl;
94 
95  scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
96 
97  // Do any mesh changes
98  mesh.update();
99 
100  if (mesh.changing())
101  {
102  Info<< "Execution time for mesh.update() = "
103  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
104  << " s" << endl;
105 
106  gh = (g & mesh.C()) - ghRef;
107  ghf = (g & mesh.Cf()) - ghRef;
108  }
109 
110  if (mesh.changing() && correctPhi)
111  {
112  // Calculate absolute flux from the mapped surface velocity
113  phi = mesh.Sf() & Uf;
114 
115  #include "correctPhi.H"
116 
117  // Make the fluxes relative to the mesh motion
119  }
120  }
121 
122  if (mesh.changing() && checkMeshCourantNo)
123  {
124  #include "meshCourantNo.H"
125  }
126 
127  turbulence->correct();
128 
129  // --- Pressure-velocity PIMPLE corrector loop
130  while (pimple.loop())
131  {
132  #include "alphaEqnsSubCycle.H"
133 
134  // correct interface on first PIMPLE corrector
135  if (pimple.corr() == 1)
136  {
137  interface.correct();
138  }
139 
141 
142  #include "UEqn.H"
143  #include "TEqn.H"
144 
145  // --- Pressure corrector loop
146  while (pimple.correct())
147  {
148  #include "pEqn.H"
149  }
150  }
151 
152  rho = alpha1*rho1 + alpha2*rho2;
153 
154  // Correct p_rgh for consistency with p and the updated densities
155  p_rgh = p - rho*gh;
156  p_rgh.correctBoundaryConditions();
157 
158  runTime.write();
159 
160  Info<< "ExecutionTime = "
161  << runTime.elapsedCpuTime()
162  << " s\n\n" << endl;
163  }
164 
165  Info<< "End\n" << endl;
166 
167  return 0;
168 }
169 
170 
171 // ************************************************************************* //
autoPtr< compressible::turbulenceModel > turbulence
Definition: createFields.H:23
surfaceScalarField & phi
U
Definition: pEqn.H:83
interfaceProperties interface(alpha1, U, mixture())
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
const dictionary & pimple
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Uf
Definition: pEqn.H:67
rho1
Definition: pEqn.H:114
const surfaceScalarField & ghf
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dynamicFvMesh & mesh
rho2
Definition: pEqn.H:115
rhoEqn solve()
Creates and initialises the velocity velocity field Uf.
alpha2
Definition: alphaEqn.H:112
static const char nl
Definition: Ostream.H:262
const dimensionedVector & g
Info<< "Reading field p_rgh\n"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Creating phaseChangeTwoPhaseMixture\n"<< endl;autoPtr< phaseChangeTwoPhaseMixture > mixture
Definition: createFields.H:33
volScalarField & alpha1
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:188
rhoPhi
Definition: rhoEqn.H:10
const volScalarField & gh
messageStream Info
volScalarField divU(fvc::div(fvc::absolute(phi, U)))
MULES: Multidimensional universal limiter for explicit solution.
checkMeshCourantNo
Definition: readControls.H:5
correctPhi
Definition: readControls.H:3
Execute application functionObjects to post-process existing results.
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:75
volScalarField & p_rgh