DPMDyMFoam.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) 2017-2018 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  DPMDyMFoam
26 
27 Description
28  Transient solver for the coupled transport of a single kinematic particle
29  cloud including the effect of the volume fraction of particles on the
30  continuous phase, with optional mesh motion and mesh topology changes.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #include "fvCFD.H"
35 #include "dynamicFvMesh.H"
38 #include "pimpleControl.H"
39 #include "CorrectPhi.H"
40 
41 #ifdef MPPIC
43  #define basicKinematicTypeCloud basicKinematicMPPICCloud
44 #else
46  #define basicKinematicTypeCloud basicKinematicCollidingCloud
47 #endif
48 
49 int main(int argc, char *argv[])
50 {
51  argList::addOption
52  (
53  "cloudName",
54  "name",
55  "specify alternative cloud name. default is 'kinematicCloud'"
56  );
57 
58  #include "postProcess.H"
59 
60  #include "setRootCaseLists.H"
61  #include "createTime.H"
62  #include "createDynamicFvMesh.H"
63  #include "createDyMControls.H"
64  #include "createFields.H"
65  #include "createUcf.H"
66  #include "initContinuityErrs.H"
67 
68  Info<< "\nStarting time loop\n" << endl;
69 
70  while (runTime.run())
71  {
72  #include "readDyMControls.H"
73  #include "CourantNo.H"
74  #include "setDeltaT.H"
75 
76  runTime++;
77 
78  Info<< "Time = " << runTime.timeName() << nl << endl;
79 
80  // Store the particle positions
81  kinematicCloud.storeGlobalPositions();
82 
83  mesh.update();
84 
85  // Calculate absolute flux from the mapped surface velocity
86  phic = mesh.Sf() & Ucf;
87 
88  if (mesh.changing() && correctPhi)
89  {
90  #include "correctPhic.H"
91  }
92 
93  // Make the flux relative to the mesh motion
94  fvc::makeRelative(phic, Uc);
95 
96  if (mesh.changing() && checkMeshCourantNo)
97  {
98  #include "meshCourantNo.H"
99  }
100 
101  continuousPhaseTransport.correct();
102  muc = rhoc*continuousPhaseTransport.nu();
103 
104  Info<< "Evolving " << kinematicCloud.name() << endl;
105  kinematicCloud.evolve();
106 
107  // Update continuous phase volume fraction field
108  alphac = max(1.0 - kinematicCloud.theta(), alphacMin);
109  alphac.correctBoundaryConditions();
110  alphacf = fvc::interpolate(alphac);
111  alphaPhic = alphacf*phic;
112 
113  fvVectorMatrix cloudSU(kinematicCloud.SU(Uc));
114  volVectorField cloudVolSUSu
115  (
116  IOobject
117  (
118  "cloudVolSUSu",
119  runTime.timeName(),
120  mesh
121  ),
122  mesh,
124  (
125  "0",
126  cloudSU.dimensions()/dimVolume,
127  Zero
128  ),
129  zeroGradientFvPatchVectorField::typeName
130  );
131 
132  cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
133  cloudVolSUSu.correctBoundaryConditions();
134  cloudSU.source() = Zero;
135 
136  // --- Pressure-velocity PIMPLE corrector loop
137  while (pimple.loop())
138  {
139  #include "UcEqn.H"
140 
141  // --- PISO loop
142  while (pimple.correct())
143  {
144  #include "pEqn.H"
145  }
146 
147  if (pimple.turbCorr())
148  {
149  continuousPhaseTurbulence->correct();
150  }
151  }
152 
153  runTime.write();
154 
155  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
156  << " ClockTime = " << runTime.elapsedClockTime() << " s"
157  << nl << endl;
158  }
159 
160  Info<< "End\n" << endl;
161 
162  return 0;
163 }
164 
165 
166 // ************************************************************************* //
pimpleNoLoopControl & pimple
Creates and initialises the velocity velocity field Ucf.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Info<< "Reading field U\"<< endl;volVectorField Uc(IOobject(IOobject::groupName("U", continuousPhaseName), runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field p\"<< endl;volScalarField p(IOobject("p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading/calculating continuous-phase face flux field phic\"<< endl;surfaceScalarField phic(IOobject(IOobject::groupName("phi", continuousPhaseName), runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), linearInterpolate(Uc) &mesh.Sf());label pRefCell=0;scalar pRefValue=0.0;setRefCell(p, pimple.dict(), pRefCell, pRefValue);mesh.setFluxRequired(p.name());Info<< "Creating turbulence model\"<< endl;singlePhaseTransportModel continuousPhaseTransport(Uc, phic);dimensionedScalar rhocValue(IOobject::groupName("rho", continuousPhaseName), dimDensity, continuousPhaseTransport.lookup(IOobject::groupName("rho", continuousPhaseName)));volScalarField rhoc(IOobject(rhocValue.name(), runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, rhocValue);volScalarField muc(IOobject(IOobject::groupName("mu", continuousPhaseName), runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), rhoc *continuousPhaseTransport.nu());Info<< "Creating field alphac\"<< endl;volScalarField alphac(IOobject(IOobject::groupName("alpha", continuousPhaseName), runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), mesh, dimensionedScalar("0", dimless, 0));word kinematicCloudName("kinematicCloud");args.optionReadIfPresent("cloudName", kinematicCloudName);Info<< "Constructing kinematicCloud "<< kinematicCloudName<< endl;basicKinematicTypeCloud kinematicCloud(kinematicCloudName, rhoc, Uc, muc, g);scalar alphacMin(1.0 - readScalar(kinematicCloud.particleProperties().subDict("constantProperties") .lookup("alphaMax")));alphac=max(1.0 - kinematicCloud.theta(), alphacMin);alphac.correctBoundaryConditions();surfaceScalarField alphacf("alphacf", fvc::interpolate(alphac));surfaceScalarField alphaPhic(IOobject::groupName("alphaPhi", continuousPhaseName), alphacf *phic);autoPtr< PhaseIncompressibleTurbulenceModel< singlePhaseTransportModel > > continuousPhaseTurbulence(PhaseIncompressibleTurbulenceModel< singlePhaseTransportModel >::New(alphac, Uc, alphaPhic, phic, continuousPhaseTransport))
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
correctPhi
checkMeshCourantNo
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
dynamicFvMesh & mesh
static const zero Zero
Definition: zero.H:97
static const char nl
Definition: Ostream.H:265
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Calculates and outputs the mean and maximum Courant Numbers.
surfaceScalarField phic(mixture.cAlpha() *mag(phi/mesh.magSf()))
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
messageStream Info
Execute application functionObjects to post-process existing results.
void makeRelative(surfaceScalarField &phi, const volVectorField &U)
Make the given flux relative.
Definition: fvcMeshPhi.C:75