[demos] Update pipe.py to use boundary-driven flow
@@ -3,14 +3,12 @@ Simulates a viscous fluid flowing through a horizontal pipe.
"""
from phi.flow import *
-DOMAIN = dict(x=50, y=32, extrapolation=extrapolation.combine_sides(x=extrapolation.BOUNDARY, y=extrapolation.ZERO))
-DT = 1.0
-BOUNDARY_MASK = StaggeredGrid(Box(x=(-INF, 0.5), y=None), **DOMAIN)
-velocity = StaggeredGrid(0, **DOMAIN)
+DT = 1.
+INFLOW_BC = extrapolation.combine_by_direction(normal=1, tangential=0)
+velocity = StaggeredGrid(0, extrapolation.combine_sides(x=(INFLOW_BC, extrapolation.BOUNDARY), y=0), x=50, y=32)
pressure = None
for _ in view('velocity, pressure', namespace=globals()).range():
velocity = advect.semi_lagrangian(velocity, velocity, DT)
- velocity = velocity * (1 - BOUNDARY_MASK) + BOUNDARY_MASK * (1, 0)
velocity, pressure = fluid.make_incompressible(velocity, solve=Solve('CG-adaptive', 1e-5, 0, x0=pressure))
velocity = diffuse.explicit(velocity, 0.1, DT)
