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-2017 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 "CMULES.H"
43 #include "EulerDdtScheme.H"
44 #include "localEulerDdtScheme.H"
45 #include "CrankNicolsonDdtScheme.H"
46 #include "subCycle.H"
47 #include "twoPhaseMixture.H"
48 #include "twoPhaseMixtureThermo.H"
50 #include "pimpleControl.H"
51 #include "fvOptions.H"
52 #include "CorrectPhi.H"
53 #include "fvcSmooth.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 int main(int argc, char *argv[])
58 {
59  #include "postProcess.H"
60 
61  #include "setRootCase.H"
62  #include "createTime.H"
63  #include "createDynamicFvMesh.H"
64  #include "initContinuityErrs.H"
65  #include "createControl.H"
66  #include "createFields.H"
67  #include "createAlphaFluxes.H"
68  #include "createFvOptions.H"
69  #include "createUf.H"
70  #include "createControls.H"
71  #include "CourantNo.H"
72  #include "setInitialDeltaT.H"
73 
74  volScalarField& p = mixture.p();
75  volScalarField& T = mixture.T();
76  const volScalarField& psi1 = mixture.thermo1().psi();
77  const volScalarField& psi2 = mixture.thermo2().psi();
78 
79  turbulence->validate();
80 
81  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82  Info<< "\nStarting time loop\n" << endl;
83 
84  while (runTime.run())
85  {
86  #include "readControls.H"
87 
88  // Store divU from the previous mesh so that it can be mapped
89  // and used in correctPhi to ensure the corrected phi has the
90  // same divergence
92 
93  if (LTS)
94  {
95  #include "setRDeltaT.H"
96  }
97  else
98  {
99  #include "CourantNo.H"
100  #include "alphaCourantNo.H"
101  #include "setDeltaT.H"
102  }
103 
104  runTime++;
105 
106  Info<< "Time = " << runTime.timeName() << nl << endl;
107 
108  // --- Pressure-velocity PIMPLE corrector loop
109  while (pimple.loop())
110  {
111  if (pimple.firstIter() || moveMeshOuterCorrectors)
112  {
113  scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
114 
115  mesh.update();
116 
117  if (mesh.changing())
118  {
119  Info<< "Execution time for mesh.update() = "
120  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
121  << " s" << endl;
122 
123  gh = (g & mesh.C()) - ghRef;
124  ghf = (g & mesh.Cf()) - ghRef;
125  }
126 
127  if (mesh.changing() && correctPhi)
128  {
129  // Calculate absolute flux from the mapped surface velocity
130  phi = mesh.Sf() & Uf;
131 
132  #include "correctPhi.H"
133 
134  // Make the fluxes relative to the mesh motion
136 
137  mixture.correct();
138  }
139 
140  if (mesh.changing() && checkMeshCourantNo)
141  {
142  #include "meshCourantNo.H"
143  }
144  }
145 
146  #include "alphaControls.H"
148 
149  #include "UEqn.H"
150  #include "TEqn.H"
151 
152  // --- Pressure corrector loop
153  while (pimple.correct())
154  {
155  #include "pEqn.H"
156  }
157 
158  if (pimple.turbCorr())
159  {
160  turbulence->correct();
161  }
162  }
163 
164  runTime.write();
165 
166  Info<< "ExecutionTime = "
167  << runTime.elapsedCpuTime()
168  << " s\n\n" << endl;
169  }
170 
171  Info<< "End\n" << endl;
172 
173  return 0;
174 }
175 
176 
177 // ************************************************************************* //
surfaceScalarField & phi
moveMeshOuterCorrectors
Definition: readControls.H:8
U
Definition: pEqn.H:83
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
const surfaceScalarField & ghf
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dynamicFvMesh & mesh
Creates and initialises the velocity velocity field Uf.
static const char nl
Definition: Ostream.H:262
const dimensionedVector & g
bool LTS
Definition: createRDeltaT.H:1
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("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\"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
Info<< "Reading field p_rgh\"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Creating phaseChangeTwoPhaseMixture\"<< endl;autoPtr< phaseChangeTwoPhaseMixture > mixture
Definition: createFields.H:33
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
const volScalarField & gh
messageStream Info
checkMeshCourantNo
Definition: readControls.H:5
zeroField divU
Definition: alphaSuSp.H:3
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
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.