Skip to content

Commit

Permalink
[physics] Fix advect.differential()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Jan 18, 2024
1 parent 3f7288a commit f9c36f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions phi/physics/advect.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ def differential(u: Field,
grad = spatial_gradient(u, stack_dim=channel('gradient'), order=order, implicit=implicit)
velocity = stack(unstack(velocity, dim='vector'), dim=channel('gradient'))
amounts = velocity * grad
return - sum(amounts.gradient)
return amounts.with_values(- math.sum(amounts.values, 'gradient'))
elif u.is_mesh:
boundary = u.boundary.spatial_gradient()
u = u.at_faces(boundary=NONE, order=order, upwind=velocity if upwind is True else upwind)
velocity = velocity.at_faces(boundary=NONE, order=order, upwind=velocity if upwind is True else upwind)
conv = density * u.mesh.integrate_surface(u.values * (velocity.values.vector @ velocity.face_normals.vector)) / u.mesh.volume
return Field(u.geometry, conv, boundary)
return Field(u.geometry, conv, 0)
raise NotImplementedError(u)


Expand Down
2 changes: 1 addition & 1 deletion phi/physics/fluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def make_incompressible(velocity: Field,
obstacles: Obstacle or Geometry or tuple or list = (),
solve: Solve = Solve(),
active: CenteredGrid = None,
order: int = 2) -> Tuple[Field, CenteredGrid]:
order: int = 2) -> Tuple[Field, Field]:
"""
Projects the given velocity field by solving for the pressure and subtracting its spatial_gradient.
Expand Down

0 comments on commit f9c36f2

Please sign in to comment.