Skip to content

grad/div/curl operators don't take side as a kwarg that can be passed to the components #2808

Closed

Description

@cdelavegamartin

This is a request/improvement to pass extra kwargs (like side) to the components of operators like grad div and curl
Current behaviour for side,

from devito import Grid, Function, VectorFunction, centered, curl

grid = Grid(shape=(11, 11, 11))
f = Function(name='f', grid=grid, space_order=2)
f_vec = VectorFunction(name='f_vec', grid=grid, space_order=2)

expr1 = f.grad().evaluate
expr2 = f.grad(order=2, side=centered).evaluate
display( expr1 )
assert expr1 == expr2

expr1 = f.div().evaluate
expr2 = f.div(order=2, side=centered).evaluate
display( expr1 )
assert expr1 == expr2

expr1 = curl(f_vec).evaluate
expr2 = curl(f_vec,order=2, side=centered).evaluate
display( expr1 )
assert expr1 == expr2
$$\left[\begin{matrix}- \frac{f(x, y, z)}{h_{x}} + \frac{f(x + h_x, y, z)}{h_{x}}\\- \frac{f(x, y, z)}{h_{y}} + \frac{f(x, y + h_y, z)}{h_{y}}\\- \frac{f(x, y, z)}{h_{z}} + \frac{f(x, y, z + h_z)}{h_{z}}\end{matrix}\right]$$ $$\left(- \frac{f(x, y, z)}{h_{x}} + \frac{f(x + h_x, y, z)}{h_{x}}\right) + \left(- \frac{f(x, y, z)}{h_{y}} + \frac{f(x, y + h_y, z)}{h_{y}}\right) + \left(- \frac{f(x, y, z)}{h_{z}} + \frac{f(x, y, z + h_z)}{h_{z}}\right)$$ $$\left[\begin{matrix}\left(\frac{f_vec_z(x, y, z + h_z/2)}{h_{y}} - \frac{f_vec_z(x, y - h_y, z + h_z/2)}{h_{y}}\right) - \left(\frac{f_vec_y(x, y + h_y/2, z)}{h_{z}} - \frac{f_vec_y(x, y + h_y/2, z - h_z)}{h_{z}}\right)\\- (\frac{f_vec_z(x, y, z + h_z/2)}{h_{x}} - \frac{f_vec_z(x - h_x, y, z + h_z/2)}{h_{x}}) + \left(\frac{f_vec_x(x + h_x/2, y, z)}{h_{z}} - \frac{f_vec_x(x + h_x/2, y, z - h_z)}{h_{z}}\right)\\\left(\frac{f_vec_y(x, y + h_y/2, z)}{h_{x}} - \frac{f_vec_y(x - h_x, y + h_y/2, z)}{h_{x}}\right) - \left(\frac{f_vec_x(x + h_x/2, y, z)}{h_{y}} - \frac{f_vec_x(x + h_x/2, y - h_y, z)}{h_{y}}\right)\end{matrix}\right]$$

Activity

  1. EdCaunt commented on Jan 5, 2026

    @EdCaunt
    Contributor

    Fixed by #2811

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions