Dear Mingzhe,
thanks for your email.
> We see discrepancies between two outputs: in the green region, one ball is
> not covered by the cubes; in the yellow region, three cubes are not covered
> by the balls. Not surprisingly, all locations with discrepancies are at the
> domain's boundary.
These discrepancies are actually correct.
For domains without boundary, the changes in the homology of the sub-levelsets (during a filtration) do only occur on critical points and each critical point corresponds to such a change (as long as the function has only isolated, non-degenerate critical points).
For domains with boundary, this is not true anymore: the changes in the homology of the sub-levelsets (during a filtration) do only occur on critical points *but* not all critical points induce some changes in the homology of the sub-levelsets.
This is illustrated in the attached pvsm file (make sure to set the input paths to simple.off right when you load the state file from ParaView).
Once you load the state file, go to the "Forward" layout tab (top left of the render view). There, hit the "Play" button of the animation controller. You will see on the right the filtration of the sub-levelsets of a toy example (see Screenshot_20230426_130356.png).
During the entire filtration, the sub-levelset has the homology of a disk. In particular, there is no change in homology when it hits the boundary saddles and the boundary maxima (correctly identified by ScalarFieldCriticalPoints).
So, from a strict persistent homology perspective, the fact that not all critical points are captured (specifically the boundary ones) is *correct*.
If you want to have a notion of importance for these boundary critical points, you can emulate what FTM used to do by considering the opposite of your scalar data, yielding a sort of "backward" filtration.
This is illustrated in the "Backward" layout tab of the state file (see Screenshot_20230436_130433.png, and hit the "play" button in the animation controller).
If the filtration goes backwards, it does start with 4 connected components (each one started at the original boundary maxima) and you can track the persistence of these.
I hope this clarifies your concerns.
Best regards,