All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interPhaseChangeFoam.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-2020 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  interPhaseChangeFoam
26 
27 Description
28  Solver for 2 incompressible, isothermal immiscible fluids with phase-change
29  (e.g. cavitation). Uses a VOF (volume of fluid) phase-fraction based
30  interface capturing approach, with optional mesh motion and mesh topology
31  changes including adaptive re-meshing.
32 
33  The momentum and other fluid properties are of the "mixture" and a
34  single momentum equation is solved.
35 
36  The set of phase-change models provided are designed to simulate cavitation
37  but other mechanisms of phase-change are supported within this solver
38  framework.
39 
40  Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #include "fvCFD.H"
45 #include "dynamicFvMesh.H"
46 #include "CMULES.H"
47 #include "subCycle.H"
48 #include "interfaceProperties.H"
51 #include "pimpleControl.H"
52 #include "fvOptions.H"
53 #include "CorrectPhi.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 int main(int argc, char *argv[])
58 {
59  #include "postProcess.H"
60 
61  #include "setRootCaseLists.H"
62  #include "createTime.H"
63  #include "createDynamicFvMesh.H"
64  #include "createDyMControls.H"
65  #include "initContinuityErrs.H"
66  #include "createFields.H"
67  #include "initCorrectPhi.H"
68  #include "createUfIfPresent.H"
69 
70  turbulence->validate();
71 
72  #include "CourantNo.H"
73  #include "setInitialDeltaT.H"
74 
75  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77  Info<< "\nStarting time loop\n" << endl;
78 
79  while (pimple.run(runTime))
80  {
81  #include "readDyMControls.H"
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 "alphaCourantNo.H"
90  #include "setDeltaT.H"
91 
92  runTime++;
93 
94  Info<< "Time = " << runTime.timeName() << nl << endl;
95 
96  // --- Pressure-velocity PIMPLE corrector loop
97  while (pimple.loop())
98  {
99  if (pimple.firstPimpleIter() || moveMeshOuterCorrectors)
100  {
101  mesh.update();
102 
103  if (mesh.changing())
104  {
105  gh = (g & mesh.C()) - ghRef;
106  ghf = (g & mesh.Cf()) - ghRef;
107 
108  if (correctPhi)
109  {
110  // Calculate absolute flux
111  // from the mapped surface velocity
112  phi = mesh.Sf() & Uf();
113 
114  #include "correctPhi.H"
115 
116  // Make the flux relative to the mesh motion
118  }
119 
120  mixture.correct();
121 
122  if (checkMeshCourantNo)
123  {
124  #include "meshCourantNo.H"
125  }
126  }
127  }
128 
130 
132  (
133  IOobject
134  (
135  "rhoPhi",
136  runTime.timeName(),
137  mesh
138  ),
139  mesh,
141  );
142 
143  #include "alphaControls.H"
144  #include "alphaEqnSubCycle.H"
145 
146  mixture.correct();
147 
148  #include "UEqn.H"
149 
150  // --- Pressure corrector loop
151  while (pimple.correct())
152  {
153  #include "pEqn.H"
154  }
155 
156  if (pimple.turbCorr())
157  {
158  turbulence->correct();
159  }
160  }
161 
162  runTime.write();
163 
164  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
165  << " ClockTime = " << runTime.elapsedClockTime() << " s"
166  << nl << endl;
167  }
168 
169  Info<< "End\n" << endl;
170 
171  return 0;
172 }
173 
174 
175 // ************************************************************************* //
pimpleNoLoopControl & pimple
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
correctPhi
checkMeshCourantNo
phi
Definition: pEqn.H:104
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
dynamicFvMesh & mesh
autoPtr< surfaceVectorField > Uf
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::momentumTransportModel > turbulence(compressible::momentumTransportModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
const surfaceScalarField & ghf
static const char nl
Definition: Ostream.H:260
moveMeshOuterCorrectors
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
U
Definition: pEqn.H:72
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
rhoPhi
Definition: rhoEqn.H:10
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
const volScalarField & gh
messageStream Info
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
zeroField divU
Definition: alphaSuSp.H:3
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
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
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
Creates and initialises the velocity field Uf if required.