You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Variational solvers accept pre_ and post_ callback functions. The docstring for NonlinearVariationalSolver describes what the pre_ callbacks should look like:
To use the ``pre_jacobian_callback`` or ``pre_function_callback``
functionality, the user-defined function must accept the current
solution as a petsc4py Vec. Example usage is given below:
.. code-block:: python3
def update_diffusivity(current_solution):
with cursol.dat.vec_wo as v:
current_solution.copy(v)
solve(trial*test*dx == dot(grad(cursol), grad(test))*dx, diffusivity)
solver = NonlinearVariationalSolver(problem,
pre_jacobian_callback=update_diffusivity)
But the post_ callbacks are not mentioned. This is confusing because the function signature for post_ callbacks is different to the pre_ ones. The post_jacobian_callback signature for instance looks like:
defcallback(current_solution, J):
...
Using the wrong function signature causes the solver to terminate without a helpful error message.
It might be helpful to look at the test_custom_callbacksregression test to see intended usage.
The text was updated successfully, but these errors were encountered:
Variational solvers accept
pre_
andpost_
callback functions. The docstring forNonlinearVariationalSolver
describes what thepre_
callbacks should look like:But the
post_
callbacks are not mentioned. This is confusing because the function signature forpost_
callbacks is different to thepre_
ones. Thepost_jacobian_callback
signature for instance looks like:Using the wrong function signature causes the solver to terminate without a helpful error message.
It might be helpful to look at the
test_custom_callbacks
regression test to see intended usage.The text was updated successfully, but these errors were encountered: