Skip to content

add InterpolationCallback

Florian Atteneder requested to merge fa/interpolationcallback into main

This PR allows to specify in a parfile a set of output times and computational nodes at which variables should be interpolated to and outputted into a separate file interpolate.h5 in the output directory. This should be useful for e.g. a convergence study where one wants to sample the solution on a grid that is different from the actual computational grid.


This PR also changed the callback interface. That is, callback functions now need to report whether they ran successfully, whereas before they returned whether they even ran. Tests seem to pass, but I am wondering whether this will break some other assumption later on ...


The following new parameters are introduced:

  """
  Interpolate and output data after `interpolate_every_iteration` full time steps.
  """
  interpolate_every_iteration = 0
  @check interpolate_every_iteration >= 0

  """
  Interpolate and output data after `interpolate_every_dt` simulation time.
  """
  interpolate_every_dt = 0.0
  @check interpolate_every_dt >= 0

  """
  List of times at which data should be interpolated and outputted.
  This will alter time stepping so that the output time is hit exactly.
  """
  interpolate_aligned_ts = Float64[]
  @check all(t -> t > 0, interpolate_aligned_ts)
  @check issorted(interpolate_aligned_ts)

  """
  List of variables that should be interpolated and outputted.
  """
  interpolate_variables = String[]

  """
  List of nodes onto which `interpolate_variables` should be interpolated and outputted.
  """
  interpolate_nodes = Float64[]

Need to implement a reader for the new output file. I think we can just rework the Output type for this. Will do this in a separate PR.

Nevermind, it already works out of the box with Output, because that does not depend on the mesh. Nice :)

Edited by Florian Atteneder

Merge request reports