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  if (correctPhi)
101  {
102  #include "correctPhi.H"
103  }
104  #include "createUf.H"
105 
106  #include "setCellMask.H"
107  #include "setInterpolatedCells.H"
108 
109  turbulence->validate();
110 
111  if (!LTS)
112  {
113  #include "CourantNo.H"
114  #include "setInitialDeltaT.H"
115  }
116 
117  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118  Info<< "\nStarting time loop\n" << endl;
119 
120  while (runTime.run())
121  {
122  #include "readControls.H"
123 
124  if (LTS)
125  {
126  #include "setRDeltaT.H"
127  }
128  else
129  {
130  #include "CourantNo.H"
131  #include "alphaCourantNo.H"
132  #include "setDeltaT.H"
133  }
134 
135  ++runTime;
136 
137  Info<< "Time = " << runTime.timeName() << nl << endl;
138 
139  // --- Pressure-velocity PIMPLE corrector loop
140  while (pimple.loop())
141  {
142  if (pimple.firstIter() || moveMeshOuterCorrectors)
143  {
144  scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
145 
146  mesh.update();
147 
148  if (mesh.changing())
149  {
150  Info<< "Execution time for mesh.update() = "
151  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
152  << " s" << endl;
153 
154  // Do not apply previous time-step mesh compression flux
155  // if the mesh topology changed
156  if (mesh.topoChanging())
157  {
158  talphaPhi1Corr0.clear();
159  }
160 
161  gh = (g & mesh.C()) - ghRef;
162  ghf = (g & mesh.Cf()) - ghRef;
163 
164  // Update cellMask field for blocking out hole cells
165  #include "setCellMask.H"
166  #include "setInterpolatedCells.H"
167 
168  const surfaceScalarField faceMaskOld
169  (
170  localMin<scalar>(mesh).interpolate(cellMask.oldTime())
171  );
172 
173  // Zero Uf on old faceMask (H-I)
174  Uf *= faceMaskOld;
175 
177  // Update Uf and phi on new C-I faces
178  Uf += (1-faceMaskOld)*Uint;
179 
180  // Update Uf boundary
181  forAll(Uf.boundaryField(), patchI)
182  {
183  Uf.boundaryFieldRef()[patchI] =
184  Uint.boundaryField()[patchI];
185  }
186 
187  phi = mesh.Sf() & Uf;
188 
189  // Correct phi on individual regions
190  if (correctPhi)
191  {
192  #include "correctPhi.H"
193  }
194 
195  mixture.correct();
196 
197  // Zero phi on current H-I
199  (
200  localMin<scalar>(mesh).interpolate(cellMask)
201  );
202  phi *= faceMask;
203  U *= cellMask;
204 
205  // Make the flux relative to the mesh motion
207 
208  }
209 
210  if (mesh.changing() && checkMeshCourantNo)
211  {
212  #include "meshCourantNo.H"
213  }
214  }
215 
216 
217  #include "alphaControls.H"
218  #include "alphaEqnSubCycle.H"
219 
221  (
222  localMin<scalar>(mesh).interpolate(cellMask)
223  );
224  rhoPhi *= faceMask;
225 
226  mixture.correct();
227 
228  #include "UEqn.H"
229 
230  // --- Pressure corrector loop
231  while (pimple.correct())
232  {
233  #include "pEqn.H"
234  }
235 
236  if (pimple.turbCorr())
237  {
238  turbulence->correct();
239  }
240  }
241 
242  runTime.write();
243 
244  runTime.printExecutionTime(Info);
245  }
246 
247  Info<< "End\n" << endl;
248 
249  return 0;
250 }
251 
252 
253 // ************************************************************************* //
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:369
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:53
setRootCaseLists.H
localEulerDdtScheme.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
EulerDdtScheme.H
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
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:26
U
U
Definition: pEqn.H:72
localMin.H
Foam::nl
constexpr char nl
Definition: Ostream.H:404
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:59
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...