Visualizing multiple functions in dolfinx

Hello,

I would like to visualize a field only in the interior of an implicitly defined geometry. For this, I am currently using the following snippet

def write(filename, mesh, data, phi=None):
    with dolfinx.io.XDMFFile(
        mesh.comm,
        filename,
        "w",
    ) as xdmffile:
        xdmffile.write_mesh(mesh)
        if isinstance(data, dolfinx.mesh.MeshTagsMetaClass):
            xdmffile.write_meshtags(data)
        elif isinstance(data, dolfinx.fem.Function):
            xdmffile.write_function(data, 0.0)
            if phi is not None:
                xdmffile.write_function(phi, 0.0)
        else:
            breakpoint()

where phi gives me the geometry definition and data contains the function to be visualized. As a postprocessing in Paraview, I would like to use an IsoVolume filter to discard the degrees of freedom which fall out of the geometry. However, the code above does not currently allow me to do so, and data is zero everywhere (unlike the case in which it is exported on its own). Any idea on how to correctly do this?

Thank you in advance.