Fix update of Dirichlet BC and RHS#383
Conversation
BenjaminRodenberg
left a comment
There was a problem hiding this comment.
Explaining the pitfall that has lead to this bug in the comments below.
| # Update Dirichlet BC | ||
| u_D.t = t + float(dt) | ||
| f.t = t + float(dt) |
There was a problem hiding this comment.
This dt is actually the dt from the timestep that was just completed, not the timestep that one is going to compute next. But the u_D and f here is used for the future timestep. Meaning: If dt changes from one timestep to the next, u_D and f will use the dt corresponding to the last time step and not corresponding to the next.
| precice_dt = precice.get_max_time_step_size() | ||
| dt.assign(np.min([fenics_dt, precice_dt])) | ||
|
|
||
| # Dirichlet BC and RHS need to point to end of current timestep | ||
| u_D.t = t + float(dt) | ||
| f.t = t + float(dt) | ||
|
|
||
| # Coupling BC needs to point to end of current timestep | ||
| read_data = precice.read_data(dt) |
There was a problem hiding this comment.
As a general advice, one should set all boundary conditions ("real" boundary conditions, RHS and coupling boundary conditions) before calling solve and before calling advance.
|
@NiklasKotarsky and @uekerman might be interesting for you. I think this also nicely illustrates how |
Fixes bug, if time step changes inside window. See precice/fenics-adapter#20.
For the purpose of documentation, if will add some comments in the diff of this PR.
With this bugfix the waveform version of the tutorial provided via #281 also works for non-matching subcycling, like described in precice/fenics-adapter#20.