From f9c36f2bc9b1f1630639dbd39a0cfc55567c6972 Mon Sep 17 00:00:00 2001 From: holl- Date: Thu, 18 Jan 2024 13:39:18 +0100 Subject: [PATCH] [physics] Fix advect.differential() --- phi/physics/advect.py | 5 ++--- phi/physics/fluid.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/phi/physics/advect.py b/phi/physics/advect.py index 356974b6c..bd5c16066 100644 --- a/phi/physics/advect.py +++ b/phi/physics/advect.py @@ -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) diff --git a/phi/physics/fluid.py b/phi/physics/fluid.py index eca235812..829d71c61 100644 --- a/phi/physics/fluid.py +++ b/phi/physics/fluid.py @@ -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.