@@ -223,17 +223,22 @@ int main(int argc, char **argv)
223223 // initialize
224224 couplingParticipant.initialize ();
225225
226- // get some time loop parameters
226+ // time loop parameters
227227 const auto tEnd = getParam<Scalar>(" TimeLoop.TEnd" );
228228 double preciceDt = couplingParticipant.getMaxTimeStepSize ();
229+ double solverDt;
229230 double dt;
230- if (getParam<bool >(" Precice.RunWithCoupling" ) == true )
231- dt = preciceDt;
232- else
231+
232+ if (getParam<bool >(" Precice.RunWithCoupling" ) == true ) {
233+ solverDt = getParam<Scalar>(" TimeLoop.InitialDt" );
234+ dt = std::min (preciceDt, solverDt);
235+ } else {
233236 dt = getParam<Scalar>(" TimeLoop.InitialDt" );
237+ }
234238
235239 // instantiate time loop
236240 auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0 , dt, tEnd);
241+ timeLoop->setMaxTimeStepSize (getParam<Scalar>(" TimeLoop.MaxDt" ));
237242
238243 // the assembler with time loop for instationary problem
239244 using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
@@ -296,23 +301,23 @@ int main(int argc, char **argv)
296301
297302 // advance precice
298303 if (getParam<bool >(" Precice.RunWithCoupling" ) == true ) {
299- couplingParticipant.advance (dt);
304+ couplingParticipant.advance (timeLoop->timeStepSize ());
305+
300306 preciceDt = couplingParticipant.getMaxTimeStepSize ();
301- dt = std::min (preciceDt, std::min (nonLinearSolver.suggestTimeStepSize (
302- timeLoop->timeStepSize ()),
303- getParam<Scalar>(" TimeLoop.MaxDt" )));
304- if (preciceDt != dt) {
305- std::cout << " preciceDt too large. We currently assume fixed timestep "
306- " size but timesteps no longer correspond: preciceDt = "
307- << preciceDt << " and dt =" << dt << std::endl;
308- // exit(1);
307+ solverDt = std::min (nonLinearSolver.suggestTimeStepSize (timeLoop->timeStepSize ()), timeLoop->maxTimeStepSize ());
308+ dt = std::min (preciceDt, solverDt);
309+
310+ if ((!fabs (preciceDt - dt)) < 1e-14 ) {
311+ std::cout << " dt from preCICE is different than dt from DuMuX. "
312+ " preCICE dt = "
313+ << preciceDt << " and DuMuX dt =" << solverDt << std::endl;
309314 }
310315 } else
311316 dt = std::min (
312317 nonLinearSolver.suggestTimeStepSize (timeLoop->timeStepSize ()),
313318 getParam<Scalar>(" TimeLoop.MaxDt" ));
314319
315- std::cout << " dt: " << dt << std::endl;
320+ std::cout << " Using dt: " << dt << std::endl;
316321
317322 if (getParam<bool >(" Precice.RunWithCoupling" ) == true ) {
318323 if (couplingParticipant.requiresToReadCheckpoint ()) {
@@ -350,7 +355,7 @@ int main(int argc, char **argv)
350355 n = 0 ;
351356 }
352357 }
353- // set new dt as suggested by the newton solver or by precice
358+ // set new dt as suggested by the newton solver or by preCICE
354359 timeLoop->setTimeStepSize (dt);
355360
356361 std::cout << " Time: " << timeLoop->time () << std::endl;
0 commit comments