assemble(form, **kwargs) and interpolate(form, **kwargs) internally create an Assembler or Interpolator object respectively. Creating those objects takes some symbolic work which you don't want to be doing repeatedly in a timestepping loop.
The Assembler is cached on the form, but it still takes some work to build the cache key and identify which Assembler is needed.
You can front load all this work using get_assembler and get_interpolator to manually save the Assembler and Interpolator objects, then call the methods on those objects yourself when needed.
This is equivalent to manually creating the Projector objects, which is already done in various places in gusto.
Example of creating the assembler:
https://github.com/firedrakeproject/firedrake/blob/f545557e7fff63dd1b94fe08362abebddf7e51ee/firedrake/matrix_free/operators.py#L163-L166
and calling the assembler:
https://github.com/firedrakeproject/firedrake/blob/f545557e7fff63dd1b94fe08362abebddf7e51ee/firedrake/matrix_free/operators.py#L227
assemble(form, **kwargs)andinterpolate(form, **kwargs)internally create anAssemblerorInterpolatorobject respectively. Creating those objects takes some symbolic work which you don't want to be doing repeatedly in a timestepping loop.The
Assembleris cached on theform, but it still takes some work to build the cache key and identify whichAssembleris needed.You can front load all this work using
get_assemblerandget_interpolatorto manually save theAssemblerandInterpolatorobjects, then call the methods on those objects yourself when needed.This is equivalent to manually creating the
Projectorobjects, which is already done in various places in gusto.Example of creating the assembler:
https://github.com/firedrakeproject/firedrake/blob/f545557e7fff63dd1b94fe08362abebddf7e51ee/firedrake/matrix_free/operators.py#L163-L166
and calling the assembler:
https://github.com/firedrakeproject/firedrake/blob/f545557e7fff63dd1b94fe08362abebddf7e51ee/firedrake/matrix_free/operators.py#L227