DPMFoam.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) 2013-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  DPMFoam
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 #include "fvOptions.H"
41 
42 #ifdef MPPIC
44  #define basicKinematicTypeCloud basicKinematicMPPICCloud
45 #else
47  #define basicKinematicTypeCloud basicKinematicCollidingCloud
48 #endif
49 
50 int main(int argc, char *argv[])
51 {
52  argList::addOption
53  (
54  "cloudName",
55  "name",
56  "specify alternative cloud name. default is 'kinematicCloud'"
57  );
58 
59  #include "postProcess.H"
60 
61  #include "setRootCaseLists.H"
62  #include "createTime.H"
63  #include "createDynamicFvMesh.H"
64  #include "createDyMControls.H"
65  #include "createFields.H"
66  #include "createUcfIfPresent.H"
67  #include "initContinuityErrs.H"
68 
69  Info<< "\nStarting time loop\n" << endl;
70 
71  while (pimple.run(runTime))
72  {
73  #include "readDyMControls.H"
74  #include "CourantNo.H"
75  #include "setDeltaT.H"
76 
77  runTime++;
78 
79  Info<< "Time = " << runTime.timeName() << nl << endl;
80 
81  // Store the particle positions
82  kinematicCloud.storeGlobalPositions();
83 
84  mesh.update();
85 
86  if (mesh.changing())
87  {
88  if (correctPhi)
89  {
90  // Calculate absolute flux from the mapped surface velocity
91  phic = mesh.Sf() & Ucf();
92 
93  #include "correctPhic.H"
94 
95  // Make the flux relative to the mesh motion
96  fvc::makeRelative(phic, Uc);
97  }
98 
100  {
101  #include "meshCourantNo.H"
102  }
103  }
104 
105  continuousPhaseTransport.correct();
106  muc = rhoc*continuousPhaseTransport.nu();
107 
108  Info<< "Evolving " << kinematicCloud.name() << endl;
109  kinematicCloud.evolve();
110 
111  // Update continuous phase volume fraction field
112  alphac = max(1.0 - kinematicCloud.theta(), alphacMin);
113  alphac.correctBoundaryConditions();
114  alphacf = fvc::interpolate(alphac);
115  alphaPhic = alphacf*phic;
116 
117  fvVectorMatrix cloudSU(kinematicCloud.SU(Uc));
118  volVectorField cloudVolSUSu
119  (
120  IOobject
121  (
122  "cloudVolSUSu",
123  runTime.timeName(),
124  mesh
125  ),
126  mesh,
128  (
129  "0",
130  cloudSU.dimensions()/dimVolume,
131  Zero
132  ),
133  zeroGradientFvPatchVectorField::typeName
134  );
135 
136  cloudVolSUSu.primitiveFieldRef() =
137  (cloudSU.diag()*Uc() - cloudSU.source())/mesh.V();
138  cloudVolSUSu.correctBoundaryConditions();
139  cloudSU.source() = cloudSU.diag()*Uc();
140 
141  // --- Pressure-velocity PIMPLE corrector loop
142  while (pimple.loop())
143  {
144  #include "UcEqn.H"
145 
146  // --- PISO loop
147  while (pimple.correct())
148  {
149  #include "pEqn.H"
150  }
151 
152  if (pimple.turbCorr())
153  {
154  continuousPhaseTurbulence->correct();
155  }
156  }
157 
158  runTime.write();
159 
160  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
161  << " ClockTime = " << runTime.elapsedClockTime() << " s"
162  << nl << endl;
163  }
164 
165  Info<< "End\n" << endl;
166 
167  return 0;
168 }
169 
170 
171 // ************************************************************************* //
pimpleNoLoopControl & pimple
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
autoPtr< surfaceVectorField > Ucf
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
correctPhi
checkMeshCourantNo
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
Creates and initialises the continuous phase face velocity field Ufc if required. ...
dynamicFvMesh & mesh
static const zero Zero
Definition: zero.H:97
static const char nl
Definition: Ostream.H:260
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.
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
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(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 - kinematicCloud.particleProperties().subDict("constantProperties") .lookup< scalar >"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< PhaseIncompressibleMomentumTransportModel< singlePhaseTransportModel > > continuousPhaseTurbulence(PhaseIncompressibleMomentumTransportModel< singlePhaseTransportModel >::New(alphac, Uc, alphaPhic, phic, continuousPhaseTransport))