From 989ec0cdbcbac0527ef60c16cd19ce4f24c339d3 Mon Sep 17 00:00:00 2001 From: Philipp Holl Date: Wed, 28 Feb 2024 13:11:57 +0100 Subject: [PATCH] [phys] Consistent sign in advect.differential() --- phi/physics/advect.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phi/physics/advect.py b/phi/physics/advect.py index ccb8c53f9..7d315d6eb 100644 --- a/phi/physics/advect.py +++ b/phi/physics/advect.py @@ -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`. @@ -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)