PhiFlow icon indicating copy to clipboard operation
PhiFlow copied to clipboard

arguments of math.spatial_gradient not available in field.spatial_gradient

Open Xunius opened this issue 2 years ago • 1 comments

Hi,

Thanks for creating the tool. I'm still learning it.

I noticed that field.spatial_gradient() calls internally math.spatial_gradient(), but some arguments to the latter (e.g. difference, dims) are not available to the former. Is there any reason these are not made available? I feel that it might be helpful to be able to specify along which dimension to compute the gradients, in a forward or centered difference manner.

Also, does it make good sense to also make spatial_gradient() available as a method of the Field class?

Xunius avatar May 19 '22 13:05 Xunius

We could expose these arguments to some degree. There are, however, a few problems involved:

  • When the gradient is sampled on a staggered grid, dims must be all spatial dimensions (or we would have to allow partial staggered grids)
  • difference corresponds to the numerical scheme you are using. We are currently working on higher-order methods and these things will be unified by a NumericalScheme class. Adding difference now will break compatibility later.

In the meantime, you can use math.spatial_gradient(grid.values).

holl- avatar May 20 '22 09:05 holl-

This is now implemented in 2.3-develop.

holl- avatar Feb 01 '23 20:02 holl-