# A Stokes Flow in a Channel

Specify a channel region.

 In:= X\[CapitalOmega] = ImplicitRegion[ 0 <= x <= 2 && 0 <= y <= 0.5 && ! (x >= 1 && y <= 0.1) && ! (x >= 1 && y >= 0.4), {x, y}]; RegionPlot[\[CapitalOmega], AspectRatio -> Automatic, ImageSize -> 300]
 Out= Define the Stokes flow operator.

 In:= XstokesFlowOperator = {Inactive[ Div][({{-1, 0}, {0, -1}}.Inactive[Grad][u[x, y], {x, y}]), {x, y}] + \!\(\*SuperscriptBox[\(w\), TagBox[ RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[x, y], Inactive[ Div][({{-1, 0}, {0, -1}}.Inactive[Grad][v[x, y], {x, y}]), {x, y}] + \!\(\*SuperscriptBox[\(w\), TagBox[ RowBox[{"(", RowBox[{"0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[x, y], \!\(\*SuperscriptBox[\(v\), TagBox[ RowBox[{"(", RowBox[{"0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[x, y] + \!\(\*SuperscriptBox[\(u\), TagBox[ RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[x, y]};

Specify an inflow profile in the positive direction on the left boundary. Specify an outflow pressure on the right-hand boundary. The fluid velocity on the remaining boundaries is 0.

 In:= XSubscript[\[CapitalGamma], D] = { DirichletCondition[u[x, y] == 4*0.3*y*(0.5 - y)/(0.41)^2, x == 0.], DirichletCondition[{u[x, y] == 0., v[x, y] == 0.}, 0 < x < 2], DirichletCondition[w[x, y] == 0., x == 2]};

Solve the equation. The interpolation order option is given to stabilize the numerical solution. The fluid velocities and are interpolated with second order, while the fluid pressure is interpolated with first order.

 In:= X{xVel, yVel, pressure} = NDSolveValue[{stokesFlowOperator == {0, 0, 0}, Subscript[\[CapitalGamma], D]}, {u, v, w}, {x, y} \[Element] \[CapitalOmega], Method -> {"FiniteElement", "InterpolationOrder" -> {u -> 2, v -> 2, w -> 1}}];

Stream plot the flow velocity.

 Out= ## Mathematica

Questions? Comments? Contact a Wolfram expert »