|
| 1 | +/*---------------------------------------------------------------------------*\ |
| 2 | + Open Source CFD-DEM coupling |
| 3 | +
|
| 4 | + Copyright (C) 2023 Behrad Esgandari, JKU Linz, Austria |
| 5 | +------------------------------------------------------------------------------- |
| 6 | +License |
| 7 | +
|
| 8 | + This program is free software: you can redistribute it and/or modify it |
| 9 | + under the terms of the GNU General Public License as published by |
| 10 | + the Free Software Foundation, either version 3 of the License, or |
| 11 | + (at your option) any later version. |
| 12 | +
|
| 13 | + This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 16 | + for more details. |
| 17 | +
|
| 18 | + You should have received a copy of the GNU General Public License |
| 19 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | +
|
| 21 | +Application |
| 22 | + cfdemSolverPimple |
| 23 | +
|
| 24 | +Description |
| 25 | + Transient solver for incompressible flow. |
| 26 | + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. |
| 27 | + The code is an evolution of the solver pimpleFoam in OpenFOAM(R) 6.0, |
| 28 | + where additional functionality for CFD-DEM coupling is added. |
| 29 | +
|
| 30 | +\*---------------------------------------------------------------------------*/ |
| 31 | + |
| 32 | +#include "fvCFD.H" |
| 33 | +#include "singlePhaseTransportModel.H" |
| 34 | +#include "turbulentTransportModel.H" |
| 35 | +#include "pimpleControl.H" |
| 36 | +#include "fvOptions.H" |
| 37 | + |
| 38 | +#include "cfdemCloud.H" |
| 39 | +#include "implicitCouple.H" |
| 40 | +#include "clockModel.H" |
| 41 | +#include "smoothingModel.H" |
| 42 | +#include "forceModel.H" |
| 43 | + |
| 44 | +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
| 45 | + |
| 46 | +int main(int argc, char *argv[]) |
| 47 | +{ |
| 48 | + #include "setRootCase.H" |
| 49 | + #include "createTime.H" |
| 50 | + #include "createMesh.H" |
| 51 | + #include "createControl.H" |
| 52 | + #include "createFields.H" |
| 53 | + #include "createFvOptions.H" |
| 54 | + #include "initContinuityErrs.H" |
| 55 | + |
| 56 | + // create cfdemCloud |
| 57 | + #include "readGravitationalAcceleration.H" |
| 58 | + cfdemCloud particleCloud(mesh); |
| 59 | + #include "checkModelType.H" |
| 60 | + |
| 61 | + // switch for periodic box simulations |
| 62 | + Switch periodicBoxSwitch |
| 63 | + ( |
| 64 | + pimple.dict().lookupOrDefault<Switch>("periodicBoxSwitch", false) |
| 65 | + ); |
| 66 | + |
| 67 | + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
| 68 | + Info<< "\nStarting time loop\n" << endl; |
| 69 | + while (runTime.loop()) |
| 70 | + { |
| 71 | + particleCloud.clockM().start(1,"Global"); |
| 72 | + |
| 73 | + Info<< "Time = " << runTime.timeName() << nl << endl; |
| 74 | + |
| 75 | + #include "CourantNo.H" |
| 76 | + |
| 77 | + // do particle stuff |
| 78 | + particleCloud.clockM().start(2,"Coupling"); |
| 79 | + bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); |
| 80 | + |
| 81 | + if(hasEvolved) |
| 82 | + { |
| 83 | + particleCloud.smoothingM().smoothen(particleCloud.forceM(0).impParticleForces()); |
| 84 | + } |
| 85 | + |
| 86 | + Info << "update Ksl.internalField()" << endl; |
| 87 | + Ksl = particleCloud.momCoupleM(0).impMomSource(); |
| 88 | + Ksl.correctBoundaryConditions(); |
| 89 | + |
| 90 | + //Force Checks |
| 91 | + vector fTotal(0,0,0); |
| 92 | + vector fImpTotal = sum(mesh.V()*Ksl.internalField()*(Us.internalField()-U.internalField())).value(); |
| 93 | + reduce(fImpTotal, sumOp<vector>()); |
| 94 | + Info << "TotalForceExp: " << fTotal << endl; |
| 95 | + Info << "TotalForceImp: " << fImpTotal << endl; |
| 96 | + |
| 97 | + #include "solverDebugInfo.H" |
| 98 | + particleCloud.clockM().stop("Coupling"); |
| 99 | + |
| 100 | + particleCloud.clockM().start(26,"Flow"); |
| 101 | + |
| 102 | + if(particleCloud.solveFlow()) |
| 103 | + { |
| 104 | + // Pressure-velocity PIMPLE corrector |
| 105 | + while (pimple.loop()) |
| 106 | + { |
| 107 | + // Momentum predictor |
| 108 | + #include "UEqn.H" |
| 109 | + |
| 110 | + // --- Inner PIMPLE loop |
| 111 | + |
| 112 | + while (pimple.correct()) |
| 113 | + { |
| 114 | + #include "pEqn.H" |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + laminarTransport.correct(); |
| 119 | + turbulence->correct(); |
| 120 | + } |
| 121 | + else |
| 122 | + { |
| 123 | + Info << "skipping flow solution." << endl; |
| 124 | + } |
| 125 | + |
| 126 | + if (periodicBoxSwitch) |
| 127 | + { |
| 128 | + #include "periodicBoxProperties.H" |
| 129 | + } |
| 130 | + |
| 131 | + runTime.write(); |
| 132 | + |
| 133 | + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" |
| 134 | + << " ClockTime = " << runTime.elapsedClockTime() << " s" |
| 135 | + << nl << endl; |
| 136 | + |
| 137 | + particleCloud.clockM().stop("Flow"); |
| 138 | + particleCloud.clockM().stop("Global"); |
| 139 | + } |
| 140 | + |
| 141 | + Info<< "End\n" << endl; |
| 142 | + |
| 143 | + return 0; |
| 144 | +} |
| 145 | + |
| 146 | + |
| 147 | +// ************************************************************************* // |
0 commit comments