-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix update of Dirichlet BC and RHS #383
Fix update of Dirichlet BC and RHS #383
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.