Jesus.M |
June 20, 2020 07:02 |
Bug in Artificial Compressibility Method using Dual-Time Stepping
Hello OpenFOAM Community,
I am implementing the Artificial Compressibility method with dual-time stepping. I finished the code by adding a for loop in order to advance the solution in real time besides the pseudo-time stepping that this method uses. Therefore, I had to set also a counter for the real time and do several modifications to the code. I fixed some previous bugs that kept me from having a clean compilation. Once I had a clean compilation, I tried the code and it runs, but it does not print the solution for the specified time-step... Any suggestion of what it can be causing this problem?
Here's the code for more clarity.
Code:
int main(int argc, char *argv[])
{
#include "postProcess.H"
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createFields.H"
#include "initContinuityErrs.H"
#include "CourantNo.H"
#include "readTimeControls.H"
#include "setInitialDeltaT.H"
scalar maxCoRealTime = runTime.controlDict().lookupOrDefault<scalar>("maxCoRealTime", 1.0);
scalar realDeltaT = runTime.controlDict().lookupOrDefault<scalar>("realDeltaT", GREAT);
scalar CoNumRealTime = 0.0;
#include "CourantNoRealTime.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
//declaration Time Variables
auto maxIterRealTime = runTime.controlDict().lookupOrDefault<scalar>("maxIterRealTime",1);
auto maxIterPseudoTime = runTime.controlDict().lookupOrDefault<scalar>("maxIterPseudoTime",1);
decltype(realDeltaT) timeTotalRealTime = 0.0;
auto runRealTime = runTime.timeIndex();
runRealTime = 0;
//declaration of fluid properties
decltype(U) Udt1 = U;
decltype(U) Udt0 = U;
//Real-time step
for(auto i = decltype(maxIterRealTime){0}; i < maxIterRealTime; ++i)
{
++runRealTime;
#include "readRealTimeControls.H"
#include "CourantNoRealTime.H"
#include "setRealDeltaT.H"
Udt0 = Udt1; // Updating U at real time.
//Pseudo-time step
while (runTime.timeIndex() < maxIterPseudoTime)
{
++runTime;
//Time derivative
auto dualDt = dimensionedScalar("dt_real", dimTime, realDeltaT);
Udt1 = U;
dt_ddt = (Udt1 - Udt0) / dualDt;
//CFL-based time-step
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
Info<< "Time = " << runTime.timeName() << nl << endl;
//Continuity Equation
phi = fvc::interpolate(U) & mesh.Sf();
fvScalarMatrix pEqn
(
fvm::ddt(p) + beta * fvc::div(U)
);
//pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
#include "continuityErrs.H"
p.correctBoundaryConditions();
//Momentum Equation
fvVectorMatrix UEqn
(
fvm::ddt(U) + fvm::div(phi,U) - fvm::laplacian(nu,U)
);
solve(UEqn == -fvc::grad(p) - dt_ddt);
}
runTime.printExecutionTime(Info);
//Update Real time and reset pseudo-time
timeTotalRealTime += realDeltaT;
runTime.setTime(timeTotalRealTime, runRealTime);
runTime.write();
runTime.setTime(0.0, 0);
}
Info<< "End\n" << endl;
return 0;
}
Thank you
|