I’m still a preCICE beginner and I cannot understand what could cause this error. The simulation starts regularly and goes on until the max-time value is reached. I even tried to input a bigger max-time value, but the error still shows up.
ERROR: advance() cannot be called when isCouplingOngoing() returns false
I’m using a mbdyn adapter written in python (not the one on github) and I’m trying a dummy test case, so mbdyn is the only solver involved.
I hypothesized that the simulation cannot reach the finalize step, but I cannot understand why.
Does anyone of you ever encountered a similar error?
It basically means that you call preCICE to advance the coupling even though your simulation has reached the max-time value. Either your simulation is running further then it should, there is some configuration issue or your dummy does something wrong.
[...]
while (precice.isCouplingOngoing()){
[...]
precice_dt = precice.advance(dt);
[...]
}
So advance can only be called when isCouplingOngoing() is true. I would assume that you have the advance call not inside a loop that checks isCouplingOngoing() all the time.
Could you show us your dummy and your configuration files to see what is wrong?
I suspected something like what you’ve just said, but I couldn’t find the error in the code.
I’m attaching the adapter I’m using (it’s a .txt because it wouldn’t let me upload a .py file) mbdynAdapter.txt (9.6 KB) mbdynInterface.txt (7.9 KB)
The missing key here is that the value of is_coupling_ongoing() gets updated during advance(), so you need to swap these two statememnts.
The second problem (which will appear later) is that you are currently using an implicit coupling scheme, but are not writing/reading checkpoint (including going back in time).
Have a look at the time logging of MBDyn and of preCICE. I guess that these two report different times.
preCICE does not know the absolute time, it only knows what timestep size it dictated, and it expects that this timestep size is correctly applied. Therefore, while preCICE expects that you go back in time when a coupling time window has not convered, MBDyn still keeps going further.
Thank you for your reply!
The first thing you suggested solved the problem and the dummy simulation could properly end with finalize().
The second problem you mentioned is a bit more tricky for me, because I’m not sure which files should I look into. I didn’t build the debug version of preCICE, maybe I should switch to that.
Did you check out the documentation about implicit coupling Step 6 – Implicit coupling | preCICE - The Coupling Library or even the full documentation about writing an adapter that starts here Step 1 – Preparation | preCICE - The Coupling Library? It explains very nicely what to do and also why. The code examples are in C++. but this should not scare you. The steps you have to implement are the same for the Python-Interface and most of them you have already implemented.
You don’t need the debug version for that, the preCICE information messages include the time information. But let’s discuss this in a separate, linked thread if needed.
Thank you @Makis!
I’ll try and see if I can modify the code with your suggestions and the preCICE documentation and if I have more questions I’ll open a linked thread.