Skip to content

Commit

Permalink
[phys] Consistent sign in advect.differential()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Feb 28, 2024
1 parent 532782a commit 989ec0c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions phi/physics/advect.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def differential(u: Field,
"""
Computes the differential advection term using the differentiation Scheme indicated by `order`, ´implicit´ and `upwind`.
For unstructured meshes, computes 1/V ∑_f (n·U_prev) U ρ A
For a velocity field u, the advection term as it appears on the right-hand-side of a PDE is -u·∇u, including the negative sign.
For unstructured meshes, computes -1/V ∑_f (n·u_prev) u ρ A
Args:
u: Scalar or vector-valued `Field` sampled on a `CenteredGrid`, `StaggeredGrid` or `Mesh`.
Expand Down Expand Up @@ -122,7 +124,7 @@ def differential(u: Field,
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, 0)
return Field(u.geometry, -conv, 0)
raise NotImplementedError(u)


Expand Down

0 comments on commit 989ec0c

Please sign in to comment.