PhiFlow
PhiFlow copied to clipboard
arguments of math.spatial_gradient not available in field.spatial_gradient
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?
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 aNumericalScheme
class. Addingdifference
now will break compatibility later.
In the meantime, you can use math.spatial_gradient(grid.values)
.
This is now implemented in 2.3-develop
.