Time-step management in MBDyn adapter

Hi preCICE community,

I’m trying to improve the overall compatibility of the MBDyn adapter. In particular I’m working on the time step management. Up to now all my simulations were based on the idea that MBDyn has the same time step of the coupling and possibly the fluid solver performs subcycling. That is, the MBDyn timestep is fixed. Nevertheless it is possible to define the current time step in MBDyn and I’m using this feature within the adapter.

I am finding some issues, or at least I don’t exactly understand what to do. I have been looking here: Step 5 – Non-matching time step sizes | preCICE - The Coupling Library and a bit also here: Waveform iteration for time interpolation of coupling data | preCICE - The Coupling Library

The following snippet contains what I’m doing with the timestep. This works if I have mdyn_dt == precice_dt (as before) but it doesn’t work if mbdyn_dt < precice_dt. Besides, I’m not sure that I can roll-back more than one time-step computation if the simulation does not converge at the end of a coupling time-step.

 // Start coupling:
 while (interface->isCouplingOngoing()){


 	// read forces from interface
 	if (interface->isReadDataAvailable()) {
 		interface->readBlockVectorData(readID, vertexSize, vertexIDs, adapterReadVector);

 	current_dt = std::min(precice_dt, mbdyn_dt);

 	MBDynAdvance(); // compute and update displacements and forces

 		interface->writeBlockVectorData(writeID, vertexSize, vertexIDs, adapterWriteVector);

 	// advance
 	precice_dt = interface->advance(current_dt);

 		// timestep not converged
 		// reloadOldState(); // set variables back to checkpoint
 		conn->putForces(false);  // tell MBDyn to repeat step
 		// timestep converged
 		conn->putForces(true); // tell MBDyn to go to the next step

On the other hand I would like to get rid of “if(interface->isWriteDataRequired(current_dt))” and “if (interface->isReadDataAvailable())” as they are on one side deprecated but they are described, as far as I understand, necessary for the time step management.

I am not specifically testing some sub-cycling in FSI (I am not even sure that I could handle this feature), my goal is to make the adapter as compliant as possible with the preCICE capabilities. Up to now, I simply configure the structural simulation with the same time-step of the coupling (in particular one has to put the same delta-t of the coupling in the MBDyn configuration file, which is not ideal). I’ve been testing the sub-cycling only in the fluid participant (driven by the Courant number).
So any suggestions on how to implement time-step management is greatly appreciated.

Thank you

Kind regards