Hi He Yifeng,
So I am not *sure*, but I *think* that you may need to change how it sets up the number of ghost zones that it acquires. I think that the nested nature won't increase the requested ghost zones quite right. What I would actually suggest is, instead of doing the gradient-of-the-gradient, is to implement this yourself with a derived field.
The original code that gets used is in:
For your purposes, there's a lot that isn't necessary -- including stuff related to non-Cartesian axes, block ordering, etc. The essence is in defining the slice_3d, the manipulation of the 'f' variable, and setting `new_field`. And, when it gets added, note that it sets 'ValidateSpatial' to have an argument of 1 -- this is the tricky bit, as it'll need to be 2, to get an extra ghost zone for your results.
(You *could* try setting that to 2 and seeing if it 'magically fixes everything' but I'm not sure, and it'll definitely be a lot slower.)
What you'll want to do is write the stencil to operate on each individual grid, add the field with the ValidateSpatial argument set to 2 instead of 1, and name it something like second_order_gradient_x or something. If you run into trouble, hit us back here on the list, or on slack!