overInterDyMFoam.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2014 OpenFOAM Foundation
9  Copyright (C) 2016-2017 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  overInterDyMFoam
29 
30 Group
31  grpMultiphaseSolvers grpMovingMeshSolvers
32 
33 Description
34  Solver for two incompressible, isothermal immiscible fluids using a VOF
35  (volume of fluid) phase-fraction based interface capturing approach,
36  with optional mesh motion and mesh topology changes including adaptive
37  re-meshing.
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #include "fvCFD.H"
42 #include "dynamicFvMesh.H"
43 #include "CMULES.H"
44 #include "EulerDdtScheme.H"
45 #include "localEulerDdtScheme.H"
46 #include "CrankNicolsonDdtScheme.H"
47 #include "subCycle.H"
50 #include "pimpleControl.H"
51 #include "fvOptions.H"
52 #include "CorrectPhi.H"
53 #include "fvcSmooth.H"
54 #include "cellCellStencilObject.H"
55 #include "localMin.H"
56 #include "interpolationCellPoint.H"
57 #include "transform.H"
58 #include "fvMeshSubset.H"
59 #include "oversetAdjustPhi.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 int main(int argc, char *argv[])
64 {
65  argList::addNote
66  (
67  "Solver for two incompressible, isothermal immiscible fluids using"
68  " VOF phase-fraction based interface capturing\n"
69  "With optional mesh motion and mesh topology changes including"
70  " adaptive re-meshing."
71  );
72 
73  #include "postProcess.H"
74 
75  #include "setRootCaseLists.H"
76  #include "createTime.H"
77  #include "createDynamicFvMesh.H"
78  #include "initContinuityErrs.H"
79  pimpleControl pimple(mesh);
80  #include "createTimeControls.H"
81  #include "createDyMControls.H"
82  #include "createFields.H"
83  #include "createAlphaFluxes.H"
84  #include "createFvOptions.H"
85 
87  (
88  IOobject
89  (
90  "rAU",
91  runTime.timeName(),
92  mesh,
93  IOobject::READ_IF_PRESENT,
94  IOobject::AUTO_WRITE
95  ),
96  mesh,
97  dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
98  );
99 
100  #include "correctPhi.H"
101  #include "createUf.H"
102 
103  turbulence->validate();
104 
105  if (!LTS)
106  {
107  #include "CourantNo.H"
108  #include "setInitialDeltaT.H"
109  }
110 
111  #include "setCellMask.H"
112  #include "setInterpolatedCells.H"
113 
114  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115  Info<< "\nStarting time loop\n" << endl;
116 
117  while (runTime.run())
118  {
119  #include "readControls.H"
120 
121  if (LTS)
122  {
123  #include "setRDeltaT.H"
124  }
125  else
126  {
127  #include "CourantNo.H"
128  #include "alphaCourantNo.H"
129  #include "setDeltaT.H"
130  }
131 
132  ++runTime;
133 
134  Info<< "Time = " << runTime.timeName() << nl << endl;
135 
136  // --- Pressure-velocity PIMPLE corrector loop
137  while (pimple.loop())
138  {
139  if (pimple.firstIter() || moveMeshOuterCorrectors)
140  {
141  scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
142 
143  mesh.update();
144 
145  if (mesh.changing())
146  {
147  Info<< "Execution time for mesh.update() = "
148  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
149  << " s" << endl;
150 
151  // Do not apply previous time-step mesh compression flux
152  // if the mesh topology changed
153  if (mesh.topoChanging())
154  {
155  talphaPhi1Corr0.clear();
156  }
157 
158  gh = (g & mesh.C()) - ghRef;
159  ghf = (g & mesh.Cf()) - ghRef;
160 
161  // Update cellMask field for blocking out hole cells
162  #include "setCellMask.H"
163  #include "setInterpolatedCells.H"
164 
165  const surfaceScalarField faceMaskOld
166  (
167  localMin<scalar>(mesh).interpolate(cellMask.oldTime())
168  );
169 
170  // Zero Uf on old faceMask (H-I)
171  Uf *= faceMaskOld;
172 
174  // Update Uf and phi on new C-I faces
175  Uf += (1-faceMaskOld)*Uint;
176 
177  // Update Uf boundary
178  forAll(Uf.boundaryField(), patchI)
179  {
180  Uf.boundaryFieldRef()[patchI] =
181  Uint.boundaryField()[patchI];
182  }
183 
184  phi = mesh.Sf() & Uf;
185 
186  // Correct phi on individual regions
187  if (correctPhi)
188  {
189  #include "correctPhi.H"
190  }
191 
192  mixture.correct();
193 
194  // Zero phi on current H-I
196  (
197  localMin<scalar>(mesh).interpolate(cellMask)
198  );
199  phi *= faceMask;
200  U *= cellMask;
201 
202  // Make the flux relative to the mesh motion
204 
205  }
206 
207  if (mesh.changing() && checkMeshCourantNo)
208  {
209  #include "meshCourantNo.H"
210  }
211  }
212 
213 
214  #include "alphaControls.H"
215  #include "alphaEqnSubCycle.H"
216 
218  (
219  localMin<scalar>(mesh).interpolate(cellMask)
220  );
221  rhoPhi *= faceMask;
222 
223  mixture.correct();
224 
225  #include "UEqn.H"
226 
227  // --- Pressure corrector loop
228  while (pimple.correct())
229  {
230  #include "pEqn.H"
231  }
232 
233  if (pimple.turbCorr())
234  {
235  turbulence->correct();
236  }
237  }
238 
239  runTime.write();
240 
241  runTime.printExecutionTime(Info);
242  }
243 
244  Info<< "End\n" << endl;
245 
246  return 0;
247 }
248 
249 
250 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
rhoPhi
rhoPhi
Definition: rhoEqn.H:10
CMULES.H
CMULES: Multidimensional universal limiter for explicit corrected implicit solution.
ghf
const surfaceScalarField & ghf
Definition: setRegionFluidFields.H:18
rAU
tmp< volScalarField > rAU
Definition: initCorrectPhi.H:1
fvOptions.H
turbulence
Info<< "Reading field U\n"<< 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\n"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
fvMeshSubset.H
subCycle.H
turbulentTransportModel.H
Uf
autoPtr< surfaceVectorField > Uf
Definition: createUfIfPresent.H:33
faceMask
surfaceScalarField faceMask(localMin< scalar >(mesh).interpolate(cellMask))
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
createUf.H
Creates and initialises the velocity velocity field Uf.
setCellMask.H
Sets blocked cells mask field.
setInterpolatedCells.H
Sets blocked cells mask field.
correctPhi
correctPhi
Definition: readDyMControls.H:3
gh
const volScalarField & gh
Definition: setRegionFluidFields.H:17
rho
rho
Definition: readInitialConditions.H:88
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
interpolationCellPoint.H
pimpleControl.H
Foam::fvc::makeRelative
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:77
createFvOptions.H
pimple
pimpleControl & pimple
Definition: setRegionFluidFields.H:56
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
setRootCaseLists.H
localEulerDdtScheme.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
EulerDdtScheme.H
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
CrankNicolsonDdtScheme.H
LTS
bool LTS
Definition: createRDeltaT.H:1
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
postProcess.H
Execute application functionObjects to post-process existing results.
g
const uniformDimensionedVectorField & g
Definition: createFluidFields.H:24
U
U
Definition: pEqn.H:72
localMin.H
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
createTimeControls.H
Read the control parameters used by setDeltaT.
createAlphaFluxes.H
meshCourantNo.H
Calculates and outputs the mean and maximum Courant Numbers.
CorrectPhi.H
createTime.H
dynamicFvMesh.H
fvCFD.H
checkMeshCourantNo
checkMeshCourantNo
Definition: readDyMControls.H:9
transform.H
3D tensor transformation operations.
Foam::surfaceVectorField
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Definition: surfaceFieldsFwd.H:57
moveMeshOuterCorrectors
moveMeshOuterCorrectors
Definition: readDyMControls.H:15
cellCellStencilObject.H
mixture
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n"<< endl;autoPtr< temperaturePhaseChangeTwoPhaseMixture > mixture
Definition: createFields.H:39
talphaPhi1Corr0
tmp< surfaceScalarField > talphaPhi1Corr0
Definition: createAlphaFluxes.H:26
immiscibleIncompressibleTwoPhaseMixture.H
oversetAdjustPhi.H
Adjust the balance of fluxes on the faces between interpolated and calculated to obey continuity.
createDynamicFvMesh.H
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
fvcSmooth.H
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...