diff --git a/changelog-entries/676.md b/changelog-entries/676.md new file mode 100644 index 000000000..f26fa19c8 --- /dev/null +++ b/changelog-entries/676.md @@ -0,0 +1 @@ +- Switched to adapter-based checkpointing in the macro-dumux participant of the two-scale heat conduction tutorial [#676](https://github.com/precice/tutorials/pull/676) diff --git a/two-scale-heat-conduction/macro-dumux/appl/main.cc b/two-scale-heat-conduction/macro-dumux/appl/main.cc index d36090d31..5932dd22e 100644 --- a/two-scale-heat-conduction/macro-dumux/appl/main.cc +++ b/two-scale-heat-conduction/macro-dumux/appl/main.cc @@ -173,10 +173,6 @@ int main(int argc, char **argv) problem->applyInitialSolution(x); auto xOld = x; - auto xCheckpoint = x; - double timeCheckpoint = 0.0; - int timeStepCheckpoint = 0; - // initialize the coupling data std::vector temperatures; for (int solIdx = 0; solIdx < numberOfElements; ++solIdx) { @@ -227,7 +223,9 @@ int main(int argc, char **argv) const int vtkOutputInterval = getParam("TimeLoop.OutputInterval"); // initialize preCICE - couplingParticipant.initialize(); + if (runWithCoupling) { + couplingParticipant.initialize(); + } // time loop parameters const auto tEnd = getParam("TimeLoop.TEnd"); @@ -246,6 +244,11 @@ int main(int argc, char **argv) auto timeLoop = std::make_shared>(0.0, dt, tEnd); timeLoop->setMaxTimeStepSize(getParam("TimeLoop.MaxDt")); + // initialize adapter checkpointing + if (runWithCoupling) { + couplingParticipant.initializeCheckpoint(x, *gridVariables, *timeLoop); + } + // the assembler with time loop for instationary problem using Assembler = FVAssembler; auto assembler = std::make_shared(problem, gridGeometry, @@ -272,11 +275,7 @@ int main(int argc, char **argv) break; // write checkpoint - if (couplingParticipant.requiresToWriteCheckpoint()) { - xCheckpoint = x; - timeCheckpoint = timeLoop->time(); - timeStepCheckpoint = timeLoop->timeStepIndex(); - } + couplingParticipant.writeCheckpointIfRequired(); preciceDt = couplingParticipant.getMaxTimeStepSize(); solverDt = std::min(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()), @@ -357,15 +356,9 @@ int main(int argc, char **argv) couplingParticipant.advance(dt); // reset to checkpoint if not converged - if (couplingParticipant.requiresToReadCheckpoint()) { - x = xCheckpoint; - xOld = x; - timeLoop->setTime(timeCheckpoint, timeStepCheckpoint); - - // TODO: previousTimeStep might be more appropriate, last one could be small - timeLoop->setTimeStepSize(dt); - gridVariables->update(x); + if (couplingParticipant.readCheckpointIfRequired()) { gridVariables->advanceTimeStep(); + xOld = x; continue; } }