interPhaseChangeDyMFoam.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  interPhaseChangeDyMFoam
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 "setRootCase.H"
62  #include "createTime.H"
63  #include "createDynamicFvMesh.H"
64  #include "createControl.H"
65  #include "createTimeControls.H"
66  #include "../interFoam/interDyMFoam/createDyMControls.H"
67  #include "initContinuityErrs.H"
68  #include "createFields.H"
69  #include "createFvOptions.H"
70 
72  (
73  IOobject
74  (
75  "rAU",
76  runTime.timeName(),
77  mesh,
78  IOobject::READ_IF_PRESENT,
79  IOobject::AUTO_WRITE
80  ),
81  mesh,
82  dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
83  );
84 
85  #include "createUf.H"
86  #include "CourantNo.H"
87  #include "setInitialDeltaT.H"
88 
89  turbulence->validate();
90 
91  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93  Info<< "\nStarting time loop\n" << endl;
94 
95  while (runTime.run())
96  {
97  #include "../interFoam/interDyMFoam/readControls.H"
98 
99  // Store divU from the previous mesh so that it can be mapped
100  // and used in correctPhi to ensure the corrected phi has the
101  // same divergence
103 
104  #include "CourantNo.H"
105  #include "setDeltaT.H"
106 
107  runTime++;
108 
109  Info<< "Time = " << runTime.timeName() << nl << endl;
110 
111  // --- Pressure-velocity PIMPLE corrector loop
112  while (pimple.loop())
113  {
114  if (pimple.firstIter() || moveMeshOuterCorrectors)
115  {
116  scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
117 
118  mesh.update();
119 
120  if (mesh.changing())
121  {
122  Info<< "Execution time for mesh.update() = "
123  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
124  << " s" << endl;
125 
126  gh = (g & mesh.C()) - ghRef;
127  ghf = (g & mesh.Cf()) - ghRef;
128  }
129 
130  if (mesh.changing() && correctPhi)
131  {
132  // Calculate absolute flux from the mapped surface velocity
133  phi = mesh.Sf() & Uf;
134 
135  #include "correctPhi.H"
136 
137  // Make the flux relative to the mesh motion
139  }
140 
141  if (mesh.changing() && checkMeshCourantNo)
142  {
143  #include "meshCourantNo.H"
144  }
145  }
146 
147  #include "alphaControls.H"
148 
150  (
151  IOobject
152  (
153  "rhoPhi",
154  runTime.timeName(),
155  mesh
156  ),
157  mesh,
159  );
160 
161  mixture->correct();
162 
163  #include "alphaEqnSubCycle.H"
164  interface.correct();
165 
166  #include "UEqn.H"
167 
168  // --- Pressure corrector loop
169  while (pimple.correct())
170  {
171  #include "pEqn.H"
172  }
173 
174  if (pimple.turbCorr())
175  {
176  turbulence->correct();
177  }
178  }
179 
180  runTime.write();
181 
182  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
183  << " ClockTime = " << runTime.elapsedClockTime() << " s"
184  << nl << endl;
185  }
186 
187  Info<< "End\n" << endl;
188 
189  return 0;
190 }
191 
192 
193 // ************************************************************************* //
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
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
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
moveMeshOuterCorrectors
Definition: readControls.H:8
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
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
rhoPhi
Definition: rhoEqn.H:10
const volScalarField & gh
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
messageStream Info
volScalarField divU(fvc::div(fvc::absolute(phi, U)))
checkMeshCourantNo
Definition: readControls.H:5
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
correctPhi
Definition: readControls.H:3
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Execute application functionObjects to post-process existing results.
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:75
Read the control parameters used by setDeltaT.
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
volScalarField rAU(1.0/UEqn.A())